; LLVM IR from zig-gamedev/zphysics :: libs/JoltC (JoltPhysicsC)

; 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::Result" = type <{ %union.anon.51, i8, [7 x i8] }>
%union.anon.51 = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider", i64, %union.anon.54 }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider" = type { ptr }
%union.anon.54 = type { i64, [8 x i8] }

; 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
declare hidden noundef ptr @_ZL5toJphPK17JPC_ShapeSettings(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local ptr @JPC_ShapeSettings_CreateShape(ptr noundef %0) #1 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %"class.JPH::Result", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef ptr @_ZL5toJphPK17JPC_ShapeSettings(ptr noundef %9)
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds ptr, ptr %11, i64 4
  %13 = load ptr, ptr %12, align 8
  call void %13(ptr dead_on_unwind writable sret(%"class.JPH::Result") align 8 %4, ptr noundef nonnull align 8 dereferenceable(64) %10)
  %14 = invoke noundef zeroext i1 @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE8HasErrorEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
          to label %15 unwind label %17

15:                                               ; preds = %1
  br i1 %14, label %16, label %21

16:                                               ; preds = %15
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %36

17:                                               ; preds = %1
  %18 = landingpad { ptr, i32 }
          cleanup
  %19 = extractvalue { ptr, i32 } %18, 0
  store ptr %19, ptr %5, align 8
  %20 = extractvalue { ptr, i32 } %18, 1
  store i32 %20, ptr %6, align 4
  br label %38

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE3GetEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
          to label %23 unwind label %32

23:                                               ; preds = %21
  %24 = invoke noundef ptr @_ZNK3JPH3RefINS_5ShapeEE6GetPtrEv(ptr noundef nonnull align 8 dereferenceable(8) %22)
          to label %25 unwind label %32

25:                                               ; preds = %23
  store ptr %24, ptr %8, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  invoke void @_ZNK3JPH9RefTargetINS_5ShapeEE6AddRefEv(ptr noundef nonnull align 4 dereferenceable(4) %27)
          to label %28 unwind label %32

28:                                               ; preds = %25
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = invoke noundef ptr @_ZL5toJpcPN3JPH5ShapeE(ptr noundef %29)
          to label %31 unwind label %32

31:                                               ; preds = %28
  store ptr %30, ptr %2, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %36

32:                                               ; preds = %28, %25, %23, %21
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %5, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %38

36:                                               ; preds = %31, %16
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33) %4) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #4
  %37 = load ptr, ptr %2, align 8
  ret ptr %37

38:                                               ; preds = %32, %17
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33) %4) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #4
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr %5, align 8
  %41 = load i32, ptr %6, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE8HasErrorEv(ptr noundef nonnull align 8 dereferenceable(33)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE3GetEv(ptr noundef nonnull align 8 dereferenceable(33)) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNK3JPH9RefTargetINS_5ShapeEE6AddRefEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJpcPN3JPH5ShapeE(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #2 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 = { 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 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 = { 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}


; 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::Result" = type <{ %union.anon.51, i8, [7 x i8] }>
%union.anon.51 = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider", i64, %union.anon.54 }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider" = type { ptr }
%union.anon.54 = type { i64, [8 x i8] }

; 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
declare hidden noundef ptr @_ZL5toJphPK17JPC_ShapeSettings(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @JPC_ShapeSettings_CreateShape(ptr noundef %0) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.JPH::Result", align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #4
  %3 = tail call noundef ptr @_ZL5toJphPK17JPC_ShapeSettings(ptr noundef %0)
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 32
  %6 = load ptr, ptr %5, align 8
  call void %6(ptr dead_on_unwind nonnull writable sret(%"class.JPH::Result") align 8 %2, ptr noundef nonnull align 8 dereferenceable(64) %3)
  %7 = call noundef zeroext i1 @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE8HasErrorEv(ptr noundef nonnull align 8 dereferenceable(33) %2)
  br i1 %7, label %16, label %8

8:                                                ; preds = %1
  %9 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE3GetEv(ptr noundef nonnull align 8 dereferenceable(33) %2)
          to label %10 unwind label %14

10:                                               ; preds = %8
  %11 = call noundef ptr @_ZNK3JPH3RefINS_5ShapeEE6GetPtrEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  call void @_ZNK3JPH9RefTargetINS_5ShapeEE6AddRefEv(ptr noundef nonnull align 4 dereferenceable(4) %12)
  %13 = call noundef ptr @_ZL5toJpcPN3JPH5ShapeE(ptr noundef %11)
  br label %16

14:                                               ; preds = %8
  %15 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33) %2) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #4
  resume { ptr, i32 } %15

16:                                               ; preds = %1, %10
  %.0 = phi ptr [ %13, %10 ], [ null, %1 ]
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33) %2) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #4
  ret ptr %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE8HasErrorEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE3GetEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNK3JPH9RefTargetINS_5ShapeEE6AddRefEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJpcPN3JPH5ShapeE(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #2 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 = { 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 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 = { 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"}


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