; LLVM IR from jrouwe/JoltPhysics :: 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"

%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::SharedLock" = type <{ ptr, ptr, i32, [4 x 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 [109 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 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 %"struct.JPH::AssertLastParam", align 1
  %10 = alloca %"class.JPH::SharedLock", align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"struct.JPH::AssertLastParam", align 1
  %15 = alloca ptr, align 8
  %16 = alloca i8, align 1
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca %"struct.JPH::AssertLastParam", align 1
  %22 = alloca %"struct.JPH::AssertLastParam", align 1
  %23 = alloca %"struct.JPH::AssertLastParam", align 1
  %24 = 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
  %25 = load ptr, ptr %5, align 8
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp sle i32 %26, 0
  br i1 %27, label %28, label %37

28:                                               ; preds = %4
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %35, label %32

32:                                               ; preds = %29
  %33 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 214)
  br i1 %33, label %34, label %35

34:                                               ; preds = %32
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !11
  br label %35

35:                                               ; preds = %34, %32, %29
  br label %36

36:                                               ; preds = %35
  br label %226

37:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #7
  %38 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 9
  %39 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 1
  %40 = load ptr, ptr %39, align 16, !tbaa !12
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %10, ptr noundef nonnull align 8 dereferenceable(64) %38, ptr noundef %40, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %41 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %25, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !30
  %43 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %42)
          to label %44 unwind label %58

44:                                               ; preds = %37
  store ptr %43, ptr %11, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %44
  %46 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 2
  %47 = load i64, ptr %46, align 8, !tbaa !31
  %48 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %25, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !30
  %50 = invoke noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %49)
          to label %51 unwind label %58

51:                                               ; preds = %45
  %52 = zext i32 %50 to i64
  %53 = icmp eq i64 %47, %52
  br i1 %53, label %62, label %54

54:                                               ; preds = %51
  %55 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 222)
          to label %56 unwind label %58

56:                                               ; preds = %54
  br i1 %55, label %57, label %62

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

58:                                               ; preds = %54, %45, %37
  %59 = landingpad { ptr, i32 }
          cleanup
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %12, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %13, align 4
  br label %227

62:                                               ; preds = %57, %56, %51
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %65, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #7
  store i8 0, ptr %16, align 1, !tbaa !33
  br label %66

66:                                               ; preds = %217, %64
  %67 = load i8, ptr %16, align 1, !tbaa !33
  %68 = zext i8 %67 to i32
  %69 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 8
  %70 = load i32, ptr %69, align 16, !tbaa !34
  %71 = icmp ult i32 %68, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %66
  store i32 6, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #7
  br label %221

73:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %74 = load ptr, ptr %15, align 8, !tbaa !5
  %75 = load i8, ptr %16, align 1, !tbaa !33
  %76 = zext i8 %75 to i64
  %77 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %74, i64 %76
  store ptr %77, ptr %18, align 8, !tbaa !5
  %78 = load ptr, ptr %18, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 16, !tbaa !35
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %216

82:                                               ; preds = %73
  %83 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 7
  %84 = load ptr, ptr %83, align 8, !tbaa !41
  %85 = load i8, ptr %16, align 1, !tbaa !33
  %86 = zext i8 %85 to i64
  %87 = getelementptr inbounds %"class.JPH::QuadTree", ptr %84, i64 %86
  %88 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %89 = load ptr, ptr %18, align 8, !tbaa !5
  %90 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !42
  %92 = load ptr, ptr %18, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 16, !tbaa !35
  %95 = ptrtoint ptr %91 to i64
  %96 = ptrtoint ptr %94 to i64
  %97 = sub i64 %95, %96
  %98 = sdiv exact i64 %97, 4
  %99 = trunc i64 %98 to i32
  %100 = load ptr, ptr %18, align 8, !tbaa !5
  %101 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %100, i32 0, i32 2
  invoke void @_ZN3JPH8QuadTree17AddBodiesFinalizeERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEEiRKNS0_8AddStateE(ptr noundef nonnull align 64 dereferenceable(81) %87, ptr noundef nonnull align 8 dereferenceable(24) %88, i32 noundef %99, ptr noundef nonnull align 16 dereferenceable(48) %101)
          to label %102 unwind label %113

102:                                              ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %103 = load ptr, ptr %18, align 8, !tbaa !5
  %104 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 16, !tbaa !35
  store ptr %105, ptr %19, align 8, !tbaa !5
  br label %106

106:                                              ; preds = %212, %102
  %107 = load ptr, ptr %19, align 8, !tbaa !5
  %108 = load ptr, ptr %18, align 8, !tbaa !5
  %109 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %108, i32 0, i32 1
  %110 = load ptr, ptr %109, align 8, !tbaa !42
  %111 = icmp ult ptr %107, %110
  br i1 %111, label %117, label %112

112:                                              ; preds = %106
  store i32 9, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %215

113:                                              ; preds = %82
  %114 = landingpad { ptr, i32 }
          cleanup
  %115 = extractvalue { ptr, i32 } %114, 0
  store ptr %115, ptr %12, align 8
  %116 = extractvalue { ptr, i32 } %114, 1
  store i32 %116, ptr %13, align 4
  br label %220

117:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  %118 = load ptr, ptr %19, align 8, !tbaa !5
  %119 = invoke noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %118)
          to label %120 unwind label %137

120:                                              ; preds = %117
  store i32 %119, ptr %20, align 4, !tbaa !9
  br label %121

121:                                              ; preds = %120
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = load i32, ptr %20, align 4, !tbaa !9
  %124 = zext i32 %123 to i64
  %125 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %122, i64 noundef %124)
          to label %126 unwind label %137

126:                                              ; preds = %121
  %127 = load ptr, ptr %125, align 8, !tbaa !5
  %128 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %127)
          to label %129 unwind label %137

129:                                              ; preds = %126
  %130 = load ptr, ptr %19, align 8, !tbaa !5
  %131 = invoke noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %128, ptr noundef nonnull align 4 dereferenceable(4) %130)
          to label %132 unwind label %137

132:                                              ; preds = %129
  br i1 %131, label %141, label %133

133:                                              ; preds = %132
  %134 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 238, ptr noundef @.str.6)
          to label %135 unwind label %137

135:                                              ; preds = %133
  br i1 %134, label %136, label %141

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

137:                                              ; preds = %209, %204, %198, %194, %189, %182, %176, %168, %163, %156, %144, %133, %129, %126, %121, %117
  %138 = landingpad { ptr, i32 }
          cleanup
  %139 = extractvalue { ptr, i32 } %138, 0
  store ptr %139, ptr %12, align 8
  %140 = extractvalue { ptr, i32 } %138, 1
  store i32 %140, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %220

141:                                              ; preds = %136, %135, %132
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  br label %144

144:                                              ; preds = %143
  %145 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %146 = load i32, ptr %20, align 4, !tbaa !9
  %147 = zext i32 %146 to i64
  %148 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %145, i64 noundef %147)
          to label %149 unwind label %137

149:                                              ; preds = %144
  %150 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %148, i32 0, i32 0
  %151 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %150) #7
  %152 = zext i8 %151 to i32
  %153 = load i8, ptr %16, align 1, !tbaa !33
  %154 = zext i8 %153 to i32
  %155 = icmp eq i32 %152, %154
  br i1 %155, label %160, label %156

156:                                              ; preds = %149
  %157 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 239)
          to label %158 unwind label %137

158:                                              ; preds = %156
  br i1 %157, label %159, label %160

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

160:                                              ; preds = %159, %158, %149
  br label %161

161:                                              ; preds = %160
  br label %162

162:                                              ; preds = %161
  br label %163

163:                                              ; preds = %162
  %164 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %165 = load i32, ptr %20, align 4, !tbaa !9
  %166 = zext i32 %165 to i64
  %167 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %164, i64 noundef %166)
          to label %168 unwind label %137

168:                                              ; preds = %163
  %169 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %167, i32 0, i32 1
  %170 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %169) #7
  %171 = zext i16 %170 to i32
  %172 = load ptr, ptr %11, align 8, !tbaa !5
  %173 = load i32, ptr %20, align 4, !tbaa !9
  %174 = zext i32 %173 to i64
  %175 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %172, i64 noundef %174)
          to label %176 unwind label %137

176:                                              ; preds = %168
  %177 = load ptr, ptr %175, align 8, !tbaa !5
  %178 = invoke noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %177)
          to label %179 unwind label %137

179:                                              ; preds = %176
  %180 = zext i16 %178 to i32
  %181 = icmp eq i32 %171, %180
  br i1 %181, label %186, label %182

182:                                              ; preds = %179
  %183 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 240)
          to label %184 unwind label %137

184:                                              ; preds = %182
  br i1 %183, label %185, label %186

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

186:                                              ; preds = %185, %184, %179
  br label %187

187:                                              ; preds = %186
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188
  %190 = load ptr, ptr %11, align 8, !tbaa !5
  %191 = load i32, ptr %20, align 4, !tbaa !9
  %192 = zext i32 %191 to i64
  %193 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %190, i64 noundef %192)
          to label %194 unwind label %137

194:                                              ; preds = %189
  %195 = load ptr, ptr %193, align 8, !tbaa !5
  %196 = invoke noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %195)
          to label %197 unwind label %137

197:                                              ; preds = %194
  br i1 %196, label %198, label %202

198:                                              ; preds = %197
  %199 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 241)
          to label %200 unwind label %137

200:                                              ; preds = %198
  br i1 %199, label %201, label %202

201:                                              ; preds = %200
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !46
  br label %202

202:                                              ; preds = %201, %200, %197
  br label %203

203:                                              ; preds = %202
  br label %204

204:                                              ; preds = %203
  %205 = load ptr, ptr %11, align 8, !tbaa !5
  %206 = load i32, ptr %20, align 4, !tbaa !9
  %207 = zext i32 %206 to i64
  %208 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %205, i64 noundef %207)
          to label %209 unwind label %137

209:                                              ; preds = %204
  %210 = load ptr, ptr %208, align 8, !tbaa !5
  invoke void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %210, i1 noundef zeroext true)
          to label %211 unwind label %137

211:                                              ; preds = %209
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  br label %212

212:                                              ; preds = %211
  %213 = load ptr, ptr %19, align 8, !tbaa !5
  %214 = getelementptr inbounds %"class.JPH::BodyID", ptr %213, i32 1
  store ptr %214, ptr %19, align 8, !tbaa !5
  br label %106, !llvm.loop !47

215:                                              ; preds = %112
  br label %216

216:                                              ; preds = %215, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %217

217:                                              ; preds = %216
  %218 = load i8, ptr %16, align 1, !tbaa !33
  %219 = add i8 %218, 1
  store i8 %219, ptr %16, align 1, !tbaa !33
  br label %66, !llvm.loop !49

220:                                              ; preds = %137, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %227

221:                                              ; preds = %72
  %222 = load ptr, ptr %15, align 8, !tbaa !5
  %223 = icmp eq ptr %222, null
  br i1 %223, label %225, label %224

224:                                              ; preds = %221
  call void @_ZN3JPH18BroadPhaseQuadTree10LayerStatedaEPv(ptr noundef %222) #7
  br label %225

225:                                              ; preds = %224, %221
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %10) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #7
  br label %226

226:                                              ; preds = %225, %36
  ret void

227:                                              ; preds = %220, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %10) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #7
  br label %228

228:                                              ; preds = %227
  %229 = load ptr, ptr %12, align 8
  %230 = load i32, ptr %13, align 4
  %231 = insertvalue { ptr, i32 } poison, ptr %229, 0
  %232 = insertvalue { ptr, i32 } %231, i32 %230, 1
  resume { ptr, i32 } %232
}

; 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 = !{i64 2158612365}
!12 = !{!13, !6, i64 16}
!13 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !14, i64 0, !6, i64 16, !16, i64 24, !17, i64 32, !18, i64 64, !6, i64 256, !6, i64 264, !10, i64 272, !27, i64 280, !7, i64 344, !23, i64 472, !10, i64 476}
!14 = !{!"_ZTSN3JPH10BroadPhaseE", !15, i64 0, !6, i64 8}
!15 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !16, i64 0, !16, i64 8, !6, i64 16}
!18 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !19, i64 64, !23, i64 112, !23, i64 116, !25, i64 120, !23, i64 128}
!19 = !{!"_ZTSN3JPH5MutexE", !20, i64 0, !22, i64 40}
!20 = !{!"_ZTSSt5mutex", !21, i64 0}
!21 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!22 = !{!"_ZTSNSt6thread2idE", !16, i64 0}
!23 = !{!"_ZTSSt6atomicIjE", !24, i64 0}
!24 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!25 = !{!"_ZTSSt6atomicImE", !26, i64 0}
!26 = !{!"_ZTSSt13__atomic_baseImE", !16, i64 0}
!27 = !{!"_ZTSN3JPH11SharedMutexE", !28, i64 0, !22, i64 56}
!28 = !{!"_ZTSSt12shared_mutex", !29, i64 0}
!29 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!30 = !{!14, !6, i64 8}
!31 = !{!13, !16, i64 24}
!32 = !{i64 2158612830}
!33 = !{!7, !7, i64 0}
!34 = !{!13, !10, i64 272}
!35 = !{!36, !6, i64 0}
!36 = !{!"_ZTSN3JPH18BroadPhaseQuadTree10LayerStateE", !6, i64 0, !6, i64 8, !37, i64 16}
!37 = !{!"_ZTSN3JPH8QuadTree8AddStateE", !38, i64 0, !39, i64 16}
!38 = !{!"_ZTSN3JPH8QuadTree6NodeIDE", !10, i64 0}
!39 = !{!"_ZTSN3JPH5AABoxE", !40, i64 0, !40, i64 16}
!40 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!41 = !{!13, !6, i64 264}
!42 = !{!36, !6, i64 8}
!43 = !{i64 2158613258}
!44 = !{i64 2158613681}
!45 = !{i64 2158614126}
!46 = !{i64 2158614507}
!47 = distinct !{!47, !48}
!48 = !{!"llvm.loop.mustprogress"}
!49 = distinct !{!49, !48}


; 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 [109 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 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
  %6 = icmp slt i32 %2, 1
  br i1 %6, label %7, label %12

7:                                                ; preds = %4
  %8 = icmp eq ptr %3, null
  br i1 %8, label %116, label %9

9:                                                ; preds = %7
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 214)
  br i1 %10, label %11, label %116

11:                                               ; preds = %9
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !5
  br label %116

12:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #7
  %13 = getelementptr inbounds i8, ptr %0, i64 280
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 16, !tbaa !6
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %5, ptr noundef nonnull align 8 dereferenceable(64) %13, ptr noundef %15, i32 noundef 8)
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !28
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load i64, ptr %19, align 8, !tbaa !29
  %21 = load ptr, ptr %16, align 8, !tbaa !28
  %22 = invoke noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %21)
          to label %23 unwind label %30

23:                                               ; preds = %12
  %24 = zext i32 %22 to i64
  %25 = icmp eq i64 %20, %24
  br i1 %25, label %32, label %26

26:                                               ; preds = %23
  %27 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 222)
          to label %28 unwind label %30

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

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

30:                                               ; preds = %26, %12
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %117

32:                                               ; preds = %29, %28, %23
  %33 = getelementptr inbounds i8, ptr %0, i64 272
  %34 = load i32, ptr %33, align 16, !tbaa !31
  %.not45 = icmp eq i32 %34, 0
  br i1 %.not45, label %._crit_edge, label %.lr.ph44

.lr.ph44:                                         ; preds = %32
  %35 = getelementptr inbounds i8, ptr %0, i64 264
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  br label %38

._crit_edge:                                      ; preds = %32
  %37 = icmp eq ptr %3, null
  br i1 %37, label %115, label %._crit_edge.thread

38:                                               ; preds = %.lr.ph44, %.loopexit
  %.03542 = phi i8 [ 0, %.lr.ph44 ], [ %111, %.loopexit ]
  %39 = zext i8 %.03542 to i64
  %40 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::LayerState", ptr %3, i64 %39
  %41 = load ptr, ptr %40, align 16, !tbaa !32
  %.not = icmp eq ptr %41, null
  br i1 %.not, label %.loopexit, label %42

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

53:                                               ; preds = %42
  %54 = load ptr, ptr %40, align 16, !tbaa !32
  %55 = load ptr, ptr %45, align 8, !tbaa !39
  %56 = icmp ult ptr %54, %55
  br i1 %56, label %.lr.ph, label %.loopexit

57:                                               ; preds = %42
  %58 = landingpad { ptr, i32 }
          cleanup
  br label %117

.lr.ph:                                           ; preds = %53, %106
  %.03241 = phi ptr [ %108, %106 ], [ %54, %53 ]
  %59 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.03241)
  %60 = zext i32 %59 to i64
  %61 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %60)
          to label %62 unwind label %70

62:                                               ; preds = %.lr.ph
  %63 = load ptr, ptr %61, align 8, !tbaa !40
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %63)
  %65 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %64, ptr noundef nonnull align 4 dereferenceable(4) %.03241)
  br i1 %65, label %72, label %66

66:                                               ; preds = %62
  %67 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 238, ptr noundef nonnull @.str.6)
          to label %68 unwind label %70

68:                                               ; preds = %66
  br i1 %67, label %69, label %72

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

70:                                               ; preds = %104, %100, %95, %91, %83, %81, %77, %72, %66, %.lr.ph
  %71 = landingpad { ptr, i32 }
          cleanup
  br label %117

72:                                               ; preds = %62, %68, %69
  %73 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %60)
          to label %74 unwind label %70

74:                                               ; preds = %72
  %75 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %73) #7
  %76 = icmp eq i8 %75, %.03542
  br i1 %76, label %81, label %77

77:                                               ; preds = %74
  %78 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 239)
          to label %79 unwind label %70

79:                                               ; preds = %77
  br i1 %78, label %80, label %81

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

81:                                               ; preds = %74, %79, %80
  %82 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %60)
          to label %83 unwind label %70

83:                                               ; preds = %81
  %84 = getelementptr inbounds i8, ptr %82, i64 2
  %85 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %84) #7
  %86 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %60)
          to label %87 unwind label %70

87:                                               ; preds = %83
  %88 = load ptr, ptr %86, align 8, !tbaa !40
  %89 = call noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %88)
  %90 = icmp eq i16 %85, %89
  br i1 %90, label %95, label %91

91:                                               ; preds = %87
  %92 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 240)
          to label %93 unwind label %70

93:                                               ; preds = %91
  br i1 %92, label %94, label %95

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

95:                                               ; preds = %87, %93, %94
  %96 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %60)
          to label %97 unwind label %70

97:                                               ; preds = %95
  %98 = load ptr, ptr %96, align 8, !tbaa !40
  %99 = call noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %98)
  br i1 %99, label %100, label %104

100:                                              ; preds = %97
  %101 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 241)
          to label %102 unwind label %70

102:                                              ; preds = %100
  br i1 %101, label %103, label %104

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

104:                                              ; preds = %103, %102, %97
  %105 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %60)
          to label %106 unwind label %70

106:                                              ; preds = %104
  %107 = load ptr, ptr %105, align 8, !tbaa !40
  call void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %107, i1 noundef zeroext true)
  %108 = getelementptr inbounds i8, ptr %.03241, i64 4
  %109 = load ptr, ptr %45, align 8, !tbaa !39
  %110 = icmp ult ptr %108, %109
  br i1 %110, label %.lr.ph, label %.loopexit, !llvm.loop !45

.loopexit:                                        ; preds = %106, %53, %38
  %111 = add i8 %.03542, 1
  %112 = zext i8 %111 to i32
  %113 = load i32, ptr %33, align 16, !tbaa !31
  %114 = icmp ugt i32 %113, %112
  br i1 %114, label %38, label %._crit_edge.thread, !llvm.loop !47

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

115:                                              ; 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
  br label %116

116:                                              ; preds = %11, %9, %7, %115
  ret void

117:                                              ; preds = %57, %70, %30
  %.pn.pn = phi { ptr, i32 } [ %31, %30 ], [ %71, %70 ], [ %58, %57 ]
  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 = !{i64 2158612365}
!6 = !{!7, !10, i64 16}
!7 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !8, i64 0, !10, i64 16, !13, i64 24, !14, i64 32, !15, i64 64, !10, i64 256, !10, i64 264, !16, i64 272, !25, i64 280, !11, i64 344, !21, i64 472, !16, i64 476}
!8 = !{!"_ZTSN3JPH10BroadPhaseE", !9, i64 0, !10, i64 8}
!9 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !13, i64 0, !13, i64 8, !10, i64 16}
!15 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !10, i64 24, !17, i64 64, !21, i64 112, !21, i64 116, !23, i64 120, !21, i64 128}
!16 = !{!"int", !11, i64 0}
!17 = !{!"_ZTSN3JPH5MutexE", !18, i64 0, !20, i64 40}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !11, i64 0}
!20 = !{!"_ZTSNSt6thread2idE", !13, i64 0}
!21 = !{!"_ZTSSt6atomicIjE", !22, i64 0}
!22 = !{!"_ZTSSt13__atomic_baseIjE", !16, i64 0}
!23 = !{!"_ZTSSt6atomicImE", !24, i64 0}
!24 = !{!"_ZTSSt13__atomic_baseImE", !13, i64 0}
!25 = !{!"_ZTSN3JPH11SharedMutexE", !26, i64 0, !20, i64 56}
!26 = !{!"_ZTSSt12shared_mutex", !27, i64 0}
!27 = !{!"_ZTSSt22__shared_mutex_pthread", !11, i64 0}
!28 = !{!8, !10, i64 8}
!29 = !{!7, !13, i64 24}
!30 = !{i64 2158612830}
!31 = !{!7, !16, i64 272}
!32 = !{!33, !10, i64 0}
!33 = !{!"_ZTSN3JPH18BroadPhaseQuadTree10LayerStateE", !10, i64 0, !10, i64 8, !34, i64 16}
!34 = !{!"_ZTSN3JPH8QuadTree8AddStateE", !35, i64 0, !36, i64 16}
!35 = !{!"_ZTSN3JPH8QuadTree6NodeIDE", !16, i64 0}
!36 = !{!"_ZTSN3JPH5AABoxE", !37, i64 0, !37, i64 16}
!37 = !{!"_ZTSN3JPH4Vec3E", !11, i64 0}
!38 = !{!7, !10, i64 264}
!39 = !{!33, !10, i64 8}
!40 = !{!10, !10, i64 0}
!41 = !{i64 2158613258}
!42 = !{i64 2158613681}
!43 = !{i64 2158614126}
!44 = !{i64 2158614507}
!45 = distinct !{!45, !46}
!46 = !{!"llvm.loop.mustprogress"}
!47 = distinct !{!47, !46}


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