; 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::AssertLastParam" = type { i8 }
%"class.JPH::BroadPhaseLayer" = type { i8 }
%"class.JPH::BroadPhase" = type { %"class.JPH::BroadPhaseQuery", ptr }
%"class.JPH::BroadPhaseQuery" = type { ptr }
%"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::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::BodyID" = type { i32 }
%"struct.JPH::QuadTree::Tracking" = type { %"struct.std::atomic.15", %"struct.std::atomic.18", %"struct.std::atomic" }
%"struct.std::atomic.15" = type { %"struct.std::__atomic_base.16" }
%"struct.std::__atomic_base.16" = type { i8 }
%"struct.std::atomic.18" = type { %"struct.std::__atomic_base.19" }
%"struct.std::__atomic_base.19" = type { i16 }

@.str.1 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 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: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 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 uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297)) #3 align 2

; 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
declare dso_local noundef ptr @_ZN3JPH18BroadPhaseQuadTree16AddBodiesPrepareEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512), ptr noundef, i32 noundef) 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) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i8 @_ZNK3JPH4Body18GetBroadPhaseLayerEv(ptr noundef nonnull align 16 dereferenceable(122)) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122)) #5 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)) #5 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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122)) #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH18BroadPhaseQuadTree17AddBodiesFinalizeEPNS_6BodyIDEiPv(ptr noundef nonnull align 64 dereferenceable(512), ptr noundef, i32 noundef, ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512), ptr noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree24NotifyBodiesLayerChangedEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %"struct.JPH::AssertLastParam", align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"struct.JPH::AssertLastParam", align 1
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca %"class.JPH::BroadPhaseLayer", align 1
  %15 = alloca %"struct.JPH::AssertLastParam", align 1
  %16 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = icmp sle i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %3
  br label %132

21:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %22 = getelementptr inbounds %"class.JPH::BroadPhase", ptr %17, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %23)
  store ptr %24, ptr %7, align 8, !tbaa !5
  br label %25

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

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

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

36:                                               ; preds = %35, %33, %25
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %"class.JPH::BodyID", ptr %39, i64 %41
  %43 = getelementptr inbounds %"class.JPH::BodyID", ptr %42, i64 -1
  store ptr %43, ptr %9, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %116, %38
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = icmp uge ptr %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %119

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %50)
  store i32 %51, ptr %10, align 4, !tbaa !9
  br label %52

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

61:                                               ; preds = %52
  %62 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef @.str.16, ptr noundef @.str.1, i32 noundef 392, ptr noundef @.str.6)
  br i1 %62, label %63, label %64

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

64:                                               ; preds = %63, %61, %52
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %67, i64 noundef %69)
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  store ptr %71, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #6
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = call i8 @_ZNK3JPH4Body18GetBroadPhaseLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %72)
  %74 = getelementptr inbounds %"class.JPH::BroadPhaseLayer", ptr %14, i32 0, i32 0
  store i8 %73, ptr %74, align 1
  %75 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) %14)
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #6
  store i8 %75, ptr %13, align 1, !tbaa !32
  br label %76

76:                                               ; preds = %66
  %77 = load i8, ptr %13, align 1, !tbaa !32
  %78 = zext i8 %77 to i32
  %79 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %17, i32 0, i32 8
  %80 = load i32, ptr %79, align 16, !tbaa !33
  %81 = icmp ult i32 %78, %80
  br i1 %81, label %85, label %82

82:                                               ; preds = %76
  %83 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 395)
  br i1 %83, label %84, label %85

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

85:                                               ; preds = %84, %82, %76
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %17, i32 0, i32 3
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = zext i32 %89 to i64
  %91 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %88, i64 noundef %90)
  %92 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %91, i32 0, i32 0
  %93 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %92) #6
  %94 = zext i8 %93 to i32
  %95 = load i8, ptr %13, align 1, !tbaa !32
  %96 = zext i8 %95 to i32
  %97 = icmp eq i32 %94, %96
  br i1 %97, label %98, label %115

98:                                               ; preds = %87
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = call noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %99)
  %101 = getelementptr inbounds %"class.JPH::BroadPhaseQuadTree", ptr %17, i32 0, i32 3
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = zext i32 %102 to i64
  %104 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %101, i64 noundef %103)
  %105 = getelementptr inbounds %"struct.JPH::QuadTree::Tracking", ptr %104, i32 0, i32 1
  %106 = call noundef zeroext i16 @_ZNSt13__atomic_baseItEaSEt(ptr noundef nonnull align 2 dereferenceable(2) %105, i16 noundef zeroext %100) #6
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = load i32, ptr %6, align 4, !tbaa !9
  %110 = sub nsw i32 %109, 1
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %"class.JPH::BodyID", ptr %108, i64 %111
  call void @_ZSt4swapIN3JPH6BodyIDEENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS5_ESt18is_move_assignableIS5_EEE5valueEvE4typeERS5_SE_(ptr noundef nonnull align 4 dereferenceable(4) %107, ptr noundef nonnull align 4 dereferenceable(4) %112) #6
  %113 = load i32, ptr %6, align 4, !tbaa !9
  %114 = add nsw i32 %113, -1
  store i32 %114, ptr %6, align 4, !tbaa !9
  br label %115

115:                                              ; preds = %98, %87
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %116

116:                                              ; preds = %115
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = getelementptr inbounds %"class.JPH::BodyID", ptr %117, i32 -1
  store ptr %118, ptr %9, align 8, !tbaa !5
  br label %44, !llvm.loop !35

119:                                              ; preds = %48
  %120 = load i32, ptr %6, align 4, !tbaa !9
  %121 = icmp sgt i32 %120, 0
  br i1 %121, label %122, label %131

122:                                              ; preds = %119
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %17, ptr noundef %123, i32 noundef %124)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = load i32, ptr %6, align 4, !tbaa !9
  %127 = call noundef ptr @_ZN3JPH18BroadPhaseQuadTree16AddBodiesPrepareEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %17, ptr noundef %125, i32 noundef %126)
  store ptr %127, ptr %16, align 8, !tbaa !5
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = load i32, ptr %6, align 4, !tbaa !9
  %130 = load ptr, ptr %16, align 8, !tbaa !5
  call void @_ZN3JPH18BroadPhaseQuadTree17AddBodiesFinalizeEPNS_6BodyIDEiPv(ptr noundef nonnull align 64 dereferenceable(512) %17, ptr noundef %128, i32 noundef %129, ptr noundef %130)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %131

131:                                              ; preds = %122, %119
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %132

132:                                              ; preds = %131, %20
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 = { 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, !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 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN3JPH10BroadPhaseE", !13, i64 0, !6, i64 8}
!13 = !{!"_ZTSN3JPH15BroadPhaseQueryE"}
!14 = !{!15, !16, i64 24}
!15 = !{!"_ZTSN3JPH18BroadPhaseQuadTreeE", !12, i64 0, !6, i64 16, !16, i64 24, !17, i64 32, !18, i64 64, !6, i64 256, !6, i64 264, !10, i64 272, !27, i64 280, !7, i64 344, !23, i64 472, !10, i64 476}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEE", !16, i64 0, !16, i64 8, !6, i64 16}
!18 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_8QuadTree4NodeEEE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, 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", !10, 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 = !{i64 2158623633}
!31 = !{i64 2158624073}
!32 = !{!7, !7, i64 0}
!33 = !{!15, !10, i64 272}
!34 = !{i64 2158624448}
!35 = distinct !{!35, !36}
!36 = !{!"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::BodyID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 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: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 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 #2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH18BroadPhaseQuadTree16AddBodiesPrepareEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512), ptr noundef, i32 noundef) 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 #2 align 2

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

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

; 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 #5 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 #5 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 #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH18BroadPhaseQuadTree17AddBodiesFinalizeEPNS_6BodyIDEiPv(ptr noundef nonnull align 64 dereferenceable(512), ptr noundef, i32 noundef, ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512), ptr noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH18BroadPhaseQuadTree24NotifyBodiesLayerChangedEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #3 align 2 {
  %4 = alloca %"class.JPH::BroadPhaseLayer", align 1
  %5 = icmp slt i32 %2, 1
  br i1 %5, label %59, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH11BodyManager9GetBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %8)
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = tail call noundef i32 @_ZNK3JPH11BodyManager12GetMaxBodiesEv(ptr noundef nonnull align 8 dereferenceable(297) %12)
  %14 = zext i32 %13 to i64
  %15 = icmp eq i64 %11, %14
  br i1 %15, label %19, label %16

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

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

19:                                               ; preds = %18, %16, %6
  %20 = zext nneg i32 %2 to i64
  %21 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %20
  %invariant.gep = getelementptr i8, ptr %1, i64 -4
  %.03034 = getelementptr inbounds i8, ptr %21, i64 -4
  %.not35 = icmp ult ptr %.03034, %1
  br i1 %.not35, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %19
  %22 = getelementptr inbounds i8, ptr %0, i64 272
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  br label %25

._crit_edge:                                      ; preds = %57
  %24 = icmp sgt i32 %.1, 0
  br i1 %24, label %._crit_edge.thread, label %59

25:                                               ; preds = %.lr.ph, %57
  %.03037 = phi ptr [ %.03034, %.lr.ph ], [ %.030, %57 ]
  %.036 = phi i32 [ %2, %.lr.ph ], [ %.1, %57 ]
  %26 = call noundef i32 @_ZNK3JPH6BodyID8GetIndexEv(ptr noundef nonnull align 4 dereferenceable(4) %.03037)
  %27 = zext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %27)
  %29 = load ptr, ptr %28, align 8, !tbaa !29
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %29)
  %31 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %30, ptr noundef nonnull align 4 dereferenceable(4) %.03037)
  br i1 %31, label %35, label %32

32:                                               ; preds = %25
  %33 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.1, i32 noundef 392, ptr noundef nonnull @.str.6)
  br i1 %33, label %34, label %35

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

35:                                               ; preds = %34, %32, %25
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %27)
  %37 = load ptr, ptr %36, align 8, !tbaa !29
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #6
  %38 = call i8 @_ZNK3JPH4Body18GetBroadPhaseLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %37)
  store i8 %38, ptr %4, align 1
  %39 = call noundef zeroext i8 @_ZNK3JPH15BroadPhaseLayercvhEv(ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  %40 = zext i8 %39 to i32
  %41 = load i32, ptr %22, align 16, !tbaa !31
  %42 = icmp ugt i32 %41, %40
  br i1 %42, label %46, label %43

43:                                               ; preds = %35
  %44 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 395)
  br i1 %44, label %45, label %46

45:                                               ; preds = %43
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !32
  br label %46

46:                                               ; preds = %45, %43, %35
  %47 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %23, i64 noundef %27)
  %48 = call noundef zeroext i8 @_ZNKSt13__atomic_baseIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %47) #6
  %49 = icmp eq i8 %48, %39
  br i1 %49, label %50, label %57

50:                                               ; preds = %46
  %51 = call noundef zeroext i16 @_ZNK3JPH4Body14GetObjectLayerEv(ptr noundef nonnull align 16 dereferenceable(122) %37)
  %52 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8QuadTree8TrackingENS_12STLAllocatorIS2_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %23, i64 noundef %27)
  %53 = getelementptr inbounds i8, ptr %52, i64 2
  %54 = call noundef zeroext i16 @_ZNSt13__atomic_baseItEaSEt(ptr noundef nonnull align 2 dereferenceable(2) %53, i16 noundef zeroext %51) #6
  %55 = sext i32 %.036 to i64
  %gep = getelementptr %"class.JPH::BodyID", ptr %invariant.gep, i64 %55
  call void @_ZSt4swapIN3JPH6BodyIDEENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS5_ESt18is_move_assignableIS5_EEE5valueEvE4typeERS5_SE_(ptr noundef nonnull align 4 dereferenceable(4) %.03037, ptr noundef nonnull align 4 dereferenceable(4) %gep) #6
  %56 = add nsw i32 %.036, -1
  br label %57

57:                                               ; preds = %50, %46
  %.1 = phi i32 [ %56, %50 ], [ %.036, %46 ]
  %.030 = getelementptr inbounds i8, ptr %.03037, i64 -4
  %.not = icmp ult ptr %.030, %1
  br i1 %.not, label %._crit_edge, label %25, !llvm.loop !33

._crit_edge.thread:                               ; preds = %19, %._crit_edge
  %.0.lcssa39 = phi i32 [ %.1, %._crit_edge ], [ %2, %19 ]
  call void @_ZN3JPH18BroadPhaseQuadTree12RemoveBodiesEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef nonnull %1, i32 noundef %.0.lcssa39)
  %58 = call noundef ptr @_ZN3JPH18BroadPhaseQuadTree16AddBodiesPrepareEPNS_6BodyIDEi(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef nonnull %1, i32 noundef %.0.lcssa39)
  call void @_ZN3JPH18BroadPhaseQuadTree17AddBodiesFinalizeEPNS_6BodyIDEiPv(ptr noundef nonnull align 64 dereferenceable(512) %0, ptr noundef nonnull %1, i32 noundef %.0.lcssa39, ptr noundef %58)
  br label %59

59:                                               ; preds = %._crit_edge, %._crit_edge.thread, %3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIN3JPH6BodyIDEENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS5_ESt18is_move_assignableIS5_EEE5valueEvE4typeERS5_SE_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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


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