; LLVM IR from zig-gamedev/zphysics :: libs/Jolt/Physics (PhysicsSystem)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.JPH::Color" = type { %union.anon }
%union.anon = type { i32 }
%"class.JPH::JobSystem::JobHandle" = type { %"class.JPH::Ref" }
%"class.JPH::Ref" = type { ptr }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%class.anon.44 = type <{ ptr, i32, [4 x i8] }>
%"struct.JPH::PhysicsUpdateContext::Step" = type { ptr, i8, i8, %"struct.JPH::BroadPhase::UpdateState", i32, %"struct.std::atomic", [60 x i8], %"struct.std::atomic", [60 x i8], %"struct.std::atomic", [60 x i8], %"struct.std::atomic", [60 x i8], %"struct.std::atomic", [60 x i8], %"struct.std::atomic", [60 x i8], %"class.JPH::StaticArray", i32, %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", ptr, i32, %"struct.std::atomic", %"struct.std::atomic", ptr, i32, %"class.JPH::JobSystem::JobHandle", %"class.JPH::StaticArray.20", %"class.JPH::StaticArray.20", %"class.JPH::StaticArray.20", %"class.JPH::StaticArray.20", %"class.JPH::JobSystem::JobHandle", %"class.JPH::StaticArray.20", %"class.JPH::JobSystem::JobHandle", %"class.JPH::JobSystem::JobHandle", %"class.JPH::JobSystem::JobHandle", %"class.JPH::StaticArray.20", %"class.JPH::JobSystem::JobHandle", %"class.JPH::StaticArray.20", %"class.JPH::JobSystem::JobHandle", %"class.JPH::JobSystem::JobHandle", %"class.JPH::StaticArray.20", %"class.JPH::JobSystem::JobHandle", %"class.JPH::JobSystem::JobHandle", %"class.JPH::StaticArray.20", %"class.JPH::StaticArray.20", %"class.JPH::JobSystem::JobHandle", %"class.JPH::JobSystem::JobHandle" }
%"struct.JPH::BroadPhase::UpdateState" = type { [4 x ptr] }
%"class.JPH::StaticArray" = type { i32, [32 x %"struct.JPH::StaticArray<JPH::PhysicsUpdateContext::BodyPairQueue, 32>::Storage"] }
%"struct.JPH::StaticArray<JPH::PhysicsUpdateContext::BodyPairQueue, 32>::Storage" = type { [128 x i8] }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::StaticArray.20" = type { i32, [4 x i8], [32 x %"struct.JPH::StaticArray<JPH::JobSystem::JobHandle, 32>::Storage"] }
%"struct.JPH::StaticArray<JPH::JobSystem::JobHandle, 32>::Storage" = type { [8 x i8] }
%"struct.JPH::PhysicsUpdateContext::BodyPairQueue" = type { %"struct.std::atomic", [60 x i8], %"struct.std::atomic", [60 x i8] }
%"class.JPH::PhysicsSystem" = type <{ ptr, ptr, %"class.JPH::BodyManager", %"class.JPH::BodyLockInterfaceNoLock", %"class.JPH::BodyLockInterfaceLocking", %"class.JPH::BodyInterface", %"class.JPH::BodyInterface", %"class.JPH::NarrowPhaseQuery", %"class.JPH::NarrowPhaseQuery", ptr, ptr, %"struct.JPH::PhysicsSettings", [4 x i8], %"class.JPH::ContactConstraintManager", %"class.JPH::ConstraintManager", %"class.JPH::IslandBuilder", %"class.JPH::LargeIslandSplitter", %"class.JPH::Mutex", %"class.JPH::Array.10", [8 x i8], %"class.JPH::Vec3", float, [12 x i8] }>
%"class.JPH::BodyManager" = type <{ %"class.JPH::Array", i32, [4 x i8], i64, %"class.JPH::Mutex", %"class.JPH::MutexArray", %"class.JPH::Array.0", %"class.JPH::Mutex", [2 x ptr], [2 x %"struct.std::atomic"], i32, [4 x i8], %"class.JPH::Mutex", %"class.JPH::Array.3", ptr, ptr, i8, [7 x i8] }>
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::MutexArray" = type <{ ptr, i32, [4 x i8] }>
%"class.JPH::Array.0" = type { i64, i64, ptr }
%"class.JPH::Array.3" = type { i64, i64, ptr }
%"class.JPH::BodyLockInterfaceNoLock" = type { %"class.JPH::BodyLockInterface" }
%"class.JPH::BodyLockInterface" = type { ptr, ptr }
%"class.JPH::BodyLockInterfaceLocking" = type { %"class.JPH::BodyLockInterface" }
%"class.JPH::BodyInterface" = type { ptr, ptr, ptr }
%"class.JPH::NarrowPhaseQuery" = type { ptr, ptr }
%"struct.JPH::PhysicsSettings" = type <{ i32, i32, i32, float, float, float, float, float, float, float, float, float, float, float, i32, i32, float, float, float, i8, i8, i8, i8, i8, i8, i8, i8 }>
%"class.JPH::ContactConstraintManager" = type { [8 x i8], [2 x %"class.JPH::ContactConstraintManager::ManifoldCache"], i32, ptr, ptr, ptr, ptr, ptr, i32, %"struct.std::atomic", ptr }
%"class.JPH::ContactConstraintManager::ManifoldCache" = type <{ %"class.JPH::LFHMAllocator", %"class.JPH::LockFreeHashMap", %"class.JPH::LockFreeHashMap.6", i8, [7 x i8] }>
%"class.JPH::LFHMAllocator" = type { ptr, i32, %"struct.std::atomic" }
%"class.JPH::LockFreeHashMap" = type { ptr, %"struct.std::atomic", ptr, i32, i32 }
%"class.JPH::LockFreeHashMap.6" = type { ptr, %"struct.std::atomic", ptr, i32, i32 }
%"class.JPH::ConstraintManager" = type { ptr, %"class.JPH::Array.7", %"class.JPH::Mutex" }
%"class.JPH::Array.7" = type { i64, i64, ptr }
%"class.JPH::IslandBuilder" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%"class.JPH::LargeIslandSplitter" = type <{ i32, [4 x i8], ptr, ptr, ptr, i32, %"struct.std::atomic", i32, [4 x i8], ptr, %"struct.std::atomic", [4 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 }
%"class.JPH::Array.10" = type { i64, i64, ptr }
%"class.JPH::Vec3" = type { %union.anon.13 }
%union.anon.13 = type { <4 x float> }
%"class.JPH::PhysicsUpdateContext" = type <{ ptr, ptr, ptr, ptr, float, float, %"struct.std::atomic", [4 x i8], ptr, ptr, ptr, %"class.JPH::Array.19", i32, [4 x i8], ptr, %"struct.std::atomic", [4 x i8] }>
%"class.JPH::Array.19" = type { %"class.JPH::STLTempAllocator", i64, i64, ptr }
%"class.JPH::STLTempAllocator" = type { ptr }

@_ZN3JPHL20cColorFindCollisionsE = external hidden global %"class.JPH::Color", align 4
@.str.33 = external hidden unnamed_addr constant [15 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager18GetNumActiveBodiesENS_9EBodyTypeE(ptr noundef nonnull align 8 dereferenceable(297), i8 noundef zeroext) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS_20PhysicsUpdateContext4StepE(ptr noundef nonnull align 16 dereferenceable(1140) %0, ptr noundef %1) #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %"class.JPH::JobSystem::JobHandle", align 8
  %20 = alloca %"class.JPH::Color", align 4
  %21 = alloca %"class.std::function", align 8
  %22 = alloca %class.anon.44, align 8
  %23 = alloca ptr, align 8
  %24 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %26, i32 0, i32 17
  %28 = call noundef i32 @_ZNK3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(4100) %27)
  store i32 %28, ptr %5, align 4, !tbaa !9
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %29, i32 0, i32 19
  %31 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %30) #7
  %32 = call noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef %31)
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = icmp uge i32 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %2
  store i32 1, ptr %6, align 4
  br label %169

36:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %37, i32 0, i32 17
  store ptr %38, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = call noundef ptr @_ZN3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EE5beginEv(ptr noundef nonnull align 4 dereferenceable(4100) %39)
  store ptr %40, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef ptr @_ZN3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EE3endEv(ptr noundef nonnull align 4 dereferenceable(4100) %41)
  store ptr %42, ptr %10, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %59, %36
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = icmp ne ptr %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %62

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %49, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::BodyPairQueue", ptr %50, i32 0, i32 0
  %52 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %51) #7
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::BodyPairQueue", ptr %53, i32 0, i32 2
  %55 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %54) #7
  %56 = sub i32 %52, %55
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add i32 %57, %56
  store i32 %58, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %59

59:                                               ; preds = %48
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::BodyPairQueue", ptr %60, i32 1
  store ptr %61, ptr %9, align 8, !tbaa !5
  br label %43

62:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %63 = getelementptr inbounds %"class.JPH::PhysicsSystem", ptr %25, i32 0, i32 2
  %64 = call noundef i32 @_ZNK3JPH11BodyManager18GetNumActiveBodiesENS_9EBodyTypeE(ptr noundef nonnull align 8 dereferenceable(297) %63, i8 noundef zeroext 0)
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %65, i32 0, i32 15
  %67 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %66) #7
  %68 = sub i32 %64, %67
  store i32 %68, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = add i32 %69, 16
  %71 = sub i32 %70, 1
  %72 = udiv i32 %71, 16
  %73 = load i32, ptr %12, align 4, !tbaa !9
  %74 = add i32 %73, 16
  %75 = sub i32 %74, 1
  %76 = udiv i32 %75, 16
  %77 = add i32 %72, %76
  store i32 %77, ptr %14, align 4, !tbaa !9
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %79 = load i32, ptr %78, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  store i32 %79, ptr %13, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %166, %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %81, i32 0, i32 19
  %83 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %82) #7
  store i32 %83, ptr %15, align 4, !tbaa !9
  %84 = load i32, ptr %15, align 4, !tbaa !9
  %85 = call noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef %84)
  %86 = load i32, ptr %13, align 4, !tbaa !9
  %87 = icmp uge i32 %85, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %80
  store i32 4, ptr %6, align 4
  br label %164

89:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %158, %89
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = load i32, ptr %5, align 4, !tbaa !9
  %93 = icmp ult i32 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  store i32 6, ptr %6, align 4
  br label %161

95:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %96 = load i32, ptr %16, align 4, !tbaa !9
  %97 = shl i32 1, %96
  store i32 %97, ptr %17, align 4, !tbaa !9
  %98 = load i32, ptr %15, align 4, !tbaa !9
  %99 = load i32, ptr %17, align 4, !tbaa !9
  %100 = and i32 %98, %99
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %154

102:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %103, i32 0, i32 19
  %105 = load i32, ptr %17, align 4, !tbaa !9
  %106 = call noundef i32 @_ZNSt13__atomic_baseIjE8fetch_orEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %104, i32 noundef %105, i32 noundef 5) #7
  store i32 %106, ptr %18, align 4, !tbaa !9
  %107 = load i32, ptr %18, align 4, !tbaa !9
  %108 = load i32, ptr %17, align 4, !tbaa !9
  %109 = and i32 %107, %108
  %110 = icmp eq i32 %109, 0
  br i1 %110, label %111, label %150

111:                                              ; preds = %102
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %112, i32 0, i32 36
  call void @_ZNK3JPH9JobSystem9JobHandle13AddDependencyEi(ptr noundef nonnull align 8 dereferenceable(8) %113, i32 noundef 1)
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %114, i32 0, i32 39
  call void @_ZNK3JPH9JobSystem9JobHandle13AddDependencyEi(ptr noundef nonnull align 8 dereferenceable(8) %115, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %116, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !11
  %119 = getelementptr inbounds %"class.JPH::PhysicsUpdateContext", ptr %118, i32 0, i32 2
  %120 = load ptr, ptr %119, align 8, !tbaa !21
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 @_ZN3JPHL20cColorFindCollisionsE, i64 4, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.start.p0(i64 32, ptr %21) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %22) #7
  %121 = getelementptr inbounds %class.anon.44, ptr %22, i32 0, i32 0
  %122 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %122, ptr %121, align 8, !tbaa !29
  %123 = getelementptr inbounds %class.anon.44, ptr %22, i32 0, i32 1
  %124 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %124, ptr %123, align 8, !tbaa !31
  call void @"_ZNSt8functionIFvvEEC2IZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS3_20PhysicsUpdateContext4StepEE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32) %21, ptr noundef nonnull align 8 dereferenceable(12) %22) #7
  %125 = getelementptr inbounds %"class.JPH::Color", ptr %20, i32 0, i32 0
  %126 = getelementptr inbounds %union.anon, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 4
  %128 = load ptr, ptr %120, align 8, !tbaa !32
  %129 = getelementptr inbounds ptr, ptr %128, i64 3
  %130 = load ptr, ptr %129, align 8
  invoke void %130(ptr dead_on_unwind writable sret(%"class.JPH::JobSystem::JobHandle") align 8 %19, ptr noundef nonnull align 8 dereferenceable(8) %120, ptr noundef @.str.33, i32 %127, ptr noundef nonnull align 8 dereferenceable(32) %21, i32 noundef 0)
          to label %131 unwind label %141

131:                                              ; preds = %111
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %21) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %21) #7
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %132, i32 0, i32 0
  %134 = load ptr, ptr %133, align 8, !tbaa !11
  %135 = getelementptr inbounds %"class.JPH::PhysicsUpdateContext", ptr %134, i32 0, i32 3
  %136 = load ptr, ptr %135, align 8, !tbaa !34
  %137 = load ptr, ptr %136, align 8, !tbaa !32
  %138 = getelementptr inbounds ptr, ptr %137, i64 0
  %139 = load ptr, ptr %138, align 8
  invoke void %139(ptr noundef nonnull align 8 dereferenceable(8) %136, ptr noundef nonnull align 8 dereferenceable(8) %19)
          to label %140 unwind label %145

140:                                              ; preds = %131
  store i32 1, ptr %6, align 4
  call void @_ZN3JPH3RefINS_9JobSystem3JobEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %151

141:                                              ; preds = %111
  %142 = landingpad { ptr, i32 }
          cleanup
  %143 = extractvalue { ptr, i32 } %142, 0
  store ptr %143, ptr %23, align 8
  %144 = extractvalue { ptr, i32 } %142, 1
  store i32 %144, ptr %24, align 4
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %21) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %21) #7
  br label %149

145:                                              ; preds = %131
  %146 = landingpad { ptr, i32 }
          cleanup
  %147 = extractvalue { ptr, i32 } %146, 0
  store ptr %147, ptr %23, align 8
  %148 = extractvalue { ptr, i32 } %146, 1
  store i32 %148, ptr %24, align 4
  call void @_ZN3JPH3RefINS_9JobSystem3JobEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %19) #7
  br label %149

149:                                              ; preds = %145, %141
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %172

150:                                              ; preds = %102
  store i32 0, ptr %6, align 4
  br label %151

151:                                              ; preds = %150, %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  %152 = load i32, ptr %6, align 4
  switch i32 %152, label %155 [
    i32 0, label %153
  ]

153:                                              ; preds = %151
  br label %154

154:                                              ; preds = %153, %95
  store i32 0, ptr %6, align 4
  br label %155

155:                                              ; preds = %154, %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  %156 = load i32, ptr %6, align 4
  switch i32 %156, label %161 [
    i32 0, label %157
  ]

157:                                              ; preds = %155
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %16, align 4, !tbaa !9
  %160 = add i32 %159, 1
  store i32 %160, ptr %16, align 4, !tbaa !9
  br label %90, !llvm.loop !35

161:                                              ; preds = %155, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  %162 = load i32, ptr %6, align 4
  switch i32 %162, label %164 [
    i32 6, label %163
  ]

163:                                              ; preds = %161
  store i32 0, ptr %6, align 4
  br label %164

164:                                              ; preds = %163, %161, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  %165 = load i32, ptr %6, align 4
  switch i32 %165, label %168 [
    i32 0, label %166
    i32 4, label %167
  ]

166:                                              ; preds = %164
  br label %80, !llvm.loop !37

167:                                              ; preds = %164
  store i32 0, ptr %6, align 4
  br label %168

168:                                              ; preds = %167, %164
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %169

169:                                              ; preds = %168, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  %170 = load i32, ptr %6, align 4
  switch i32 %170, label %177 [
    i32 0, label %171
    i32 1, label %171
  ]

171:                                              ; preds = %169, %169
  ret void

172:                                              ; preds = %149
  %173 = load ptr, ptr %23, align 8
  %174 = load i32, ptr %24, align 4
  %175 = insertvalue { ptr, i32 } poison, ptr %173, 0
  %176 = insertvalue { ptr, i32 } %175, i32 %174, 1
  resume { ptr, i32 } %176

177:                                              ; preds = %169
  unreachable
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef) #3

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK3JPH9JobSystem9JobHandle13AddDependencyEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @"_ZNSt8functionIFvvEEC2IZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS3_20PhysicsUpdateContext4StepEE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(12)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { 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 #7 = { 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 0}
!12 = !{!"_ZTSN3JPH20PhysicsUpdateContext4StepE", !6, i64 0, !13, i64 8, !13, i64 9, !14, i64 16, !10, i64 48, !15, i64 52, !7, i64 56, !15, i64 116, !7, i64 120, !15, i64 180, !7, i64 184, !15, i64 244, !7, i64 248, !15, i64 308, !7, i64 312, !15, i64 372, !7, i64 376, !17, i64 436, !10, i64 4536, !15, i64 4540, !15, i64 4544, !15, i64 4548, !15, i64 4552, !15, i64 4556, !15, i64 4560, !6, i64 4568, !10, i64 4576, !15, i64 4580, !15, i64 4584, !6, i64 4592, !10, i64 4600, !18, i64 4608, !20, i64 4616, !20, i64 4880, !20, i64 5144, !20, i64 5408, !18, i64 5672, !20, i64 5680, !18, i64 5944, !18, i64 5952, !18, i64 5960, !20, i64 5968, !18, i64 6232, !20, i64 6240, !18, i64 6504, !18, i64 6512, !20, i64 6520, !18, i64 6784, !18, i64 6792, !20, i64 6800, !20, i64 7064, !18, i64 7328, !18, i64 7336}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN3JPH10BroadPhase11UpdateStateE", !7, i64 0}
!15 = !{!"_ZTSSt6atomicIjE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!17 = !{!"_ZTSN3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EEE", !10, i64 0, !7, i64 4}
!18 = !{!"_ZTSN3JPH9JobSystem9JobHandleE", !19, i64 0}
!19 = !{!"_ZTSN3JPH3RefINS_9JobSystem3JobEEE", !6, i64 0}
!20 = !{!"_ZTSN3JPH11StaticArrayINS_9JobSystem9JobHandleELj32EEE", !10, i64 0, !7, i64 8}
!21 = !{!22, !6, i64 16}
!22 = !{!"_ZTSN3JPH20PhysicsUpdateContextE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !23, i64 32, !23, i64 36, !15, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !24, i64 72, !10, i64 104, !6, i64 112, !15, i64 120}
!23 = !{!"float", !7, i64 0}
!24 = !{!"_ZTSN3JPH5ArrayINS_20PhysicsUpdateContext4StepENS_16STLTempAllocatorIS2_EEEE", !25, i64 0, !26, i64 8, !26, i64 16, !6, i64 24}
!25 = !{!"_ZTSN3JPH16STLTempAllocatorINS_20PhysicsUpdateContext4StepEEE", !6, i64 0}
!26 = !{!"long", !7, i64 0}
!27 = !{i64 0, i64 4, !28}
!28 = !{!7, !7, i64 0}
!29 = !{!30, !6, i64 0}
!30 = !{!"_ZTSZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS_20PhysicsUpdateContext4StepEE3$_0", !6, i64 0, !10, i64 8}
!31 = !{!30, !10, i64 8}
!32 = !{!33, !33, i64 0}
!33 = !{!"vtable pointer", !8, i64 0}
!34 = !{!22, !6, i64 24}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}
!37 = distinct !{!37, !36}


; 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::Color" = type { %union.anon }
%union.anon = type { i32 }
%"class.JPH::JobSystem::JobHandle" = type { %"class.JPH::Ref" }
%"class.JPH::Ref" = type { ptr }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%class.anon.44 = type <{ ptr, i32, [4 x i8] }>

@_ZN3JPHL20cColorFindCollisionsE = external hidden local_unnamed_addr global %"class.JPH::Color", align 4
@.str.33 = external hidden unnamed_addr constant [15 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3JPH11BodyManager18GetNumActiveBodiesENS_9EBodyTypeE(ptr noundef nonnull align 8 dereferenceable(297), i8 noundef zeroext) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS_20PhysicsUpdateContext4StepE(ptr noundef nonnull align 16 dereferenceable(1140) %0, ptr noundef %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"class.JPH::JobSystem::JobHandle", align 8
  %6 = alloca %"class.std::function", align 8
  %7 = alloca %class.anon.44, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %8 = getelementptr inbounds i8, ptr %1, i64 436
  %9 = tail call noundef i32 @_ZNK3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(4100) %8)
  store i32 %9, ptr %3, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 4540
  %11 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %10) #6
  %12 = tail call noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef %11)
  %.not = icmp ult i32 %12, %9
  br i1 %.not, label %13, label %.thread

13:                                               ; preds = %2
  %14 = tail call noundef ptr @_ZN3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EE5beginEv(ptr noundef nonnull align 4 dereferenceable(4100) %8)
  %15 = tail call noundef ptr @_ZN3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EE3endEv(ptr noundef nonnull align 4 dereferenceable(4100) %8)
  %.not4657 = icmp eq ptr %14, %15
  br i1 %.not4657, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %16 = add i32 %34, 15
  %17 = lshr i32 %16, 4
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %13
  %.043.lcssa = phi i32 [ 0, %13 ], [ %17, %._crit_edge.loopexit ]
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = tail call noundef i32 @_ZNK3JPH11BodyManager18GetNumActiveBodiesENS_9EBodyTypeE(ptr noundef nonnull align 8 dereferenceable(297) %18, i8 noundef zeroext 0)
  %20 = getelementptr inbounds i8, ptr %1, i64 372
  %21 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %20) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %22 = add i32 %19, 15
  %23 = sub i32 %22, %21
  %24 = lshr i32 %23, 4
  %25 = add nuw nsw i32 %24, %.043.lcssa
  store i32 %25, ptr %4, align 4, !tbaa !5
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %27 = load i32, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %28 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %10) #6
  %29 = call noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef %28)
  %.not4763 = icmp ult i32 %29, %27
  br i1 %.not4763, label %.preheader, label %.thread

.lr.ph:                                           ; preds = %13, %.lr.ph
  %.04359 = phi i32 [ %34, %.lr.ph ], [ 0, %13 ]
  %.04458 = phi ptr [ %35, %.lr.ph ], [ %14, %13 ]
  %30 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %.04458) #6
  %31 = getelementptr inbounds i8, ptr %.04458, i64 64
  %32 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %31) #6
  %33 = add i32 %30, %.04359
  %34 = sub i32 %33, %32
  %35 = getelementptr inbounds i8, ptr %.04458, i64 128
  %.not46 = icmp eq ptr %35, %15
  br i1 %.not46, label %._crit_edge.loopexit, label %.lr.ph

.loopexit:                                        ; preds = %.critedge52, %.preheader
  %36 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %10) #6
  %37 = call noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef %36)
  %.not47 = icmp ult i32 %37, %27
  br i1 %.not47, label %.preheader, label %.thread

.preheader:                                       ; preds = %._crit_edge, %.loopexit
  %38 = phi i32 [ %36, %.loopexit ], [ %28, %._crit_edge ]
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %.not5060.not = icmp eq i32 %39, 0
  br i1 %.not5060.not, label %.loopexit, label %.lr.ph62

.lr.ph62:                                         ; preds = %.preheader, %.critedge52
  %40 = phi i32 [ %69, %.critedge52 ], [ %39, %.preheader ]
  %.04561 = phi i32 [ %70, %.critedge52 ], [ 0, %.preheader ]
  %41 = shl nuw i32 1, %.04561
  %42 = and i32 %41, %38
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %.critedge52

44:                                               ; preds = %.lr.ph62
  %45 = call noundef i32 @_ZNSt13__atomic_baseIjE8fetch_orEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %10, i32 noundef %41, i32 noundef 5) #6
  %46 = and i32 %45, %41
  %.not49 = icmp eq i32 %46, 0
  br i1 %.not49, label %47, label %..critedge52_crit_edge

..critedge52_crit_edge:                           ; preds = %44
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %.critedge52

47:                                               ; preds = %44
  %48 = getelementptr inbounds i8, ptr %1, i64 5672
  call void @_ZNK3JPH9JobSystem9JobHandle13AddDependencyEi(ptr noundef nonnull align 8 dereferenceable(8) %48, i32 noundef 1)
  %49 = getelementptr inbounds i8, ptr %1, i64 5952
  call void @_ZNK3JPH9JobSystem9JobHandle13AddDependencyEi(ptr noundef nonnull align 8 dereferenceable(8) %49, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %50 = load ptr, ptr %1, align 8, !tbaa !9
  %51 = getelementptr inbounds i8, ptr %50, i64 16
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %.sroa.0.0.copyload = load i32, ptr @_ZN3JPHL20cColorFindCollisionsE, align 4, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #6
  store ptr %1, ptr %7, align 8, !tbaa !27
  %53 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %.04561, ptr %53, align 8, !tbaa !29
  call void @"_ZNSt8functionIFvvEEC2IZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS3_20PhysicsUpdateContext4StepEE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(12) %7) #6
  %54 = load ptr, ptr %52, align 8, !tbaa !30
  %55 = getelementptr inbounds i8, ptr %54, i64 24
  %56 = load ptr, ptr %55, align 8
  invoke void %56(ptr dead_on_unwind nonnull writable sret(%"class.JPH::JobSystem::JobHandle") align 8 %5, ptr noundef nonnull align 8 dereferenceable(8) %52, ptr noundef nonnull @.str.33, i32 %.sroa.0.0.copyload, ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef 0)
          to label %57 unwind label %64

57:                                               ; preds = %47
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  %58 = load ptr, ptr %1, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %58, i64 24
  %60 = load ptr, ptr %59, align 8, !tbaa !32
  %61 = load ptr, ptr %60, align 8, !tbaa !30
  %62 = load ptr, ptr %61, align 8
  invoke void %62(ptr noundef nonnull align 8 dereferenceable(8) %60, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %63 unwind label %66

63:                                               ; preds = %57
  call void @_ZN3JPH3RefINS_9JobSystem3JobEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %.thread

64:                                               ; preds = %47
  %65 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  br label %68

66:                                               ; preds = %57
  %67 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3JPH3RefINS_9JobSystem3JobEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  br label %68

68:                                               ; preds = %66, %64
  %.pn = phi { ptr, i32 } [ %67, %66 ], [ %65, %64 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  resume { ptr, i32 } %.pn

.critedge52:                                      ; preds = %..critedge52_crit_edge, %.lr.ph62
  %69 = phi i32 [ %.pre, %..critedge52_crit_edge ], [ %40, %.lr.ph62 ]
  %70 = add nuw i32 %.04561, 1
  %.not50 = icmp ult i32 %70, %69
  br i1 %.not50, label %.lr.ph62, label %.loopexit, !llvm.loop !33

.thread:                                          ; preds = %.loopexit, %._crit_edge, %63, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3JPH9CountBitsEj(i32 noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @"_ZNSt8functionIFvvEEC2IZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS3_20PhysicsUpdateContext4StepEE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(12)) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = { 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 #5 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN3JPH20PhysicsUpdateContext4StepE", !11, i64 0, !12, i64 8, !12, i64 9, !13, i64 16, !6, i64 48, !14, i64 52, !7, i64 56, !14, i64 116, !7, i64 120, !14, i64 180, !7, i64 184, !14, i64 244, !7, i64 248, !14, i64 308, !7, i64 312, !14, i64 372, !7, i64 376, !16, i64 436, !6, i64 4536, !14, i64 4540, !14, i64 4544, !14, i64 4548, !14, i64 4552, !14, i64 4556, !14, i64 4560, !11, i64 4568, !6, i64 4576, !14, i64 4580, !14, i64 4584, !11, i64 4592, !6, i64 4600, !17, i64 4608, !19, i64 4616, !19, i64 4880, !19, i64 5144, !19, i64 5408, !17, i64 5672, !19, i64 5680, !17, i64 5944, !17, i64 5952, !17, i64 5960, !19, i64 5968, !17, i64 6232, !19, i64 6240, !17, i64 6504, !17, i64 6512, !19, i64 6520, !17, i64 6784, !17, i64 6792, !19, i64 6800, !19, i64 7064, !17, i64 7328, !17, i64 7336}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSN3JPH10BroadPhase11UpdateStateE", !7, i64 0}
!14 = !{!"_ZTSSt6atomicIjE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIjE", !6, i64 0}
!16 = !{!"_ZTSN3JPH11StaticArrayINS_20PhysicsUpdateContext13BodyPairQueueELj32EEE", !6, i64 0, !7, i64 4}
!17 = !{!"_ZTSN3JPH9JobSystem9JobHandleE", !18, i64 0}
!18 = !{!"_ZTSN3JPH3RefINS_9JobSystem3JobEEE", !11, i64 0}
!19 = !{!"_ZTSN3JPH11StaticArrayINS_9JobSystem9JobHandleELj32EEE", !6, i64 0, !7, i64 8}
!20 = !{!21, !11, i64 16}
!21 = !{!"_ZTSN3JPH20PhysicsUpdateContextE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !22, i64 32, !22, i64 36, !14, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !23, i64 72, !6, i64 104, !11, i64 112, !14, i64 120}
!22 = !{!"float", !7, i64 0}
!23 = !{!"_ZTSN3JPH5ArrayINS_20PhysicsUpdateContext4StepENS_16STLTempAllocatorIS2_EEEE", !24, i64 0, !25, i64 8, !25, i64 16, !11, i64 24}
!24 = !{!"_ZTSN3JPH16STLTempAllocatorINS_20PhysicsUpdateContext4StepEEE", !11, i64 0}
!25 = !{!"long", !7, i64 0}
!26 = !{!7, !7, i64 0}
!27 = !{!28, !11, i64 0}
!28 = !{!"_ZTSZNK3JPH13PhysicsSystem25TrySpawnJobFindCollisionsEPNS_20PhysicsUpdateContext4StepEE3$_0", !11, i64 0, !6, i64 8}
!29 = !{!28, !6, i64 8}
!30 = !{!31, !31, i64 0}
!31 = !{!"vtable pointer", !8, i64 0}
!32 = !{!21, !11, i64 24}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


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