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

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) #2

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

16:                                               ; preds = %3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Mm_Rect, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds %struct.anon.1, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = getelementptr inbounds %struct.anon.1, ptr %8, i32 0, i32 0
  store float %20, ptr %21, align 4, !tbaa !9
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Mm_Rect, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.anon.1, ptr %23, i32 0, i32 0
  %25 = load float, ptr %24, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 0
  store float %25, ptr %26, align 4, !tbaa !9
  br label %38

27:                                               ; preds = %3
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Mm_Rect, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.anon.1, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !9
  %32 = getelementptr inbounds %struct.anon.1, ptr %8, i32 0, i32 0
  store float %31, ptr %32, align 4, !tbaa !9
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Mm_Rect, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %struct.anon.1, ptr %34, i32 0, i32 0
  %36 = load float, ptr %35, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 0
  store float %36, ptr %37, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %27, %16
  %39 = getelementptr inbounds %struct.anon.1, ptr %5, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = fcmp oge float %40, 0.000000e+00
  br i1 %41, label %42, label %53

42:                                               ; preds = %38
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Mm_Rect, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.anon.1, ptr %44, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = getelementptr inbounds %struct.anon.1, ptr %8, i32 0, i32 1
  store float %46, ptr %47, align 4, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Mm_Rect, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.anon.1, ptr %49, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 1
  store float %51, ptr %52, align 4, !tbaa !9
  br label %64

53:                                               ; preds = %38
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.Mm_Rect, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.anon.1, ptr %55, i32 0, i32 1
  %57 = load float, ptr %56, align 4, !tbaa !9
  %58 = getelementptr inbounds %struct.anon.1, ptr %8, i32 0, i32 1
  store float %57, ptr %58, align 4, !tbaa !9
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Mm_Rect, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.anon.1, ptr %60, i32 0, i32 1
  %62 = load float, ptr %61, align 4, !tbaa !9
  %63 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 1
  store float %62, ptr %63, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %53, %42
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !10
  %65 = getelementptr inbounds %union.Vec2, ptr %10, i32 0, i32 0
  %66 = load <2 x float>, ptr %65, align 4
  %67 = getelementptr inbounds %union.Vec2, ptr %11, i32 0, i32 0
  %68 = load <2 x float>, ptr %67, align 4
  %69 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %66, <2 x float> %68)
  %70 = getelementptr inbounds %union.Vec2, ptr %4, i32 0, i32 0
  store <2 x float> %69, ptr %70, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %71 = getelementptr inbounds %union.Vec2, ptr %4, i32 0, i32 0
  %72 = load <2 x float>, ptr %71, align 4
  ret <2 x float> %72
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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" }
attributes #3 = { 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" }
attributes #4 = { nounwind }

!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}
!10 = !{i64 0, i64 8, !9}


; 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 uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_Z7supportRK7Mm_RectS1_4Vec2(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %1, <2 x float> %2) local_unnamed_addr #1 {
  %.sroa.021.0.vec.extract = extractelement <2 x float> %2, i64 0
  %4 = fcmp ult float %.sroa.021.0.vec.extract, 0.000000e+00
  %5 = load <4 x float>, ptr %0, align 4
  %6 = load <4 x float>, ptr %1, align 4
  %.sroa.08.0.vec.insert = shufflevector <4 x float> %5, <4 x float> poison, <2 x i32> <i32 2, i32 poison>
  %.sroa.02.0.vec.insert = shufflevector <4 x float> %6, <4 x float> poison, <2 x i32> <i32 0, i32 poison>
  %.sroa.08.0.vec.insert11 = shufflevector <4 x float> %5, <4 x float> poison, <2 x i32> <i32 0, i32 poison>
  %.sroa.02.0.vec.insert5 = shufflevector <4 x float> %6, <4 x float> poison, <2 x i32> <i32 2, i32 poison>
  %.sroa.02.0 = select i1 %4, <2 x float> %.sroa.02.0.vec.insert5, <2 x float> %.sroa.02.0.vec.insert
  %.sroa.08.0 = select i1 %4, <2 x float> %.sroa.08.0.vec.insert11, <2 x float> %.sroa.08.0.vec.insert
  %7 = extractelement <4 x float> %5, i64 3
  %8 = extractelement <4 x float> %6, i64 1
  %9 = extractelement <4 x float> %5, i64 1
  %10 = extractelement <4 x float> %6, i64 3
  %.sroa.021.4.vec.extract = extractelement <2 x float> %2, i64 1
  %11 = fcmp ult float %.sroa.021.4.vec.extract, 0.000000e+00
  %. = select i1 %11, float %9, float %7
  %.32 = select i1 %11, float %10, float %8
  %.sroa.08.4.vec.insert13 = insertelement <2 x float> %.sroa.08.0, float %., i64 1
  %.sroa.02.4.vec.insert7 = insertelement <2 x float> %.sroa.02.0, float %.32, i64 1
  %12 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %.sroa.08.4.vec.insert13, <2 x float> %.sroa.02.4.vec.insert7)
  ret <2 x float> %12
}

attributes #0 = { inlinehint 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" }
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)"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass