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

; 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::FixedSizeFreeList<JPH::QuadTree::Node>::Batch" = type { i32, i32, i32 }
%"class.JPH::QuadTree::NodeID" = type { i32 }
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::BodyID" = type { i32 }
%"struct.JPH::QuadTree::AddState" = type { %"class.JPH::QuadTree::NodeID", %"class.JPH::AABox" }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon.1 }
%union.anon.1 = type { <4 x float> }
%"class.JPH::QuadTree" = type <{ ptr, %"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch", [44 x i8], %"struct.std::atomic.0", [2 x %"struct.JPH::QuadTree::RootNode"], %"struct.std::atomic.0", %"struct.std::atomic.6", [47 x i8] }>
%"struct.JPH::QuadTree::RootNode" = type { %"struct.std::atomic.0" }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"struct.std::atomic.6" = type { %"struct.std::__atomic_base.7" }
%"struct.std::__atomic_base.7" = type { i8 }
%"class.JPH::QuadTree::Node" = type { [4 x %"struct.std::atomic"], [4 x %"struct.std::atomic"], [4 x %"struct.std::atomic"], [4 x %"struct.std::atomic"], [4 x %"struct.std::atomic"], [4 x %"struct.std::atomic"], [4 x %"class.JPH::QuadTree::AtomicNodeID"], %"struct.std::atomic.0", %"struct.std::atomic.0", i32 }
%"struct.std::atomic" = type { float }
%"class.JPH::QuadTree::AtomicNodeID" = type { %"struct.std::atomic.0" }

@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [17 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: 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) #1

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH8QuadTree14AddBodiesAbortERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEERKNS0_8AddStateE(ptr noundef nonnull align 64 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(48) %2) #4 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch", align 4
  %8 = alloca [128 x %"class.JPH::QuadTree::NodeID"], align 16
  %9 = alloca %"struct.JPH::AssertLastParam", align 1
  %10 = alloca i32, align 4
  %11 = alloca %"class.JPH::QuadTree::NodeID", align 4
  %12 = alloca %"class.JPH::BodyID", align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca %"class.JPH::QuadTree::NodeID", align 4
  %19 = alloca %"struct.JPH::AssertLastParam", align 1
  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
  %20 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #5
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr %8) #5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.JPH::QuadTree::AddState", ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %8, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %23, ptr align 16 %22, i64 4, i1 false), !tbaa.struct !9
  br label %24

24:                                               ; preds = %3
  %25 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %8, i64 0, i64 0
  %26 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %25)
  br i1 %26, label %30, label %27

27:                                               ; preds = %24
  %28 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 872)
  br i1 %28, label %29, label %30

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

30:                                               ; preds = %29, %27, %24
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !10
  br label %33

33:                                               ; preds = %93, %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %34 = load i32, ptr %10, align 4, !tbaa !10
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %8, i64 0, i64 %35
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %36, i64 4, i1 false), !tbaa.struct !9
  %37 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID6IsBodyEv(ptr noundef nonnull align 4 dereferenceable(4) %11)
  br i1 %37, label %38, label %44

38:                                               ; preds = %33
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call i32 @_ZNK3JPH8QuadTree6NodeID9GetBodyIDEv(ptr noundef nonnull align 4 dereferenceable(4) %11)
  %41 = getelementptr inbounds %"class.JPH::BodyID", ptr %12, i32 0, i32 0
  store i32 %40, ptr %41, align 4
  %42 = getelementptr inbounds %"class.JPH::BodyID", ptr %12, i32 0, i32 0
  %43 = load i32, ptr %42, align 4
  call void @_ZN3JPH8QuadTree23sInvalidateBodyLocationERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEENS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %39, i32 %43)
  br label %90

44:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %45 = call noundef i32 @_ZNK3JPH8QuadTree6NodeID12GetNodeIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %11)
  store i32 %45, ptr %13, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %46 = getelementptr inbounds %"class.JPH::QuadTree", ptr %20, i32 0, i32 0
  %47 = load ptr, ptr %46, align 64, !tbaa !13
  %48 = load i32, ptr %13, align 4, !tbaa !10
  %49 = call noundef nonnull align 4 dereferenceable(124) ptr @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE3GetEj(ptr noundef nonnull align 64 dereferenceable(132) %47, i32 noundef %48)
  store ptr %49, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.JPH::QuadTree::Node", ptr %50, i32 0, i32 6
  store ptr %51, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  %53 = getelementptr inbounds [4 x %"class.JPH::QuadTree::AtomicNodeID"], ptr %52, i64 0, i64 0
  store ptr %53, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = getelementptr inbounds [4 x %"class.JPH::QuadTree::AtomicNodeID"], ptr %54, i64 0, i64 0
  %56 = getelementptr inbounds %"class.JPH::QuadTree::AtomicNodeID", ptr %55, i64 4
  store ptr %56, ptr %17, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %83, %44
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = icmp ne ptr %58, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %86

62:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %63 = load ptr, ptr %16, align 8, !tbaa !5
  %64 = call i32 @_ZNK3JPH8QuadTree12AtomicNodeIDcvNS0_6NodeIDEEv(ptr noundef nonnull align 4 dereferenceable(4) %63)
  %65 = getelementptr inbounds %"class.JPH::QuadTree::NodeID", ptr %18, i32 0, i32 0
  store i32 %64, ptr %65, align 4
  %66 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %18)
  br i1 %66, label %67, label %82

67:                                               ; preds = %62
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %10, align 4, !tbaa !10
  %70 = icmp slt i32 %69, 128
  br i1 %70, label %74, label %71

71:                                               ; preds = %68
  %72 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.27, ptr noundef @.str.1, i32 noundef 891)
  br i1 %72, label %73, label %74

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

74:                                               ; preds = %73, %71, %68
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %10, align 4, !tbaa !10
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %8, i64 0, i64 %78
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %79, ptr align 4 %18, i64 4, i1 false), !tbaa.struct !9
  %80 = load i32, ptr %10, align 4, !tbaa !10
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %10, align 4, !tbaa !10
  br label %82

82:                                               ; preds = %76, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.JPH::QuadTree::AtomicNodeID", ptr %84, i32 1
  store ptr %85, ptr %16, align 8, !tbaa !5
  br label %57

86:                                               ; preds = %61
  %87 = getelementptr inbounds %"class.JPH::QuadTree", ptr %20, i32 0, i32 0
  %88 = load ptr, ptr %87, align 64, !tbaa !13
  %89 = load i32, ptr %13, align 4, !tbaa !10
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE16AddObjectToBatchERNS3_5BatchEj(ptr noundef nonnull align 64 dereferenceable(132) %88, ptr noundef nonnull align 4 dereferenceable(12) %7, i32 noundef %89)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %90

90:                                               ; preds = %86, %38
  %91 = load i32, ptr %10, align 4, !tbaa !10
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr %10, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %93

93:                                               ; preds = %90
  %94 = load i32, ptr %10, align 4, !tbaa !10
  %95 = icmp sge i32 %94, 0
  br i1 %95, label %33, label %96, !llvm.loop !22

96:                                               ; preds = %93
  %97 = getelementptr inbounds %"class.JPH::QuadTree", ptr %20, i32 0, i32 0
  %98 = load ptr, ptr %97, align 64, !tbaa !13
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE19DestructObjectBatchERNS3_5BatchE(ptr noundef nonnull align 64 dereferenceable(132) %98, ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{i64 2158748744}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSN3JPH8QuadTreeE", !6, i64 0, !15, i64 8, !16, i64 64, !7, i64 68, !16, i64 76, !18, i64 80}
!15 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchE", !11, i64 0, !11, i64 4, !11, i64 8}
!16 = !{!"_ZTSSt6atomicIjE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIjE", !11, i64 0}
!18 = !{!"_ZTSSt6atomicIbE", !19, i64 0}
!19 = !{!"_ZTSSt13__atomic_baseIbE", !20, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{i64 2158749083}
!22 = distinct !{!22, !23}
!23 = !{!"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::FixedSizeFreeList<JPH::QuadTree::Node>::Batch" = type { i32, i32, i32 }
%"class.JPH::QuadTree::NodeID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [17 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(124) ptr @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE3GetEj(ptr noundef nonnull align 64 dereferenceable(132), i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK3JPH8QuadTree6NodeID12GetNodeIndexEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK3JPH8QuadTree12AtomicNodeIDcvNS0_6NodeIDEEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK3JPH8QuadTree6NodeID9GetBodyIDEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH8QuadTree14AddBodiesAbortERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEERKNS0_8AddStateE(ptr nocapture noundef nonnull readonly align 64 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr nocapture noundef nonnull readonly align 16 dereferenceable(48) %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %"struct.JPH::FixedSizeFreeList<JPH::QuadTree::Node>::Batch", align 4
  %5 = alloca [128 x %"class.JPH::QuadTree::NodeID"], align 16
  %6 = alloca %"class.JPH::QuadTree::NodeID", align 4
  %7 = alloca %"class.JPH::QuadTree::NodeID", align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %4) #4
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %5) #4
  %8 = load i32, ptr %2, align 16, !tbaa !5
  store i32 %8, ptr %5, align 16, !tbaa !5
  %9 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %5)
  br i1 %9, label %.preheader, label %10

10:                                               ; preds = %3
  %11 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i32 noundef 872)
  br i1 %11, label %12, label %.preheader

12:                                               ; preds = %10
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !9
  br label %.preheader

.preheader:                                       ; preds = %12, %10, %3
  br label %13

13:                                               ; preds = %.preheader, %77
  %.0 = phi i32 [ %78, %77 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %14 = zext nneg i32 %.0 to i64
  %15 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %5, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr %6, align 4, !tbaa !5
  %17 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID6IsBodyEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  br i1 %17, label %18, label %20

18:                                               ; preds = %13
  %19 = call i32 @_ZNK3JPH8QuadTree6NodeID9GetBodyIDEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @_ZN3JPH8QuadTree23sInvalidateBodyLocationERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEENS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 %19)
  br label %77

20:                                               ; preds = %13
  %21 = call noundef i32 @_ZNK3JPH8QuadTree6NodeID12GetNodeIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %22 = load ptr, ptr %0, align 64, !tbaa !10
  %23 = call noundef nonnull align 4 dereferenceable(124) ptr @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE3GetEj(ptr noundef nonnull align 64 dereferenceable(132) %22, i32 noundef %21)
  %.017.ptr = getelementptr inbounds i8, ptr %23, i64 96
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %24 = call i32 @_ZNK3JPH8QuadTree12AtomicNodeIDcvNS0_6NodeIDEEv(ptr noundef nonnull align 4 dereferenceable(4) %.017.ptr)
  store i32 %24, ptr %7, align 4
  %25 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br i1 %25, label %26, label %36

26:                                               ; preds = %20
  %27 = icmp ult i32 %.0, 128
  br i1 %27, label %31, label %28

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

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

31:                                               ; preds = %30, %28, %26
  %32 = zext nneg i32 %.0 to i64
  %33 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %5, i64 0, i64 %32
  %34 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %34, ptr %33, align 4, !tbaa !5
  %35 = add nuw nsw i32 %.0, 1
  br label %36

36:                                               ; preds = %31, %20
  %.2 = phi i32 [ %35, %31 ], [ %.0, %20 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %.017.ptr.1 = getelementptr inbounds i8, ptr %23, i64 100
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %37 = call i32 @_ZNK3JPH8QuadTree12AtomicNodeIDcvNS0_6NodeIDEEv(ptr noundef nonnull align 4 dereferenceable(4) %.017.ptr.1)
  store i32 %37, ptr %7, align 4
  %38 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br i1 %38, label %39, label %49

39:                                               ; preds = %36
  %40 = icmp ult i32 %.2, 128
  br i1 %40, label %44, label %41

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

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

44:                                               ; preds = %43, %41, %39
  %45 = zext nneg i32 %.2 to i64
  %46 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %5, i64 0, i64 %45
  %47 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %47, ptr %46, align 4, !tbaa !5
  %48 = add nuw nsw i32 %.2, 1
  br label %49

49:                                               ; preds = %44, %36
  %.2.1 = phi i32 [ %48, %44 ], [ %.2, %36 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %.017.ptr.2 = getelementptr inbounds i8, ptr %23, i64 104
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %50 = call i32 @_ZNK3JPH8QuadTree12AtomicNodeIDcvNS0_6NodeIDEEv(ptr noundef nonnull align 4 dereferenceable(4) %.017.ptr.2)
  store i32 %50, ptr %7, align 4
  %51 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br i1 %51, label %52, label %62

52:                                               ; preds = %49
  %53 = icmp ult i32 %.2.1, 128
  br i1 %53, label %57, label %54

54:                                               ; preds = %52
  %55 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.1, i32 noundef 891)
  br i1 %55, label %56, label %57

56:                                               ; preds = %54
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !19
  br label %57

57:                                               ; preds = %56, %54, %52
  %58 = zext nneg i32 %.2.1 to i64
  %59 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %5, i64 0, i64 %58
  %60 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %60, ptr %59, align 4, !tbaa !5
  %61 = add nuw nsw i32 %.2.1, 1
  br label %62

62:                                               ; preds = %57, %49
  %.2.2 = phi i32 [ %61, %57 ], [ %.2.1, %49 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %.017.ptr.3 = getelementptr inbounds i8, ptr %23, i64 108
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %63 = call i32 @_ZNK3JPH8QuadTree12AtomicNodeIDcvNS0_6NodeIDEEv(ptr noundef nonnull align 4 dereferenceable(4) %.017.ptr.3)
  store i32 %63, ptr %7, align 4
  %64 = call noundef zeroext i1 @_ZNK3JPH8QuadTree6NodeID7IsValidEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br i1 %64, label %65, label %75

65:                                               ; preds = %62
  %66 = icmp ult i32 %.2.2, 128
  br i1 %66, label %70, label %67

67:                                               ; preds = %65
  %68 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.1, i32 noundef 891)
  br i1 %68, label %69, label %70

69:                                               ; preds = %67
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !19
  br label %70

70:                                               ; preds = %69, %67, %65
  %71 = zext nneg i32 %.2.2 to i64
  %72 = getelementptr inbounds [128 x %"class.JPH::QuadTree::NodeID"], ptr %5, i64 0, i64 %71
  %73 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %73, ptr %72, align 4, !tbaa !5
  %74 = add nuw nsw i32 %.2.2, 1
  br label %75

75:                                               ; preds = %70, %62
  %.2.3 = phi i32 [ %74, %70 ], [ %.2.2, %62 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %76 = load ptr, ptr %0, align 64, !tbaa !10
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE16AddObjectToBatchERNS3_5BatchEj(ptr noundef nonnull align 64 dereferenceable(132) %76, ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef %21)
  br label %77

77:                                               ; preds = %75, %18
  %.3 = phi i32 [ %.0, %18 ], [ %.2.3, %75 ]
  %78 = add nsw i32 %.3, -1
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  %79 = icmp sgt i32 %.3, 0
  br i1 %79, label %13, label %80, !llvm.loop !20

80:                                               ; preds = %77
  %81 = load ptr, ptr %0, align 64, !tbaa !10
  call void @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE19DestructObjectBatchERNS3_5BatchE(ptr noundef nonnull align 64 dereferenceable(132) %81, ptr noundef nonnull align 4 dereferenceable(12) %4)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  ret void
}

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 = { 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 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 2158748744}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTSN3JPH8QuadTreeE", !12, i64 0, !13, i64 8, !14, i64 64, !7, i64 68, !14, i64 76, !16, i64 80}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchE", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!"_ZTSSt6atomicIjE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIjE", !6, i64 0}
!16 = !{!"_ZTSSt6atomicIbE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIbE", !18, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{i64 2158749083}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass