; 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] }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__.JPC_Shape_sRestoreFromBinaryState = external hidden unnamed_addr constant [53 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; 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)) #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNK3JPH9RefTargetINS_5ShapeEE6AddRefEv(ptr noundef nonnull align 4 dereferenceable(4)) #4 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

; Function Attrs: mustprogress uwtable
define dso_local ptr @JPC_Shape_sRestoreFromBinaryState(ptr noundef %0) #3 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
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  br label %14

12:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.28, ptr noundef @.str.1, i32 noundef 1998, ptr noundef @__PRETTY_FUNCTION__.JPC_Shape_sRestoreFromBinaryState) #6
  unreachable

13:                                               ; No predecessors!
  br label %14

14:                                               ; preds = %13, %11
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #7
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN3JPH5Shape23sRestoreFromBinaryStateERNS_8StreamInE(ptr dead_on_unwind writable sret(%"class.JPH::Result") align 8 %4, ptr noundef nonnull align 8 dereferenceable(8) %15)
  %16 = invoke noundef zeroext i1 @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE8HasErrorEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
          to label %17 unwind label %19

17:                                               ; preds = %14
  br i1 %16, label %18, label %23

18:                                               ; preds = %17
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %38

19:                                               ; preds = %14
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %5, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %6, align 4
  br label %40

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %24 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE3GetEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
          to label %25 unwind label %34

25:                                               ; preds = %23
  %26 = invoke noundef ptr @_ZNK3JPH3RefINS_5ShapeEE6GetPtrEv(ptr noundef nonnull align 8 dereferenceable(8) %24)
          to label %27 unwind label %34

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

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

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

34:                                               ; preds = %30, %27, %25, %23
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %5, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %40

38:                                               ; preds = %33, %18
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33) %4) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #7
  %39 = load ptr, ptr %2, align 8
  ret ptr %39

40:                                               ; preds = %34, %19
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(33) %4) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #7
  br label %41

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

declare void @_ZN3JPH5Shape23sRestoreFromBinaryStateERNS_8StreamInE(ptr dead_on_unwind writable sret(%"class.JPH::Result") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { 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 = { 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 = { "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 = { noreturn nounwind }
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"}


; 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] }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__.JPC_Shape_sRestoreFromBinaryState = external hidden unnamed_addr constant [53 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; 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 #3 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 #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNK3JPH9RefTargetINS_5ShapeEE6AddRefEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @JPC_Shape_sRestoreFromBinaryState(ptr noundef %0) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.JPH::Result", align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.1, i32 noundef 1998, ptr noundef nonnull @__PRETTY_FUNCTION__.JPC_Shape_sRestoreFromBinaryState) #6
  unreachable

4:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #7
  call void @_ZN3JPH5Shape23sRestoreFromBinaryStateERNS_8StreamInE(ptr dead_on_unwind nonnull writable sret(%"class.JPH::Result") align 8 %2, ptr noundef nonnull align 8 dereferenceable(8) %0)
  %5 = call noundef zeroext i1 @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE8HasErrorEv(ptr noundef nonnull align 8 dereferenceable(33) %2)
  br i1 %5, label %14, label %6

6:                                                ; preds = %4
  %7 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH6ResultINS_3RefINS_5ShapeEEEE3GetEv(ptr noundef nonnull align 8 dereferenceable(33) %2)
          to label %8 unwind label %12

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

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

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

declare void @_ZN3JPH5Shape23sRestoreFromBinaryStateERNS_8StreamInE(ptr dead_on_unwind writable sret(%"class.JPH::Result") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { 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 = { 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 = { "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 = { noreturn nounwind }
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)"}


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