; LLVM IR from jrouwe/JoltPhysics :: 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::BodyAccess::Grant" = type { 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, ptr, %"class.std::function", %"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", %"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 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"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 }
%"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 } }
%"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> }
%"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] }
%"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] }
%"class.JPH::JobSystem::JobHandle" = type { %"class.JPH::Ref" }
%"class.JPH::Ref" = type { ptr }
%"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 }

; 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: 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)) #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH10BodyAccess5GrantC2ENS0_7EAccessES2_(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext, i8 noundef zeroext) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13PhysicsSystem29JobDetermineActiveConstraintsEPNS_20PhysicsUpdateContext4StepE(ptr noundef nonnull align 16 dereferenceable(1172) %0, ptr noundef %1) #5 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.JPH::BodyAccess::Grant", align 1
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #7
  call void @_ZN3JPH10BodyAccess5GrantC2ENS0_7EAccessES2_(ptr noundef nonnull align 1 dereferenceable(1) %5, i8 noundef zeroext 0, i8 noundef zeroext 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %17 = getelementptr inbounds %"class.JPH::PhysicsSystem", ptr %16, i32 0, i32 16
  %18 = invoke noundef i32 @_ZNK3JPH17ConstraintManager17GetNumConstraintsEv(ptr noundef nonnull align 8 dereferenceable(80) %17)
          to label %19 unwind label %29

19:                                               ; preds = %2
  store i32 %18, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %20 = alloca i8, i64 512, align 16
  store ptr %20, ptr %10, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %74, %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %22, i32 0, i32 5
  %24 = call noundef i32 @_ZNSt13__atomic_baseIjE9fetch_addEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef 64, i32 noundef 5) #7
  store i32 %24, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp uge i32 %25, %26
  br i1 %27, label %28, label %33

28:                                               ; preds = %21
  store i32 2, ptr %12, align 4
  br label %72

29:                                               ; preds = %2
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %7, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %8, align 4
  br label %77

33:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = add i32 %34, 64
  store i32 %35, ptr %14, align 4, !tbaa !9
  %36 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %14)
          to label %37 unwind label %63

37:                                               ; preds = %33
  %38 = load i32, ptr %36, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  store i32 %38, ptr %13, align 4, !tbaa !9
  %39 = getelementptr inbounds %"class.JPH::PhysicsSystem", ptr %16, i32 0, i32 16
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  invoke void @_ZNK3JPH17ConstraintManager20GetActiveConstraintsEjjPPNS_10ConstraintERj(ptr noundef nonnull align 8 dereferenceable(80) %39, i32 noundef %40, i32 noundef %41, ptr noundef %42, ptr noundef nonnull align 4 dereferenceable(4) %9)
          to label %43 unwind label %67

43:                                               ; preds = %37
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = icmp ugt i32 %44, 0
  br i1 %45, label %46, label %71

46:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %47, i32 0, i32 7
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = call noundef i32 @_ZNSt13__atomic_baseIjE9fetch_addEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %48, i32 noundef %49, i32 noundef 5) #7
  store i32 %50, ptr %15, align 4, !tbaa !9
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.JPH::PhysicsUpdateContext::Step", ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !11
  %54 = getelementptr inbounds %"class.JPH::PhysicsUpdateContext", ptr %53, i32 0, i32 8
  %55 = load ptr, ptr %54, align 8, !tbaa !21
  %56 = load i32, ptr %15, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %55, i64 %57
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = zext i32 %60 to i64
  %62 = mul i64 %61, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %58, ptr align 8 %59, i64 %62, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %71

63:                                               ; preds = %33
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %7, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %75

67:                                               ; preds = %37
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %7, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %8, align 4
  br label %75

71:                                               ; preds = %46, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  store i32 0, ptr %12, align 4
  br label %72

72:                                               ; preds = %71, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  %73 = load i32, ptr %12, align 4
  switch i32 %73, label %83 [
    i32 0, label %74
    i32 2, label %76
  ]

74:                                               ; preds = %72
  br label %21, !llvm.loop !27

75:                                               ; preds = %67, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %77

76:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @_ZN3JPH10BodyAccess5GrantD2Ev(ptr noundef nonnull align 1 dereferenceable(1) %5) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #7
  ret void

77:                                               ; preds = %75, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @_ZN3JPH10BodyAccess5GrantD2Ev(ptr noundef nonnull align 1 dereferenceable(1) %5) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #7
  br label %78

78:                                               ; preds = %77
  %79 = load ptr, ptr %7, align 8
  %80 = load i32, ptr %8, align 4
  %81 = insertvalue { ptr, i32 } poison, ptr %79, 0
  %82 = insertvalue { ptr, i32 } %81, i32 %80, 1
  resume { ptr, i32 } %82

83:                                               ; preds = %72
  unreachable
}

declare void @_ZNK3JPH17ConstraintManager20GetActiveConstraintsEjjPPNS_10ConstraintERj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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 48}
!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 = distinct !{!27, !28}
!28 = !{!"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::BodyAccess::Grant" = type { i8 }

; 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: 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 #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK3JPH17ConstraintManager17GetNumConstraintsEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress 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) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH10BodyAccess5GrantC2ENS0_7EAccessES2_(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext, i8 noundef zeroext) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13PhysicsSystem29JobDetermineActiveConstraintsEPNS_20PhysicsUpdateContext4StepE(ptr noundef nonnull align 16 dereferenceable(1172) %0, ptr noundef %1) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.JPH::BodyAccess::Grant", align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #7
  call void @_ZN3JPH10BodyAccess5GrantC2ENS0_7EAccessES2_(ptr noundef nonnull align 1 dereferenceable(1) %3, i8 noundef zeroext 0, i8 noundef zeroext 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %7 = getelementptr inbounds i8, ptr %0, i64 824
  %8 = invoke noundef i32 @_ZNK3JPH17ConstraintManager17GetNumConstraintsEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
          to label %9 unwind label %14

9:                                                ; preds = %2
  store i32 %8, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %10 = alloca [512 x i8], align 16
  %11 = getelementptr inbounds i8, ptr %1, i64 52
  %12 = call noundef i32 @_ZNSt13__atomic_baseIjE9fetch_addEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef 64, i32 noundef 5) #7
  %.not21 = icmp ult i32 %12, %8
  br i1 %.not21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %9
  %13 = getelementptr inbounds i8, ptr %1, i64 116
  br label %16

14:                                               ; preds = %2
  %15 = landingpad { ptr, i32 }
          cleanup
  br label %38

16:                                               ; preds = %.lr.ph, %35
  %17 = phi i32 [ %12, %.lr.ph ], [ %36, %35 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  %18 = add i32 %17, 64
  store i32 %18, ptr %6, align 4, !tbaa !5
  %19 = 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) %6)
  %20 = load i32, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  invoke void @_ZNK3JPH17ConstraintManager20GetActiveConstraintsEjjPPNS_10ConstraintERj(ptr noundef nonnull align 8 dereferenceable(80) %7, i32 noundef %17, i32 noundef %20, ptr noundef nonnull %10, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %21 unwind label %33

21:                                               ; preds = %16
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %.not18 = icmp eq i32 %22, 0
  br i1 %.not18, label %35, label %23

23:                                               ; preds = %21
  %24 = call noundef i32 @_ZNSt13__atomic_baseIjE9fetch_addEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef %22, i32 noundef 5) #7
  %25 = load ptr, ptr %1, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %25, i64 48
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  %28 = zext i32 %24 to i64
  %29 = getelementptr inbounds ptr, ptr %27, i64 %28
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = shl nuw nsw i64 %31, 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr nonnull align 16 %10, i64 %32, i1 false)
  br label %35

33:                                               ; preds = %16
  %34 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  br label %38

35:                                               ; preds = %21, %23
  %36 = call noundef i32 @_ZNSt13__atomic_baseIjE9fetch_addEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef 64, i32 noundef 5) #7
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp ult i32 %36, %37
  br i1 %.not, label %16, label %._crit_edge

._crit_edge:                                      ; preds = %35, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @_ZN3JPH10BodyAccess5GrantD2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #7
  ret void

38:                                               ; preds = %33, %14
  %.pn = phi { ptr, i32 } [ %34, %33 ], [ %15, %14 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @_ZN3JPH10BodyAccess5GrantD2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #7
  resume { ptr, i32 } %.pn
}

declare void @_ZNK3JPH17ConstraintManager20GetActiveConstraintsEjjPPNS_10ConstraintERj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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 = !{!"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 48}
!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}


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