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

; 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.Riemann::TriangleMesh" = type { %"class.Riemann::StaticMesh", 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.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"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] }

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7Riemann12TriangleMesh14CreateEmptyBVHEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %"class.Riemann::TriangleMesh", ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %17

9:                                                ; preds = %1
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 96) #4
  invoke void @_ZN7Riemann8MeshBVH4C2Ev(ptr noundef nonnull align 16 dereferenceable(96) %10)
          to label %11 unwind label %13

11:                                               ; preds = %9
  %12 = getelementptr inbounds %"class.Riemann::TriangleMesh", ptr %5, i32 0, i32 1
  store ptr %10, ptr %12, align 8, !tbaa !9
  br label %20

13:                                               ; preds = %9
  %14 = landingpad { ptr, i32 }
          cleanup
  %15 = extractvalue { ptr, i32 } %14, 0
  store ptr %15, ptr %3, align 8
  %16 = extractvalue { ptr, i32 } %14, 1
  store i32 %16, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 96) #5
  br label %23

17:                                               ; preds = %1
  %18 = getelementptr inbounds %"class.Riemann::TriangleMesh", ptr %5, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  call void @_ZN7Riemann8MeshBVH47ReleaseEv(ptr noundef nonnull align 16 dereferenceable(96) %19)
  br label %20

20:                                               ; preds = %17, %11
  %21 = getelementptr inbounds %"class.Riemann::TriangleMesh", ptr %5, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  ret ptr %22

23:                                               ; preds = %13
  %24 = load ptr, ptr %3, align 8
  %25 = load i32, ptr %4, align 4
  %26 = insertvalue { ptr, i32 } poison, ptr %24, 0
  %27 = insertvalue { ptr, i32 } %26, i32 %25, 1
  resume { ptr, i32 } %27
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Riemann8MeshBVH4C2Ev(ptr noundef nonnull align 16 dereferenceable(96)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann8MeshBVH47ReleaseEv(ptr noundef nonnull align 16 dereferenceable(96)) #3 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 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !6, i64 184}
!10 = !{!"_ZTSN7Riemann12TriangleMeshE", !11, i64 0, !6, i64 184}
!11 = !{!"_ZTSN7Riemann10StaticMeshE", !12, i64 0, !12, i64 4, !13, i64 8, !17, i64 32, !13, i64 56, !13, i64 80, !21, i64 104, !7, i64 128, !24, i64 136, !6, i64 168, !6, i64 176}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSSt6vectorIN5Maths8TVector3IfEESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTSSt6vectorItSaItEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseItSaItEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseItSaItEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseItSaItEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSN5Maths6TAABB3IfEE", !22, i64 0, !22, i64 12}
!22 = !{!"_ZTSN5Maths8TVector3IfEE", !23, i64 0, !23, i64 4, !23, i64 8}
!23 = !{!"float", !7, i64 0}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !25, i64 0, !26, i64 8, !7, i64 16}
!25 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!26 = !{!"long", !7, i64 0}


; 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 uwtable
define dso_local noundef ptr @_ZN7Riemann12TriangleMesh14CreateEmptyBVHEv(ptr nocapture noundef nonnull align 8 dereferenceable(192) %0) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 184
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %10

5:                                                ; preds = %1
  %6 = tail call noalias noundef nonnull dereferenceable(96) ptr @_Znwm(i64 noundef 96) #4
  invoke void @_ZN7Riemann8MeshBVH4C2Ev(ptr noundef nonnull align 16 dereferenceable(96) %6)
          to label %7 unwind label %8

7:                                                ; preds = %5
  store ptr %6, ptr %2, align 8, !tbaa !5
  br label %11

8:                                                ; preds = %5
  %9 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %6, i64 noundef 96) #5
  resume { ptr, i32 } %9

10:                                               ; preds = %1
  tail call void @_ZN7Riemann8MeshBVH47ReleaseEv(ptr noundef nonnull align 16 dereferenceable(96) %3)
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %7
  %12 = phi ptr [ %.pre, %10 ], [ %6, %7 ]
  ret ptr %12
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Riemann8MeshBVH4C2Ev(ptr noundef nonnull align 16 dereferenceable(96)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann8MeshBVH47ReleaseEv(ptr noundef nonnull align 16 dereferenceable(96)) local_unnamed_addr #3 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 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !15, i64 184}
!6 = !{!"_ZTSN7Riemann12TriangleMeshE", !7, i64 0, !15, i64 184}
!7 = !{!"_ZTSN7Riemann10StaticMeshE", !8, i64 0, !8, i64 4, !11, i64 8, !16, i64 32, !11, i64 56, !11, i64 80, !20, i64 104, !9, i64 128, !23, i64 136, !15, i64 168, !15, i64 176}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSSt6vectorIN5Maths8TVector3IfEESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN5Maths8TVector3IfEESaIS2_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !9, i64 0}
!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", !15, i64 0, !15, i64 8, !15, i64 16}
!20 = !{!"_ZTSN5Maths6TAABB3IfEE", !21, i64 0, !21, i64 12}
!21 = !{!"_ZTSN5Maths8TVector3IfEE", !22, i64 0, !22, i64 4, !22, i64 8}
!22 = !{!"float", !9, i64 0}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !25, i64 8, !9, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !15, i64 0}
!25 = !{!"long", !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass