; LLVM IR from zig-gamedev/zphysics :: libs/Jolt/TriangleSplitter (TriangleSplitterMorton)

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

%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%class.anon = type { ptr }
%"class.JPH::TriangleSplitterMorton" = type { %"class.JPH::TriangleSplitter", %"class.JPH::Array.0" }
%"class.JPH::TriangleSplitter" = type { ptr, ptr, ptr, %"class.JPH::Array", %"class.JPH::Array.0" }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::Array.0" = type { i64, i64, ptr }

@_ZTVN3JPH22TriangleSplitterMortonE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH22TriangleSplitterMortonC2ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS2_EEEERKNS1_INS_15IndexedTriangleENS3_IS8_EEEE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.JPH::AABox", align 16
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"class.JPH::Vec3", align 16
  %12 = alloca i32, align 4
  %13 = alloca %"class.JPH::Vec3", align 16
  %14 = alloca ptr, align 8
  %15 = alloca %class.anon, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN3JPH16TriangleSplitterC2ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS2_EEEERKNS1_INS_15IndexedTriangleENS3_IS8_EEEE(ptr noundef nonnull align 8 dereferenceable(72) %16, ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef nonnull align 8 dereferenceable(24) %18)
  store ptr getelementptr inbounds inrange(-16, 32) ({ [6 x ptr] }, ptr @_ZTVN3JPH22TriangleSplitterMortonE, i32 0, i32 0, i32 2), ptr %16, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.JPH::TriangleSplitterMorton", ptr %16, i32 0, i32 1
  call void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %19) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #7
  invoke void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32) %7)
          to label %20 unwind label %29

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %49, %20
  %22 = load i32, ptr %10, align 4, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = invoke noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %24)
          to label %26 unwind label %33

26:                                               ; preds = %21
  %27 = icmp ult i64 %23, %25
  br i1 %27, label %37, label %28

28:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %52

29:                                               ; preds = %57, %53, %52, %3
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %8, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %9, align 4
  br label %109

33:                                               ; preds = %43, %42, %37, %21
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %8, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %109

37:                                               ; preds = %26
  %38 = getelementptr inbounds %"class.JPH::TriangleSplitter", ptr %16, i32 0, i32 3
  %39 = load i32, ptr %10, align 4, !tbaa !11
  %40 = zext i32 %39 to i64
  %41 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN3JPH5ArrayINS_6Float3ENS_12STLAllocatorIS1_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %40)
          to label %42 unwind label %33

42:                                               ; preds = %37
  invoke void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(12) %41)
          to label %43 unwind label %33

43:                                               ; preds = %42
  %44 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  %45 = load double, ptr %44, align 16
  %46 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  %47 = load double, ptr %46, align 8
  invoke void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32) %7, double %45, double %47)
          to label %48 unwind label %33

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %10, align 4, !tbaa !11
  %51 = add i32 %50, 1
  store i32 %51, ptr %10, align 4, !tbaa !11
  br label %21, !llvm.loop !13

52:                                               ; preds = %28
  invoke void @_ZN3JPH5AABox23EnsureMinimalEdgeLengthEf(ptr noundef nonnull align 16 dereferenceable(32) %7, float noundef 0x3EE4F8B580000000)
          to label %53 unwind label %29

53:                                               ; preds = %52
  %54 = getelementptr inbounds %"class.JPH::TriangleSplitterMorton", ptr %16, i32 0, i32 1
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = invoke noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %55)
          to label %57 unwind label %29

57:                                               ; preds = %53
  invoke void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %54, i64 noundef %56)
          to label %58 unwind label %29

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %59

59:                                               ; preds = %89, %58
  %60 = load i32, ptr %12, align 4, !tbaa !11
  %61 = zext i32 %60 to i64
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = invoke noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %62)
          to label %64 unwind label %67

64:                                               ; preds = %59
  %65 = icmp ult i64 %61, %63
  br i1 %65, label %71, label %66

66:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %92

67:                                               ; preds = %83, %77, %76, %71, %59
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %8, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %109

71:                                               ; preds = %64
  %72 = getelementptr inbounds %"class.JPH::TriangleSplitter", ptr %16, i32 0, i32 3
  %73 = load i32, ptr %12, align 4, !tbaa !11
  %74 = zext i32 %73 to i64
  %75 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN3JPH5ArrayINS_6Float3ENS_12STLAllocatorIS1_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %72, i64 noundef %74)
          to label %76 unwind label %67

76:                                               ; preds = %71
  invoke void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(12) %75)
          to label %77 unwind label %67

77:                                               ; preds = %76
  %78 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %79 = load double, ptr %78, align 16
  %80 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %81 = load double, ptr %80, align 8
  %82 = invoke noundef i32 @_ZN3JPH10MortonCode14sGetMortonCodeENS_4Vec3ERKNS_5AABoxE(double %79, double %81, ptr noundef nonnull align 16 dereferenceable(32) %7)
          to label %83 unwind label %67

83:                                               ; preds = %77
  %84 = getelementptr inbounds %"class.JPH::TriangleSplitterMorton", ptr %16, i32 0, i32 1
  %85 = load i32, ptr %12, align 4, !tbaa !11
  %86 = zext i32 %85 to i64
  %87 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %84, i64 noundef %86)
          to label %88 unwind label %67

88:                                               ; preds = %83
  store i32 %82, ptr %87, align 4, !tbaa !11
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %12, align 4, !tbaa !11
  %91 = add i32 %90, 1
  store i32 %91, ptr %12, align 4, !tbaa !11
  br label %59, !llvm.loop !15

92:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %93 = getelementptr inbounds %"class.JPH::TriangleSplitterMorton", ptr %16, i32 0, i32 1
  store ptr %93, ptr %14, align 8, !tbaa !5
  %94 = getelementptr inbounds %"class.JPH::TriangleSplitter", ptr %16, i32 0, i32 4
  %95 = invoke noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %94)
          to label %96 unwind label %105

96:                                               ; preds = %92
  %97 = getelementptr inbounds %"class.JPH::TriangleSplitter", ptr %16, i32 0, i32 4
  %98 = invoke noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %97)
          to label %99 unwind label %105

99:                                               ; preds = %96
  %100 = getelementptr inbounds %class.anon, ptr %15, i32 0, i32 0
  %101 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %101, ptr %100, align 8, !tbaa !5
  %102 = getelementptr inbounds %class.anon, ptr %15, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8
  invoke void @"_ZN3JPH9QuickSortIPjZNS_22TriangleSplitterMortonC1ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS4_EEEERKNS3_INS_15IndexedTriangleENS5_ISA_EEEEE3$_0EEvT_SG_T0_"(ptr noundef %95, ptr noundef %98, ptr %103)
          to label %104 unwind label %105

104:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #7
  ret void

105:                                              ; preds = %99, %96, %92
  %106 = landingpad { ptr, i32 }
          cleanup
  %107 = extractvalue { ptr, i32 } %106, 0
  store ptr %107, ptr %8, align 8
  %108 = extractvalue { ptr, i32 } %106, 1
  store i32 %108, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %109

109:                                              ; preds = %105, %67, %33, %29
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #7
  call void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %19) #7
  call void @_ZN3JPH16TriangleSplitterD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %16) #7
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %8, align 8
  %112 = load i32, ptr %9, align 4
  %113 = insertvalue { ptr, i32 } poison, ptr %111, 0
  %114 = insertvalue { ptr, i32 } %113, i32 %112, 1
  resume { ptr, i32 } %114
}

declare void @_ZN3JPH16TriangleSplitterC2ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS2_EEEERKNS1_INS_15IndexedTriangleENS3_IS8_EEEE(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32), double, double) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN3JPH5ArrayINS_6Float3ENS_12STLAllocatorIS1_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #5 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABox23EnsureMinimalEdgeLengthEf(ptr noundef nonnull align 16 dereferenceable(32), float noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH10MortonCode14sGetMortonCodeENS_4Vec3ERKNS_5AABoxE(double, double, ptr noundef nonnull align 16 dereferenceable(32)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZN3JPH9QuickSortIPjZNS_22TriangleSplitterMortonC1ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS4_EEEERKNS3_INS_15IndexedTriangleENS5_ISA_EEEEE3$_0EEvT_SG_T0_"(ptr noundef, ptr noundef, ptr) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH16TriangleSplitterD2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "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 #2 = { "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 nounwind uwtable "min-legal-vector-width"="0" "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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "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 #6 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }

@_ZTVN3JPH22TriangleSplitterMortonE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH22TriangleSplitterMortonC2ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS2_EEEERKNS1_INS_15IndexedTriangleENS3_IS8_EEEE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.JPH::AABox", align 16
  %5 = alloca %"class.JPH::Vec3", align 16
  %6 = alloca %"class.JPH::Vec3", align 16
  tail call void @_ZN3JPH16TriangleSplitterC2ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS2_EEEERKNS1_INS_15IndexedTriangleENS3_IS8_EEEE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2)
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTVN3JPH22TriangleSplitterMortonE, i64 16), ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #7
  invoke void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32) %4)
          to label %.preheader21 unwind label %11

.preheader21:                                     ; preds = %3
  %8 = call noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader21
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = getelementptr inbounds i8, ptr %5, i64 8
  br label %15

._crit_edge:                                      ; preds = %22, %.preheader21
  invoke void @_ZN3JPH5AABox23EnsureMinimalEdgeLengthEf(ptr noundef nonnull align 16 dereferenceable(32) %4, float noundef 0x3EE4F8B580000000)
          to label %27 unwind label %11

11:                                               ; preds = %27, %._crit_edge, %3
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %55

13:                                               ; preds = %19, %18, %15
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %55

15:                                               ; preds = %.lr.ph, %22
  %16 = phi i64 [ 0, %.lr.ph ], [ %24, %22 ]
  %.01722 = phi i32 [ 0, %.lr.ph ], [ %23, %22 ]
  %17 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN3JPH5ArrayINS_6Float3ENS_12STLAllocatorIS1_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %16)
          to label %18 unwind label %13

18:                                               ; preds = %15
  invoke void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(12) %17)
          to label %19 unwind label %13

19:                                               ; preds = %18
  %20 = load double, ptr %5, align 16
  %21 = load double, ptr %10, align 8
  invoke void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32) %4, double %20, double %21)
          to label %22 unwind label %13

22:                                               ; preds = %19
  %23 = add i32 %.01722, 1
  %24 = zext i32 %23 to i64
  %25 = call noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %26 = icmp ugt i64 %25, %24
  br i1 %26, label %15, label %._crit_edge, !llvm.loop !8

27:                                               ; preds = %._crit_edge
  %28 = call noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  invoke void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %28)
          to label %.preheader unwind label %11

.preheader:                                       ; preds = %27
  %29 = call noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %.not26 = icmp eq i64 %29, 0
  br i1 %.not26, label %._crit_edge25, label %.lr.ph24

.lr.ph24:                                         ; preds = %.preheader
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %31 = getelementptr inbounds i8, ptr %6, i64 8
  br label %37

._crit_edge25:                                    ; preds = %47, %.preheader
  %32 = getelementptr inbounds i8, ptr %0, i64 48
  %33 = call noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %32)
  %34 = call noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %32)
  invoke void @"_ZN3JPH9QuickSortIPjZNS_22TriangleSplitterMortonC1ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS4_EEEERKNS3_INS_15IndexedTriangleENS5_ISA_EEEEE3$_0EEvT_SG_T0_"(ptr noundef %33, ptr noundef %34, ptr nonnull %7)
          to label %52 unwind label %53

35:                                               ; preds = %45, %41, %40, %37
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %55

37:                                               ; preds = %.lr.ph24, %47
  %38 = phi i64 [ 0, %.lr.ph24 ], [ %49, %47 ]
  %.01623 = phi i32 [ 0, %.lr.ph24 ], [ %48, %47 ]
  %39 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN3JPH5ArrayINS_6Float3ENS_12STLAllocatorIS1_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %38)
          to label %40 unwind label %35

40:                                               ; preds = %37
  invoke void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16) %6, ptr noundef nonnull align 4 dereferenceable(12) %39)
          to label %41 unwind label %35

41:                                               ; preds = %40
  %42 = load double, ptr %6, align 16
  %43 = load double, ptr %31, align 8
  %44 = invoke noundef i32 @_ZN3JPH10MortonCode14sGetMortonCodeENS_4Vec3ERKNS_5AABoxE(double %42, double %43, ptr noundef nonnull align 16 dereferenceable(32) %4)
          to label %45 unwind label %35

45:                                               ; preds = %41
  %46 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %38)
          to label %47 unwind label %35

47:                                               ; preds = %45
  store i32 %44, ptr %46, align 4, !tbaa !10
  %48 = add i32 %.01623, 1
  %49 = zext i32 %48 to i64
  %50 = call noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %51 = icmp ugt i64 %50, %49
  br i1 %51, label %37, label %._crit_edge25, !llvm.loop !13

52:                                               ; preds = %._crit_edge25
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #7
  ret void

53:                                               ; preds = %._crit_edge25
  %54 = landingpad { ptr, i32 }
          cleanup
  br label %55

55:                                               ; preds = %53, %35, %13, %11
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %36, %35 ], [ %54, %53 ], [ %12, %11 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #7
  call void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #7
  call void @_ZN3JPH16TriangleSplitterD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0) #7
  resume { ptr, i32 } %.pn
}

declare void @_ZN3JPH16TriangleSplitterC2ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS2_EEEERKNS1_INS_15IndexedTriangleENS3_IS8_EEEE(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5ArrayINS_15IndexedTriangleENS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32), double, double) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN3JPH5ArrayINS_6Float3ENS_12STLAllocatorIS1_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABox23EnsureMinimalEdgeLengthEf(ptr noundef nonnull align 16 dereferenceable(32), float noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH10MortonCode14sGetMortonCodeENS_4Vec3ERKNS_5AABoxE(double, double, ptr noundef nonnull align 16 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZN3JPH9QuickSortIPjZNS_22TriangleSplitterMortonC1ERKNS_5ArrayINS_6Float3ENS_12STLAllocatorIS4_EEEERKNS3_INS_15IndexedTriangleENS5_ISA_EEEEE3$_0EEvT_SG_T0_"(ptr noundef, ptr noundef, ptr) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH5ArrayIjNS_12STLAllocatorIjEEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH16TriangleSplitterD2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #3 align 2

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass