; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z7supportRK7Mm_Rect4Vec2)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }
%struct.Mm_Rect = type { %union.Vec2, %union.Vec2 }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local <2 x float> @_Z4vec2ff(float noundef, float noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_Z7supportRK7Mm_Rect4Vec2(ptr noundef nonnull align 4 dereferenceable(16) %0, <2 x float> %1) #1 {
  %3 = alloca %union.Vec2, align 4
  %4 = alloca %union.Vec2, align 4
  %5 = alloca ptr, align 8
  %6 = getelementptr inbounds %union.Vec2, ptr %4, i32 0, i32 0
  store <2 x float> %1, ptr %6, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.anon.1, ptr %4, i32 0, i32 0
  %8 = load float, ptr %7, align 4, !tbaa !9
  %9 = fcmp oge float %8, 0.000000e+00
  br i1 %9, label %10, label %15

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Mm_Rect, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !9
  br label %20

15:                                               ; preds = %2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Mm_Rect, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.anon.1, ptr %17, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %15, %10
  %21 = phi float [ %14, %10 ], [ %19, %15 ]
  %22 = getelementptr inbounds %struct.anon.1, ptr %4, i32 0, i32 1
  %23 = load float, ptr %22, align 4, !tbaa !9
  %24 = fcmp oge float %23, 0.000000e+00
  br i1 %24, label %25, label %30

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Mm_Rect, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.anon.1, ptr %27, i32 0, i32 1
  %29 = load float, ptr %28, align 4, !tbaa !9
  br label %35

30:                                               ; preds = %20
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Mm_Rect, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.anon.1, ptr %32, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %30, %25
  %36 = phi float [ %29, %25 ], [ %34, %30 ]
  %37 = call <2 x float> @_Z4vec2ff(float noundef %21, float noundef %36)
  %38 = getelementptr inbounds %union.Vec2, ptr %3, i32 0, i32 0
  store <2 x float> %37, ptr %38, align 4
  %39 = getelementptr inbounds %union.Vec2, ptr %3, i32 0, i32 0
  %40 = load <2 x float>, ptr %39, align 4
  ret <2 x float> %40
}

attributes #0 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local <2 x float> @_Z4vec2ff(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local <2 x float> @_Z7supportRK7Mm_Rect4Vec2(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, <2 x float> %1) local_unnamed_addr #1 {
  %.sroa.0.0.vec.extract = extractelement <2 x float> %1, i64 0
  %3 = fcmp ult float %.sroa.0.0.vec.extract, 0.000000e+00
  %.in.idx = select i1 %3, i64 0, i64 8
  %.in = getelementptr inbounds i8, ptr %0, i64 %.in.idx
  %4 = load float, ptr %.in, align 4, !tbaa !5
  %.sroa.0.4.vec.extract = extractelement <2 x float> %1, i64 1
  %5 = fcmp ult float %.sroa.0.4.vec.extract, 0.000000e+00
  %.in5.v = select i1 %5, i64 4, i64 12
  %.in5 = getelementptr inbounds i8, ptr %0, i64 %.in5.v
  %6 = load float, ptr %.in5, align 4, !tbaa !5
  %7 = tail call <2 x float> @_Z4vec2ff(float noundef %4, float noundef %6)
  ret <2 x float> %7
}

attributes #0 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass