; LLVM IR from atlantis13579/Riemann :: Src/CollisionPrimitive/TriangleMesh.ll (ZN7Riemann12TriangleMesh8BuildBVHEv)

; 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.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl" }
%"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Riemann::StaticMesh" = type { i32, i32, %"class.std::vector", %"class.std::vector.0", %"class.std::vector", %"class.std::vector", %"class.Maths::TAABB3", i8, %"class.std::__cxx11::basic_string", ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Maths::TVector3<float>, std::allocator<Maths::TVector3<float>>>::_Vector_impl" }
%"struct.std::_Vector_base<Maths::TVector3<float>, std::allocator<Maths::TVector3<float>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Maths::TVector3<float>, std::allocator<Maths::TVector3<float>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Maths::TVector3<float>, std::allocator<Maths::TVector3<float>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.Riemann::TriangleMesh" = type { %"class.Riemann::StaticMesh", ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7Riemann12TriangleMesh14CreateEmptyBVHEv(ptr noundef nonnull align 8 dereferenceable(192)) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann12TriangleMesh8BuildBVHEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::vector.8", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.Maths::TAABB3", align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.Maths::TAABB3", align 4
  %9 = alloca %"class.std::vector.13", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  %11 = getelementptr inbounds %"class.Riemann::StaticMesh", ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %1
  br label %69

15:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #5
  call void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #5
  %16 = getelementptr inbounds %"class.Riemann::StaticMesh", ptr %10, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  invoke void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %18)
          to label %19 unwind label %27

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  invoke void @_ZN5Maths6TAABB3IfE5EmptyEv(ptr dead_on_unwind writable sret(%"class.Maths::TAABB3") align 4 %6)
          to label %20 unwind label %31

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

21:                                               ; preds = %50, %20
  %22 = load i32, ptr %7, align 4, !tbaa !26
  %23 = getelementptr inbounds %"class.Riemann::StaticMesh", ptr %10, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = icmp ult i32 %22, %24
  br i1 %25, label %35, label %26

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

27:                                               ; preds = %15
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %4, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %5, align 4
  br label %75

31:                                               ; preds = %62, %19
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %4, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %5, align 4
  br label %74

35:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #5
  %36 = load i32, ptr %7, align 4, !tbaa !26
  %37 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184) %10, i32 noundef %36, i32 noundef 0)
          to label %38 unwind label %53

38:                                               ; preds = %35
  %39 = load i32, ptr %7, align 4, !tbaa !26
  %40 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184) %10, i32 noundef %39, i32 noundef 1)
          to label %41 unwind label %53

41:                                               ; preds = %38
  %42 = load i32, ptr %7, align 4, !tbaa !26
  %43 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184) %10, i32 noundef %42, i32 noundef 2)
          to label %44 unwind label %53

44:                                               ; preds = %41
  invoke void @_ZN5Maths6TAABB3IfEC2ERKNS_8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(24) %8, ptr noundef nonnull align 4 dereferenceable(12) %37, ptr noundef nonnull align 4 dereferenceable(12) %40, ptr noundef nonnull align 4 dereferenceable(12) %43)
          to label %45 unwind label %53

45:                                               ; preds = %44
  invoke void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(24) %8)
          to label %46 unwind label %53

46:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  %47 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #5
  %48 = invoke noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfE11EncapsulateERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %6, ptr noundef nonnull align 4 dereferenceable(24) %47)
          to label %49 unwind label %57

49:                                               ; preds = %46
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %7, align 4, !tbaa !26
  %52 = add i32 %51, 1
  store i32 %52, ptr %7, align 4, !tbaa !26
  br label %21, !llvm.loop !27

53:                                               ; preds = %45, %44, %41, %38, %35
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %4, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  br label %61

57:                                               ; preds = %46
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %4, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %5, align 4
  br label %61

61:                                               ; preds = %57, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %74

62:                                               ; preds = %26
  %63 = invoke noundef ptr @_ZN7Riemann12TriangleMesh14CreateEmptyBVHEv(ptr noundef nonnull align 8 dereferenceable(192) %10)
          to label %64 unwind label %31

64:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #5
  call void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #5
  %65 = getelementptr inbounds %"class.Riemann::TriangleMesh", ptr %10, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !29
  invoke void @_ZN7Riemann8MeshBVH415BuildFromBoundsERS0_RKSt6vectorIN5Maths6TAABB3IfEESaIS5_EERS2_IjSaIjEERKS5_(ptr noundef nonnull align 16 dereferenceable(96) %66, ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 4 dereferenceable(24) %6)
          to label %67 unwind label %70

67:                                               ; preds = %64
  invoke void @_ZN7Riemann10StaticMesh7ReorderERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(184) %10, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %68 unwind label %70

68:                                               ; preds = %67
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  call void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #5
  br label %69

69:                                               ; preds = %68, %14
  ret void

70:                                               ; preds = %67, %64
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %4, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %5, align 4
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #5
  br label %74

74:                                               ; preds = %70, %61, %31
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  br label %75

75:                                               ; preds = %74, %27
  call void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #5
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %4, align 8
  %78 = load i32, ptr %5, align 4
  %79 = insertvalue { ptr, i32 } poison, ptr %77, 0
  %80 = insertvalue { ptr, i32 } %79, i32 %78, 1
  resume { ptr, i32 } %80
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths6TAABB3IfE5EmptyEv(ptr dead_on_unwind noalias writable sret(%"class.Maths::TAABB3") align 4) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184), i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths6TAABB3IfEC2ERKNS_8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #0 align 2

; 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
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfE11EncapsulateERKS1_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) #0 align 2

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

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

declare void @_ZN7Riemann8MeshBVH415BuildFromBoundsERS0_RKSt6vectorIN5Maths6TAABB3IfEESaIS5_EERS2_IjSaIjEERKS5_(ptr noundef nonnull align 16 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Riemann10StaticMesh7ReorderERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTSN7Riemann10StaticMeshE", !11, i64 0, !11, i64 4, !12, i64 8, !16, i64 32, !12, i64 56, !12, i64 80, !20, i64 104, !7, i64 128, !23, i64 136, !6, i64 168, !6, i64 176}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSSt6vectorIN5Maths8TVector3IfEESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"_ZTSSt6vectorItSaItEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseItSaItEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseItSaItEE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseItSaItEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSN5Maths6TAABB3IfEE", !21, i64 0, !21, i64 12}
!21 = !{!"_ZTSN5Maths8TVector3IfEE", !22, i64 0, !22, i64 4, !22, i64 8}
!22 = !{!"float", !7, i64 0}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !25, i64 8, !7, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!25 = !{!"long", !7, i64 0}
!26 = !{!11, !11, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!30, !6, i64 184}
!30 = !{!"_ZTSN7Riemann12TriangleMeshE", !10, i64 0, !6, i64 184}


; 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.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl" }
%"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Maths::TAABB3<float>, std::allocator<Maths::TAABB3<float>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7Riemann12TriangleMesh14CreateEmptyBVHEv(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann12TriangleMesh8BuildBVHEv(ptr noundef nonnull align 8 dereferenceable(192) %0) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.std::vector.8", align 8
  %3 = alloca %"class.Maths::TAABB3", align 4
  %4 = alloca %"class.Maths::TAABB3", align 4
  %5 = alloca %"class.std::vector.13", align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %42, label %9

9:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #5
  %10 = load i32, ptr %6, align 4, !tbaa !5
  %11 = zext i32 %10 to i64
  invoke void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %11)
          to label %12 unwind label %15

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  invoke void @_ZN5Maths6TAABB3IfE5EmptyEv(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TAABB3") align 4 %3)
          to label %.preheader unwind label %17

.preheader:                                       ; preds = %12
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %29, %.preheader
  %14 = invoke noundef ptr @_ZN7Riemann12TriangleMesh14CreateEmptyBVHEv(ptr noundef nonnull align 8 dereferenceable(192) %0)
          to label %37 unwind label %17

15:                                               ; preds = %9
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %46

17:                                               ; preds = %._crit_edge, %12
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %45

.lr.ph:                                           ; preds = %.preheader, %29
  %.014 = phi i32 [ %30, %29 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  %19 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %.014, i32 noundef 0)
          to label %20 unwind label %33

20:                                               ; preds = %.lr.ph
  %21 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %.014, i32 noundef 1)
          to label %22 unwind label %33

22:                                               ; preds = %20
  %23 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %.014, i32 noundef 2)
          to label %24 unwind label %33

24:                                               ; preds = %22
  invoke void @_ZN5Maths6TAABB3IfEC2ERKNS_8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(24) %4, ptr noundef nonnull align 4 dereferenceable(12) %19, ptr noundef nonnull align 4 dereferenceable(12) %21, ptr noundef nonnull align 4 dereferenceable(12) %23)
          to label %25 unwind label %33

25:                                               ; preds = %24
  invoke void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 4 dereferenceable(24) %4)
          to label %26 unwind label %33

26:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  %27 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #5
  %28 = invoke noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfE11EncapsulateERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(24) %27)
          to label %29 unwind label %35

29:                                               ; preds = %26
  %30 = add nuw i32 %.014, 1
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !25

33:                                               ; preds = %25, %24, %22, %20, %.lr.ph
  %34 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  br label %45

35:                                               ; preds = %26
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %45

37:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #5
  %38 = getelementptr inbounds i8, ptr %0, i64 184
  %39 = load ptr, ptr %38, align 8, !tbaa !27
  invoke void @_ZN7Riemann8MeshBVH415BuildFromBoundsERS0_RKSt6vectorIN5Maths6TAABB3IfEESaIS5_EERS2_IjSaIjEERKS5_(ptr noundef nonnull align 16 dereferenceable(96) %39, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 4 dereferenceable(24) %3)
          to label %40 unwind label %43

40:                                               ; preds = %37
  invoke void @_ZN7Riemann10StaticMesh7ReorderERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(184) %0, ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %41 unwind label %43

41:                                               ; preds = %40
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  call void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  br label %42

42:                                               ; preds = %1, %41
  ret void

43:                                               ; preds = %40, %37
  %44 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  br label %45

45:                                               ; preds = %33, %35, %43, %17
  %.pn.pn = phi { ptr, i32 } [ %44, %43 ], [ %18, %17 ], [ %36, %35 ], [ %34, %33 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  br label %46

46:                                               ; preds = %45, %15
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %45 ], [ %16, %15 ]
  call void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  resume { ptr, i32 } %.pn.pn.pn
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths6TAABB3IfE5EmptyEv(ptr dead_on_unwind noalias writable sret(%"class.Maths::TAABB3") align 4) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN5Maths6TAABB3IfEESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK7Riemann10StaticMesh9GetVertexEii(ptr noundef nonnull align 8 dereferenceable(184), i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths6TAABB3IfEC2ERKNS_8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfE11EncapsulateERKS1_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #0 align 2

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

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

declare void @_ZN7Riemann8MeshBVH415BuildFromBoundsERS0_RKSt6vectorIN5Maths6TAABB3IfEESaIS5_EERS2_IjSaIjEERKS5_(ptr noundef nonnull align 16 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Riemann10StaticMesh7ReorderERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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, !7, i64 4}
!6 = !{!"_ZTSN7Riemann10StaticMeshE", !7, i64 0, !7, i64 4, !10, i64 8, !15, i64 32, !10, i64 56, !10, i64 80, !19, i64 104, !8, i64 128, !22, i64 136, !14, i64 168, !14, i64 176}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN5Maths8TVector3IfEESaIS2_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSSt6vectorItSaItEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseItSaItEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseItSaItEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseItSaItEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!19 = !{!"_ZTSN5Maths6TAABB3IfEE", !20, i64 0, !20, i64 12}
!20 = !{!"_ZTSN5Maths8TVector3IfEE", !21, i64 0, !21, i64 4, !21, i64 8}
!21 = !{!"float", !8, i64 0}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !23, i64 0, !24, i64 8, !8, i64 16}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!24 = !{!"long", !8, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!28, !14, i64 184}
!28 = !{!"_ZTSN7Riemann12TriangleMeshE", !6, i64 0, !14, i64 184}


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