; 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::BroadPhaseLayer" = type { i8 }
%"class.JPH::SharedLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"struct.JPH::AssertLastParam" = type { i8 }
%class.anon.20 = type { ptr }
%class.anon.21 = type { ptr }
%"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 }
%"class.JPH::BodyID" = type { i32 }
%"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::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 }

@_ZN3JPHL23cBroadPhaseLayerInvalidE = external hidden constant %"class.JPH::BroadPhaseLayer", align 1
@.str.1 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [32 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: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297)) #3 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)) #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 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) #2 align 2

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

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

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

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

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

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

29:                                               ; preds = %3
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %40, label %32

32:                                               ; preds = %29
  %33 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 284)
          to label %34 unwind label %36

34:                                               ; preds = %32
  br i1 %33, label %35, label %40

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

36:                                               ; preds = %32
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %9, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %10, align 4
  br label %213

40:                                               ; preds = %35, %34, %29
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %43 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %25, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !30
  %45 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %44)
          to label %46 unwind label %60

46:                                               ; preds = %42
  store ptr %45, ptr %11, align 8, !tbaa !5
  br label %47

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

53:                                               ; preds = %47
  %54 = zext i32 %52 to i64
  %55 = icmp eq i64 %49, %54
  br i1 %55, label %64, label %56

56:                                               ; preds = %53
  %57 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 287)
          to label %58 unwind label %60

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

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

60:                                               ; preds = %56, %47, %42
  %61 = landingpad { ptr, i32 }
          cleanup
  %62 = extractvalue { ptr, i32 } %61, 0
  store ptr %62, ptr %9, align 8
  %63 = extractvalue { ptr, i32 } %61, 1
  store i32 %63, ptr %10, align 4
  br label %212

64:                                               ; preds = %59, %58, %53
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %67 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %68 = invoke noundef ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %67)
          to label %69 unwind label %110

69:                                               ; preds = %66
  store ptr %68, ptr %13, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %"class.JPH::BodyID", ptr %71, i64 %73
  %75 = getelementptr inbounds %class.anon.20, ptr %14, i32 0, i32 0
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %76, ptr %75, align 8, !tbaa !33
  %77 = getelementptr inbounds %class.anon.20, ptr %14, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8
  invoke void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_0EEvT_S5_T0_"(ptr noundef %70, ptr noundef %74, ptr %78)
          to label %79 unwind label %110

79:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %80, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %"class.JPH::BodyID", ptr %81, i64 %83
  store ptr %84, ptr %16, align 8, !tbaa !5
  br label %85

85:                                               ; preds = %206, %79
  %86 = load ptr, ptr %15, align 8, !tbaa !5
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  %88 = icmp ult ptr %86, %87
  br i1 %88, label %89, label %210

89:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #7
  %90 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  %92 = invoke noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %91)
          to label %93 unwind label %114

93:                                               ; preds = %89
  %94 = zext i32 %92 to i64
  %95 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %90, i64 noundef %94)
          to label %96 unwind label %114

96:                                               ; preds = %93
  %97 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %95, i32 0, i32 0
  %98 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %97) #7
  store i8 %98, ptr %17, align 1, !tbaa !35
  br label %99

99:                                               ; preds = %96
  %100 = load i8, ptr %17, align 1, !tbaa !35
  %101 = zext i8 %100 to i32
  %102 = invoke noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
          to label %103 unwind label %114

103:                                              ; preds = %99
  %104 = zext i8 %102 to i32
  %105 = icmp ne i32 %101, %104
  br i1 %105, label %118, label %106

106:                                              ; preds = %103
  %107 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.14, ptr noundef @.str.1, i32 noundef 298)
          to label %108 unwind label %114

108:                                              ; preds = %106
  br i1 %107, label %109, label %118

109:                                              ; preds = %108
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !36
  br label %118

110:                                              ; preds = %69, %66
  %111 = landingpad { ptr, i32 }
          cleanup
  %112 = extractvalue { ptr, i32 } %111, 0
  store ptr %112, ptr %9, align 8
  %113 = extractvalue { ptr, i32 } %111, 1
  store i32 %113, ptr %10, align 4
  br label %211

114:                                              ; preds = %106, %99, %93, %89
  %115 = landingpad { ptr, i32 }
          cleanup
  %116 = extractvalue { ptr, i32 } %115, 0
  store ptr %116, ptr %9, align 8
  %117 = extractvalue { ptr, i32 } %115, 1
  store i32 %117, ptr %10, align 4
  br label %209

118:                                              ; preds = %109, %108, %103
  br label %119

119:                                              ; preds = %118
  br label %120

120:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  %122 = load ptr, ptr %16, align 8, !tbaa !5
  %123 = getelementptr inbounds %class.anon.21, ptr %20, i32 0, i32 0
  %124 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %124, ptr %123, align 8, !tbaa !37
  %125 = getelementptr inbounds %class.anon.21, ptr %20, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8
  %127 = invoke noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef %121, ptr noundef %122, ptr noundef nonnull align 1 dereferenceable(1) %17, ptr %126)
          to label %128 unwind label %151

128:                                              ; preds = %120
  store ptr %127, ptr %19, align 8, !tbaa !5
  %129 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 7
  %130 = load ptr, ptr %129, align 8, !tbaa !39
  %131 = load i8, ptr %17, align 1, !tbaa !35
  %132 = zext i8 %131 to i64
  %133 = getelementptr inbounds %"class.JPH::QuadTree", ptr %130, i64 %132
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %136 = load ptr, ptr %15, align 8, !tbaa !5
  %137 = load ptr, ptr %19, align 8, !tbaa !5
  %138 = load ptr, ptr %15, align 8, !tbaa !5
  %139 = ptrtoint ptr %137 to i64
  %140 = ptrtoint ptr %138 to i64
  %141 = sub i64 %139, %140
  %142 = sdiv exact i64 %141, 4
  %143 = trunc i64 %142 to i32
  invoke void @_ZN3JPH8QuadTree12RemoveBodiesERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %133, ptr noundef nonnull align 8 dereferenceable(24) %134, ptr noundef nonnull align 8 dereferenceable(24) %135, ptr noundef %136, i32 noundef %143)
          to label %144 unwind label %151

144:                                              ; preds = %128
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %145 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %145, ptr %21, align 8, !tbaa !5
  br label %146

146:                                              ; preds = %202, %144
  %147 = load ptr, ptr %21, align 8, !tbaa !5
  %148 = load ptr, ptr %19, align 8, !tbaa !5
  %149 = icmp ult ptr %147, %148
  br i1 %149, label %155, label %150

150:                                              ; preds = %146
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %206

151:                                              ; preds = %128, %120
  %152 = landingpad { ptr, i32 }
          cleanup
  %153 = extractvalue { ptr, i32 } %152, 0
  store ptr %153, ptr %9, align 8
  %154 = extractvalue { ptr, i32 } %152, 1
  store i32 %154, ptr %10, align 4
  br label %208

155:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  %156 = load ptr, ptr %21, align 8, !tbaa !5
  %157 = invoke noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %156)
          to label %158 unwind label %184

158:                                              ; preds = %155
  store i32 %157, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %159 = load ptr, ptr %13, align 8, !tbaa !5
  %160 = load i32, ptr %22, align 4, !tbaa !9
  %161 = zext i32 %160 to i64
  %162 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %159, i64 %161
  store ptr %162, ptr %23, align 8, !tbaa !5
  %163 = invoke noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
          to label %164 unwind label %188

164:                                              ; preds = %158
  %165 = load ptr, ptr %23, align 8, !tbaa !5
  %166 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %165, i32 0, i32 0
  %167 = call noundef zeroext i8 @_ZNSt13__atomic_baseIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %166, i8 noundef zeroext %163) #7
  %168 = load ptr, ptr %23, align 8, !tbaa !5
  %169 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %168, i32 0, i32 1
  %170 = call noundef zeroext i16 @_ZNSt13__atomic_baseItEaSEt(ptr noundef nonnull align 2 dereferenceable(2) %169, i16 noundef zeroext -1) #7
  br label %171

171:                                              ; preds = %164
  %172 = load ptr, ptr %11, align 8, !tbaa !5
  %173 = load i32, ptr %22, 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 %188

176:                                              ; preds = %171
  %177 = load ptr, ptr %175, align 8, !tbaa !5
  %178 = invoke noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %177)
          to label %179 unwind label %188

179:                                              ; preds = %176
  br i1 %178, label %192, label %180

180:                                              ; preds = %179
  %181 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 315)
          to label %182 unwind label %188

182:                                              ; preds = %180
  br i1 %181, label %183, label %192

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

184:                                              ; preds = %155
  %185 = landingpad { ptr, i32 }
          cleanup
  %186 = extractvalue { ptr, i32 } %185, 0
  store ptr %186, ptr %9, align 8
  %187 = extractvalue { ptr, i32 } %185, 1
  store i32 %187, ptr %10, align 4
  br label %205

188:                                              ; preds = %199, %194, %180, %176, %171, %158
  %189 = landingpad { ptr, i32 }
          cleanup
  %190 = extractvalue { ptr, i32 } %189, 0
  store ptr %190, ptr %9, align 8
  %191 = extractvalue { ptr, i32 } %189, 1
  store i32 %191, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %205

192:                                              ; preds = %183, %182, %179
  br label %193

193:                                              ; preds = %192
  br label %194

194:                                              ; preds = %193
  %195 = load ptr, ptr %11, align 8, !tbaa !5
  %196 = load i32, ptr %22, align 4, !tbaa !9
  %197 = zext i32 %196 to i64
  %198 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %195, i64 noundef %197)
          to label %199 unwind label %188

199:                                              ; preds = %194
  %200 = load ptr, ptr %198, align 8, !tbaa !5
  invoke void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %200, i1 noundef zeroext false)
          to label %201 unwind label %188

201:                                              ; preds = %199
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %202

202:                                              ; preds = %201
  %203 = load ptr, ptr %21, align 8, !tbaa !5
  %204 = getelementptr inbounds %"class.JPH::BodyID", ptr %203, i32 1
  store ptr %204, ptr %21, align 8, !tbaa !5
  br label %146, !llvm.loop !41

205:                                              ; preds = %188, %184
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %208

206:                                              ; preds = %150
  %207 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %207, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #7
  br label %85, !llvm.loop !43

208:                                              ; preds = %205, %151
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %209

209:                                              ; preds = %208, %114
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %211

210:                                              ; preds = %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %7) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #7
  ret void

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

212:                                              ; preds = %211, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %213

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_0EEvT_S5_T0_"(ptr noundef, ptr noundef, ptr) #2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), ptr) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{i64 2158436264}
!30 = !{!13, !6, i64 8}
!31 = !{!12, !15, i64 24}
!32 = !{i64 2158436672}
!33 = !{!34, !6, i64 0}
!34 = !{!"_ZTSZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEiE3$_0", !6, i64 0}
!35 = !{!7, !7, i64 0}
!36 = !{i64 2158437128}
!37 = !{!38, !6, i64 0}
!38 = !{!"_ZTSZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEiE3$_1", !6, i64 0}
!39 = !{!12, !6, i64 264}
!40 = !{i64 2158441575}
!41 = distinct !{!41, !42}
!42 = !{!"llvm.loop.mustprogress"}
!43 = distinct !{!43, !42}


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

@_ZN3JPHL23cBroadPhaseLayerInvalidE = external hidden constant %"class.JPH::BroadPhaseLayer", align 1
@.str.1 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [32 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: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297)) local_unnamed_addr #3 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 #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 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 #2 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 #4 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.JPH::SharedLock", align 8
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #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) %4, ptr noundef nonnull align 8 dereferenceable(64) %6, ptr noundef %8, i32 noundef 8)
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %16, label %10

10:                                               ; preds = %3
  %11 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 284)
          to label %12 unwind label %14

12:                                               ; preds = %10
  br i1 %11, label %13, label %16

13:                                               ; preds = %12
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #7, !srcloc !27
  br label %16

14:                                               ; preds = %10
  %15 = landingpad { ptr, i32 }
          cleanup
  br label %94

16:                                               ; preds = %13, %12, %3
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !28
  %19 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %18)
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load i64, ptr %20, align 8, !tbaa !29
  %22 = load ptr, ptr %17, align 8, !tbaa !28
  %23 = invoke noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %22)
          to label %24 unwind label %31

24:                                               ; preds = %16
  %25 = zext i32 %23 to i64
  %26 = icmp eq i64 %21, %25
  br i1 %26, label %33, label %27

27:                                               ; preds = %24
  %28 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 287)
          to label %29 unwind label %31

29:                                               ; preds = %27
  br i1 %28, label %30, label %33

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

31:                                               ; preds = %27, %16
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %94

33:                                               ; preds = %30, %29, %24
  %34 = getelementptr inbounds i8, ptr %0, i64 32
  %35 = call noundef ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %34)
  %36 = sext i32 %2 to i64
  %37 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %36
  invoke void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_0EEvT_S5_T0_"(ptr noundef %1, ptr noundef %37, ptr %35)
          to label %.preheader49 unwind label %50

.preheader49:                                     ; preds = %33
  br i1 %9, label %.lr.ph52, label %._crit_edge53

.lr.ph52:                                         ; preds = %.preheader49
  %38 = getelementptr inbounds i8, ptr %0, i64 264
  br label %39

39:                                               ; preds = %.lr.ph52, %._crit_edge
  %.04151 = phi ptr [ %1, %.lr.ph52 ], [ %55, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #7
  %40 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.04151)
  %41 = zext i32 %40 to i64
  %42 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef %41)
          to label %43 unwind label %52

43:                                               ; preds = %39
  %44 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %42) #7
  store i8 %44, ptr %5, align 1, !tbaa !31
  %45 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %.not = icmp eq i8 %44, %45
  br i1 %.not, label %46, label %54

46:                                               ; preds = %43
  %47 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i32 noundef 298)
          to label %48 unwind label %52

48:                                               ; preds = %46
  br i1 %47, label %49, label %54

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

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

52:                                               ; preds = %46, %39
  %53 = landingpad { ptr, i32 }
          cleanup
  br label %93

54:                                               ; preds = %49, %48, %43
  %55 = invoke noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef nonnull %.04151, ptr noundef nonnull %37, ptr noundef nonnull align 1 dereferenceable(1) %5, ptr %35)
          to label %56 unwind label %68

56:                                               ; preds = %54
  %57 = load ptr, ptr %38, align 8, !tbaa !33
  %58 = load i8, ptr %5, align 1, !tbaa !31
  %59 = zext i8 %58 to i64
  %60 = getelementptr inbounds %"class.JPH::QuadTree", ptr %57, i64 %59
  %61 = ptrtoint ptr %55 to i64
  %62 = ptrtoint ptr %.04151 to i64
  %63 = sub i64 %61, %62
  %64 = lshr exact i64 %63, 2
  %65 = trunc i64 %64 to i32
  invoke void @_ZN3JPH8QuadTree12RemoveBodiesERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %60, ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 8 dereferenceable(24) %34, ptr noundef nonnull %.04151, i32 noundef %65)
          to label %.preheader unwind label %68

.preheader:                                       ; preds = %56
  %66 = icmp ult ptr %.04151, %55
  br i1 %66, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %89, %.preheader
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  %67 = icmp ult ptr %55, %37
  br i1 %67, label %39, label %._crit_edge53, !llvm.loop !34

68:                                               ; preds = %56, %54
  %69 = landingpad { ptr, i32 }
          cleanup
  br label %93

.lr.ph:                                           ; preds = %.preheader, %89
  %.04050 = phi ptr [ %91, %89 ], [ %.04151, %.preheader ]
  %70 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.04050)
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %35, i64 %71
  %73 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %74 = call noundef zeroext i8 @_ZNSt13__atomic_baseIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %72, i8 noundef zeroext %73) #7
  %75 = getelementptr inbounds i8, ptr %72, i64 2
  %76 = call noundef zeroext i16 @_ZNSt13__atomic_baseItEaSEt(ptr noundef nonnull align 2 dereferenceable(2) %75, i16 noundef zeroext -1) #7
  %77 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %71)
          to label %78 unwind label %85

78:                                               ; preds = %.lr.ph
  %79 = load ptr, ptr %77, align 8, !tbaa !36
  %80 = call noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %79)
  br i1 %80, label %87, label %81

81:                                               ; preds = %78
  %82 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i32 noundef 315)
          to label %83 unwind label %85

83:                                               ; preds = %81
  br i1 %82, label %84, label %87

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

85:                                               ; preds = %87, %81, %.lr.ph
  %86 = landingpad { ptr, i32 }
          cleanup
  br label %93

87:                                               ; preds = %84, %83, %78
  %88 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %71)
          to label %89 unwind label %85

89:                                               ; preds = %87
  %90 = load ptr, ptr %88, align 8, !tbaa !36
  call void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %90, i1 noundef zeroext false)
  %91 = getelementptr inbounds i8, ptr %.04050, i64 4
  %92 = icmp ult ptr %91, %55
  br i1 %92, label %.lr.ph, label %._crit_edge, !llvm.loop !38

93:                                               ; preds = %68, %85, %52
  %.pn.pn = phi { ptr, i32 } [ %53, %52 ], [ %86, %85 ], [ %69, %68 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  br label %94

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

94:                                               ; preds = %31, %93, %50, %14
  %.pn.pn.pn.pn.pn = phi { ptr, i32 } [ %15, %14 ], [ %32, %31 ], [ %.pn.pn, %93 ], [ %51, %50 ]
  call void @_ZN3JPH10SharedLockINS_11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %4) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #7
  resume { ptr, i32 } %.pn.pn.pn.pn.pn
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_0EEvT_S5_T0_"(ptr noundef, ptr noundef, ptr) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), ptr) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{i64 2158436264}
!28 = !{!7, !9, i64 8}
!29 = !{!6, !12, i64 24}
!30 = !{i64 2158436672}
!31 = !{!10, !10, i64 0}
!32 = !{i64 2158437128}
!33 = !{!6, !9, i64 264}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = !{!9, !9, i64 0}
!37 = !{i64 2158441575}
!38 = distinct !{!38, !35}


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