; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Body (BodyManager)

; 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::UniqueLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::BodyID" = type { i32 }
%"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::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.3" = type { i64, i64, ptr }
%"class.JPH::Body" = type <{ %"class.JPH::Vec3", %"class.JPH::Quat", %"class.JPH::AABox", %"class.JPH::RefConst", ptr, i64, %"class.JPH::CollisionGroup", float, float, %"class.JPH::BodyID", i16, i8, %"class.JPH::BroadPhaseLayer", i8, %"struct.std::atomic.8", [6 x i8] }>
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::Quat" = type { %"class.JPH::Vec4" }
%"class.JPH::Vec4" = type { %union.anon.6 }
%union.anon.6 = type { <4 x float> }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::RefConst" = type { ptr }
%"class.JPH::CollisionGroup" = type { %"class.JPH::RefConst.7", i32, i32 }
%"class.JPH::RefConst.7" = type { ptr }
%"class.JPH::BroadPhaseLayer" = type { i8 }
%"struct.std::atomic.8" = type { %"struct.std::__atomic_base.9" }
%"struct.std::__atomic_base.9" = type { i8 }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 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 uwtable
declare dso_local void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef) unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH11BodyManager16ValidateFreeListEv(ptr noundef nonnull align 8 dereferenceable(297)) #1 align 2

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

20:                                               ; preds = %4
  br label %82

21:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #6
  %22 = getelementptr inbounds %"class.JPH::BodyManager", ptr %17, i32 0, i32 4
  call void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %9, ptr noundef nonnull align 8 dereferenceable(48) %22, ptr noundef %17, i32 noundef 4)
  br label %23

23:                                               ; preds = %21
  %24 = getelementptr inbounds %"class.JPH::BodyManager", ptr %17, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp uge i32 %25, %26
  br i1 %27, label %36, label %28

28:                                               ; preds = %23
  %29 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 443)
          to label %30 unwind label %32

30:                                               ; preds = %28
  br i1 %29, label %31, label %36

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

32:                                               ; preds = %80, %28
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %11, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %12, align 4
  br label %83

36:                                               ; preds = %31, %30, %23
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = getelementptr inbounds %"class.JPH::BodyManager", ptr %17, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = sub i32 %41, %39
  store i32 %42, ptr %40, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %43, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %"class.JPH::BodyID", ptr %44, i64 %46
  store ptr %47, ptr %14, align 8, !tbaa !5
  br label %48

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

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

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = invoke noundef ptr @_ZN3JPH11BodyManager18RemoveBodyInternalERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(297) %17, ptr noundef nonnull align 4 dereferenceable(4) %54)
          to label %56 unwind label %67

56:                                               ; preds = %53
  store ptr %55, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  invoke void @_ZN3JPH6BodyIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %16)
          to label %57 unwind label %71

57:                                               ; preds = %56
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.JPH::Body", ptr %58, i32 0, i32 9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %59, ptr align 4 %16, i64 4, i1 false), !tbaa.struct !24
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %75

62:                                               ; preds = %57
  %63 = load ptr, ptr %15, align 8, !tbaa !5
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %63, ptr %64, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds ptr, ptr %65, i32 1
  store ptr %66, ptr %8, align 8, !tbaa !5
  br label %75

67:                                               ; preds = %53
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %11, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %12, align 4
  br label %79

71:                                               ; preds = %56
  %72 = landingpad { ptr, i32 }
          cleanup
  %73 = extractvalue { ptr, i32 } %72, 0
  store ptr %73, ptr %11, align 8
  %74 = extractvalue { ptr, i32 } %72, 1
  store i32 %74, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %79

75:                                               ; preds = %62, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = getelementptr inbounds %"class.JPH::BodyID", ptr %77, i32 1
  store ptr %78, ptr %13, align 8, !tbaa !5
  br label %48, !llvm.loop !25

79:                                               ; preds = %71, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %83

80:                                               ; preds = %52
  invoke void @_ZNK3JPH11BodyManager16ValidateFreeListEv(ptr noundef nonnull align 8 dereferenceable(297) %17)
          to label %81 unwind label %32

81:                                               ; preds = %80
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %9) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #6
  br label %82

82:                                               ; preds = %81, %20
  ret void

83:                                               ; preds = %79, %32
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %9) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #6
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %11, align 8
  %86 = load i32, ptr %12, align 4
  %87 = insertvalue { ptr, i32 } poison, ptr %85, 0
  %88 = insertvalue { ptr, i32 } %87, i32 %86, 1
  resume { ptr, i32 } %88
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH11BodyManager18RemoveBodyInternalERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(297), ptr noundef nonnull align 4 dereferenceable(4)) #5 align 2

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"_ZTSN3JPH11BodyManagerE", !13, i64 0, !10, i64 24, !14, i64 32, !15, i64 40, !19, i64 88, !20, i64 104, !15, i64 128, !7, i64 176, !7, i64 192, !10, i64 200, !15, i64 208, !21, i64 256, !6, i64 280, !6, i64 288, !22, i64 296}
!13 = !{!"_ZTSN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN3JPH5MutexE", !16, i64 0, !18, i64 40}
!16 = !{!"_ZTSSt5mutex", !17, i64 0}
!17 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!18 = !{!"_ZTSNSt6thread2idE", !14, i64 0}
!19 = !{!"_ZTSN3JPH10MutexArrayINS_11SharedMutexEEE", !6, i64 0, !10, i64 8}
!20 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!21 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!22 = !{!"bool", !7, i64 0}
!23 = !{i64 2158734252}
!24 = !{i64 0, i64 4, !9}
!25 = distinct !{!25, !26}
!26 = !{!"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::UniqueLock" = type <{ ptr, ptr, i32, [4 x i8] }>
%"class.JPH::BodyID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 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 uwtable
declare dso_local void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef) unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH11BodyManager16ValidateFreeListEv(ptr noundef nonnull align 8 dereferenceable(297)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH11BodyManager12RemoveBodiesEPKNS_6BodyIDEiPPNS_4BodyE(ptr noundef nonnull align 8 dereferenceable(297) %0, ptr noundef %1, i32 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.JPH::UniqueLock", align 8
  %6 = alloca %"class.JPH::BodyID", align 4
  %7 = icmp slt i32 %2, 1
  br i1 %7, label %34, label %8

8:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  call void @_ZN3JPH10UniqueLockINS_5MutexEEC2ERS1_PKNS_11BodyManagerENS_17EPhysicsLockTypesE(ptr noundef nonnull align 8 dereferenceable(20) %5, ptr noundef nonnull align 8 dereferenceable(48) %9, ptr noundef nonnull %0, i32 noundef 4)
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %.not = icmp ult i32 %11, %2
  br i1 %.not, label %12, label %.lr.ph.preheader

12:                                               ; preds = %8
  %13 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 443)
          to label %14 unwind label %16

14:                                               ; preds = %12
  br i1 %13, label %15, label %.lr.ph.preheader

15:                                               ; preds = %14
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !21
  br label %.lr.ph.preheader

16:                                               ; preds = %._crit_edge, %12
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %35

.lr.ph.preheader:                                 ; preds = %8, %14, %15
  %18 = load i32, ptr %10, align 8, !tbaa !5
  %19 = sub i32 %18, %2
  store i32 %19, ptr %10, align 8, !tbaa !5
  %20 = zext nneg i32 %2 to i64
  %21 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %20
  br label %.lr.ph

._crit_edge:                                      ; preds = %30
  invoke void @_ZNK3JPH11BodyManager16ValidateFreeListEv(ptr noundef nonnull align 8 dereferenceable(297) %0)
          to label %33 unwind label %16

.lr.ph:                                           ; preds = %.lr.ph.preheader, %30
  %.024 = phi ptr [ %.1, %30 ], [ %3, %.lr.ph.preheader ]
  %.01823 = phi ptr [ %31, %30 ], [ %1, %.lr.ph.preheader ]
  %22 = invoke noundef ptr @_ZN3JPH11BodyManager18RemoveBodyInternalERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(297) %0, ptr noundef nonnull align 4 dereferenceable(4) %.01823)
          to label %23 unwind label %28

23:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @_ZN3JPH6BodyIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %24 = getelementptr inbounds i8, ptr %22, i64 112
  %25 = load i32, ptr %6, align 4, !tbaa !22
  store i32 %25, ptr %24, align 16, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  %.not22 = icmp eq ptr %.024, null
  br i1 %.not22, label %30, label %26

26:                                               ; preds = %23
  store ptr %22, ptr %.024, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %.024, i64 8
  br label %30

28:                                               ; preds = %.lr.ph
  %29 = landingpad { ptr, i32 }
          cleanup
  br label %35

30:                                               ; preds = %26, %23
  %.1 = phi ptr [ %27, %26 ], [ null, %23 ]
  %31 = getelementptr inbounds i8, ptr %.01823, i64 4
  %32 = icmp ult ptr %31, %21
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !24

33:                                               ; preds = %._crit_edge
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  br label %34

34:                                               ; preds = %4, %33
  ret void

35:                                               ; preds = %28, %16
  %.pn = phi { ptr, i32 } [ %29, %28 ], [ %17, %16 ]
  call void @_ZN3JPH10UniqueLockINS_5MutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH11BodyManager18RemoveBodyInternalERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(297), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !12, i64 24}
!6 = !{!"_ZTSN3JPH11BodyManagerE", !7, i64 0, !12, i64 24, !8, i64 32, !13, i64 40, !17, i64 88, !18, i64 104, !13, i64 128, !9, i64 176, !9, i64 192, !12, i64 200, !13, i64 208, !19, i64 256, !11, i64 280, !11, i64 288, !20, i64 296}
!7 = !{!"_ZTSN3JPH5ArrayIPNS_4BodyENS_12STLAllocatorIS2_EEEE", !8, i64 0, !8, i64 8, !11, i64 16}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"_ZTSN3JPH5MutexE", !14, i64 0, !16, i64 40}
!14 = !{!"_ZTSSt5mutex", !15, i64 0}
!15 = !{!"_ZTSSt12__mutex_base", !9, i64 0}
!16 = !{!"_ZTSNSt6thread2idE", !8, i64 0}
!17 = !{!"_ZTSN3JPH10MutexArrayINS_11SharedMutexEEE", !11, i64 0, !12, i64 8}
!18 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !8, i64 0, !8, i64 8, !11, i64 16}
!19 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !8, i64 0, !8, i64 8, !11, i64 16}
!20 = !{!"bool", !9, i64 0}
!21 = !{i64 2158734252}
!22 = !{!12, !12, i64 0}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass