; 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"

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

27:                                               ; preds = %3
  br label %200

28:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #7
  %29 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 9
  %30 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 1
  %31 = load ptr, ptr %30, 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) %29, ptr noundef %31, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %32 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %24, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !29
  %34 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %33)
          to label %35 unwind label %49

35:                                               ; preds = %28
  store ptr %34, ptr %8, align 8, !tbaa !5
  br label %36

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

42:                                               ; preds = %36
  %43 = zext i32 %41 to i64
  %44 = icmp eq i64 %38, %43
  br i1 %44, label %53, label %45

45:                                               ; preds = %42
  %46 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 301)
          to label %47 unwind label %49

47:                                               ; preds = %45
  br i1 %46, label %48, label %53

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

49:                                               ; preds = %45, %36, %28
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %9, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %10, align 4
  br label %202

53:                                               ; preds = %48, %47, %42
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %56 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 3
  %57 = invoke noundef ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %56)
          to label %58 unwind label %99

58:                                               ; preds = %55
  store ptr %57, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %"class.JPH::BodyID", ptr %60, i64 %62
  %64 = getelementptr inbounds %class.anon.20, ptr %13, i32 0, i32 0
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %65, ptr %64, align 8, !tbaa !32
  %66 = getelementptr inbounds %class.anon.20, ptr %13, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8
  invoke void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_0EEvT_S5_T0_"(ptr noundef %59, ptr noundef %63, ptr %67)
          to label %68 unwind label %99

68:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %69, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %"class.JPH::BodyID", ptr %70, i64 %72
  store ptr %73, ptr %15, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %195, %68
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = icmp ult ptr %75, %76
  br i1 %77, label %78, label %199

78:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #7
  %79 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 3
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = invoke noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %80)
          to label %82 unwind label %103

82:                                               ; preds = %78
  %83 = zext i32 %81 to i64
  %84 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %79, i64 noundef %83)
          to label %85 unwind label %103

85:                                               ; preds = %82
  %86 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %84, i32 0, i32 0
  %87 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %86) #7
  store i8 %87, ptr %16, align 1, !tbaa !34
  br label %88

88:                                               ; preds = %85
  %89 = load i8, ptr %16, align 1, !tbaa !34
  %90 = zext i8 %89 to i32
  %91 = invoke noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
          to label %92 unwind label %103

92:                                               ; preds = %88
  %93 = zext i8 %91 to i32
  %94 = icmp ne i32 %90, %93
  br i1 %94, label %107, label %95

95:                                               ; preds = %92
  %96 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.14, ptr noundef @.str.1, i32 noundef 312)
          to label %97 unwind label %103

97:                                               ; preds = %95
  br i1 %96, label %98, label %107

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

99:                                               ; preds = %58, %55
  %100 = landingpad { ptr, i32 }
          cleanup
  %101 = extractvalue { ptr, i32 } %100, 0
  store ptr %101, ptr %9, align 8
  %102 = extractvalue { ptr, i32 } %100, 1
  store i32 %102, ptr %10, align 4
  br label %201

103:                                              ; preds = %95, %88, %82, %78
  %104 = landingpad { ptr, i32 }
          cleanup
  %105 = extractvalue { ptr, i32 } %104, 0
  store ptr %105, ptr %9, align 8
  %106 = extractvalue { ptr, i32 } %104, 1
  store i32 %106, ptr %10, align 4
  br label %198

107:                                              ; preds = %98, %97, %92
  br label %108

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %110 = load ptr, ptr %14, align 8, !tbaa !5
  %111 = load ptr, ptr %15, align 8, !tbaa !5
  %112 = getelementptr inbounds %class.anon.21, ptr %19, i32 0, i32 0
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %113, ptr %112, align 8, !tbaa !36
  %114 = getelementptr inbounds %class.anon.21, ptr %19, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8
  %116 = invoke noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef %110, ptr noundef %111, ptr noundef nonnull align 1 dereferenceable(1) %16, ptr %115)
          to label %117 unwind label %140

117:                                              ; preds = %109
  store ptr %116, ptr %18, align 8, !tbaa !5
  %118 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 7
  %119 = load ptr, ptr %118, align 8, !tbaa !38
  %120 = load i8, ptr %16, align 1, !tbaa !34
  %121 = zext i8 %120 to i64
  %122 = getelementptr inbounds %"class.JPH::QuadTree", ptr %119, i64 %121
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  %124 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %24, i32 0, i32 3
  %125 = load ptr, ptr %14, align 8, !tbaa !5
  %126 = load ptr, ptr %18, align 8, !tbaa !5
  %127 = load ptr, ptr %14, align 8, !tbaa !5
  %128 = ptrtoint ptr %126 to i64
  %129 = ptrtoint ptr %127 to i64
  %130 = sub i64 %128, %129
  %131 = sdiv exact i64 %130, 4
  %132 = trunc i64 %131 to i32
  invoke void @_ZN3JPH8QuadTree12RemoveBodiesERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %122, ptr noundef nonnull align 8 dereferenceable(24) %123, ptr noundef nonnull align 8 dereferenceable(24) %124, ptr noundef %125, i32 noundef %132)
          to label %133 unwind label %140

133:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %134 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %134, ptr %20, align 8, !tbaa !5
  br label %135

135:                                              ; preds = %191, %133
  %136 = load ptr, ptr %20, align 8, !tbaa !5
  %137 = load ptr, ptr %18, align 8, !tbaa !5
  %138 = icmp ult ptr %136, %137
  br i1 %138, label %144, label %139

139:                                              ; preds = %135
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  br label %195

140:                                              ; preds = %117, %109
  %141 = landingpad { ptr, i32 }
          cleanup
  %142 = extractvalue { ptr, i32 } %141, 0
  store ptr %142, ptr %9, align 8
  %143 = extractvalue { ptr, i32 } %141, 1
  store i32 %143, ptr %10, align 4
  br label %197

144:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  %145 = load ptr, ptr %20, align 8, !tbaa !5
  %146 = invoke noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %145)
          to label %147 unwind label %173

147:                                              ; preds = %144
  store i32 %146, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %148 = load ptr, ptr %12, align 8, !tbaa !5
  %149 = load i32, ptr %21, align 4, !tbaa !9
  %150 = zext i32 %149 to i64
  %151 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %148, i64 %150
  store ptr %151, ptr %22, align 8, !tbaa !5
  %152 = invoke noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
          to label %153 unwind label %177

153:                                              ; preds = %147
  %154 = load ptr, ptr %22, align 8, !tbaa !5
  %155 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %154, i32 0, i32 0
  %156 = call noundef zeroext i8 @_ZNSt13__atomic_baseIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %155, i8 noundef zeroext %152) #7
  %157 = load ptr, ptr %22, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %157, i32 0, i32 1
  %159 = call noundef zeroext i16 @_ZNSt13__atomic_baseItEaSEt(ptr noundef nonnull align 2 dereferenceable(2) %158, i16 noundef zeroext -1) #7
  br label %160

160:                                              ; preds = %153
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  %162 = load i32, ptr %21, align 4, !tbaa !9
  %163 = zext i32 %162 to i64
  %164 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %161, i64 noundef %163)
          to label %165 unwind label %177

165:                                              ; preds = %160
  %166 = load ptr, ptr %164, align 8, !tbaa !5
  %167 = invoke noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %166)
          to label %168 unwind label %177

168:                                              ; preds = %165
  br i1 %167, label %181, label %169

169:                                              ; preds = %168
  %170 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 329)
          to label %171 unwind label %177

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

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

173:                                              ; preds = %144
  %174 = landingpad { ptr, i32 }
          cleanup
  %175 = extractvalue { ptr, i32 } %174, 0
  store ptr %175, ptr %9, align 8
  %176 = extractvalue { ptr, i32 } %174, 1
  store i32 %176, ptr %10, align 4
  br label %194

177:                                              ; preds = %188, %183, %169, %165, %160, %147
  %178 = landingpad { ptr, i32 }
          cleanup
  %179 = extractvalue { ptr, i32 } %178, 0
  store ptr %179, ptr %9, align 8
  %180 = extractvalue { ptr, i32 } %178, 1
  store i32 %180, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  br label %194

181:                                              ; preds = %172, %171, %168
  br label %182

182:                                              ; preds = %181
  br label %183

183:                                              ; preds = %182
  %184 = load ptr, ptr %8, align 8, !tbaa !5
  %185 = load i32, ptr %21, align 4, !tbaa !9
  %186 = zext i32 %185 to i64
  %187 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %184, i64 noundef %186)
          to label %188 unwind label %177

188:                                              ; preds = %183
  %189 = load ptr, ptr %187, align 8, !tbaa !5
  invoke void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %189, i1 noundef zeroext false)
          to label %190 unwind label %177

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

191:                                              ; preds = %190
  %192 = load ptr, ptr %20, align 8, !tbaa !5
  %193 = getelementptr inbounds %"class.JPH::BodyID", ptr %192, i32 1
  store ptr %193, ptr %20, align 8, !tbaa !5
  br label %135, !llvm.loop !40

194:                                              ; preds = %177, %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  br label %197

195:                                              ; preds = %139
  %196 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %196, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #7
  br label %74, !llvm.loop !42

197:                                              ; preds = %194, %140
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %198

198:                                              ; preds = %197, %103
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %201

199:                                              ; preds = %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #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
  br label %200

200:                                              ; preds = %199, %27
  ret void

201:                                              ; preds = %198, %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %202

202:                                              ; preds = %201, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #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
  br label %203

203:                                              ; preds = %202
  %204 = load ptr, ptr %9, align 8
  %205 = load i32, ptr %10, align 4
  %206 = insertvalue { ptr, i32 } poison, ptr %204, 0
  %207 = insertvalue { ptr, i32 } %206, i32 %205, 1
  resume { ptr, i32 } %207
}

; 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 = !{!13, !6, i64 8}
!30 = !{!12, !15, i64 24}
!31 = !{i64 2158621061}
!32 = !{!33, !6, i64 0}
!33 = !{!"_ZTSZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEiE3$_0", !6, i64 0}
!34 = !{!7, !7, i64 0}
!35 = !{i64 2158621510}
!36 = !{!37, !6, i64 0}
!37 = !{!"_ZTSZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEiE3$_1", !6, i64 0}
!38 = !{!12, !6, i64 264}
!39 = !{i64 2158621889}
!40 = distinct !{!40, !41}
!41 = !{!"llvm.loop.mustprogress"}
!42 = distinct !{!42, !41}


; 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 [109 x i8], align 1
@.str.3 = 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
  %6 = icmp slt i32 %2, 1
  br i1 %6, label %88, label %7

7:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #7
  %8 = getelementptr inbounds i8, ptr %0, i64 280
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, 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) %8, ptr noundef %10, i32 noundef 8)
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !27
  %13 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %12)
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !28
  %16 = load ptr, ptr %11, align 8, !tbaa !27
  %17 = invoke noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %16)
          to label %18 unwind label %25

18:                                               ; preds = %7
  %19 = zext i32 %17 to i64
  %20 = icmp eq i64 %15, %19
  br i1 %20, label %27, label %21

21:                                               ; preds = %18
  %22 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 301)
          to label %23 unwind label %25

23:                                               ; preds = %21
  br i1 %22, label %24, label %27

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

25:                                               ; preds = %21, %7
  %26 = landingpad { ptr, i32 }
          cleanup
  br label %89

27:                                               ; preds = %24, %23, %18
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  %29 = call noundef ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %28)
  %30 = zext nneg i32 %2 to i64
  %31 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %30
  invoke void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_0EEvT_S5_T0_"(ptr noundef %1, ptr noundef nonnull %31, ptr %29)
          to label %.lr.ph51 unwind label %44

.lr.ph51:                                         ; preds = %27
  %32 = getelementptr inbounds i8, ptr %0, i64 264
  br label %33

33:                                               ; preds = %.lr.ph51, %._crit_edge
  %.04050 = phi ptr [ %1, %.lr.ph51 ], [ %49, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #7
  %34 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.04050)
  %35 = zext i32 %34 to i64
  %36 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %35)
          to label %37 unwind label %46

37:                                               ; preds = %33
  %38 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %36) #7
  store i8 %38, ptr %5, align 1, !tbaa !30
  %39 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %.not = icmp eq i8 %38, %39
  br i1 %.not, label %40, label %48

40:                                               ; preds = %37
  %41 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i32 noundef 312)
          to label %42 unwind label %46

42:                                               ; preds = %40
  br i1 %41, label %43, label %48

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

44:                                               ; preds = %27
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %89

46:                                               ; preds = %40, %33
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %87

48:                                               ; preds = %43, %42, %37
  %49 = invoke noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree12RemoveBodiesES2_iE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef nonnull %.04050, ptr noundef nonnull %31, ptr noundef nonnull align 1 dereferenceable(1) %5, ptr %29)
          to label %50 unwind label %62

50:                                               ; preds = %48
  %51 = load ptr, ptr %32, align 8, !tbaa !32
  %52 = load i8, ptr %5, align 1, !tbaa !30
  %53 = zext i8 %52 to i64
  %54 = getelementptr inbounds %"class.JPH::QuadTree", ptr %51, i64 %53
  %55 = ptrtoint ptr %49 to i64
  %56 = ptrtoint ptr %.04050 to i64
  %57 = sub i64 %55, %56
  %58 = lshr exact i64 %57, 2
  %59 = trunc i64 %58 to i32
  invoke void @_ZN3JPH8QuadTree12RemoveBodiesERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %54, ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull %.04050, i32 noundef %59)
          to label %.preheader unwind label %62

.preheader:                                       ; preds = %50
  %60 = icmp ult ptr %.04050, %49
  br i1 %60, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %83, %.preheader
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  %61 = icmp ult ptr %49, %31
  br i1 %61, label %33, label %._crit_edge52, !llvm.loop !33

62:                                               ; preds = %50, %48
  %63 = landingpad { ptr, i32 }
          cleanup
  br label %87

.lr.ph:                                           ; preds = %.preheader, %83
  %.03949 = phi ptr [ %85, %83 ], [ %.04050, %.preheader ]
  %64 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.03949)
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %29, i64 %65
  %67 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %68 = call noundef zeroext i8 @_ZNSt13__atomic_baseIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %66, i8 noundef zeroext %67) #7
  %69 = getelementptr inbounds i8, ptr %66, i64 2
  %70 = call noundef zeroext i16 @_ZNSt13__atomic_baseItEaSEt(ptr noundef nonnull align 2 dereferenceable(2) %69, i16 noundef zeroext -1) #7
  %71 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %65)
          to label %72 unwind label %79

72:                                               ; preds = %.lr.ph
  %73 = load ptr, ptr %71, align 8, !tbaa !35
  %74 = call noundef zeroext i1 @_ZNK3JPH4Body14IsInBroadPhaseEv(ptr noundef nonnull align 16 dereferenceable(122) %73)
  br i1 %74, label %81, label %75

75:                                               ; preds = %72
  %76 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i32 noundef 329)
          to label %77 unwind label %79

77:                                               ; preds = %75
  br i1 %76, label %78, label %81

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

79:                                               ; preds = %81, %75, %.lr.ph
  %80 = landingpad { ptr, i32 }
          cleanup
  br label %87

81:                                               ; preds = %78, %77, %72
  %82 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %65)
          to label %83 unwind label %79

83:                                               ; preds = %81
  %84 = load ptr, ptr %82, align 8, !tbaa !35
  call void @_ZN3JPH4Body23SetInBroadPhaseInternalEb(ptr noundef nonnull align 16 dereferenceable(122) %84, i1 noundef zeroext false)
  %85 = getelementptr inbounds i8, ptr %.03949, i64 4
  %86 = icmp ult ptr %85, %49
  br i1 %86, label %.lr.ph, label %._crit_edge, !llvm.loop !37

87:                                               ; preds = %62, %79, %46
  %.pn.pn = phi { ptr, i32 } [ %47, %46 ], [ %80, %79 ], [ %63, %62 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  br label %89

._crit_edge52:                                    ; preds = %._crit_edge
  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
  br label %88

88:                                               ; preds = %3, %._crit_edge52
  ret void

89:                                               ; preds = %44, %87, %25
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %26, %25 ], [ %.pn.pn, %87 ], [ %45, %44 ]
  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
}

; 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 = !{!7, !9, i64 8}
!28 = !{!6, !12, i64 24}
!29 = !{i64 2158621061}
!30 = !{!10, !10, i64 0}
!31 = !{i64 2158621510}
!32 = !{!6, !9, i64 264}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{!9, !9, i64 0}
!36 = !{i64 2158621889}
!37 = distinct !{!37, !34}


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