; LLVM IR from zig-gamedev/zphysics :: libs/Jolt/Physics/Collision/BroadPhase (BroadPhaseQuadTree)

; 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::SharedLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::BroadPhaseQuadTree" = type { %"class.JPH::BroadPhase", ptr, i64, %"class.JPH::Array", [8 x i8], %"class.JPH::FixedSizeFreeList", ptr, ptr, i32, %"class.JPH::SharedMutex", [2 x %"class.JPH::SharedMutex"], %"struct.std::atomic", i32, [32 x i8] }
%"class.JPH::BroadPhase" = type { %"class.JPH::BroadPhaseQuery", ptr }
%"class.JPH::BroadPhaseQuery" = type { ptr }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::FixedSizeFreeList" = type <{ i32, i32, i32, i32, i32, [4 x i8], ptr, [32 x i8], %"class.JPH::Mutex", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic.0", %"struct.std::atomic", [60 x i8] }>
%"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 }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i64 }
%"class.JPH::SharedMutex" = type { %"class.std::shared_mutex", %"class.std::thread::id" }
%"class.std::shared_mutex" = type { %"class.std::__shared_mutex_pthread" }
%"class.std::__shared_mutex_pthread" = type { %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"struct.JPH::BroadPhaseQuadTree::LayerState" = type { ptr, ptr, %"struct.JPH::QuadTree::AddState" }
%"struct.JPH::QuadTree::AddState" = type { %"class.JPH::QuadTree::NodeID", %"class.JPH::AABox" }
%"class.JPH::QuadTree::NodeID" = type { i32 }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::QuadTree" = type <{ ptr, %"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch", [44 x i8], %"struct.std::atomic", [2 x %"struct.JPH::QuadTree::RootNode"], %"struct.std::atomic", %"struct.std::atomic.2", [47 x i8] }>
%"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch" = type { i32, i32, i32 }
%"struct.JPH::QuadTree::RootNode" = type { %"struct.std::atomic" }
%"struct.std::atomic.2" = type { %"struct.std::__atomic_base.3" }
%"struct.std::__atomic_base.3" = type { i8 }
%"struct.JPH::QuadTree::Tracking" = type { %"struct.std::atomic.15", %"struct.std::atomic.18", %"struct.std::atomic" }
%"struct.std::atomic.15" = type { %"struct.std::__atomic_base.16" }
%"struct.std::__atomic_base.16" = type { i8 }
%"struct.std::atomic.18" = type { %"struct.std::__atomic_base.19" }
%"struct.std::__atomic_base.19" = type { i16 }
%"class.JPH::BodyID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [65 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297)) #2 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH18BroadPhaseQuadTree10LayerStatedaEPv(ptr noundef) #4 align 2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122)) #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122)) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree17AddBodiesFinalizeEPNS_6BodyIDEiPv(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %"class.JPH::SharedLock", align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"struct.JPH::AssertLastParam", align 1
  %14 = alloca ptr, align 8
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca %"struct.JPH::AssertLastParam", align 1
  %21 = alloca %"struct.JPH::AssertLastParam", align 1
  %22 = alloca %"struct.JPH::AssertLastParam", align 1
  %23 = alloca %"struct.JPH::AssertLastParam", align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #7
  %25 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 9
  %26 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 1
  %27 = load ptr, ptr %26, align 16, !tbaa !11
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %9, ptr noundef nonnull align 8 dereferenceable(64) %25, ptr noundef %27, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %28 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %24, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !29
  %30 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %29)
          to label %31 unwind label %45

31:                                               ; preds = %4
  store ptr %30, ptr %10, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %31
  %33 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 2
  %34 = load i64, ptr %33, align 8, !tbaa !30
  %35 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %24, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !29
  %37 = invoke noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %36)
          to label %38 unwind label %45

38:                                               ; preds = %32
  %39 = zext i32 %37 to i64
  %40 = icmp eq i64 %34, %39
  br i1 %40, label %49, label %41

41:                                               ; preds = %38
  %42 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 215)
          to label %43 unwind label %45

43:                                               ; preds = %41
  br i1 %42, label %44, label %49

44:                                               ; preds = %43
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !31
  br label %49

45:                                               ; preds = %41, %32, %4
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %11, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %12, align 4
  br label %213

49:                                               ; preds = %44, %43, %38
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %52, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #7
  store i8 0, ptr %15, align 1, !tbaa !32
  br label %53

53:                                               ; preds = %204, %51
  %54 = load i8, ptr %15, align 1, !tbaa !32
  %55 = zext i8 %54 to i32
  %56 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 8
  %57 = load i32, ptr %56, align 16, !tbaa !33
  %58 = icmp ult i32 %55, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %53
  store i32 4, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #7
  br label %208

60:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = load i8, ptr %15, align 1, !tbaa !32
  %63 = zext i8 %62 to i64
  %64 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %61, i64 %63
  store ptr %64, ptr %17, align 8, !tbaa !5
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 16, !tbaa !34
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %203

69:                                               ; preds = %60
  %70 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 7
  %71 = load ptr, ptr %70, align 8, !tbaa !40
  %72 = load i8, ptr %15, align 1, !tbaa !32
  %73 = zext i8 %72 to i64
  %74 = getelementptr inbounds %"class.JPH::QuadTree", ptr %71, i64 %73
  %75 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 3
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !41
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 16, !tbaa !34
  %82 = ptrtoint ptr %78 to i64
  %83 = ptrtoint ptr %81 to i64
  %84 = sub i64 %82, %83
  %85 = sdiv exact i64 %84, 4
  %86 = trunc i64 %85 to i32
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %87, i32 0, i32 2
  invoke void @_ZN3JPH8QuadTree17AddBodiesFinalizeERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEEiRKNS0_8AddStateE(ptr noundef nonnull align 64 dereferenceable(81) %74, ptr noundef nonnull align 8 dereferenceable(24) %75, i32 noundef %86, ptr noundef nonnull align 16 dereferenceable(48) %88)
          to label %89 unwind label %100

89:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 16, !tbaa !34
  store ptr %92, ptr %18, align 8, !tbaa !5
  br label %93

93:                                               ; preds = %199, %89
  %94 = load ptr, ptr %18, align 8, !tbaa !5
  %95 = load ptr, ptr %17, align 8, !tbaa !5
  %96 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %95, i32 0, i32 1
  %97 = load ptr, ptr %96, align 8, !tbaa !41
  %98 = icmp ult ptr %94, %97
  br i1 %98, label %104, label %99

99:                                               ; preds = %93
  store i32 7, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %202

100:                                              ; preds = %69
  %101 = landingpad { ptr, i32 }
          cleanup
  %102 = extractvalue { ptr, i32 } %101, 0
  store ptr %102, ptr %11, align 8
  %103 = extractvalue { ptr, i32 } %101, 1
  store i32 %103, ptr %12, align 4
  br label %207

104:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  %105 = load ptr, ptr %18, align 8, !tbaa !5
  %106 = invoke noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %105)
          to label %107 unwind label %124

107:                                              ; preds = %104
  store i32 %106, ptr %19, align 4, !tbaa !9
  br label %108

108:                                              ; preds = %107
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = load i32, ptr %19, align 4, !tbaa !9
  %111 = zext i32 %110 to i64
  %112 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %109, i64 noundef %111)
          to label %113 unwind label %124

113:                                              ; preds = %108
  %114 = load ptr, ptr %112, align 8, !tbaa !5
  %115 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %114)
          to label %116 unwind label %124

116:                                              ; preds = %113
  %117 = load ptr, ptr %18, align 8, !tbaa !5
  %118 = invoke noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %115, ptr noundef nonnull align 4 dereferenceable(4) %117)
          to label %119 unwind label %124

119:                                              ; preds = %116
  br i1 %118, label %128, label %120

120:                                              ; preds = %119
  %121 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 231, ptr noundef @.str.7)
          to label %122 unwind label %124

122:                                              ; preds = %120
  br i1 %121, label %123, label %128

123:                                              ; preds = %122
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !42
  br label %128

124:                                              ; preds = %196, %191, %185, %181, %176, %169, %163, %155, %150, %143, %131, %120, %116, %113, %108, %104
  %125 = landingpad { ptr, i32 }
          cleanup
  %126 = extractvalue { ptr, i32 } %125, 0
  store ptr %126, ptr %11, align 8
  %127 = extractvalue { ptr, i32 } %125, 1
  store i32 %127, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %207

128:                                              ; preds = %123, %122, %119
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  %132 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 3
  %133 = load i32, ptr %19, align 4, !tbaa !9
  %134 = zext i32 %133 to i64
  %135 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %132, i64 noundef %134)
          to label %136 unwind label %124

136:                                              ; preds = %131
  %137 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %135, i32 0, i32 0
  %138 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %137) #7
  %139 = zext i8 %138 to i32
  %140 = load i8, ptr %15, align 1, !tbaa !32
  %141 = zext i8 %140 to i32
  %142 = icmp eq i32 %139, %141
  br i1 %142, label %147, label %143

143:                                              ; preds = %136
  %144 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 232)
          to label %145 unwind label %124

145:                                              ; preds = %143
  br i1 %144, label %146, label %147

146:                                              ; preds = %145
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !43
  br label %147

147:                                              ; preds = %146, %145, %136
  br label %148

148:                                              ; preds = %147
  br label %149

149:                                              ; preds = %148
  br label %150

150:                                              ; preds = %149
  %151 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 3
  %152 = load i32, ptr %19, align 4, !tbaa !9
  %153 = zext i32 %152 to i64
  %154 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %151, i64 noundef %153)
          to label %155 unwind label %124

155:                                              ; preds = %150
  %156 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %154, i32 0, i32 1
  %157 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %156) #7
  %158 = zext i16 %157 to i32
  %159 = load ptr, ptr %10, align 8, !tbaa !5
  %160 = load i32, ptr %19, align 4, !tbaa !9
  %161 = zext i32 %160 to i64
  %162 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %159, i64 noundef %161)
          to label %163 unwind label %124

163:                                              ; preds = %155
  %164 = load ptr, ptr %162, align 8, !tbaa !5
  %165 = invoke noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %164)
          to label %166 unwind label %124

166:                                              ; preds = %163
  %167 = zext i16 %165 to i32
  %168 = icmp eq i32 %158, %167
  br i1 %168, label %173, label %169

169:                                              ; preds = %166
  %170 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 233)
          to label %171 unwind label %124

171:                                              ; preds = %169
  br i1 %170, label %172, label %173

172:                                              ; preds = %171
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !44
  br label %173

173:                                              ; preds = %172, %171, %166
  br label %174

174:                                              ; preds = %173
  br label %175

175:                                              ; preds = %174
  br label %176

176:                                              ; preds = %175
  %177 = load ptr, ptr %10, align 8, !tbaa !5
  %178 = load i32, ptr %19, align 4, !tbaa !9
  %179 = zext i32 %178 to i64
  %180 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %177, i64 noundef %179)
          to label %181 unwind label %124

181:                                              ; preds = %176
  %182 = load ptr, ptr %180, align 8, !tbaa !5
  %183 = invoke noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %182)
          to label %184 unwind label %124

184:                                              ; preds = %181
  br i1 %183, label %185, label %189

185:                                              ; preds = %184
  %186 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 234)
          to label %187 unwind label %124

187:                                              ; preds = %185
  br i1 %186, label %188, label %189

188:                                              ; preds = %187
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !45
  br label %189

189:                                              ; preds = %188, %187, %184
  br label %190

190:                                              ; preds = %189
  br label %191

191:                                              ; preds = %190
  %192 = load ptr, ptr %10, align 8, !tbaa !5
  %193 = load i32, ptr %19, align 4, !tbaa !9
  %194 = zext i32 %193 to i64
  %195 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %192, i64 noundef %194)
          to label %196 unwind label %124

196:                                              ; preds = %191
  %197 = load ptr, ptr %195, align 8, !tbaa !5
  invoke void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %197, i1 noundef zeroext true)
          to label %198 unwind label %124

198:                                              ; preds = %196
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %199

199:                                              ; preds = %198
  %200 = load ptr, ptr %18, align 8, !tbaa !5
  %201 = getelementptr inbounds %"class.JPH::BodyID", ptr %200, i32 1
  store ptr %201, ptr %18, align 8, !tbaa !5
  br label %93, !llvm.loop !46

202:                                              ; preds = %99
  br label %203

203:                                              ; preds = %202, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %204

204:                                              ; preds = %203
  %205 = load i8, ptr %15, align 1, !tbaa !32
  %206 = add i8 %205, 1
  store i8 %206, ptr %15, align 1, !tbaa !32
  br label %53, !llvm.loop !48

207:                                              ; preds = %124, %100
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %213

208:                                              ; preds = %59
  %209 = load ptr, ptr %14, align 8, !tbaa !5
  %210 = icmp eq ptr %209, null
  br i1 %210, label %212, label %211

211:                                              ; preds = %208
  call void @_ZN3JPH18BroadPhaseQuadTree10LayerStatedaEPv(ptr noundef %209) #7
  br label %212

212:                                              ; preds = %211, %208
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #7
  ret void

213:                                              ; preds = %207, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #7
  br label %214

214:                                              ; preds = %213
  %215 = load ptr, ptr %11, align 8
  %216 = load i32, ptr %12, align 4
  %217 = insertvalue { ptr, i32 } poison, ptr %215, 0
  %218 = insertvalue { ptr, i32 } %217, i32 %216, 1
  resume { ptr, i32 } %218
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH10SharedLockINS_11SharedMutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(64), ptr noundef, i32 noundef) unnamed_addr #2 align 2

declare void @_ZN3JPH8QuadTree17AddBodiesFinalizeERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEEiRKNS0_8AddStateE(ptr noundef nonnull align 64 dereferenceable(81), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef nonnull align 16 dereferenceable(48)) #6

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122), i1 noundef zeroext) #5 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 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 = { 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 #6 = { "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 = { 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 = !{!12, !6, i64 16}
!12 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !13, i64 0, !6, i64 16, !15, i64 24, !16, i64 32, !17, i64 64, !6, i64 256, !6, i64 264, !10, i64 272, !26, i64 280, !7, i64 344, !22, i64 472, !10, i64 476}
!13 = !{!"_ZTSN3JPH10BroadPhaseE", !14, i64 0, !6, i64 8}
!14 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !15, i64 0, !15, i64 8, !6, i64 16}
!17 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !18, i64 64, !22, i64 112, !22, i64 116, !24, i64 120, !22, i64 128}
!18 = !{!"_ZTSN3JPH5MutexE", !19, i64 0, !21, i64 40}
!19 = !{!"_ZTSSt5mutex", !20, i64 0}
!20 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!21 = !{!"_ZTSNSt6thread2idE", !15, i64 0}
!22 = !{!"_ZTSSt6atomicIjE", !23, i64 0}
!23 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!24 = !{!"_ZTSSt6atomicImE", !25, i64 0}
!25 = !{!"_ZTSSt13__atomic_baseImE", !15, i64 0}
!26 = !{!"_ZTSN3JPH11SharedMutexE", !27, i64 0, !21, i64 56}
!27 = !{!"_ZTSSt12shared_mutex", !28, i64 0}
!28 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!29 = !{!13, !6, i64 8}
!30 = !{!12, !15, i64 24}
!31 = !{i64 2158432450}
!32 = !{!7, !7, i64 0}
!33 = !{!12, !10, i64 272}
!34 = !{!35, !6, i64 0}
!35 = !{!"_ZTSN3JPH18BroadPhaseQuadTree10LayerStateE", !6, i64 0, !6, i64 8, !36, i64 16}
!36 = !{!"_ZTSN3JPH8QuadTree8AddStateE", !37, i64 0, !38, i64 16}
!37 = !{!"_ZTSN3JPH8QuadTree6NodeIDE", !10, i64 0}
!38 = !{!"_ZTSN3JPH5AABoxE", !39, i64 0, !39, i64 16}
!39 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!40 = !{!12, !6, i64 264}
!41 = !{!35, !6, i64 8}
!42 = !{i64 2158432885}
!43 = !{i64 2158433315}
!44 = !{i64 2158433767}
!45 = !{i64 2158434155}
!46 = distinct !{!46, !47}
!47 = !{!"llvm.loop.mustprogress"}
!48 = distinct !{!48, !47}


; 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::SharedLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"struct.JPH::BroadPhaseQuadTree::LayerState" = type { ptr, ptr, %"struct.JPH::QuadTree::AddState" }
%"struct.JPH::QuadTree::AddState" = type { %"class.JPH::QuadTree::NodeID", %"class.JPH::AABox" }
%"class.JPH::QuadTree::NodeID" = type { i32 }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::QuadTree" = type <{ ptr, %"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch", [44 x i8], %"struct.std::atomic", [2 x %"struct.JPH::QuadTree::RootNode"], %"struct.std::atomic", %"struct.std::atomic.2", [47 x i8] }>
%"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch" = type { i32, i32, i32 }
%"struct.JPH::QuadTree::RootNode" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"struct.std::atomic.2" = type { %"struct.std::__atomic_base.3" }
%"struct.std::__atomic_base.3" = type { i8 }

@.str.1 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [65 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297)) local_unnamed_addr #2 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH18BroadPhaseQuadTree10LayerStatedaEPv(ptr noundef) local_unnamed_addr #4 align 2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree17AddBodiesFinalizeEPNS_6BodyIDEiPv(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr nocapture noundef readnone %1, i32 noundef %2, ptr noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.JPH::SharedLock", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 280
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 16, !tbaa !5
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %5, ptr noundef nonnull align 8 dereferenceable(64) %6, ptr noundef %8, i32 noundef 8)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !27
  %11 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load i64, ptr %12, align 8, !tbaa !28
  %14 = load ptr, ptr %9, align 8, !tbaa !27
  %15 = invoke noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %14)
          to label %16 unwind label %23

16:                                               ; preds = %4
  %17 = zext i32 %15 to i64
  %18 = icmp eq i64 %13, %17
  br i1 %18, label %25, label %19

19:                                               ; preds = %16
  %20 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 215)
          to label %21 unwind label %23

21:                                               ; preds = %19
  br i1 %20, label %22, label %25

22:                                               ; preds = %21
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !29
  br label %25

23:                                               ; preds = %19, %4
  %24 = landingpad { ptr, i32 }
          cleanup
  br label %109

25:                                               ; preds = %22, %21, %16
  %26 = getelementptr inbounds i8, ptr %0, i64 272
  %27 = load i32, ptr %26, align 16, !tbaa !30
  %.not43 = icmp eq i32 %27, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph42

.lr.ph42:                                         ; preds = %25
  %28 = getelementptr inbounds i8, ptr %0, i64 264
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  br label %31

._crit_edge:                                      ; preds = %25
  %30 = icmp eq ptr %3, null
  br i1 %30, label %108, label %._crit_edge.thread

31:                                               ; preds = %.lr.ph42, %.loopexit
  %.03340 = phi i8 [ 0, %.lr.ph42 ], [ %104, %.loopexit ]
  %32 = zext i8 %.03340 to i64
  %33 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %3, i64 %32
  %34 = load ptr, ptr %33, align 16, !tbaa !31
  %.not = icmp eq ptr %34, null
  br i1 %.not, label %.loopexit, label %35

35:                                               ; preds = %31
  %36 = load ptr, ptr %28, align 8, !tbaa !37
  %37 = getelementptr inbounds %"class.JPH::QuadTree", ptr %36, i64 %32
  %38 = getelementptr inbounds i8, ptr %33, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !38
  %40 = ptrtoint ptr %39 to i64
  %41 = ptrtoint ptr %34 to i64
  %42 = sub i64 %40, %41
  %43 = lshr exact i64 %42, 2
  %44 = trunc i64 %43 to i32
  %45 = getelementptr inbounds i8, ptr %33, i64 16
  invoke void @_ZN3JPH8QuadTree17AddBodiesFinalizeERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEEiRKNS0_8AddStateE(ptr noundef nonnull align 64 dereferenceable(81) %37, ptr noundef nonnull align 8 dereferenceable(24) %29, i32 noundef %44, ptr noundef nonnull align 16 dereferenceable(48) %45)
          to label %46 unwind label %50

46:                                               ; preds = %35
  %47 = load ptr, ptr %33, align 16, !tbaa !31
  %48 = load ptr, ptr %38, align 8, !tbaa !38
  %49 = icmp ult ptr %47, %48
  br i1 %49, label %.lr.ph, label %.loopexit

50:                                               ; preds = %35
  %51 = landingpad { ptr, i32 }
          cleanup
  br label %109

.lr.ph:                                           ; preds = %46, %99
  %.03039 = phi ptr [ %101, %99 ], [ %47, %46 ]
  %52 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.03039)
  %53 = zext i32 %52 to i64
  %54 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %53)
          to label %55 unwind label %63

55:                                               ; preds = %.lr.ph
  %56 = load ptr, ptr %54, align 8, !tbaa !39
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %56)
  %58 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %57, ptr noundef nonnull align 4 dereferenceable(4) %.03039)
  br i1 %58, label %65, label %59

59:                                               ; preds = %55
  %60 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 231, ptr noundef nonnull @.str.7)
          to label %61 unwind label %63

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

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

63:                                               ; preds = %97, %93, %88, %84, %76, %74, %70, %65, %59, %.lr.ph
  %64 = landingpad { ptr, i32 }
          cleanup
  br label %109

65:                                               ; preds = %55, %61, %62
  %66 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %53)
          to label %67 unwind label %63

67:                                               ; preds = %65
  %68 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %66) #7
  %69 = icmp eq i8 %68, %.03340
  br i1 %69, label %74, label %70

70:                                               ; preds = %67
  %71 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 232)
          to label %72 unwind label %63

72:                                               ; preds = %70
  br i1 %71, label %73, label %74

73:                                               ; preds = %72
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !41
  br label %74

74:                                               ; preds = %67, %72, %73
  %75 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %53)
          to label %76 unwind label %63

76:                                               ; preds = %74
  %77 = getelementptr inbounds i8, ptr %75, i64 2
  %78 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %77) #7
  %79 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %53)
          to label %80 unwind label %63

80:                                               ; preds = %76
  %81 = load ptr, ptr %79, align 8, !tbaa !39
  %82 = call noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %81)
  %83 = icmp eq i16 %78, %82
  br i1 %83, label %88, label %84

84:                                               ; preds = %80
  %85 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 233)
          to label %86 unwind label %63

86:                                               ; preds = %84
  br i1 %85, label %87, label %88

87:                                               ; preds = %86
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !42
  br label %88

88:                                               ; preds = %80, %86, %87
  %89 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %53)
          to label %90 unwind label %63

90:                                               ; preds = %88
  %91 = load ptr, ptr %89, align 8, !tbaa !39
  %92 = call noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %91)
  br i1 %92, label %93, label %97

93:                                               ; preds = %90
  %94 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 234)
          to label %95 unwind label %63

95:                                               ; preds = %93
  br i1 %94, label %96, label %97

96:                                               ; preds = %95
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !43
  br label %97

97:                                               ; preds = %96, %95, %90
  %98 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %53)
          to label %99 unwind label %63

99:                                               ; preds = %97
  %100 = load ptr, ptr %98, align 8, !tbaa !39
  call void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %100, i1 noundef zeroext true)
  %101 = getelementptr inbounds i8, ptr %.03039, i64 4
  %102 = load ptr, ptr %38, align 8, !tbaa !38
  %103 = icmp ult ptr %101, %102
  br i1 %103, label %.lr.ph, label %.loopexit, !llvm.loop !44

.loopexit:                                        ; preds = %99, %46, %31
  %104 = add i8 %.03340, 1
  %105 = zext i8 %104 to i32
  %106 = load i32, ptr %26, align 16, !tbaa !30
  %107 = icmp ugt i32 %106, %105
  br i1 %107, label %31, label %._crit_edge.thread, !llvm.loop !46

._crit_edge.thread:                               ; preds = %.loopexit, %._crit_edge
  call void @_ZN3JPH18BroadPhaseQuadTree10LayerStatedaEPv(ptr noundef nonnull %3) #7
  br label %108

108:                                              ; preds = %._crit_edge.thread, %._crit_edge
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #7
  ret void

109:                                              ; preds = %50, %63, %23
  %.pn.pn = phi { ptr, i32 } [ %24, %23 ], [ %64, %63 ], [ %51, %50 ]
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #7
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH10SharedLockINS_11SharedMutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(64), ptr noundef, i32 noundef) unnamed_addr #2 align 2

declare void @_ZN3JPH8QuadTree17AddBodiesFinalizeERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEEiRKNS0_8AddStateE(ptr noundef nonnull align 64 dereferenceable(81), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef nonnull align 16 dereferenceable(48)) local_unnamed_addr #6

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122), i1 noundef zeroext) local_unnamed_addr #5 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 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 = { 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 #6 = { "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 = { 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, !9, i64 16}
!6 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !7, i64 0, !9, i64 16, !12, i64 24, !13, i64 32, !14, i64 64, !9, i64 256, !9, i64 264, !15, i64 272, !24, i64 280, !10, i64 344, !20, i64 472, !15, i64 476}
!7 = !{!"_ZTSN3JPH10BroadPhaseE", !8, i64 0, !9, i64 8}
!8 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !12, i64 0, !12, i64 8, !9, i64 16}
!14 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !9, i64 24, !16, i64 64, !20, i64 112, !20, i64 116, !22, i64 120, !20, i64 128}
!15 = !{!"int", !10, i64 0}
!16 = !{!"_ZTSN3JPH5MutexE", !17, i64 0, !19, i64 40}
!17 = !{!"_ZTSSt5mutex", !18, i64 0}
!18 = !{!"_ZTSSt12__mutex_base", !10, i64 0}
!19 = !{!"_ZTSNSt6thread2idE", !12, i64 0}
!20 = !{!"_ZTSSt6atomicIjE", !21, i64 0}
!21 = !{!"_ZTSSt13__atomic_baseIjE", !15, i64 0}
!22 = !{!"_ZTSSt6atomicImE", !23, i64 0}
!23 = !{!"_ZTSSt13__atomic_baseImE", !12, i64 0}
!24 = !{!"_ZTSN3JPH11SharedMutexE", !25, i64 0, !19, i64 56}
!25 = !{!"_ZTSSt12shared_mutex", !26, i64 0}
!26 = !{!"_ZTSSt22__shared_mutex_pthread", !10, i64 0}
!27 = !{!7, !9, i64 8}
!28 = !{!6, !12, i64 24}
!29 = !{i64 2158432450}
!30 = !{!6, !15, i64 272}
!31 = !{!32, !9, i64 0}
!32 = !{!"_ZTSN3JPH18BroadPhaseQuadTree10LayerStateE", !9, i64 0, !9, i64 8, !33, i64 16}
!33 = !{!"_ZTSN3JPH8QuadTree8AddStateE", !34, i64 0, !35, i64 16}
!34 = !{!"_ZTSN3JPH8QuadTree6NodeIDE", !15, i64 0}
!35 = !{!"_ZTSN3JPH5AABoxE", !36, i64 0, !36, i64 16}
!36 = !{!"_ZTSN3JPH4Vec3E", !10, i64 0}
!37 = !{!6, !9, i64 264}
!38 = !{!32, !9, i64 8}
!39 = !{!9, !9, i64 0}
!40 = !{i64 2158432885}
!41 = !{i64 2158433315}
!42 = !{i64 2158433767}
!43 = !{i64 2158434155}
!44 = distinct !{!44, !45}
!45 = !{!"llvm.loop.mustprogress"}
!46 = distinct !{!46, !45}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass