; 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 }
%"struct.JPH::AssertLastParam" = type { i8 }
%class.anon.22 = type { ptr }
%class.anon.23 = 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.2 = external hidden unnamed_addr constant [25 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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; 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 zeroext i1 @_ZN3JPH11SharedMutex9is_lockedEv(ptr noundef nonnull align 8 dereferenceable(64)) #5 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: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1)) #4 align 2

; 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: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree23NotifyBodiesAABBChangedEPNS_6BodyIDEib(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2, i1 noundef zeroext %3) unnamed_addr #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca %"struct.JPH::AssertLastParam", align 1
  %10 = alloca ptr, align 8
  %11 = alloca %"struct.JPH::AssertLastParam", align 1
  %12 = alloca ptr, align 8
  %13 = alloca %class.anon.22, 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.23, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %20 = zext i1 %3 to i8
  store i8 %20, ptr %8, align 1, !tbaa !11
  %21 = load ptr, ptr %5, align 8
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp sle i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %4
  br label %130

25:                                               ; preds = %4
  %26 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 9
  %30 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 1
  %31 = load ptr, ptr %30, align 16, !tbaa !15
  call void @_ZN3JPH11PhysicsLock11sLockSharedINS_11SharedMutexEEEvRT_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(64) %29, ptr noundef %31, i32 noundef 8)
  br label %41

32:                                               ; preds = %25
  br label %33

33:                                               ; preds = %32
  %34 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 9
  %35 = call noundef zeroext i1 @_ZN3JPH11SharedMutex9is_lockedEv(ptr noundef nonnull align 8 dereferenceable(64) %34)
  br i1 %35, label %39, label %36

36:                                               ; preds = %33
  %37 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 349)
  br i1 %37, label %38, label %39

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

39:                                               ; preds = %38, %36, %33
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %42 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %21, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !34
  %44 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %43)
  store ptr %44, ptr %10, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %41
  %46 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 2
  %47 = load i64, ptr %46, align 8, !tbaa !35
  %48 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %21, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !34
  %50 = call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %49)
  %51 = zext i32 %50 to i64
  %52 = icmp eq i64 %47, %51
  br i1 %52, label %56, label %53

53:                                               ; preds = %45
  %54 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 352)
  br i1 %54, label %55, label %56

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

56:                                               ; preds = %55, %53, %45
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %59 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 3
  %60 = call noundef ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %59)
  store ptr %60, ptr %12, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %"class.JPH::BodyID", ptr %62, i64 %64
  %66 = getelementptr inbounds %class.anon.22, ptr %13, i32 0, i32 0
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %67, ptr %66, align 8, !tbaa !37
  %68 = getelementptr inbounds %class.anon.22, ptr %13, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8
  call void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree23NotifyBodiesAABBChangedES2_ibE3$_0EEvT_S5_T0_"(ptr noundef %61, ptr noundef %65, ptr %69)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %70, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %"class.JPH::BodyID", ptr %71, i64 %73
  store ptr %74, ptr %15, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %98, %58
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = icmp ult ptr %76, %77
  br i1 %78, label %79, label %122

79:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #7
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %81)
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %80, i64 %83
  %85 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %84, i32 0, i32 0
  %86 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %85) #7
  store i8 %86, ptr %16, align 1, !tbaa !39
  br label %87

87:                                               ; preds = %79
  %88 = load i8, ptr %16, align 1, !tbaa !39
  %89 = zext i8 %88 to i32
  %90 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %91 = zext i8 %90 to i32
  %92 = icmp ne i32 %89, %91
  br i1 %92, label %96, label %93

93:                                               ; preds = %87
  %94 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.14, ptr noundef @.str.1, i32 noundef 363)
  br i1 %94, label %95, label %96

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

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

97:                                               ; preds = %96
  br label %98

98:                                               ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %99 = load ptr, ptr %14, align 8, !tbaa !5
  %100 = load ptr, ptr %15, align 8, !tbaa !5
  %101 = getelementptr inbounds %class.anon.23, ptr %19, i32 0, i32 0
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %102, ptr %101, align 8, !tbaa !41
  %103 = getelementptr inbounds %class.anon.23, ptr %19, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8
  %105 = call noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree23NotifyBodiesAABBChangedES2_ibE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef %99, ptr noundef %100, ptr noundef nonnull align 1 dereferenceable(1) %16, ptr %104)
  store ptr %105, ptr %18, align 8, !tbaa !5
  %106 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 7
  %107 = load ptr, ptr %106, align 8, !tbaa !43
  %108 = load i8, ptr %16, align 1, !tbaa !39
  %109 = zext i8 %108 to i64
  %110 = getelementptr inbounds %"class.JPH::QuadTree", ptr %107, i64 %109
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 3
  %113 = load ptr, ptr %14, align 8, !tbaa !5
  %114 = load ptr, ptr %18, align 8, !tbaa !5
  %115 = load ptr, ptr %14, align 8, !tbaa !5
  %116 = ptrtoint ptr %114 to i64
  %117 = ptrtoint ptr %115 to i64
  %118 = sub i64 %116, %117
  %119 = sdiv exact i64 %118, 4
  %120 = trunc i64 %119 to i32
  call void @_ZN3JPH8QuadTree23NotifyBodiesAABBChangedERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERKNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %110, ptr noundef nonnull align 8 dereferenceable(24) %111, ptr noundef nonnull align 8 dereferenceable(24) %112, ptr noundef %113, i32 noundef %120)
  %121 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %121, 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 %75, !llvm.loop !44

122:                                              ; preds = %75
  %123 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %124 = trunc i8 %123 to i1
  br i1 %124, label %125, label %129

125:                                              ; preds = %122
  %126 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 9
  %127 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %21, i32 0, i32 1
  %128 = load ptr, ptr %127, align 16, !tbaa !15
  call void @_ZN3JPH11PhysicsLock13sUnlockSharedINS_11SharedMutexEEEvRT_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(64) %126, ptr noundef %128, i32 noundef 8)
  br label %129

129:                                              ; preds = %125, %122
  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 %10) #7
  br label %130

130:                                              ; preds = %129, %24
  ret void
}

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

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

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

declare void @_ZN3JPH8QuadTree23NotifyBodiesAABBChangedERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERKNS1_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

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

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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 16}
!16 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !17, i64 0, !6, i64 16, !19, i64 24, !20, i64 32, !21, i64 64, !6, i64 256, !6, i64 264, !10, i64 272, !30, i64 280, !7, i64 344, !26, i64 472, !10, i64 476}
!17 = !{!"_ZTSN3JPH10BroadPhaseE", !18, i64 0, !6, i64 8}
!18 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!21 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !22, i64 64, !26, i64 112, !26, i64 116, !28, i64 120, !26, i64 128}
!22 = !{!"_ZTSN3JPH5MutexE", !23, i64 0, !25, i64 40}
!23 = !{!"_ZTSSt5mutex", !24, i64 0}
!24 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!25 = !{!"_ZTSNSt6thread2idE", !19, i64 0}
!26 = !{!"_ZTSSt6atomicIjE", !27, i64 0}
!27 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!28 = !{!"_ZTSSt6atomicImE", !29, i64 0}
!29 = !{!"_ZTSSt13__atomic_baseImE", !19, i64 0}
!30 = !{!"_ZTSN3JPH11SharedMutexE", !31, i64 0, !25, i64 56}
!31 = !{!"_ZTSSt12shared_mutex", !32, i64 0}
!32 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!33 = !{i64 2158622318}
!34 = !{!17, !6, i64 8}
!35 = !{!16, !19, i64 24}
!36 = !{i64 2158622719}
!37 = !{!38, !6, i64 0}
!38 = !{!"_ZTSZN3JPH18BroadPhaseQuadTree23NotifyBodiesAABBChangedEPNS_6BodyIDEibE3$_0", !6, i64 0}
!39 = !{!7, !7, i64 0}
!40 = !{i64 2158623168}
!41 = !{!42, !6, i64 0}
!42 = !{!"_ZTSZN3JPH18BroadPhaseQuadTree23NotifyBodiesAABBChangedEPNS_6BodyIDEibE3$_1", !6, i64 0}
!43 = !{!16, !6, i64 264}
!44 = distinct !{!44, !45}
!45 = !{!"llvm.loop.mustprogress"}


; 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::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 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = 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.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.2 = external hidden unnamed_addr constant [25 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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; 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 zeroext i1 @_ZN3JPH11SharedMutex9is_lockedEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #5 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: 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: 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: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree23NotifyBodiesAABBChangedEPNS_6BodyIDEib(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2, i1 noundef zeroext %3) unnamed_addr #3 align 2 {
  %5 = alloca i8, align 1
  %6 = icmp slt i32 %2, 1
  br i1 %6, label %60, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 280
  br i1 %3, label %9, label %12

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load ptr, ptr %10, align 16, !tbaa !5
  tail call void @_ZN3JPH11PhysicsLock11sLockSharedINS_11SharedMutexEEEvRT_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(64) %8, ptr noundef %11, i32 noundef 8)
  br label %17

12:                                               ; preds = %7
  %13 = tail call noundef zeroext i1 @_ZN3JPH11SharedMutex9is_lockedEv(ptr noundef nonnull align 8 dereferenceable(64) %8)
  br i1 %13, label %17, label %14

14:                                               ; preds = %12
  %15 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 349)
  br i1 %15, label %16, label %17

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

17:                                               ; preds = %16, %14, %12, %9
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !28
  %20 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %19)
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  %22 = load i64, ptr %21, align 8, !tbaa !29
  %23 = load ptr, ptr %18, align 8, !tbaa !28
  %24 = tail call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %23)
  %25 = zext i32 %24 to i64
  %26 = icmp eq i64 %22, %25
  br i1 %26, label %.lr.ph, label %27

27:                                               ; preds = %17
  %28 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 352)
  br i1 %28, label %29, label %.lr.ph

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

.lr.ph:                                           ; preds = %17, %27, %29
  %30 = getelementptr inbounds i8, ptr %0, i64 32
  %31 = tail call noundef ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %30)
  %32 = zext nneg i32 %2 to i64
  %33 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %32
  tail call void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNS_18BroadPhaseQuadTree23NotifyBodiesAABBChangedES2_ibE3$_0EEvT_S5_T0_"(ptr noundef %1, ptr noundef nonnull %33, ptr %31)
  %34 = getelementptr inbounds i8, ptr %0, i64 264
  br label %35

35:                                               ; preds = %.lr.ph, %44
  %.025 = phi ptr [ %1, %.lr.ph ], [ %45, %44 ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #7
  %36 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.025)
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %31, i64 %37
  %39 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %38) #7
  store i8 %39, ptr %5, align 1, !tbaa !31
  %40 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %.not = icmp eq i8 %39, %40
  br i1 %.not, label %41, label %44

41:                                               ; preds = %35
  %42 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i32 noundef 363)
  br i1 %42, label %43, label %44

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

44:                                               ; preds = %43, %41, %35
  %45 = call noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEhZNS0_18BroadPhaseQuadTree23NotifyBodiesAABBChangedES2_ibE3$_1ET_S5_S5_RKT0_T1_"(ptr noundef nonnull %.025, ptr noundef nonnull %33, ptr noundef nonnull align 1 dereferenceable(1) %5, ptr %31)
  %46 = load ptr, ptr %34, align 8, !tbaa !33
  %47 = load i8, ptr %5, align 1, !tbaa !31
  %48 = zext i8 %47 to i64
  %49 = getelementptr inbounds %"class.JPH::QuadTree", ptr %46, i64 %48
  %50 = ptrtoint ptr %45 to i64
  %51 = ptrtoint ptr %.025 to i64
  %52 = sub i64 %50, %51
  %53 = lshr exact i64 %52, 2
  %54 = trunc i64 %53 to i32
  call void @_ZN3JPH8QuadTree23NotifyBodiesAABBChangedERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERKNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %49, ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull %.025, i32 noundef %54)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  %55 = icmp ult ptr %45, %33
  br i1 %55, label %35, label %._crit_edge, !llvm.loop !34

._crit_edge:                                      ; preds = %44
  br i1 %3, label %56, label %60

56:                                               ; preds = %._crit_edge
  %57 = getelementptr inbounds i8, ptr %0, i64 280
  %58 = getelementptr inbounds i8, ptr %0, i64 16
  %59 = load ptr, ptr %58, align 16, !tbaa !5
  call void @_ZN3JPH11PhysicsLock13sUnlockSharedINS_11SharedMutexEEEvRT_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(64) %57, ptr noundef %59, i32 noundef 8)
  br label %60

60:                                               ; preds = %._crit_edge, %56, %4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH11PhysicsLock11sLockSharedINS_11SharedMutexEEEvRT_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

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

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

declare void @_ZN3JPH8QuadTree23NotifyBodiesAABBChangedERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERKNS1_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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH11PhysicsLock13sUnlockSharedINS_11SharedMutexEEEvRT_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

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


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