; 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::BroadPhase::UpdateState" = type { [4 x ptr] }
%"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 }
%"struct.JPH::BroadPhaseQuadTree::UpdateStateImpl" = type <{ ptr, %"struct.JPH::QuadTree::UpdateState", [4 x i8] }>
%"struct.JPH::QuadTree::UpdateState" = type { %"class.JPH::QuadTree::NodeID" }
%"class.JPH::QuadTree::NodeID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81)) #2 align 2

declare void @_ZN3JPH8QuadTree13UpdatePrepareERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEERNS0_11UpdateStateEb(ptr noundef nonnull align 64 dereferenceable(81), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), i1 noundef zeroext) #3

; 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: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree13UpdatePrepareEv(ptr dead_on_unwind noalias writable sret(%"struct.JPH::BroadPhase::UpdateState") align 8 %0, ptr noundef nonnull align 64 dereferenceable(512) %1) unnamed_addr #5 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.JPH::AssertLastParam", align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  br label %10

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 9
  %12 = call noundef zeroext i1 @_ZN3JPH11SharedMutex9is_lockedEv(ptr noundef nonnull align 8 dereferenceable(64) %11)
  br i1 %12, label %16, label %13

13:                                               ; preds = %10
  %14 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 105)
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %15, %13, %10
  br label %17

17:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store ptr %0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %18

18:                                               ; preds = %61, %17
  %19 = load i32, ptr %6, align 4, !tbaa !10
  %20 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 8
  %21 = load i32, ptr %20, align 16, !tbaa !12
  %22 = icmp ult i32 %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  store i32 4, ptr %7, align 4
  br label %64

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %25 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 7
  %26 = load ptr, ptr %25, align 8, !tbaa !30
  %27 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 12
  %28 = load i32, ptr %27, align 4, !tbaa !31
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds %"class.JPH::QuadTree", ptr %26, i64 %29
  store ptr %30, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 12
  %32 = load i32, ptr %31, align 4, !tbaa !31
  %33 = add i32 %32, 1
  %34 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 8
  %35 = load i32, ptr %34, align 16, !tbaa !12
  %36 = urem i32 %33, %35
  %37 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 12
  store i32 %36, ptr %37, align 4, !tbaa !31
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = call noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81) %38)
  br i1 %39, label %40, label %57

40:                                               ; preds = %24
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef zeroext i1 @_ZNK3JPH8QuadTree7IsDirtyEv(ptr noundef nonnull align 64 dereferenceable(81) %41)
  br i1 %42, label %43, label %57

43:                                               ; preds = %40
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = call noundef zeroext i1 @_ZNK3JPH8QuadTree12CanBeUpdatedEv(ptr noundef nonnull align 64 dereferenceable(81) %44)
  br i1 %45, label %46, label %57

46:                                               ; preds = %43
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::UpdateStateImpl", ptr %48, i32 0, i32 0
  store ptr %47, ptr %49, align 8, !tbaa !32
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %9, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !36
  %53 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %52)
  %54 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %9, i32 0, i32 3
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::UpdateStateImpl", ptr %55, i32 0, i32 1
  call void @_ZN3JPH8QuadTree13UpdatePrepareERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEERNS0_11UpdateStateEb(ptr noundef nonnull align 64 dereferenceable(81) %50, ptr noundef nonnull align 8 dereferenceable(24) %53, ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef nonnull align 4 dereferenceable(4) %56, i1 noundef zeroext false)
  store i32 1, ptr %7, align 4
  br label %58

57:                                               ; preds = %43, %40, %24
  store i32 0, ptr %7, align 4
  br label %58

58:                                               ; preds = %57, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %59 = load i32, ptr %7, align 4
  switch i32 %59, label %64 [
    i32 0, label %60
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %6, align 4, !tbaa !10
  %63 = add i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !10
  br label %18, !llvm.loop !37

64:                                               ; preds = %58, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %65 = load i32, ptr %7, align 4
  switch i32 %65, label %69 [
    i32 4, label %66
  ]

66:                                               ; preds = %64
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.JPH::BroadPhaseQuadTree::UpdateStateImpl", ptr %67, i32 0, i32 0
  store ptr null, ptr %68, align 8, !tbaa !32
  store i32 1, ptr %7, align 4
  br label %69

69:                                               ; preds = %66, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret void
}

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

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

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

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 = { 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 #3 = { "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 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 2158609148}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 272}
!13 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !14, i64 0, !6, i64 16, !16, i64 24, !17, i64 32, !18, i64 64, !6, i64 256, !6, i64 264, !11, i64 272, !27, i64 280, !7, i64 344, !23, i64 472, !11, i64 476}
!14 = !{!"_ZTSN3JPH10BroadPhaseE", !15, i64 0, !6, i64 8}
!15 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !16, i64 0, !16, i64 8, !6, i64 16}
!18 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !19, i64 64, !23, i64 112, !23, i64 116, !25, i64 120, !23, i64 128}
!19 = !{!"_ZTSN3JPH5MutexE", !20, i64 0, !22, i64 40}
!20 = !{!"_ZTSSt5mutex", !21, i64 0}
!21 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!22 = !{!"_ZTSNSt6thread2idE", !16, i64 0}
!23 = !{!"_ZTSSt6atomicIjE", !24, i64 0}
!24 = !{!"_ZTSSt13__atomic_baseIjE", !11, i64 0}
!25 = !{!"_ZTSSt6atomicImE", !26, i64 0}
!26 = !{!"_ZTSSt13__atomic_baseImE", !16, 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 264}
!31 = !{!13, !11, i64 476}
!32 = !{!33, !6, i64 0}
!33 = !{!"_ZTSN3JPH18BroadPhaseQuadTree15UpdateStateImplE", !6, i64 0, !34, i64 8}
!34 = !{!"_ZTSN3JPH8QuadTree11UpdateStateE", !35, i64 0}
!35 = !{!"_ZTSN3JPH8QuadTree6NodeIDE", !11, i64 0}
!36 = !{!14, !6, i64 8}
!37 = distinct !{!37, !38}
!38 = !{!"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"

%"struct.JPH::BroadPhase::UpdateState" = type { [4 x ptr] }
%"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.2 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

declare void @_ZN3JPH8QuadTree13UpdatePrepareERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEERNS0_11UpdateStateEb(ptr noundef nonnull align 64 dereferenceable(81), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), i1 noundef zeroext) local_unnamed_addr #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 #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree13UpdatePrepareEv(ptr dead_on_unwind noalias writable sret(%"struct.JPH::BroadPhase::UpdateState") align 8 %0, ptr noundef nonnull align 64 dereferenceable(512) %1) unnamed_addr #4 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 280
  %4 = tail call noundef zeroext i1 @_ZN3JPH11SharedMutex9is_lockedEv(ptr noundef nonnull align 8 dereferenceable(64) %3)
  br i1 %4, label %8, label %5

5:                                                ; preds = %2
  %6 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 105)
  br i1 %6, label %7, label %8

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

8:                                                ; preds = %2, %5, %7
  %9 = getelementptr inbounds i8, ptr %1, i64 272
  %10 = load i32, ptr %9, align 16, !tbaa !6
  %.not17.not = icmp eq i32 %10, 0
  br i1 %.not17.not, label %.critedge16, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %11 = getelementptr inbounds i8, ptr %1, i64 264
  %12 = getelementptr inbounds i8, ptr %1, i64 476
  br label %13

13:                                               ; preds = %.lr.ph, %31
  %14 = phi i32 [ %10, %.lr.ph ], [ %33, %31 ]
  %.018 = phi i32 [ 0, %.lr.ph ], [ %32, %31 ]
  %15 = load ptr, ptr %11, align 8, !tbaa !28
  %16 = load i32, ptr %12, align 4, !tbaa !29
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds %"class.JPH::QuadTree", ptr %15, i64 %17
  %19 = add i32 %16, 1
  %20 = urem i32 %19, %14
  store i32 %20, ptr %12, align 4, !tbaa !29
  %21 = tail call noundef zeroext i1 @_ZNK3JPH8QuadTree9HasBodiesEv(ptr noundef nonnull align 64 dereferenceable(81) %18)
  br i1 %21, label %22, label %31

22:                                               ; preds = %13
  %23 = tail call noundef zeroext i1 @_ZNK3JPH8QuadTree7IsDirtyEv(ptr noundef nonnull align 64 dereferenceable(81) %18)
  br i1 %23, label %24, label %31

24:                                               ; preds = %22
  %25 = tail call noundef zeroext i1 @_ZNK3JPH8QuadTree12CanBeUpdatedEv(ptr noundef nonnull align 64 dereferenceable(81) %18)
  br i1 %25, label %.critedge, label %31

.critedge:                                        ; preds = %24
  store ptr %18, ptr %0, align 8, !tbaa !30
  %26 = getelementptr inbounds i8, ptr %1, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !34
  %28 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %27)
  %29 = getelementptr inbounds i8, ptr %1, i64 32
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN3JPH8QuadTree13UpdatePrepareERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEERNS0_11UpdateStateEb(ptr noundef nonnull align 64 dereferenceable(81) %18, ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull align 8 dereferenceable(24) %29, ptr noundef nonnull align 4 dereferenceable(4) %30, i1 noundef zeroext false)
  br label %34

31:                                               ; preds = %24, %22, %13
  %32 = add nuw i32 %.018, 1
  %33 = load i32, ptr %9, align 16, !tbaa !6
  %.not = icmp ult i32 %32, %33
  br i1 %.not, label %13, label %.critedge16, !llvm.loop !35

.critedge16:                                      ; preds = %31, %8
  store ptr null, ptr %0, align 8, !tbaa !30
  br label %34

34:                                               ; preds = %.critedge, %.critedge16
  ret void
}

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

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

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

attributes #0 = { 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 #1 = { 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 #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 = { 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 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 = { 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 = !{i64 2158609148}
!6 = !{!7, !16, i64 272}
!7 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !8, i64 0, !10, i64 16, !13, i64 24, !14, i64 32, !15, i64 64, !10, i64 256, !10, i64 264, !16, i64 272, !25, i64 280, !11, i64 344, !21, i64 472, !16, i64 476}
!8 = !{!"_ZTSN3JPH10BroadPhaseE", !9, i64 0, !10, i64 8}
!9 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !13, i64 0, !13, i64 8, !10, i64 16}
!15 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !10, i64 24, !17, i64 64, !21, i64 112, !21, i64 116, !23, i64 120, !21, i64 128}
!16 = !{!"int", !11, i64 0}
!17 = !{!"_ZTSN3JPH5MutexE", !18, i64 0, !20, i64 40}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !11, 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", !11, i64 0}
!28 = !{!7, !10, i64 264}
!29 = !{!7, !16, i64 476}
!30 = !{!31, !10, i64 0}
!31 = !{!"_ZTSN3JPH18BroadPhaseQuadTree15UpdateStateImplE", !10, i64 0, !32, i64 8}
!32 = !{!"_ZTSN3JPH8QuadTree11UpdateStateE", !33, i64 0}
!33 = !{!"_ZTSN3JPH8QuadTree6NodeIDE", !16, i64 0}
!34 = !{!8, !10, i64 8}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass