; 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::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.std::shared_lock" = type <{ ptr, i8, [7 x i8] }>
%"class.JPH::BroadPhaseLayer" = type { i8 }
%"class.JPH::BroadPhaseQuadTree" = type { %"class.JPH::BroadPhase", ptr, i64, %"class.JPH::Array", [8 x i8], %"class.JPH::FixedSizeFreeList", ptr, ptr, i32, %"class.JPH::SharedMutex", [2 x %"class.JPH::SharedMutex"], %"struct.std::atomic", i32, [32 x i8] }
%"class.JPH::BroadPhase" = type { %"class.JPH::BroadPhaseQuery", ptr }
%"class.JPH::BroadPhaseQuery" = type { ptr }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::FixedSizeFreeList" = type <{ i32, i32, i32, i32, i32, [4 x i8], ptr, [32 x i8], %"class.JPH::Mutex", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic.0", %"struct.std::atomic", [60 x i8] }>
%"class.JPH::Mutex" = type { %"class.std::mutex", %"class.std::thread::id" }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::thread::id" = type { i64 }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i64 }
%"class.JPH::SharedMutex" = type { %"class.std::shared_mutex", %"class.std::thread::id" }
%"class.std::shared_mutex" = type { %"class.std::__shared_mutex_pthread" }
%"class.std::__shared_mutex_pthread" = type { %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt11shared_lockIN3JPH11SharedMutexEEC2ERS1_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #2 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 nounwind uwtable
declare dso_local void @_ZNSt11shared_lockIN3JPH11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEE14ShouldEarlyOutEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH18BroadPhaseQuadTree13CollideSphereENS_4Vec3EfRNS_18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEEERKNS_21BroadPhaseLayerFilterERKNS_17ObjectLayerFilterE(ptr noundef nonnull align 64 dereferenceable(512) %0, double %1, double %2, float noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca %"class.JPH::Vec3", align 16
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %"struct.JPH::AssertLastParam", align 1
  %15 = alloca %"class.std::shared_lock", align 8
  %16 = alloca i8, align 1
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca %"class.JPH::BroadPhaseLayer", align 1
  %22 = alloca %"class.JPH::Vec3", align 16
  %23 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  store double %1, ptr %23, align 16
  %24 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  store double %2, ptr %24, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  store ptr %6, ptr %13, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8
  br label %26

26:                                               ; preds = %7
  %27 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 2
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %25, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !30
  %31 = call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %30)
  %32 = zext i32 %31 to i64
  %33 = icmp eq i64 %28, %32
  br i1 %33, label %37, label %34

34:                                               ; preds = %26
  %35 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 466)
  br i1 %35, label %36, label %37

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

37:                                               ; preds = %36, %34, %26
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #8
  %39 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 10
  %40 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 11
  %41 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %40) #8
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds [2 x %"class.JPH::SharedMutex"], ptr %39, i64 0, i64 %42
  call void @_ZNSt11shared_lockIN3JPH11SharedMutexEEC2ERS1_(ptr noundef nonnull align 8 dereferenceable(9) %15, ptr noundef nonnull align 8 dereferenceable(64) %43)
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #8
  store i8 0, ptr %16, align 1, !tbaa !32
  br label %44

44:                                               ; preds = %95, %38
  %45 = load i8, ptr %16, align 1, !tbaa !32
  %46 = zext i8 %45 to i32
  %47 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 8
  %48 = load i32, ptr %47, align 16, !tbaa !33
  %49 = icmp ult i32 %46, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %44
  store i32 4, ptr %17, align 4
  br label %98

51:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %52 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 7
  %53 = load ptr, ptr %52, align 8, !tbaa !34
  %54 = load i8, ptr %16, align 1, !tbaa !32
  %55 = zext i8 %54 to i64
  %56 = getelementptr inbounds %"class.JPH::QuadTree", ptr %53, i64 %55
  store ptr %56, ptr %18, align 8, !tbaa !5
  %57 = load ptr, ptr %18, align 8, !tbaa !5
  %58 = invoke noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81) %57)
          to label %59 unwind label %86

59:                                               ; preds = %51
  br i1 %58, label %60, label %91

60:                                               ; preds = %59
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load i8, ptr %16, align 1, !tbaa !32
  invoke void @_ZN3JPH15BroadPhaseLayerC2Eh(ptr noundef nonnull align 1 dereferenceable(1) %21, i8 noundef zeroext %62)
          to label %63 unwind label %86

63:                                               ; preds = %60
  %64 = getelementptr inbounds %"class.JPH::BroadPhaseLayer", ptr %21, i32 0, i32 0
  %65 = load i8, ptr %64, align 1
  %66 = load ptr, ptr %61, align 8, !tbaa !35
  %67 = getelementptr inbounds ptr, ptr %66, i64 2
  %68 = load ptr, ptr %67, align 8
  %69 = invoke noundef zeroext i1 %68(ptr noundef nonnull align 8 dereferenceable(8) %61, i8 %65)
          to label %70 unwind label %86

70:                                               ; preds = %63
  br i1 %69, label %71, label %91

71:                                               ; preds = %70
  %72 = load ptr, ptr %18, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %22, ptr align 16 %8, i64 16, i1 false), !tbaa.struct !37
  %73 = load float, ptr %10, align 4, !tbaa !9
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  %76 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %25, i32 0, i32 3
  %77 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 0
  %78 = load double, ptr %77, align 16
  %79 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 1
  %80 = load double, ptr %79, align 8
  invoke void @_ZNK3JPH8QuadTree13CollideSphereENS_4Vec3EfRNS_18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEEERKNS_17ObjectLayerFilterERKNS_5ArrayINS0_8TrackingENS_12STLAllocatorISB_EEEE(ptr noundef nonnull align 64 dereferenceable(81) %72, double %78, double %80, float noundef %73, ptr noundef nonnull align 8 dereferenceable(24) %74, ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef nonnull align 8 dereferenceable(24) %76)
          to label %81 unwind label %86

81:                                               ; preds = %71
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  %83 = invoke noundef zeroext i1 @_ZNK3JPH18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEE14ShouldEarlyOutEv(ptr noundef nonnull align 8 dereferenceable(24) %82)
          to label %84 unwind label %86

84:                                               ; preds = %81
  br i1 %83, label %85, label %90

85:                                               ; preds = %84
  store i32 4, ptr %17, align 4
  br label %92

86:                                               ; preds = %81, %71, %63, %60, %51
  %87 = landingpad { ptr, i32 }
          cleanup
  %88 = extractvalue { ptr, i32 } %87, 0
  store ptr %88, ptr %19, align 8
  %89 = extractvalue { ptr, i32 } %87, 1
  store i32 %89, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #8
  call void @_ZNSt11shared_lockIN3JPH11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %15) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #8
  br label %100

90:                                               ; preds = %84
  br label %91

91:                                               ; preds = %90, %70, %59
  store i32 0, ptr %17, align 4
  br label %92

92:                                               ; preds = %91, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  %93 = load i32, ptr %17, align 4
  switch i32 %93, label %98 [
    i32 0, label %94
  ]

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94
  %96 = load i8, ptr %16, align 1, !tbaa !32
  %97 = add i8 %96, 1
  store i8 %97, ptr %16, align 1, !tbaa !32
  br label %44, !llvm.loop !38

98:                                               ; preds = %92, %50
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #8
  br label %99

99:                                               ; preds = %98
  call void @_ZNSt11shared_lockIN3JPH11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %15) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #8
  ret void

100:                                              ; preds = %86
  %101 = load ptr, ptr %19, align 8
  %102 = load i32, ptr %20, align 4
  %103 = insertvalue { ptr, i32 } poison, ptr %101, 0
  %104 = insertvalue { ptr, i32 } %103, i32 %102, 1
  resume { ptr, i32 } %104
}

declare void @_ZNK3JPH8QuadTree13CollideSphereENS_4Vec3EfRNS_18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEEERKNS_17ObjectLayerFilterERKNS_5ArrayINS0_8TrackingENS_12STLAllocatorISB_EEEE(ptr noundef nonnull align 64 dereferenceable(81), double, double, float noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(24)) #6

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #7

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !15, i64 24}
!12 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !13, i64 0, !6, i64 16, !15, i64 24, !16, i64 32, !17, i64 64, !6, i64 256, !6, i64 264, !18, i64 272, !27, i64 280, !7, i64 344, !23, i64 472, !18, 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", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !6, i64 24, !19, i64 64, !23, i64 112, !23, i64 116, !25, i64 120, !23, i64 128}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTSN3JPH5MutexE", !20, i64 0, !22, i64 40}
!20 = !{!"_ZTSSt5mutex", !21, i64 0}
!21 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!22 = !{!"_ZTSNSt6thread2idE", !15, i64 0}
!23 = !{!"_ZTSSt6atomicIjE", !24, i64 0}
!24 = !{!"_ZTSSt13__atomic_baseIjE", !18, i64 0}
!25 = !{!"_ZTSSt6atomicImE", !26, i64 0}
!26 = !{!"_ZTSSt13__atomic_baseImE", !15, i64 0}
!27 = !{!"_ZTSN3JPH11SharedMutexE", !28, i64 0, !22, i64 56}
!28 = !{!"_ZTSSt12shared_mutex", !29, i64 0}
!29 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!30 = !{!13, !6, i64 8}
!31 = !{i64 2158625651}
!32 = !{!7, !7, i64 0}
!33 = !{!12, !18, i64 272}
!34 = !{!12, !6, i64 264}
!35 = !{!36, !36, i64 0}
!36 = !{!"vtable pointer", !8, i64 0}
!37 = !{i64 0, i64 16, !32}
!38 = distinct !{!38, !39}
!39 = !{!"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.std::shared_lock" = type <{ ptr, i8, [7 x i8] }>
%"class.JPH::BroadPhaseLayer" = type { i8 }
%"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 }
%"class.std::thread::id" = type { i64 }
%"class.JPH::QuadTree" = type <{ ptr, %"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch", [44 x i8], %"struct.std::atomic", [2 x %"struct.JPH::QuadTree::RootNode"], %"struct.std::atomic", %"struct.std::atomic.2", [47 x i8] }>
%"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch" = type { i32, i32, i32 }
%"struct.JPH::QuadTree::RootNode" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"struct.std::atomic.2" = type { %"struct.std::__atomic_base.3" }
%"struct.std::__atomic_base.3" = type { i8 }

@.str.1 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt11shared_lockIN3JPH11SharedMutexEEC2ERS1_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #2 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 nounwind uwtable
declare dso_local void @_ZNSt11shared_lockIN3JPH11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEE14ShouldEarlyOutEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

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

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

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

20:                                               ; preds = %7, %17, %19
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #7
  %21 = getelementptr inbounds i8, ptr %0, i64 344
  %22 = getelementptr inbounds i8, ptr %0, i64 472
  %23 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %22) #7
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [2 x %"class.JPH::SharedMutex"], ptr %21, i64 0, i64 %24
  call void @_ZNSt11shared_lockIN3JPH11SharedMutexEEC2ERS1_(ptr noundef nonnull align 8 dereferenceable(9) %8, ptr noundef nonnull align 8 dereferenceable(64) %25)
  %26 = getelementptr inbounds i8, ptr %0, i64 272
  %27 = load i32, ptr %26, align 16, !tbaa !29
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %20
  %28 = getelementptr inbounds i8, ptr %0, i64 264
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  br label %30

30:                                               ; preds = %.lr.ph, %.critedge
  %.017 = phi i8 [ 0, %.lr.ph ], [ %47, %.critedge ]
  %31 = load ptr, ptr %28, align 8, !tbaa !30
  %32 = zext i8 %.017 to i64
  %33 = getelementptr inbounds %"class.JPH::QuadTree", ptr %31, i64 %32
  %34 = call noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81) %33)
  br i1 %34, label %35, label %.critedge

35:                                               ; preds = %30
  call void @_ZN3JPH15BroadPhaseLayerC2Eh(ptr noundef nonnull align 1 dereferenceable(1) %9, i8 noundef zeroext %.017)
  %36 = load i8, ptr %9, align 1
  %37 = load ptr, ptr %5, align 8, !tbaa !31
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  %39 = load ptr, ptr %38, align 8
  %40 = invoke noundef zeroext i1 %39(ptr noundef nonnull align 8 dereferenceable(8) %5, i8 %36)
          to label %41 unwind label %45

41:                                               ; preds = %35
  br i1 %40, label %42, label %.critedge

42:                                               ; preds = %41
  invoke void @_ZNK3JPH8QuadTree13CollideSphereENS_4Vec3EfRNS_18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEEERKNS_17ObjectLayerFilterERKNS_5ArrayINS0_8TrackingENS_12STLAllocatorISB_EEEE(ptr noundef nonnull align 64 dereferenceable(81) %33, double %1, double %2, float noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(24) %29)
          to label %43 unwind label %45

43:                                               ; preds = %42
  %44 = call noundef zeroext i1 @_ZNK3JPH18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEE14ShouldEarlyOutEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  br i1 %44, label %._crit_edge, label %.critedge

45:                                               ; preds = %42, %35
  %46 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt11shared_lockIN3JPH11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %8) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #7
  resume { ptr, i32 } %46

.critedge:                                        ; preds = %43, %41, %30
  %47 = add i8 %.017, 1
  %48 = zext i8 %47 to i32
  %49 = load i32, ptr %26, align 16, !tbaa !29
  %50 = icmp ugt i32 %49, %48
  br i1 %50, label %30, label %._crit_edge, !llvm.loop !33

._crit_edge:                                      ; preds = %.critedge, %43, %20
  call void @_ZNSt11shared_lockIN3JPH11SharedMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %8) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #7
  ret void
}

declare void @_ZNK3JPH8QuadTree13CollideSphereENS_4Vec3EfRNS_18CollisionCollectorINS_6BodyIDENS_36CollisionCollectorTraitsCollideShapeEEERKNS_17ObjectLayerFilterERKNS_5ArrayINS0_8TrackingENS_12STLAllocatorISB_EEEE(ptr noundef nonnull align 64 dereferenceable(81), double, double, float noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(24)) 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 = { 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 = { 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 #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, !12, i64 24}
!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 = !{i64 2158625651}
!29 = !{!6, !15, i64 272}
!30 = !{!6, !9, i64 264}
!31 = !{!32, !32, i64 0}
!32 = !{!"vtable pointer", !11, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


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