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

; 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::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::BodyID" = type { i32 }

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 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: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH6BodyIDdaEPv(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: mustprogress uwtable
define dso_local void @_ZN3JPH11BodyManager4InitEjjRKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 8 dereferenceable(297) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %"class.JPH::UniqueLock", align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca %"struct.JPH::AssertLastParam", align 1
  %18 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #8
  %20 = getelementptr inbounds %"class.JPH::BodyManager", ptr %19, i32 0, i32 4
  call void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %9, ptr noundef nonnull align 8 dereferenceable(48) %20, ptr noundef %19, i32 noundef 4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %4
  %24 = call noundef i32 @_ZNSt6thread20hardware_concurrencyEv() #8
  %25 = mul i32 2, %24
  br label %28

26:                                               ; preds = %4
  %27 = load i32, ptr %7, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %26, %23
  %29 = phi i32 [ %25, %23 ], [ %27, %26 ]
  %30 = invoke noundef i32 @_ZN3JPH15GetNextPowerOf2Ej(i32 noundef %29)
          to label %31 unwind label %52

31:                                               ; preds = %28
  %32 = invoke noundef i32 @_ZN3JPH5ClampIjEET_S1_S1_S1_(i32 noundef %30, i32 noundef 1, i32 noundef 64)
          to label %33 unwind label %52

33:                                               ; preds = %31
  store i32 %32, ptr %10, align 4, !tbaa !9
  %34 = getelementptr inbounds %"class.JPH::BodyManager", ptr %19, i32 0, i32 5
  %35 = load i32, ptr %10, align 4, !tbaa !9
  invoke void @_ZN3JPH10MutexArrayINS_11SharedMutexEE4InitEj(ptr noundef nonnull align 8 dereferenceable(12) %34, i32 noundef %35)
          to label %36 unwind label %52

36:                                               ; preds = %33
  %37 = getelementptr inbounds %"class.JPH::BodyManager", ptr %19, i32 0, i32 0
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  invoke void @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %39)
          to label %40 unwind label %52

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %41 = getelementptr inbounds %"class.JPH::BodyManager", ptr %19, i32 0, i32 8
  store ptr %41, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = getelementptr inbounds [2 x ptr], ptr %42, i64 0, i64 0
  store ptr %43, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds [2 x ptr], ptr %44, i64 0, i64 0
  %46 = getelementptr inbounds ptr, ptr %45, i64 2
  store ptr %46, ptr %15, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %91, %40
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = load ptr, ptr %15, align 8, !tbaa !5
  %50 = icmp ne ptr %48, %49
  br i1 %50, label %56, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  br label %99

52:                                               ; preds = %36, %33, %31, %28
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %11, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %12, align 4
  br label %110

56:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %57, ptr %16, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %56
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = icmp eq ptr %60, null
  br i1 %61, label %70, label %62

62:                                               ; preds = %58
  %63 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 121)
          to label %64 unwind label %66

64:                                               ; preds = %62
  br i1 %63, label %65, label %70

65:                                               ; preds = %64
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #8, !srcloc !11
  br label %70

66:                                               ; preds = %72, %62
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %11, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %12, align 4
  br label %98

70:                                               ; preds = %65, %64, %58
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %6, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %74, i64 4)
  %76 = extractvalue { i64, i1 } %75, 1
  %77 = extractvalue { i64, i1 } %75, 0
  %78 = select i1 %76, i64 -1, i64 %77
  %79 = invoke noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef %78)
          to label %80 unwind label %66

80:                                               ; preds = %72
  %81 = icmp eq i64 %74, 0
  br i1 %81, label %89, label %82

82:                                               ; preds = %80
  %83 = getelementptr inbounds %"class.JPH::BodyID", ptr %79, i64 %74
  br label %84

84:                                               ; preds = %86, %82
  %85 = phi ptr [ %79, %82 ], [ %87, %86 ]
  invoke void @_ZN3JPH6BodyIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %85)
          to label %86 unwind label %94

86:                                               ; preds = %84
  %87 = getelementptr inbounds %"class.JPH::BodyID", ptr %85, i64 1
  %88 = icmp eq ptr %87, %83
  br i1 %88, label %89, label %84

89:                                               ; preds = %86, %80
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %79, ptr %90, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %91

91:                                               ; preds = %89
  %92 = load ptr, ptr %14, align 8, !tbaa !5
  %93 = getelementptr inbounds ptr, ptr %92, i32 1
  store ptr %93, ptr %14, align 8, !tbaa !5
  br label %47

94:                                               ; preds = %84
  %95 = landingpad { ptr, i32 }
          cleanup
  %96 = extractvalue { ptr, i32 } %95, 0
  store ptr %96, ptr %11, align 8
  %97 = extractvalue { ptr, i32 } %95, 1
  store i32 %97, ptr %12, align 4
  call void @_ZN3JPH6BodyIDdaEPv(ptr noundef %79) #8
  br label %98

