; 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::AssertLastParam" = type { i8 }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::QuadTree::NodeID" = type { i32 }
%"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::FixedSizeFreeList<JPH::QuadTree::Node>::Batch" = type { i32, i32, i32 }
%"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.24 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [53 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 i32 @_ZN3JPH8QuadTree6NodeID8sInvalidEv() #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH8QuadTree4Node21InvalidateChildBoundsEi(ptr noundef nonnull align 4 dereferenceable(124), i32 noundef) #4 align 2

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

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

; Function Attrs: 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) #4 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH8QuadTree12RemoveBodiesERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3, i32 noundef %4) #5 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"struct.JPH::AssertLastParam", align 1
  %12 = alloca %"struct.JPH::AssertLastParam", align 1
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %"struct.JPH::AssertLastParam", align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.JPH::BodyID", align 4
  %19 = alloca %"class.JPH::BodyID", align 4
  %20 = alloca ptr, align 8
  %21 = alloca %"class.JPH::QuadTree::NodeID", align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  %22 = load ptr, ptr %6, align 8
  br label %23

23:                                               ; preds = %5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %29, label %26

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

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

29:                                               ; preds = %28, %26, %23
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %37, label %34

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

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

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

38:                                               ; preds = %37
  %39 = getelementptr inbounds %"class.JPH::QuadTree", ptr %22, i32 0, i32 6
  %40 = call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %39, i1 noundef zeroext true) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %41, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %"class.JPH::BodyID", ptr %42, i64 %44
  store ptr %45, ptr %14, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %90, %38
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = icmp ult ptr %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %93

51:                                               ; preds = %46
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %54)
  %56 = zext i32 %55 to i64
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %56)
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %58)
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %59, ptr noundef nonnull align 4 dereferenceable(4) %60)
  br i1 %61, label %65, label %62

62:                                               ; preds = %52
  %63 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef @.str.28, ptr noundef @.str.1, i32 noundef 919, ptr noundef @.str.29)
  br i1 %63, label %64, label %65

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

65:                                               ; preds = %64, %62, %52
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %69, i64 4, i1 false), !tbaa.struct !14
  %70 = getelementptr inbounds %"class.JPH::BodyID", ptr %18, i32 0, i32 0
  %71 = load i32, ptr %70, align 4
  call void @_ZNK3JPH8QuadTree15GetBodyLocationERKNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEENS_6BodyIDERjS9_(ptr noundef nonnull align 64 dereferenceable(81) %22, ptr noundef nonnull align 8 dereferenceable(24) %68, i32 %71, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %73, i64 4, i1 false), !tbaa.struct !14
  %74 = getelementptr inbounds %"class.JPH::BodyID", ptr %19, i32 0, i32 0
  %75 = load i32, ptr %74, align 4
  call void @_ZN3JPH8QuadTree23sInvalidateBodyLocationERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEENS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %72, i32 %75)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %76 = getelementptr inbounds %"class.JPH::QuadTree", ptr %22, i32 0, i32 0
  %77 = load ptr, ptr %76, align 64, !tbaa !15
  %78 = load i32, ptr %16, align 4, !tbaa !9
  %79 = call noundef nonnull align 4 dereferenceable(124) ptr @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE3GetEj(ptr noundef nonnull align 64 dereferenceable(132) %77, i32 noundef %78)
  store ptr %79, ptr %20, align 8, !tbaa !5
  %80 = load ptr, ptr %20, align 8, !tbaa !5
  %81 = load i32, ptr %17, align 4, !tbaa !9
  call void @_ZN3JPH8QuadTree4Node21InvalidateChildBoundsEi(ptr noundef nonnull align 4 dereferenceable(124) %80, i32 noundef %81)
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %82 = call i32 @_ZN3JPH8QuadTree6NodeID8sInvalidEv()
  %83 = getelementptr inbounds %"class.JPH::QuadTree::NodeID", ptr %21, i32 0, i32 0
  store i32 %82, ptr %83, align 4
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.JPH::QuadTree::Node", ptr %84, i32 0, i32 6
  %86 = load i32, ptr %17, align 4, !tbaa !9
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds [4 x %"class.JPH::QuadTree::AtomicNodeID"], ptr %85, i64 0, i64 %87
  call void @_ZN3JPH8QuadTree12AtomicNodeIDaSERKNS0_6NodeIDE(ptr noundef nonnull align 4 dereferenceable(4) %88, ptr noundef nonnull align 4 dereferenceable(4) %21)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  %89 = load i32, ptr %16, align 4, !tbaa !9
  call void @_ZN3JPH8QuadTree25MarkNodeAndParentsChangedEj(ptr noundef nonnull align 64 dereferenceable(81) %22, i32 noundef %89)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %90

90:                                               ; preds = %67
  %91 = load ptr, ptr %13, align 8, !tbaa !5
  %92 = getelementptr inbounds %"class.JPH::BodyID", ptr %91, i32 1
  store ptr %92, ptr %13, align 8, !tbaa !5
  br label %46, !llvm.loop !23

93:                                               ; preds = %50
  %94 = load i32, ptr %10, align 4, !tbaa !9
  %95 = getelementptr inbounds %"class.JPH::QuadTree", ptr %22, i32 0, i32 3
  %96 = call noundef i32 @_ZNSt13__atomic_baseIjEmIEj(ptr noundef nonnull align 4 dereferenceable(4) %95, i32 noundef %94) #6
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122)) #3 align 2

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

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

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

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 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 2158749430}
!12 = !{i64 2158749761}
!13 = !{i64 2158750207}
!14 = !{i64 0, i64 4, !9}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTSN3JPH8QuadTreeE", !6, i64 0, !17, i64 8, !18, i64 64, !7, i64 68, !18, i64 76, !20, i64 80}
!17 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE5BatchE", !10, i64 0, !10, i64 4, !10, i64 8}
!18 = !{!"_ZTSSt6atomicIjE", !19, i64 0}
!19 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!20 = !{!"_ZTSSt6atomicIbE", !21, i64 0}
!21 = !{!"_ZTSSt13__atomic_baseIbE", !22, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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::QuadTree::NodeID" = type { i32 }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::QuadTree::AtomicNodeID" = type { %"struct.std::atomic.0" }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [53 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 i32 @_ZN3JPH8QuadTree6NodeID8sInvalidEv() local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH8QuadTree12AtomicNodeIDaSERKNS0_6NodeIDE(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) 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 #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH8QuadTree4Node21InvalidateChildBoundsEi(ptr noundef nonnull align 4 dereferenceable(124), i32 noundef) local_unnamed_addr #3 align 2

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

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

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

; 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 #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH8QuadTree12RemoveBodiesERKNS_5ArrayIPNS_4BodyENS_12STLAllocatorIS3_EEEERNS1_INS0_8TrackingENS4_IS9_EEEEPKNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #4 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.JPH::QuadTree::NodeID", align 4
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %9, label %12

9:                                                ; preds = %5
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i32 noundef 910)
  br i1 %10, label %11, label %12

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

12:                                               ; preds = %11, %9, %5
  %13 = icmp sgt i32 %4, 0
  br i1 %13, label %.lr.ph.preheader, label %14

14:                                               ; preds = %12
  %15 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 911)
  br i1 %15, label %16, label %.thread

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

.thread:                                          ; preds = %14, %16
  %17 = getelementptr inbounds i8, ptr %0, i64 80
  %18 = tail call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %17, i1 noundef zeroext true) #5
  br label %._crit_edge

.lr.ph.preheader:                                 ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  %20 = tail call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %19, i1 noundef zeroext true) #5
  %21 = zext nneg i32 %4 to i64
  %22 = getelementptr inbounds %"class.JPH::BodyID", ptr %3, i64 %21
  br label %.lr.ph

._crit_edge:                                      ; preds = %34, %.thread
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  %24 = call noundef i32 @_ZNSt13__atomic_baseIjEmIEj(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef %4) #5
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %34
  %.019 = phi ptr [ %45, %34 ], [ %3, %.lr.ph.preheader ]
  %25 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.019)
  %26 = zext i32 %25 to i64
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %26)
  %28 = load ptr, ptr %27, align 8, !tbaa !7
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %28)
  %30 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %29, ptr noundef nonnull align 4 dereferenceable(4) %.019)
  br i1 %30, label %34, label %31

31:                                               ; preds = %.lr.ph
  %32 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.1, i32 noundef 919, ptr noundef nonnull @.str.29)
  br i1 %32, label %33, label %34

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

34:                                               ; preds = %33, %31, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %.sroa.02.0.copyload = load i32, ptr %.019, align 4, !tbaa !12
  call void @_ZNK3JPH8QuadTree15GetBodyLocationERKNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEENS_6BodyIDERjS9_(ptr noundef nonnull align 64 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(24) %2, i32 %.sroa.02.0.copyload, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %.sroa.0.0.copyload = load i32, ptr %.019, align 4, !tbaa !12
  call void @_ZN3JPH8QuadTree23sInvalidateBodyLocationERNS_5ArrayINS0_8TrackingENS_12STLAllocatorIS2_EEEENS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %2, i32 %.sroa.0.0.copyload)
  %35 = load ptr, ptr %0, align 64, !tbaa !14
  %36 = load i32, ptr %6, align 4, !tbaa !12
  %37 = call noundef nonnull align 4 dereferenceable(124) ptr @_ZN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEE3GetEj(ptr noundef nonnull align 64 dereferenceable(132) %35, i32 noundef %36)
  %38 = load i32, ptr %7, align 4, !tbaa !12
  call void @_ZN3JPH8QuadTree4Node21InvalidateChildBoundsEi(ptr noundef nonnull align 4 dereferenceable(124) %37, i32 noundef %38)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %39 = call i32 @_ZN3JPH8QuadTree6NodeID8sInvalidEv()
  store i32 %39, ptr %8, align 4
  %40 = getelementptr inbounds i8, ptr %37, i64 96
  %41 = load i32, ptr %7, align 4, !tbaa !12
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds [4 x %"class.JPH::QuadTree::AtomicNodeID"], ptr %40, i64 0, i64 %42
  call void @_ZN3JPH8QuadTree12AtomicNodeIDaSERKNS0_6NodeIDE(ptr noundef nonnull align 4 dereferenceable(4) %43, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  %44 = load i32, ptr %6, align 4, !tbaa !12
  call void @_ZN3JPH8QuadTree25MarkNodeAndParentsChangedEj(ptr noundef nonnull align 64 dereferenceable(81) %0, i32 noundef %44)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  %45 = getelementptr inbounds i8, ptr %.019, i64 4
  %46 = icmp ult ptr %45, %22
  br i1 %46, label %.lr.ph, label %._crit_edge, !llvm.loop !22
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #2 align 2

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

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

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

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


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