; LLVM IR from jdeokkim/ferox :: src (geometry)

; 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.frVector2_ = type { float, float }
%struct.frTransform_ = type { %struct.frVector2_, %struct.anon.1, float }
%struct.anon.1 = type { float, float }
%struct.frAABB_ = type { float, float, float, float }
%struct.frShape_ = type { i32, %union.frShapeData_, %struct.frMaterial_, float }
%union.frShapeData_ = type { %struct.anon.0 }
%struct.anon.0 = type { %struct.frVertices_, %struct.frVertices_ }
%struct.frVertices_ = type { [8 x %struct.frVector2_], i32 }
%struct.frMaterial_ = type { float, float, float }
%struct.anon = type { float }

@__const.frGetShapeAABB.minVertex = external hidden unnamed_addr constant %struct.frVector2_, align 4
@__const.frGetShapeAABB.maxVertex = external hidden unnamed_addr constant %struct.frVector2_, align 4

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @frGetShapeAABB(ptr noundef %0, ptr noundef byval(%struct.frTransform_) align 8 %1) #3 {
  %3 = alloca %struct.frAABB_, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %struct.frVector2_, align 4
  %6 = alloca %struct.frVector2_, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.frVector2_, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 4 %3, i8 0, i64 16, i1 false)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %131

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.frShape_, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %42

16:                                               ; preds = %11
  %17 = getelementptr inbounds %struct.frTransform_, ptr %1, i32 0, i32 0
  %18 = getelementptr inbounds %struct.frVector2_, ptr %17, i32 0, i32 0
  %19 = load float, ptr %18, align 8, !tbaa !14
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.frShape_, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.anon, ptr %21, i32 0, i32 0
  %23 = load float, ptr %22, align 4, !tbaa !18
  %24 = fsub float %19, %23
  %25 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 0
  store float %24, ptr %25, align 4, !tbaa !19
  %26 = getelementptr inbounds %struct.frTransform_, ptr %1, i32 0, i32 0
  %27 = getelementptr inbounds %struct.frVector2_, ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !21
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.frShape_, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %struct.anon, ptr %30, i32 0, i32 0
  %32 = load float, ptr %31, align 4, !tbaa !18
  %33 = fsub float %28, %32
  %34 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 1
  store float %33, ptr %34, align 4, !tbaa !22
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.frShape_, ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 0
  %38 = load float, ptr %37, align 4, !tbaa !18
  %39 = fmul float 2.000000e+00, %38
  %40 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 3
  store float %39, ptr %40, align 4, !tbaa !23
  %41 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 2
  store float %39, ptr %41, align 4, !tbaa !24
  br label %130

42:                                               ; preds = %11
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.frShape_, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 2
  br i1 %46, label %47, label %129

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 @__const.frGetShapeAABB.minVertex, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 @__const.frGetShapeAABB.maxVertex, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !25
  br label %48

48:                                               ; preds = %107, %47
  %49 = load i32, ptr %7, align 4, !tbaa !25
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.frShape_, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.anon.0, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.frVertices_, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !18
  %55 = icmp slt i32 %49, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %110

57:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.frShape_, ptr %58, i32 0, i32 1
  %60 = getelementptr inbounds %struct.anon.0, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.frVertices_, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %7, align 4, !tbaa !25
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [8 x %struct.frVector2_], ptr %61, i64 0, i64 %63
  %65 = load <2 x float>, ptr %64, align 4
  %66 = call <2 x float> @frVector2Transform(<2 x float> %65, ptr noundef byval(%struct.frTransform_) align 8 %1)
  store <2 x float> %66, ptr %8, align 4
  %67 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 0
  %68 = load float, ptr %67, align 4, !tbaa !26
  %69 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 0
  %70 = load float, ptr %69, align 4, !tbaa !26
  %71 = fcmp ogt float %68, %70
  br i1 %71, label %72, label %76

72:                                               ; preds = %57
  %73 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 0
  %74 = load float, ptr %73, align 4, !tbaa !26
  %75 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 0
  store float %74, ptr %75, align 4, !tbaa !26
  br label %76

76:                                               ; preds = %72, %57
  %77 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 1
  %78 = load float, ptr %77, align 4, !tbaa !27
  %79 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 1
  %80 = load float, ptr %79, align 4, !tbaa !27
  %81 = fcmp ogt float %78, %80
  br i1 %81, label %82, label %86

82:                                               ; preds = %76
  %83 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 1
  %84 = load float, ptr %83, align 4, !tbaa !27
  %85 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 1
  store float %84, ptr %85, align 4, !tbaa !27
  br label %86

86:                                               ; preds = %82, %76
  %87 = getelementptr inbounds %struct.frVector2_, ptr %6, i32 0, i32 0
  %88 = load float, ptr %87, align 4, !tbaa !26
  %89 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 0
  %90 = load float, ptr %89, align 4, !tbaa !26
  %91 = fcmp olt float %88, %90
  br i1 %91, label %92, label %96

92:                                               ; preds = %86
  %93 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 0
  %94 = load float, ptr %93, align 4, !tbaa !26
  %95 = getelementptr inbounds %struct.frVector2_, ptr %6, i32 0, i32 0
  store float %94, ptr %95, align 4, !tbaa !26
  br label %96

96:                                               ; preds = %92, %86
  %97 = getelementptr inbounds %struct.frVector2_, ptr %6, i32 0, i32 1
  %98 = load float, ptr %97, align 4, !tbaa !27
  %99 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 1
  %100 = load float, ptr %99, align 4, !tbaa !27
  %101 = fcmp olt float %98, %100
  br i1 %101, label %102, label %106

102:                                              ; preds = %96
  %103 = getelementptr inbounds %struct.frVector2_, ptr %8, i32 0, i32 1
  %104 = load float, ptr %103, align 4, !tbaa !27
  %105 = getelementptr inbounds %struct.frVector2_, ptr %6, i32 0, i32 1
  store float %104, ptr %105, align 4, !tbaa !27
  br label %106

106:                                              ; preds = %102, %96
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %7, align 4, !tbaa !25
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %7, align 4, !tbaa !25
  br label %48, !llvm.loop !28

110:                                              ; preds = %56
  %111 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 0
  %112 = load float, ptr %111, align 4, !tbaa !26
  %113 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 0
  store float %112, ptr %113, align 4, !tbaa !19
  %114 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 1
  %115 = load float, ptr %114, align 4, !tbaa !27
  %116 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 1
  store float %115, ptr %116, align 4, !tbaa !22
  %117 = getelementptr inbounds %struct.frVector2_, ptr %6, i32 0, i32 0
  %118 = load float, ptr %117, align 4, !tbaa !26
  %119 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 0
  %120 = load float, ptr %119, align 4, !tbaa !26
  %121 = fsub float %118, %120
  %122 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 2
  store float %121, ptr %122, align 4, !tbaa !24
  %123 = getelementptr inbounds %struct.frVector2_, ptr %6, i32 0, i32 1
  %124 = load float, ptr %123, align 4, !tbaa !27
  %125 = getelementptr inbounds %struct.frVector2_, ptr %5, i32 0, i32 1
  %126 = load float, ptr %125, align 4, !tbaa !27
  %127 = fsub float %124, %126
  %128 = getelementptr inbounds %struct.frAABB_, ptr %3, i32 0, i32 3
  store float %127, ptr %128, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %129

129:                                              ; preds = %110, %42
  br label %130

130:                                              ; preds = %129, %16
  br label %131

131:                                              ; preds = %130, %2
  %132 = load { <2 x float>, <2 x float> }, ptr %3, align 4
  ret { <2 x float>, <2 x float> } %132
}

; Function Attrs: alwaysinline nounwind uwtable
declare <2 x float> @frVector2Transform(<2 x float>, ptr noundef byval(%struct.frTransform_) align 8) #4

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = { alwaysinline 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 #5 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"frShape_", !11, i64 0, !7, i64 4, !12, i64 140, !13, i64 152}
!11 = !{!"int", !7, i64 0}
!12 = !{!"frMaterial_", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"frTransform_", !16, i64 0, !17, i64 8, !13, i64 16}
!16 = !{!"frVector2_", !13, i64 0, !13, i64 4}
!17 = !{!"", !13, i64 0, !13, i64 4}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !13, i64 0}
!20 = !{!"frAABB_", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!21 = !{!15, !13, i64 4}
!22 = !{!20, !13, i64 4}
!23 = !{!20, !13, i64 12}
!24 = !{!20, !13, i64 8}
!25 = !{!11, !11, i64 0}
!26 = !{!16, !13, i64 0}
!27 = !{!16, !13, i64 4}
!28 = distinct !{!28, !29}
!29 = !{!"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"

%struct.frVector2_ = type { float, float }
%struct.frTransform_ = type { %struct.frVector2_, %struct.anon.1, float }
%struct.anon.1 = type { float, float }

@__const.frGetShapeAABB.minVertex = external hidden unnamed_addr constant %struct.frVector2_, align 4
@__const.frGetShapeAABB.maxVertex = external hidden unnamed_addr constant %struct.frVector2_, align 4

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @frGetShapeAABB(ptr noundef readonly %0, ptr noundef byval(%struct.frTransform_) align 8 %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %39, label %3

3:                                                ; preds = %2
  %4 = load i32, ptr %0, align 4, !tbaa !5
  switch i32 %4, label %39 [
    i32 1, label %5
    i32 2, label %14
  ]

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load float, ptr %6, align 4, !tbaa !12
  %8 = load <2 x float>, ptr %1, align 8, !tbaa !13
  %9 = insertelement <2 x float> poison, float %7, i64 0
  %10 = shufflevector <2 x float> %9, <2 x float> poison, <2 x i32> zeroinitializer
  %11 = fsub <2 x float> %8, %10
  %12 = fmul float %7, 2.000000e+00
  %13 = insertelement <2 x float> poison, float %12, i64 0
  %.sroa.636.8.vec.insert = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  br label %39

14:                                               ; preds = %3
  %15 = load <2 x float>, ptr @__const.frGetShapeAABB.minVertex, align 4
  %16 = load <2 x float>, ptr @__const.frGetShapeAABB.maxVertex, align 4
  %17 = getelementptr inbounds i8, ptr %0, i64 68
  %18 = load i32, ptr %17, align 4, !tbaa !12
  %19 = icmp sgt i32 %18, 0
  %20 = shufflevector <2 x float> %15, <2 x float> %16, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  br i1 %19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %14
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  br label %26

._crit_edge:                                      ; preds = %26, %14
  %22 = phi <4 x float> [ %20, %14 ], [ %35, %26 ]
  %23 = shufflevector <4 x float> %22, <4 x float> poison, <2 x i32> <i32 0, i32 1>
  %24 = shufflevector <4 x float> %22, <4 x float> poison, <2 x i32> <i32 2, i32 3>
  %25 = fsub <2 x float> %24, %23
  br label %39

26:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %27 = phi <4 x float> [ %20, %.lr.ph ], [ %35, %26 ]
  %28 = getelementptr inbounds [8 x %struct.frVector2_], ptr %21, i64 0, i64 %indvars.iv
  %29 = load <2 x float>, ptr %28, align 4
  %30 = tail call <2 x float> @frVector2Transform(<2 x float> %29, ptr noundef nonnull byval(%struct.frTransform_) align 8 %1)
  %31 = shufflevector <2 x float> %30, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %32 = fcmp ogt <4 x float> %27, %31
  %33 = fcmp olt <4 x float> %27, %31
  %34 = shufflevector <4 x i1> %32, <4 x i1> %33, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
  %35 = select <4 x i1> %34, <4 x float> %31, <4 x float> %27
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %36 = load i32, ptr %17, align 4, !tbaa !12
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next, %37
  br i1 %38, label %26, label %._crit_edge, !llvm.loop !14

39:                                               ; preds = %3, %5, %._crit_edge, %2
  %.sroa.030.0 = phi <2 x float> [ %11, %5 ], [ %23, %._crit_edge ], [ zeroinitializer, %2 ], [ zeroinitializer, %3 ]
  %.sroa.636.0 = phi <2 x float> [ %.sroa.636.8.vec.insert, %5 ], [ %25, %._crit_edge ], [ zeroinitializer, %2 ], [ zeroinitializer, %3 ]
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.sroa.030.0, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.sroa.636.0, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

; Function Attrs: alwaysinline nounwind uwtable
declare <2 x float> @frVector2Transform(<2 x float>, ptr noundef byval(%struct.frTransform_) align 8) local_unnamed_addr #1

attributes #0 = { 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 = { alwaysinline 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, !7, i64 0}
!6 = !{!"frShape_", !7, i64 0, !8, i64 4, !10, i64 140, !11, i64 152}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"frMaterial_", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"float", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass