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

@_ZN3JPHL23cBroadPhaseLayerInvalidE = external hidden constant %"class.JPH::BroadPhaseLayer", align 1
@.str = external hidden unnamed_addr constant [60 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [109 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: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree4InitEPNS_11BodyManagerERKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.JPH::AssertLastParam", align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN3JPH10BroadPhase4InitEPNS_11BodyManagerERKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %12, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 6
  store ptr %14, ptr %15, align 64, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !28
  %18 = getelementptr inbounds ptr, ptr %17, i64 2
  %19 = load ptr, ptr %18, align 8
  %20 = call noundef i32 %19(ptr noundef nonnull align 8 dereferenceable(8) %16)
  %21 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 8
  store i32 %20, ptr %21, align 16, !tbaa !30
  br label %22

22:                                               ; preds = %3
  %23 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 8
  %24 = load i32, ptr %23, align 16, !tbaa !30
  %25 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %26 = zext i8 %25 to i32
  %27 = icmp ult i32 %24, %26
  br i1 %27, label %31, label %28

28:                                               ; preds = %22
  %29 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 26)
  br i1 %29, label %30, label %31

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

31:                                               ; preds = %30, %28, %22
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 1
  store ptr %33, ptr %34, align 16, !tbaa !32
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %35)
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 2
  store i64 %37, ptr %38, align 8, !tbaa !33
  %39 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 3
  %40 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !33
  call void @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %41)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %42 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 2
  %43 = load i64, ptr %42, align 8, !tbaa !33
  %44 = add i64 %43, 1
  %45 = trunc i64 %44 to i32
  %46 = udiv i32 %45, 2
  store i32 %46, ptr %8, align 4, !tbaa !34
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %47 = load i32, ptr %8, align 4, !tbaa !34
  %48 = load i32, ptr %8, align 4, !tbaa !34
  %49 = add i32 %48, 2
  %50 = udiv i32 %49, 3
  %51 = add i32 %47, %50
  store i32 %51, ptr %9, align 4, !tbaa !34
  %52 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 5
  %53 = load i32, ptr %9, align 4, !tbaa !34
  %54 = mul i32 2, %53
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE4InitEjj(ptr noundef nonnull align 64 dereferenceable(132) %52, i32 noundef %54, i32 noundef 256)
  %55 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 8
  %56 = load i32, ptr %55, align 16, !tbaa !30
  %57 = zext i32 %56 to i64
  %58 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %57, i64 128)
  %59 = extractvalue { i64, i1 } %58, 1
  %60 = extractvalue { i64, i1 } %58, 0
  %61 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %60, i64 64)
  %62 = extractvalue { i64, i1 } %61, 1
  %63 = or i1 %59, %62
  %64 = extractvalue { i64, i1 } %61, 0
  %65 = select i1 %63, i64 -1, i64 %64
  %66 = call noundef ptr @_ZN3JPH8QuadTreenaEmSt11align_val_t(i64 noundef %65, i64 noundef 64)
  %67 = getelementptr inbounds i8, ptr %66, i64 56
  store i64 %57, ptr %67, align 8
  %68 = getelementptr inbounds i8, ptr %66, i64 64
  %69 = icmp eq i64 %57, 0
  br i1 %69, label %76, label %70

70:                                               ; preds = %32
  %71 = getelementptr inbounds %"class.JPH::QuadTree", ptr %68, i64 %57
  br label %72

72:                                               ; preds = %72, %70
  %73 = phi ptr [ %68, %70 ], [ %74, %72 ]
  call void @_ZN3JPH8QuadTreeC2Ev(ptr noundef nonnull align 64 dereferenceable(81) %73) #8
  %74 = getelementptr inbounds %"class.JPH::QuadTree", ptr %73, i64 1
  %75 = icmp eq ptr %74, %71
  br i1 %75, label %76, label %72

76:                                               ; preds = %72, %32
  %77 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 7
  store ptr %68, ptr %77, align 8, !tbaa !35
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !34
  br label %78

78:                                               ; preds = %91, %76
  %79 = load i32, ptr %10, align 4, !tbaa !34
  %80 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 8
  %81 = load i32, ptr %80, align 16, !tbaa !30
  %82 = icmp ult i32 %79, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %94

84:                                               ; preds = %78
  %85 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 7
  %86 = load ptr, ptr %85, align 8, !tbaa !35
  %87 = load i32, ptr %10, align 4, !tbaa !34
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds %"class.JPH::QuadTree", ptr %86, i64 %88
  %90 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %11, i32 0, i32 5
  call void @_ZN3JPH8QuadTree4InitERNS_17FixedSizeFreeListINS0_4NodeEEE(ptr noundef nonnull align 64 dereferenceable(81) %89, ptr noundef nonnull align 64 dereferenceable(132) %90)
  br label %91

91:                                               ; preds = %84
  %92 = load i32, ptr %10, align 4, !tbaa !34
  %93 = add i32 %92, 1
  store i32 %93, ptr %10, align 4, !tbaa !34
  br label %78, !llvm.loop !36

94:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  ret void
}

declare void @_ZN3JPH10BroadPhase4InitEPNS_11BodyManagerERKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #4 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) #5

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH8QuadTreenaEmSt11align_val_t(i64 noundef, i64 noundef) #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH8QuadTreeC2Ev(ptr noundef nonnull align 64 dereferenceable(81)) unnamed_addr #7 align 2

declare void @_ZN3JPH8QuadTree4InitERNS_17FixedSizeFreeListINS0_4NodeEEE(ptr noundef nonnull align 64 dereferenceable(81), ptr noundef nonnull align 64 dereferenceable(132)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { 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 #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { alwaysinline 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 #7 = { 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 #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, !6, i64 256}
!10 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !11, i64 0, !6, i64 16, !13, i64 24, !14, i64 32, !15, i64 64, !6, i64 256, !6, i64 264, !16, i64 272, !25, i64 280, !7, i64 344, !21, i64 472, !16, i64 476}
!11 = !{!"_ZTSN3JPH10BroadPhaseE", !12, i64 0, !6, i64 8}
!12 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !13, i64 0, !13, i64 8, !6, i64 16}
!15 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !6, i64 24, !17, i64 64, !21, i64 112, !21, i64 116, !23, i64 120, !21, i64 128}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSN3JPH5MutexE", !18, i64 0, !20, i64 40}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !7, 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", !7, i64 0}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !8, i64 0}
!30 = !{!10, !16, i64 272}
!31 = !{i64 2158608656}
!32 = !{!10, !6, i64 16}
!33 = !{!10, !13, i64 24}
!34 = !{!16, !16, i64 0}
!35 = !{!10, !6, i64 264}
!36 = distinct !{!36, !37}
!37 = !{!"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::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 }

@_ZN3JPHL23cBroadPhaseLayerInvalidE = external hidden constant %"class.JPH::BroadPhaseLayer", align 1
@.str = external hidden unnamed_addr constant [60 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [109 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree4InitEPNS_11BodyManagerERKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2) unnamed_addr #0 align 2 {
  tail call void @_ZN3JPH10BroadPhase4InitEPNS_11BodyManagerERKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %4 = getelementptr inbounds i8, ptr %0, i64 256
  store ptr %2, ptr %4, align 64, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !27
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load ptr, ptr %6, align 8
  %8 = tail call noundef i32 %7(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %9 = getelementptr inbounds i8, ptr %0, i64 272
  store i32 %8, ptr %9, align 16, !tbaa !29
  %10 = tail call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZN3JPHL23cBroadPhaseLayerInvalidE)
  %11 = zext i8 %10 to i32
  %12 = icmp ult i32 %8, %11
  br i1 %12, label %16, label %13

13:                                               ; preds = %3
  %14 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 26)
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %3, %13, %15
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %1, ptr %17, align 16, !tbaa !31
  %18 = tail call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %1)
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %19, ptr %20, align 8, !tbaa !32
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %19)
  %22 = load i64, ptr %20, align 8, !tbaa !32
  %23 = trunc i64 %22 to i32
  %24 = add i32 %23, 1
  %25 = lshr i32 %24, 1
  %26 = add nuw i32 %25, 2
  %27 = udiv i32 %26, 3
  %28 = add nuw i32 %27, %25
  %29 = getelementptr inbounds i8, ptr %0, i64 64
  %30 = shl i32 %28, 1
  tail call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE4InitEjj(ptr noundef nonnull align 64 dereferenceable(132) %29, i32 noundef %30, i32 noundef 256)
  %31 = load i32, ptr %9, align 16, !tbaa !29
  %32 = zext i32 %31 to i64
  %33 = shl nuw nsw i64 %32, 7
  %34 = or disjoint i64 %33, 64
  %35 = tail call noundef ptr @_ZN3JPH8QuadTreenaEmSt11align_val_t(i64 noundef %34, i64 noundef 64)
  %36 = getelementptr inbounds i8, ptr %35, i64 56
  store i64 %32, ptr %36, align 8
  %37 = getelementptr inbounds i8, ptr %35, i64 64
  %38 = icmp eq i32 %31, 0
  br i1 %38, label %.loopexit, label %39

39:                                               ; preds = %16
  %40 = getelementptr inbounds %"class.JPH::QuadTree", ptr %37, i64 %32
  br label %41

41:                                               ; preds = %41, %39
  %42 = phi ptr [ %37, %39 ], [ %43, %41 ]
  tail call void @_ZN3JPH8QuadTreeC2Ev(ptr noundef nonnull align 64 dereferenceable(81) %42) #6
  %43 = getelementptr inbounds i8, ptr %42, i64 128
  %44 = icmp eq ptr %43, %40
  br i1 %44, label %.loopexit, label %41

.loopexit:                                        ; preds = %41, %16
  %45 = getelementptr inbounds i8, ptr %0, i64 264
  store ptr %37, ptr %45, align 8, !tbaa !33
  %46 = load i32, ptr %9, align 16, !tbaa !29
  %.not = icmp eq i32 %46, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.loopexit
  ret void

.lr.ph:                                           ; preds = %.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.loopexit ]
  %47 = load ptr, ptr %45, align 8, !tbaa !33
  %48 = getelementptr inbounds %"class.JPH::QuadTree", ptr %47, i64 %indvars.iv
  tail call void @_ZN3JPH8QuadTree4InitERNS_17FixedSizeFreeListINS0_4NodeEEE(ptr noundef nonnull align 64 dereferenceable(81) %48, ptr noundef nonnull align 64 dereferenceable(132) %29)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = load i32, ptr %9, align 16, !tbaa !29
  %50 = zext i32 %49 to i64
  %51 = icmp ult i64 %indvars.iv.next, %50
  br i1 %51, label %.lr.ph, label %._crit_edge, !llvm.loop !34
}

declare void @_ZN3JPH10BroadPhase4InitEPNS_11BodyManagerERKNS_24BroadPhaseLayerInterfaceE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2 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 #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH8QuadTreenaEmSt11align_val_t(i64 noundef, i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH8QuadTreeC2Ev(ptr noundef nonnull align 64 dereferenceable(81)) unnamed_addr #5 align 2

declare void @_ZN3JPH8QuadTree4InitERNS_17FixedSizeFreeListINS0_4NodeEEE(ptr noundef nonnull align 64 dereferenceable(81), ptr noundef nonnull align 64 dereferenceable(132)) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { 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 #3 = { 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 #4 = { alwaysinline 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 #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 = { 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 256}
!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 = !{!28, !28, i64 0}
!28 = !{!"vtable pointer", !11, i64 0}
!29 = !{!6, !15, i64 272}
!30 = !{i64 2158608656}
!31 = !{!6, !9, i64 16}
!32 = !{!6, !12, i64 24}
!33 = !{!6, !9, i64 264}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass