; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Constraints (ContactConstraintManager)

; 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.anon.14 = type { i8 }
%class.anon.16 = type { 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.0", 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.0" = type { ptr, %"struct.std::atomic", ptr, i32, i32 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }

; 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 void @_ZN3JPH24ContactConstraintManager13ManifoldCache8FinalizeEv(ptr noundef nonnull align 8 dereferenceable(81)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24ContactConstraintManagerC2ERKNS_15PhysicsSettingsE(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef nonnull align 4 dereferenceable(83) %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %class.anon.14, align 1
  %8 = alloca %class.anon.16, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds [2 x %"class.JPH::ContactConstraintManager::ManifoldCache"], ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %11, i64 2
  br label %13

13:                                               ; preds = %15, %2
  %14 = phi ptr [ %11, %2 ], [ %16, %15 ]
  invoke void @_ZN3JPH24ContactConstraintManager13ManifoldCacheC2Ev(ptr noundef nonnull align 8 dereferenceable(81) %14)
          to label %15 unwind label %36

15:                                               ; preds = %13
  %16 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %14, i64 1
  %17 = icmp eq ptr %16, %12
  br i1 %17, label %18, label %13

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 2
  store i32 0, ptr %19, align 8, !tbaa !9
  %20 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %21, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 4
  store ptr null, ptr %22, align 8, !tbaa !14
  %23 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  %24 = call noundef ptr @_ZNK3JPH24ContactConstraintManager16mCombineFrictionMUlRKNS_4BodyERKNS_10SubShapeIDES4_S7_E_cvPFfS4_S7_S4_S7_EEv(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  store ptr %24, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 6
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  %26 = call noundef ptr @_ZNK3JPH24ContactConstraintManager19mCombineRestitutionMUlRKNS_4BodyERKNS_10SubShapeIDES4_S7_E_cvPFfS4_S7_S4_S7_EEv(ptr noundef nonnull align 1 dereferenceable(1) %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  store ptr %26, ptr %25, align 8, !tbaa !16
  %27 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 7
  store ptr null, ptr %27, align 8, !tbaa !17
  %28 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 8
  store i32 0, ptr %28, align 8, !tbaa !18
  %29 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 9
  call void @_ZNSt6atomicIjEC2Ej(ptr noundef nonnull align 4 dereferenceable(4) %29, i32 noundef 0) #5
  %30 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 1
  %31 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %9, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = xor i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2 x %"class.JPH::ContactConstraintManager::ManifoldCache"], ptr %30, i64 0, i64 %34
  call void @_ZN3JPH24ContactConstraintManager13ManifoldCache8FinalizeEv(ptr noundef nonnull align 8 dereferenceable(81) %35)
  ret void

36:                                               ; preds = %13
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %5, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %6, align 4
  %40 = icmp eq ptr %11, %14
  br i1 %40, label %45, label %41

41:                                               ; preds = %41, %36
  %42 = phi ptr [ %14, %36 ], [ %43, %41 ]
  %43 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %42, i64 -1
  call void @_ZN3JPH24ContactConstraintManager13ManifoldCacheD2Ev(ptr noundef nonnull align 8 dereferenceable(81) %43) #5
  %44 = icmp eq ptr %43, %11
  br i1 %44, label %45, label %41

45:                                               ; preds = %41, %36
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %5, align 8
  %48 = load i32, ptr %6, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIjEC2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) 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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress 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 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 184}
!10 = !{!"_ZTSN3JPH24ContactConstraintManagerE", !7, i64 8, !11, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !11, i64 232, !12, i64 236, !6, i64 240}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSSt6atomicIjE", !13, i64 0}
!13 = !{!"_ZTSSt13__atomic_baseIjE", !11, i64 0}
!14 = !{!10, !6, i64 200}
!15 = !{!10, !6, i64 208}
!16 = !{!10, !6, i64 216}
!17 = !{!10, !6, i64 224}
!18 = !{!10, !11, i64 232}


; 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.anon.14 = type { i8 }
%class.anon.16 = type { i8 }
%"class.JPH::ContactConstraintManager::ManifoldCache" = type <{ %"class.JPH::LFHMAllocator", %"class.JPH::LockFreeHashMap", %"class.JPH::LockFreeHashMap.0", i8, [7 x i8] }>
%"class.JPH::LFHMAllocator" = type { ptr, i32, %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::LockFreeHashMap" = type { ptr, %"struct.std::atomic", ptr, i32, i32 }
%"class.JPH::LockFreeHashMap.0" = type { ptr, %"struct.std::atomic", ptr, i32, i32 }

; 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 void @_ZN3JPH24ContactConstraintManager13ManifoldCache8FinalizeEv(ptr noundef nonnull align 8 dereferenceable(81)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24ContactConstraintManagerC2ERKNS_15PhysicsSettingsE(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef nonnull align 4 dereferenceable(83) %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.anon.14, align 1
  %4 = alloca %class.anon.16, align 1
  %.ptr.ptr = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN3JPH24ContactConstraintManager13ManifoldCacheC2Ev(ptr noundef nonnull align 8 dereferenceable(81) %.ptr.ptr)
  %.ptr.ptr.1 = getelementptr inbounds i8, ptr %0, i64 96
  invoke void @_ZN3JPH24ContactConstraintManager13ManifoldCacheC2Ev(ptr noundef nonnull align 8 dereferenceable(81) %.ptr.ptr.1)
          to label %5 unwind label %.preheader.preheader

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 184
  store i32 0, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 192
  store ptr %1, ptr %7, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 200
  store ptr null, ptr %8, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 208
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #5
  %10 = call noundef ptr @_ZNK3JPH24ContactConstraintManager16mCombineFrictionMUlRKNS_4BodyERKNS_10SubShapeIDES4_S7_E_cvPFfS4_S7_S4_S7_EEv(ptr noundef nonnull align 1 dereferenceable(1) %3) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #5
  store ptr %10, ptr %9, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 216
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #5
  %12 = call noundef ptr @_ZNK3JPH24ContactConstraintManager19mCombineRestitutionMUlRKNS_4BodyERKNS_10SubShapeIDES4_S7_E_cvPFfS4_S7_S4_S7_EEv(ptr noundef nonnull align 1 dereferenceable(1) %4) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #5
  store ptr %12, ptr %11, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 224
  store ptr null, ptr %13, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %0, i64 232
  store i32 0, ptr %14, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %0, i64 236
  call void @_ZNSt6atomicIjEC2Ej(ptr noundef nonnull align 4 dereferenceable(4) %15, i32 noundef 0) #5
  %16 = load i32, ptr %6, align 8, !tbaa !5
  %17 = xor i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2 x %"class.JPH::ContactConstraintManager::ManifoldCache"], ptr %.ptr.ptr, i64 0, i64 %18
  call void @_ZN3JPH24ContactConstraintManager13ManifoldCache8FinalizeEv(ptr noundef nonnull align 8 dereferenceable(81) %19)
  ret void

.preheader.preheader:                             ; preds = %2
  %20 = landingpad { ptr, i32 }
          cleanup
  %.ptr9 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN3JPH24ContactConstraintManager13ManifoldCacheD2Ev(ptr noundef nonnull align 8 dereferenceable(81) %.ptr9) #5
  resume { ptr, i32 } %20
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIjEC2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) 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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress 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 = { 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 #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, !9, i64 184}
!6 = !{!"_ZTSN3JPH24ContactConstraintManagerE", !7, i64 8, !9, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !9, i64 232, !11, i64 236, !10, i64 240}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"_ZTSSt6atomicIjE", !12, i64 0}
!12 = !{!"_ZTSSt13__atomic_baseIjE", !9, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !10, i64 200}
!15 = !{!6, !10, i64 208}
!16 = !{!6, !10, i64 216}
!17 = !{!6, !10, i64 224}
!18 = !{!6, !9, i64 232}


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