98:                                               ; preds = %94, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  br label %110

99:                                               ; preds = %51
  %100 = getelementptr inbounds %"class.JPH::BodyManager", ptr %19, i32 0, i32 6
  %101 = load i32, ptr %6, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #8
  store i8 0, ptr %18, align 1, !tbaa !12
  invoke void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24) %100, i64 noundef %102, ptr noundef nonnull align 1 dereferenceable(1) %18)
          to label %103 unwind label %106

103:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #8
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %"class.JPH::BodyManager", ptr %19, i32 0, i32 15
  store ptr %104, ptr %105, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %9) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #8
  ret void

106:                                              ; preds = %99
  %107 = landingpad { ptr, i32 }
          cleanup
  %108 = extractvalue { ptr, i32 } %107, 0
  store ptr %108, ptr %11, align 8
  %109 = extractvalue { ptr, i32 } %107, 1
  store i32 %109, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #8
  br label %110

110:                                              ; preds = %106, %98, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %9) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #8
  br label %111

111:                                              ; preds = %110
  %112 = load ptr, ptr %11, align 8
  %113 = load i32, ptr %12, align 4
  %114 = insertvalue { ptr, i32 } poison, ptr %112, 0
  %115 = insertvalue { ptr, i32 } %114, i32 %113, 1
  resume { ptr, i32 } %115
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH5ClampIjEET_S1_S1_S1_(i32 noundef, i32 noundef, i32 noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH15GetNextPowerOf2Ej(i32 noundef) #5

; Function Attrs: nounwind
declare noundef i32 @_ZNSt6thread20hardware_concurrencyEv() #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH10MutexArrayINS_11SharedMutexEE4InitEj(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #1 align 2

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #7

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef) #4 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #5 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 = { alwaysinline 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 = { alwaysinline 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 = { 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 #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!11 = !{i64 2158726003}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !6, i64 288}
!14 = !{!"_ZTSN3JPH11BodyManagerE", !15, i64 0, !10, i64 24, !16, i64 32, !17, i64 40, !21, i64 88, !22, i64 104, !17, i64 128, !7, i64 176, !7, i64 192, !10, i64 200, !17, i64 208, !23, i64 256, !6, i64 280, !6, i64 288, !24, i64 296}
!15 = !{!"_ZTSN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEE", !16, i64 0, !16, i64 8, !6, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3JPH5MutexE", !18, i64 0, !20, i64 40}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!20 = !{!"_ZTSNSt6thread2idE", !16, i64 0}
!21 = !{!"_ZTSN3JPH10MutexArrayINS_11SharedMutexEEE", !6, i64 0, !10, i64 8}
!22 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !16, i64 0, !16, i64 8, !6, i64 16}
!23 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !16, i64 0, !16, i64 8, !6, i64 16}
!24 = !{!"bool", !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"

%"class.JPH::UniqueLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"class.JPH::BodyID" = type { i32 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH11BodyManager4InitEjjRKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 8 dereferenceable(297) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.JPH::UniqueLock", align 8
  %6 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  call void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %5, ptr noundef nonnull align 8 dereferenceable(48) %7, ptr noundef nonnull %0, i32 noundef 4)
  %8 = icmp eq i32 %2, 0
  br i1 %8, label %9, label %12

9:                                                ; preds = %4
  %10 = call noundef i32 @_ZNSt6thread20hardware_concurrencyEv() #6
  %11 = shl i32 %10, 1
  br label %12

12:                                               ; preds = %4, %9
  %13 = phi i32 [ %11, %9 ], [ %2, %4 ]
  %14 = invoke noundef i32 @_ZN3JPH15GetNextPowerOf2Ej(i32 noundef %13)
          to label %15 unwind label %41

15:                                               ; preds = %12
  %16 = invoke noundef i32 @_ZN3JPH5ClampIjEET_S1_S1_S1_(i32 noundef %14, i32 noundef 1, i32 noundef 64)
          to label %17 unwind label %41

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 88
  invoke void @_ZN3JPH10MutexArrayINS_11SharedMutexEE4InitEj(ptr noundef nonnull align 8 dereferenceable(12) %18, i32 noundef %16)
          to label %19 unwind label %41

19:                                               ; preds = %17
  %20 = zext i32 %1 to i64
  invoke void @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %20)
          to label %.preheader unwind label %41

.preheader:                                       ; preds = %19
  %.018.ptr23 = getelementptr inbounds i8, ptr %0, i64 176
  %21 = shl nuw nsw i64 %20, 2
  %22 = icmp eq i32 %1, 0
  %23 = load ptr, ptr %.018.ptr23, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %22, label %.preheader.split.us.preheader, label %.preheader.split.preheader

.preheader.split.preheader:                       ; preds = %.preheader
  br i1 %24, label %48, label %43

.preheader.split.us.preheader:                    ; preds = %.preheader
  br i1 %24, label %29, label %25

25:                                               ; preds = %.preheader.split.us.preheader
  %26 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 121)
          to label %27 unwind label %.split.us

27:                                               ; preds = %25
  br i1 %26, label %28, label %29

28:                                               ; preds = %27
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !9
  br label %29

29:                                               ; preds = %28, %27, %.preheader.split.us.preheader
  %30 = invoke noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef %21)
          to label %.preheader.split.us.1 unwind label %.split.us

.preheader.split.us.1:                            ; preds = %29
  store ptr %30, ptr %.018.ptr23, align 8, !tbaa !5
  %.018.ptr.us = getelementptr inbounds i8, ptr %0, i64 184
  %31 = load ptr, ptr %.018.ptr.us, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %37, label %33

33:                                               ; preds = %.preheader.split.us.1
  %34 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 121)
          to label %35 unwind label %.split.us

35:                                               ; preds = %33
  br i1 %34, label %36, label %37

36:                                               ; preds = %35
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !9
  br label %37

37:                                               ; preds = %36, %35, %.preheader.split.us.1
  %38 = invoke noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef %21)
          to label %.split27.us.loopexit unwind label %.split.us

.split27.us.loopexit:                             ; preds = %37
  store ptr %38, ptr %.018.ptr.us, align 8, !tbaa !5
  br label %.split27.us

.split.us:                                        ; preds = %37, %33, %29, %25
  %39 = landingpad { ptr, i32 }
          cleanup
  br label %74

.split27.us:                                      ; preds = %.loopexit.1, %.split27.us.loopexit
  %40 = getelementptr inbounds i8, ptr %0, i64 104
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #6
  store i8 0, ptr %6, align 1, !tbaa !10
  invoke void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %20, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %70 unwind label %72

41:                                               ; preds = %19, %17, %15, %12
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %74

43:                                               ; preds = %.preheader.split.preheader
  %44 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 121)
          to label %45 unwind label %.split

45:                                               ; preds = %43
  br i1 %44, label %46, label %48

46:                                               ; preds = %45
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !9
  br label %48

.split:                                           ; preds = %62, %58, %48, %43
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %74

48:                                               ; preds = %46, %45, %.preheader.split.preheader
  %49 = invoke noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef %21)
          to label %50 unwind label %.split

50:                                               ; preds = %48
  %51 = getelementptr inbounds %"class.JPH::BodyID", ptr %49, i64 %20
  br label %52

52:                                               ; preds = %52, %50
  %53 = phi ptr [ %49, %50 ], [ %54, %52 ]
  call void @_ZN3JPH6BodyIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %53)
  %54 = getelementptr inbounds i8, ptr %53, i64 4
  %55 = icmp eq ptr %54, %51
  br i1 %55, label %.loopexit, label %52

.loopexit:                                        ; preds = %52
  store ptr %49, ptr %.018.ptr23, align 8, !tbaa !5
  %.018.ptr = getelementptr inbounds i8, ptr %0, i64 184
  %56 = load ptr, ptr %.018.ptr, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %62, label %58

58:                                               ; preds = %.loopexit
  %59 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 121)
          to label %60 unwind label %.split

60:                                               ; preds = %58
  br i1 %59, label %61, label %62

61:                                               ; preds = %60
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !9
  br label %62

62:                                               ; preds = %61, %60, %.loopexit
  %63 = invoke noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef %21)
          to label %64 unwind label %.split

64:                                               ; preds = %62
  %65 = getelementptr inbounds %"class.JPH::BodyID", ptr %63, i64 %20
  br label %66

66:                                               ; preds = %66, %64
  %67 = phi ptr [ %63, %64 ], [ %68, %66 ]
  call void @_ZN3JPH6BodyIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %67)
  %68 = getelementptr inbounds i8, ptr %67, i64 4
  %69 = icmp eq ptr %68, %65
  br i1 %69, label %.loopexit.1, label %66

.loopexit.1:                                      ; preds = %66
  store ptr %63, ptr %.018.ptr, align 8, !tbaa !5
  br label %.split27.us

70:                                               ; preds = %.split27.us
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #6
  %71 = getelementptr inbounds i8, ptr %0, i64 288
  store ptr %3, ptr %71, align 8, !tbaa !11
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  ret void

72:                                               ; preds = %.split27.us
  %73 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #6
  br label %74

74:                                               ; preds = %.split, %.split.us, %72, %41
  %.pn = phi { ptr, i32 } [ %73, %72 ], [ %42, %41 ], [ %47, %.split ], [ %39, %.split.us ]
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  resume { ptr, i32 } %.pn
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH5ClampIjEET_S1_S1_S1_(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH15GetNextPowerOf2Ej(i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare noundef i32 @_ZNSt6thread20hardware_concurrencyEv() local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH10MutexArrayINS_11SharedMutexEE4InitEj(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 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: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH6BodyIDnaEm(i64 noundef) local_unnamed_addr #3 align 2

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,SROAPass,SimplifyCFGPass