; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Collision/BroadPhase (BroadPhaseQuadTree)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.JPH::AssertLastParam" = type { i8 }
%class.anon.26 = type { ptr }
%class.anon.27 = type { ptr }
%"class.JPH::BroadPhaseLayer" = type { i8 }
%"class.JPH::BroadPhase" = type { %"class.JPH::BroadPhaseQuery", ptr }
%"class.JPH::BroadPhaseQuery" = 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::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 }

@.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.17 = external hidden unnamed_addr constant [36 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81)) #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)) #3 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH15BroadPhaseLayerC2Eh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) unnamed_addr #5 align 2

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

32:                                               ; preds = %7
  %33 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %28, i32 0, i32 2
  %34 = load i64, ptr %33, align 8, !tbaa !16
  %35 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %28, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %36)
  %38 = zext i32 %37 to i64
  %39 = icmp eq i64 %34, %38
  br i1 %39, label %43, label %40

40:                                               ; preds = %32
  %41 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 564)
  br i1 %41, label %42, label %43

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

43:                                               ; preds = %42, %40, %32
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %46 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %28, i32 0, i32 3
  %47 = call noundef ptr @_ZNK3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %46)
  store ptr %47, ptr %17, align 8, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds %"class.JPH::BodyID", ptr %49, i64 %51
  %53 = getelementptr inbounds %class.anon.26, ptr %18, i32 0, i32 0
  %54 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %54, ptr %53, align 8, !tbaa !33
  %55 = getelementptr inbounds %class.anon.26, ptr %18, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8
  call void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNKS_18BroadPhaseQuadTree18FindCollidingPairsES2_ifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEEE3$_0EEvT_SG_T0_"(ptr noundef %48, ptr noundef %52, ptr %56)
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %57, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %"class.JPH::BodyID", ptr %58, i64 %60
  store ptr %61, ptr %20, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %134, %45
  %63 = load ptr, ptr %19, align 8, !tbaa !5
  %64 = load ptr, ptr %20, align 8, !tbaa !5
  %65 = icmp ult ptr %63, %64
  br i1 %65, label %66, label %136

66:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 2, ptr %21) #7
  %67 = load ptr, ptr %17, align 8, !tbaa !5
  %68 = load ptr, ptr %19, align 8, !tbaa !5
  %69 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %68)
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %67, i64 %70
  %72 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %71, i32 0, i32 1
  %73 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %72) #7
  store i16 %73, ptr %21, align 2, !tbaa !35
  br label %74

74:                                               ; preds = %66
  %75 = load i16, ptr %21, align 2, !tbaa !35
  %76 = zext i16 %75 to i32
  %77 = icmp ne i32 %76, 65535
  br i1 %77, label %81, label %78

78:                                               ; preds = %74
  %79 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.17, ptr noundef @.str.1, i32 noundef 577)
  br i1 %79, label %80, label %81

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

81:                                               ; preds = %80, %78, %74
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %84 = load ptr, ptr %19, align 8, !tbaa !5
  %85 = load ptr, ptr %20, align 8, !tbaa !5
  %86 = getelementptr inbounds %class.anon.27, ptr %24, i32 0, i32 0
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %87, ptr %86, align 8, !tbaa !38
  %88 = getelementptr inbounds %class.anon.27, ptr %24, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8
  %90 = call noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEtZNKS0_18BroadPhaseQuadTree18FindCollidingPairsES2_ifRKNS0_29ObjectVsBroadPhaseLayerFilterERKNS0_21ObjectLayerPairFilterERNS0_18CollisionCollectorINS0_8BodyPairENS0_36CollisionCollectorTraitsCollideShapeEEEE3$_1ET_SG_SG_RKT0_T1_"(ptr noundef %84, ptr noundef %85, ptr noundef nonnull align 2 dereferenceable(2) %21, ptr %89)
  store ptr %90, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %25) #7
  store i8 0, ptr %25, align 1, !tbaa !40
  br label %91

91:                                               ; preds = %131, %83
  %92 = load i8, ptr %25, align 1, !tbaa !40
  %93 = zext i8 %92 to i32
  %94 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %28, i32 0, i32 8
  %95 = load i32, ptr %94, align 16, !tbaa !41
  %96 = icmp ult i32 %93, %95
  br i1 %96, label %98, label %97

97:                                               ; preds = %91
  call void @llvm.lifetime.end.p0(i64 1, ptr %25) #7
  br label %134

98:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #7
  %99 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %28, i32 0, i32 7
  %100 = load ptr, ptr %99, align 8, !tbaa !42
  %101 = load i8, ptr %25, align 1, !tbaa !40
  %102 = zext i8 %101 to i64
  %103 = getelementptr inbounds %"class.JPH::QuadTree", ptr %100, i64 %102
  store ptr %103, ptr %26, align 8, !tbaa !5
  %104 = load ptr, ptr %26, align 8, !tbaa !5
  %105 = call noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81) %104)
  br i1 %105, label %106, label %130

106:                                              ; preds = %98
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = load i16, ptr %21, align 2, !tbaa !35
  %109 = load i8, ptr %25, align 1, !tbaa !40
  call void @_ZN3JPH15BroadPhaseLayerC2Eh(ptr noundef nonnull align 1 dereferenceable(1) %27, i8 noundef zeroext %109)
  %110 = getelementptr inbounds %"class.JPH::BroadPhaseLayer", ptr %27, i32 0, i32 0
  %111 = load i8, ptr %110, align 1
  %112 = load ptr, ptr %107, align 8, !tbaa !43
  %113 = getelementptr inbounds ptr, ptr %112, i64 2
  %114 = load ptr, ptr %113, align 8
  %115 = call noundef zeroext i1 %114(ptr noundef nonnull align 8 dereferenceable(8) %107, i16 noundef zeroext %108, i8 %111)
  br i1 %115, label %116, label %130

116:                                              ; preds = %106
  %117 = load ptr, ptr %26, align 8, !tbaa !5
  %118 = load ptr, ptr %15, align 8, !tbaa !5
  %119 = load ptr, ptr %19, align 8, !tbaa !5
  %120 = load ptr, ptr %23, align 8, !tbaa !5
  %121 = load ptr, ptr %19, align 8, !tbaa !5
  %122 = ptrtoint ptr %120 to i64
  %123 = ptrtoint ptr %121 to i64
  %124 = sub i64 %122, %123
  %125 = sdiv exact i64 %124, 4
  %126 = trunc i64 %125 to i32
  %127 = load float, ptr %11, align 4, !tbaa !11
  %128 = load ptr, ptr %14, align 8, !tbaa !5
  %129 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZNK3JPH8QuadTree18FindCollidingPairsERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEEPKNS_6BodyIDEifRNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEERKNS_21ObjectLayerPairFilterE(ptr noundef nonnull align 64 dereferenceable(81) %117, ptr noundef nonnull align 8 dereferenceable(24) %118, ptr noundef %119, i32 noundef %126, float noundef %127, ptr noundef nonnull align 1 %128, ptr noundef nonnull align 8 dereferenceable(8) %129)
  br label %130

130:                                              ; preds = %116, %106, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #7
  br label %131

131:                                              ; preds = %130
  %132 = load i8, ptr %25, align 1, !tbaa !40
  %133 = add i8 %132, 1
  store i8 %133, ptr %25, align 1, !tbaa !40
  br label %91, !llvm.loop !45

134:                                              ; preds = %97
  %135 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %135, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr %21) #7
  br label %62, !llvm.loop !47

136:                                              ; preds = %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNKS_18BroadPhaseQuadTree18FindCollidingPairsES2_ifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEEE3$_0EEvT_SG_T0_"(ptr noundef, ptr noundef, ptr) #1

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #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 = { 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 #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 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN3JPH10BroadPhaseE", !15, i64 0, !6, i64 8}
!15 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!16 = !{!17, !18, i64 24}
!17 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !14, i64 0, !6, i64 16, !18, i64 24, !19, i64 32, !20, i64 64, !6, i64 256, !6, i64 264, !10, i64 272, !29, i64 280, !7, i64 344, !25, i64 472, !10, i64 476}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !18, i64 0, !18, i64 8, !6, i64 16}
!20 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !21, i64 64, !25, i64 112, !25, i64 116, !27, i64 120, !25, i64 128}
!21 = !{!"_ZTSN3JPH5MutexE", !22, i64 0, !24, i64 40}
!22 = !{!"_ZTSSt5mutex", !23, i64 0}
!23 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!24 = !{!"_ZTSNSt6thread2idE", !18, i64 0}
!25 = !{!"_ZTSSt6atomicIjE", !26, i64 0}
!26 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!27 = !{!"_ZTSSt6atomicImE", !28, i64 0}
!28 = !{!"_ZTSSt13__atomic_baseImE", !18, i64 0}
!29 = !{!"_ZTSN3JPH11SharedMutexE", !30, i64 0, !24, i64 56}
!30 = !{!"_ZTSSt12shared_mutex", !31, i64 0}
!31 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!32 = !{i64 2158627255}
!33 = !{!34, !6, i64 0}
!34 = !{!"_ZTSZNK3JPH18BroadPhaseQuadTree18FindCollidingPairsEPNS_6BodyIDEifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEEE3$_0", !6, i64 0}
!35 = !{!36, !36, i64 0}
!36 = !{!"short", !7, i64 0}
!37 = !{i64 2158627642}
!38 = !{!39, !6, i64 0}
!39 = !{!"_ZTSZNK3JPH18BroadPhaseQuadTree18FindCollidingPairsEPNS_6BodyIDEifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEEE3$_1", !6, i64 0}
!40 = !{!7, !7, i64 0}
!41 = !{!17, !10, i64 272}
!42 = !{!17, !6, i64 264}
!43 = !{!44, !44, i64 0}
!44 = !{!"vtable pointer", !8, i64 0}
!45 = distinct !{!45, !46}
!46 = !{!"llvm.loop.mustprogress"}
!47 = distinct !{!47, !46}


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

@.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.17 = external hidden unnamed_addr constant [36 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81)) 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 #3 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH15BroadPhaseLayerC2Eh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH18BroadPhaseQuadTree18FindCollidingPairsEPNS_6BodyIDEifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEE(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2, float noundef %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 1 %6) unnamed_addr #2 align 2 {
  %8 = alloca i16, align 2
  %9 = alloca %"class.JPH::BroadPhaseLayer", align 1
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = tail call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %15)
  %17 = zext i32 %16 to i64
  %18 = icmp eq i64 %14, %17
  br i1 %18, label %22, label %19

19:                                               ; preds = %7
  %20 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 564)
  br i1 %20, label %21, label %22

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

22:                                               ; preds = %21, %19, %7
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %24 = tail call noundef ptr @_ZNK3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %23)
  %25 = sext i32 %2 to i64
  %26 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %25
  tail call void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNKS_18BroadPhaseQuadTree18FindCollidingPairsES2_ifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEEE3$_0EEvT_SG_T0_"(ptr noundef %1, ptr noundef %26, ptr %24)
  %27 = icmp sgt i32 %2, 0
  br i1 %27, label %.lr.ph35, label %._crit_edge36

.lr.ph35:                                         ; preds = %22
  %28 = getelementptr inbounds i8, ptr %0, i64 272
  %29 = getelementptr inbounds i8, ptr %0, i64 264
  br label %30

30:                                               ; preds = %.lr.ph35, %._crit_edge
  %.033 = phi ptr [ %1, %.lr.ph35 ], [ %39, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %8) #7
  %31 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.033)
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %24, i64 %32, i32 1
  %34 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %33) #7
  store i16 %34, ptr %8, align 2, !tbaa !29
  %.not = icmp eq i16 %34, -1
  br i1 %.not, label %35, label %38

35:                                               ; preds = %30
  %36 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.1, i32 noundef 577)
  br i1 %36, label %37, label %38

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

38:                                               ; preds = %37, %35, %30
  %39 = call noundef ptr @"_ZSt11upper_boundIPN3JPH6BodyIDEtZNKS0_18BroadPhaseQuadTree18FindCollidingPairsES2_ifRKNS0_29ObjectVsBroadPhaseLayerFilterERKNS0_21ObjectLayerPairFilterERNS0_18CollisionCollectorINS0_8BodyPairENS0_36CollisionCollectorTraitsCollideShapeEEEE3$_1ET_SG_SG_RKT0_T1_"(ptr noundef nonnull %.033, ptr noundef nonnull %26, ptr noundef nonnull align 2 dereferenceable(2) %8, ptr %24)
  %40 = load i32, ptr %28, align 16, !tbaa !32
  %.not37 = icmp eq i32 %40, 0
  br i1 %.not37, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %38
  %41 = ptrtoint ptr %39 to i64
  %42 = ptrtoint ptr %.033 to i64
  %43 = sub i64 %41, %42
  %44 = lshr exact i64 %43, 2
  %45 = trunc i64 %44 to i32
  br label %47

._crit_edge:                                      ; preds = %60, %38
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %8) #7
  %46 = icmp ult ptr %39, %26
  br i1 %46, label %30, label %._crit_edge36, !llvm.loop !33

47:                                               ; preds = %.lr.ph, %60
  %.03032 = phi i8 [ 0, %.lr.ph ], [ %61, %60 ]
  %48 = load ptr, ptr %29, align 8, !tbaa !35
  %49 = zext i8 %.03032 to i64
  %50 = getelementptr inbounds %"class.JPH::QuadTree", ptr %48, i64 %49
  %51 = call noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81) %50)
  br i1 %51, label %52, label %60

52:                                               ; preds = %47
  %53 = load i16, ptr %8, align 2, !tbaa !29
  call void @_ZN3JPH15BroadPhaseLayerC2Eh(ptr noundef nonnull align 1 dereferenceable(1) %9, i8 noundef zeroext %.03032)
  %54 = load i8, ptr %9, align 1
  %55 = load ptr, ptr %4, align 8, !tbaa !36
  %56 = getelementptr inbounds i8, ptr %55, i64 16
  %57 = load ptr, ptr %56, align 8
  %58 = call noundef zeroext i1 %57(ptr noundef nonnull align 8 dereferenceable(8) %4, i16 noundef zeroext %53, i8 %54)
  br i1 %58, label %59, label %60

59:                                               ; preds = %52
  call void @_ZNK3JPH8QuadTree18FindCollidingPairsERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEEPKNS_6BodyIDEifRNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEERKNS_21ObjectLayerPairFilterE(ptr noundef nonnull align 64 dereferenceable(81) %50, ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull %.033, i32 noundef %45, float noundef %3, ptr noundef nonnull align 1 %6, ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %60

60:                                               ; preds = %59, %52, %47
  %61 = add i8 %.03032, 1
  %62 = zext i8 %61 to i32
  %63 = load i32, ptr %28, align 16, !tbaa !32
  %64 = icmp ugt i32 %63, %62
  br i1 %64, label %47, label %._crit_edge, !llvm.loop !38

._crit_edge36:                                    ; preds = %._crit_edge, %22
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZN3JPH9QuickSortIPNS_6BodyIDEZNKS_18BroadPhaseQuadTree18FindCollidingPairsES2_ifRKNS_29ObjectVsBroadPhaseLayerFilterERKNS_21ObjectLayerPairFilterERNS_18CollisionCollectorINS_8BodyPairENS_36CollisionCollectorTraitsCollideShapeEEEE3$_0EEvT_SG_T0_"(ptr noundef, ptr noundef, ptr) local_unnamed_addr #1

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #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 = { 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 #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, !8, i64 8}
!6 = !{!"_ZTSN3JPH10BroadPhaseE", !7, i64 0, !8, i64 8}
!7 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !13, i64 24}
!12 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !6, i64 0, !8, i64 16, !13, i64 24, !14, i64 32, !15, i64 64, !8, i64 256, !8, i64 264, !16, i64 272, !25, i64 280, !9, i64 344, !21, i64 472, !16, i64 476}
!13 = !{!"long", !9, i64 0}
!14 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !13, i64 0, !13, i64 8, !8, i64 16}
!15 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !8, i64 24, !17, i64 64, !21, i64 112, !21, i64 116, !23, i64 120, !21, i64 128}
!16 = !{!"int", !9, i64 0}
!17 = !{!"_ZTSN3JPH5MutexE", !18, i64 0, !20, i64 40}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !9, i64 0}
!20 = !{!"_ZTSNSt6thread2idE", !13, i64 0}
!21 = !{!"_ZTSSt6atomicIjE", !22, i64 0}
!22 = !{!"_ZTSSt13__atomic_baseIjE", !16, i64 0}
!23 = !{!"_ZTSSt6atomicImE", !24, i64 0}
!24 = !{!"_ZTSSt13__atomic_baseImE", !13, i64 0}
!25 = !{!"_ZTSN3JPH11SharedMutexE", !26, i64 0, !20, i64 56}
!26 = !{!"_ZTSSt12shared_mutex", !27, i64 0}
!27 = !{!"_ZTSSt22__shared_mutex_pthread", !9, i64 0}
!28 = !{i64 2158627255}
!29 = !{!30, !30, i64 0}
!30 = !{!"short", !9, i64 0}
!31 = !{i64 2158627642}
!32 = !{!12, !16, i64 272}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{!12, !8, i64 264}
!36 = !{!37, !37, i64 0}
!37 = !{!"vtable pointer", !10, i64 0}
!38 = distinct !{!38, !34}


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