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

; 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"

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

; 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: mustprogress uwtable
define dso_local { <2 x float>, <2 x float> } @_Z22mm_rect_enclosing_quad4Vec2S_S_S_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) #2 {
  %5 = alloca %struct.Mm_Rect, align 4
  %6 = alloca %union.Vec2, align 4
  %7 = alloca %union.Vec2, align 4
  %8 = alloca %union.Vec2, align 4
  %9 = alloca %union.Vec2, align 4
  %10 = alloca [4 x %union.Vec2], align 16
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca %union.Vec2, align 4
  %14 = alloca %union.Vec2, align 4
  %15 = alloca %union.Vec2, align 4
  %16 = alloca %union.Vec2, align 4
  %17 = alloca %union.Vec2, align 4
  %18 = alloca %union.Vec2, align 4
  %19 = getelementptr inbounds %union.Vec2, ptr %6, i32 0, i32 0
  store <2 x float> %0, ptr %19, align 4
  %20 = getelementptr inbounds %union.Vec2, ptr %7, i32 0, i32 0
  store <2 x float> %1, ptr %20, align 4
  %21 = getelementptr inbounds %union.Vec2, ptr %8, i32 0, i32 0
  store <2 x float> %2, ptr %21, align 4
  %22 = getelementptr inbounds %union.Vec2, ptr %9, i32 0, i32 0
  store <2 x float> %3, ptr %22, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !5
  %23 = getelementptr inbounds %union.Vec2, ptr %10, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %23, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !5
  %24 = getelementptr inbounds %union.Vec2, ptr %10, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !5
  %25 = getelementptr inbounds %union.Vec2, ptr %10, i64 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !5
  %26 = getelementptr inbounds [4 x %union.Vec2], ptr %10, i64 0, i64 0
  %27 = getelementptr inbounds %struct.Mm_Rect, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 16 %26, i64 8, i1 false), !tbaa.struct !5
  %28 = getelementptr inbounds [4 x %union.Vec2], ptr %10, i64 0, i64 0
  %29 = getelementptr inbounds %struct.Mm_Rect, ptr %5, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 16 %28, i64 8, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %58, %4
  %31 = load i32, ptr %11, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = icmp slt i64 %32, 4
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %61

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %36 = getelementptr inbounds [4 x %union.Vec2], ptr %10, i64 0, i64 0
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds %union.Vec2, ptr %36, i64 %38
  store ptr %39, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %40 = getelementptr inbounds %struct.Mm_Rect, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %40, i64 8, i1 false), !tbaa.struct !5
  %41 = load ptr, ptr %12, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %41, i64 8, i1 false), !tbaa.struct !5
  %42 = getelementptr inbounds %union.Vec2, ptr %14, i32 0, i32 0
  %43 = load <2 x float>, ptr %42, align 4
  %44 = getelementptr inbounds %union.Vec2, ptr %15, i32 0, i32 0
  %45 = load <2 x float>, ptr %44, align 4
  %46 = call <2 x float> @_Z8vec2_min4Vec2S_(<2 x float> %43, <2 x float> %45)
  %47 = getelementptr inbounds %union.Vec2, ptr %13, i32 0, i32 0
  store <2 x float> %46, ptr %47, align 4
  %48 = getelementptr inbounds %struct.Mm_Rect, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %48, ptr align 4 %13, i64 8, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %49 = getelementptr inbounds %struct.Mm_Rect, ptr %5, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %49, i64 8, i1 false), !tbaa.struct !5
  %50 = load ptr, ptr %12, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %50, i64 8, i1 false), !tbaa.struct !5
  %51 = getelementptr inbounds %union.Vec2, ptr %17, i32 0, i32 0
  %52 = load <2 x float>, ptr %51, align 4
  %53 = getelementptr inbounds %union.Vec2, ptr %18, i32 0, i32 0
  %54 = load <2 x float>, ptr %53, align 4
  %55 = call <2 x float> @_Z8vec2_max4Vec2S_(<2 x float> %52, <2 x float> %54)
  %56 = getelementptr inbounds %union.Vec2, ptr %16, i32 0, i32 0
  store <2 x float> %55, ptr %56, align 4
  %57 = getelementptr inbounds %struct.Mm_Rect, ptr %5, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %57, ptr align 4 %16, i64 8, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %58

58:                                               ; preds = %35
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = add i32 %59, 1
  store i32 %60, ptr %11, align 4, !tbaa !9
  br label %30, !llvm.loop !13

61:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #4
  %62 = load { <2 x float>, <2 x float> }, ptr %5, align 4
  ret { <2 x float>, <2 x float> } %62
}

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

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #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 = !{i64 0, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_Z22mm_rect_enclosing_quad4Vec2S_S_S_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) local_unnamed_addr #0 {
  %5 = tail call <2 x float> @_Z8vec2_min4Vec2S_(<2 x float> %0, <2 x float> %1)
  %6 = tail call <2 x float> @_Z8vec2_max4Vec2S_(<2 x float> %0, <2 x float> %1)
  %7 = tail call <2 x float> @_Z8vec2_min4Vec2S_(<2 x float> %5, <2 x float> %2)
  %8 = tail call <2 x float> @_Z8vec2_max4Vec2S_(<2 x float> %6, <2 x float> %2)
  %9 = tail call <2 x float> @_Z8vec2_min4Vec2S_(<2 x float> %7, <2 x float> %3)
  %10 = tail call <2 x float> @_Z8vec2_max4Vec2S_(<2 x float> %8, <2 x float> %3)
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %9, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %10, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

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

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

!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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass