; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Body/BodyManager.ll (ZN3JPH11BodyManager7AddBodyEPNS_4BodyE)

; 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::UniqueLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::BodyManager" = type <{ %"class.JPH::Array", i32, [4 x i8], i64, %"class.JPH::Mutex", %"class.JPH::MutexArray", %"class.JPH::Array.0", %"class.JPH::Mutex", [2 x ptr], [2 x %"struct.std::atomic"], i32, [4 x i8], %"class.JPH::Mutex", %"class.JPH::Array.3", ptr, ptr, i8, [7 x i8] }>
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::MutexArray" = type <{ ptr, i32, [4 x i8] }>
%"class.JPH::Array.0" = type { i64, i64, ptr }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::Mutex" = type { %"class.std::mutex", %"class.std::thread::id" }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::thread::id" = type { i64 }
%"class.JPH::Array.3" = type { i64, i64, ptr }
%"class.JPH::Body" = type <{ %"class.JPH::Vec3", %"class.JPH::Quat", %"class.JPH::AABox", %"class.JPH::RefConst", ptr, i64, %"class.JPH::CollisionGroup", float, float, %"class.JPH::BodyID", i16, i8, %"class.JPH::BroadPhaseLayer", i8, %"struct.std::atomic.8", [6 x i8] }>
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::Quat" = type { %"class.JPH::Vec4" }
%"class.JPH::Vec4" = type { %union.anon.6 }
%union.anon.6 = type { <4 x float> }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::RefConst" = type { ptr }
%"class.JPH::CollisionGroup" = type { %"class.JPH::RefConst.7", i32, i32 }
%"class.JPH::RefConst.7" = type { ptr }
%"class.JPH::BroadPhaseLayer" = type { i8 }
%"struct.std::atomic.8" = type { %"struct.std::__atomic_base.9" }
%"struct.std::__atomic_base.9" = type { i8 }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [35 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: mustprogress uwtable
declare dso_local void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH11BodyManager19sIsValidBodyPointerEPKNS_4BodyE(ptr noundef) #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3JPH11BodyManager7AddBodyEPNS_4BodyE(ptr noundef nonnull align 8 dereferenceable(297) %0, ptr noundef %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.JPH::UniqueLock", align 8
  %8 = alloca %"struct.JPH::AssertLastParam", align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"struct.JPH::AssertLastParam", align 1
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca %"class.JPH::BodyID", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %16)
  %18 = call noundef zeroext i1 @_ZNK3JPH6BodyID9IsInvalidEv(ptr noundef nonnull align 4 dereferenceable(4) %17)
  br i1 %18, label %20, label %19

19:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %107

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #6
  %21 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 4
  call void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %7, ptr noundef nonnull align 8 dereferenceable(48) %21, ptr noundef %15, i32 noundef 4)
  %22 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 3
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = icmp ne i64 %23, -1
  br i1 %24, label %25, label %76

25:                                               ; preds = %20
  br label %26

26:                                               ; preds = %25
  %27 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 3
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = and i64 %28, 1
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %39, label %31

31:                                               ; preds = %26
  %32 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 299)
          to label %33 unwind label %35

33:                                               ; preds = %31
  br i1 %32, label %34, label %39

34:                                               ; preds = %33
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !22
  br label %39

35:                                               ; preds = %87, %84, %79, %76, %66, %61, %55, %51, %46, %31
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %9, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %10, align 4
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %7) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %109

39:                                               ; preds = %34, %33, %26
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  %42 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 3
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = lshr i64 %43, 1
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %6, align 4, !tbaa !23
  br label %46

46:                                               ; preds = %41
  %47 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  %48 = load i32, ptr %6, align 4, !tbaa !23
  %49 = zext i32 %48 to i64
  %50 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %47, i64 noundef %49)
          to label %51 unwind label %35

51:                                               ; preds = %46
  %52 = load ptr, ptr %50, align 8, !tbaa !5
  %53 = invoke noundef zeroext i1 @_ZN3JPH11BodyManager19sIsValidBodyPointerEPKNS_4BodyE(ptr noundef %52)
          to label %54 unwind label %35

54:                                               ; preds = %51
  br i1 %53, label %55, label %59

55:                                               ; preds = %54
  %56 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 301)
          to label %57 unwind label %35

57:                                               ; preds = %55
  br i1 %56, label %58, label %59

58:                                               ; preds = %57
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !24
  br label %59

59:                                               ; preds = %58, %57, %54
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  %62 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  %63 = load i32, ptr %6, align 4, !tbaa !23
  %64 = zext i32 %63 to i64
  %65 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %64)
          to label %66 unwind label %35

66:                                               ; preds = %61
  %67 = load ptr, ptr %65, align 8, !tbaa !5
  %68 = ptrtoint ptr %67 to i64
  %69 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 3
  store i64 %68, ptr %69, align 8, !tbaa !9
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  %72 = load i32, ptr %6, align 4, !tbaa !23
  %73 = zext i32 %72 to i64
  %74 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %71, i64 noundef %73)
          to label %75 unwind label %35

75:                                               ; preds = %66
  store ptr %70, ptr %74, align 8, !tbaa !5
  br label %93

76:                                               ; preds = %20
  %77 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  %78 = invoke noundef i64 @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %77)
          to label %79 unwind label %35

79:                                               ; preds = %76
  %80 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  %81 = invoke noundef i64 @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE8capacityEv(ptr noundef nonnull align 8 dereferenceable(24) %80)
          to label %82 unwind label %35

82:                                               ; preds = %79
  %83 = icmp ult i64 %78, %81
  br i1 %83, label %84, label %91

84:                                               ; preds = %82
  %85 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  %86 = invoke noundef i64 @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %85)
          to label %87 unwind label %35

87:                                               ; preds = %84
  %88 = trunc i64 %86 to i32
  store i32 %88, ptr %6, align 4, !tbaa !23
  %89 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 0
  invoke void @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %89, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %90 unwind label %35

90:                                               ; preds = %87
  br label %92

91:                                               ; preds = %82
  store i1 false, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %97

92:                                               ; preds = %90
  br label %93

93:                                               ; preds = %92, %75
  %94 = getelementptr inbounds %"class.JPH::BodyManager", ptr %15, i32 0, i32 1
  %95 = load i32, ptr %94, align 8, !tbaa !25
  %96 = add i32 %95, 1
  store i32 %96, ptr %94, align 8, !tbaa !25
  store i32 0, ptr %12, align 4
  br label %97

97:                                               ; preds = %93, %91
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %7) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  %98 = load i32, ptr %12, align 4
  switch i32 %98, label %106 [
    i32 0, label %99
  ]

99:                                               ; preds = %97
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #6
  %100 = load i32, ptr %6, align 4, !tbaa !23
  %101 = call noundef zeroext i8 @_ZN3JPH11BodyManager21GetNextSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(297) %15, i32 noundef %100)
  store i8 %101, ptr %13, align 1, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %102 = load i32, ptr %6, align 4, !tbaa !23
  %103 = load i8, ptr %13, align 1, !tbaa !26
  call void @_ZN3JPH6BodyIDC2Ejh(ptr noundef nonnull align 4 dereferenceable(4) %14, i32 noundef %102, i8 noundef zeroext %103)
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %"class.JPH::Body", ptr %104, i32 0, i32 9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %105, ptr align 4 %14, i64 4, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  store i1 true, ptr %3, align 1
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #6
  br label %106

106:                                              ; preds = %99, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %107

107:                                              ; preds = %106, %19
  %108 = load i1, ptr %3, align 1
  ret i1 %108

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3JPH11BodyManager21GetNextSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(297), i32 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH6BodyIDC2Ejh(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i8 noundef zeroext) unnamed_addr #1 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 = { 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 #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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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, !12, i64 32}
!10 = !{!"_ZTSN3JPH11BodyManagerE", !11, i64 0, !13, i64 24, !12, i64 32, !14, i64 40, !18, i64 88, !19, i64 104, !14, i64 128, !7, i64 176, !7, i64 192, !13, i64 200, !14, i64 208, !20, i64 256, !6, i64 280, !6, i64 288, !21, i64 296}
!11 = !{!"_ZTSN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3JPH5MutexE", !15, i64 0, !17, i64 40}
!15 = !{!"_ZTSSt5mutex", !16, i64 0}
!16 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!17 = !{!"_ZTSNSt6thread2idE", !12, i64 0}
!18 = !{!"_ZTSN3JPH10MutexArrayINS_11SharedMutexEEE", !6, i64 0, !13, i64 8}
!19 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!20 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!21 = !{!"bool", !7, i64 0}
!22 = !{i64 2158727208}
!23 = !{!13, !13, i64 0}
!24 = !{i64 2158727570}
!25 = !{!10, !13, i64 24}
!26 = !{!7, !7, i64 0}
!27 = !{i64 0, i64 4, !23}


; 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::UniqueLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"class.JPH::BodyID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [35 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: mustprogress uwtable
declare dso_local void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH11BodyManager19sIsValidBodyPointerEPKNS_4BodyE(ptr noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH6BodyID9IsInvalidEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3JPH11BodyManager7AddBodyEPNS_4BodyE(ptr noundef nonnull align 8 dereferenceable(297) %0, ptr noundef nonnull %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca %"class.JPH::UniqueLock", align 8
  %5 = alloca %"class.JPH::BodyID", align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %1)
  %7 = tail call noundef zeroext i1 @_ZNK3JPH6BodyID9IsInvalidEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  br i1 %7, label %8, label %54

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  call void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %4, ptr noundef nonnull align 8 dereferenceable(48) %9, ptr noundef nonnull %0, i32 noundef 4)
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %.not = icmp eq i64 %11, -1
  br i1 %.not, label %39, label %12

12:                                               ; preds = %8
  %13 = and i64 %11, 1
  %.not13 = icmp eq i64 %13, 0
  br i1 %.not13, label %14, label %20

14:                                               ; preds = %12
  %15 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 299)
          to label %16 unwind label %18

16:                                               ; preds = %14
  br i1 %15, label %17, label %20

17:                                               ; preds = %16
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !22
  br label %20

18:                                               ; preds = %43, %34, %32, %28, %20, %14
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  resume { ptr, i32 } %19

20:                                               ; preds = %17, %16, %12
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = lshr i64 %21, 1
  %23 = and i64 %22, 4294967295
  %24 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %23)
          to label %25 unwind label %18

25:                                               ; preds = %20
  %26 = load ptr, ptr %24, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZN3JPH11BodyManager19sIsValidBodyPointerEPKNS_4BodyE(ptr noundef %26)
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 301)
          to label %30 unwind label %18

30:                                               ; preds = %28
  br i1 %29, label %31, label %32

31:                                               ; preds = %30
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !23
  br label %32

32:                                               ; preds = %31, %30, %25
  %33 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %23)
          to label %34 unwind label %18

34:                                               ; preds = %32
  %35 = load ptr, ptr %33, align 8, !tbaa !5
  %36 = ptrtoint ptr %35 to i64
  store i64 %36, ptr %10, align 8, !tbaa !9
  %37 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %23)
          to label %38 unwind label %18

38:                                               ; preds = %34
  store ptr %1, ptr %37, align 8, !tbaa !5
  br label %46

39:                                               ; preds = %8
  %40 = call noundef i64 @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %41 = call noundef i64 @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE8capacityEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %42 = icmp ult i64 %40, %41
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  %44 = call noundef i64 @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  invoke void @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %46 unwind label %18

45:                                               ; preds = %39
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  br label %54

46:                                               ; preds = %38, %43
  %.011.in = phi i64 [ %22, %38 ], [ %44, %43 ]
  %.011 = trunc i64 %.011.in to i32
  %47 = getelementptr inbounds i8, ptr %0, i64 24
  %48 = load i32, ptr %47, align 8, !tbaa !24
  %49 = add i32 %48, 1
  store i32 %49, ptr %47, align 8, !tbaa !24
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  %50 = call noundef zeroext i8 @_ZN3JPH11BodyManager21GetNextSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(297) %0, i32 noundef %.011)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @_ZN3JPH6BodyIDC2Ejh(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef %.011, i8 noundef zeroext %50)
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 112
  %53 = load i32, ptr %5, align 4, !tbaa !25
  store i32 %53, ptr %52, align 16, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %54

54:                                               ; preds = %45, %46, %2
  %.2 = phi i1 [ false, %2 ], [ false, %45 ], [ true, %46 ]
  ret i1 %.2
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3JPH11BodyManager21GetNextSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(297), i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH6BodyIDC2Ejh(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i8 noundef zeroext) unnamed_addr #1 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 = { 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 #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 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 = { 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, !12, i64 32}
!10 = !{!"_ZTSN3JPH11BodyManagerE", !11, i64 0, !13, i64 24, !12, i64 32, !14, i64 40, !18, i64 88, !19, i64 104, !14, i64 128, !7, i64 176, !7, i64 192, !13, i64 200, !14, i64 208, !20, i64 256, !6, i64 280, !6, i64 288, !21, i64 296}
!11 = !{!"_ZTSN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3JPH5MutexE", !15, i64 0, !17, i64 40}
!15 = !{!"_ZTSSt5mutex", !16, i64 0}
!16 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!17 = !{!"_ZTSNSt6thread2idE", !12, i64 0}
!18 = !{!"_ZTSN3JPH10MutexArrayINS_11SharedMutexEEE", !6, i64 0, !13, i64 8}
!19 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!20 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!21 = !{!"bool", !7, i64 0}
!22 = !{i64 2158727208}
!23 = !{i64 2158727570}
!24 = !{!10, !13, i64 24}
!25 = !{!13, !13, i64 0}


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