; 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"

%"struct.JPH::AssertLastParam" = 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 }

@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3JPH24ContactConstraintManagerD2Ev(ptr noundef nonnull align 8 dereferenceable(248) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.JPH::AssertLastParam", align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  br label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %4, i32 0, i32 7
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp eq ptr %7, null
  br i1 %8, label %13, label %9

9:                                                ; preds = %5
  %10 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 679)
          to label %11 unwind label %24

11:                                               ; preds = %9
  br i1 %10, label %12, label %13

12:                                               ; preds = %11
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !14
  br label %13

13:                                               ; preds = %12, %11, %5
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = getelementptr inbounds %"class.JPH::ContactConstraintManager", ptr %4, i32 0, i32 1
  %17 = getelementptr inbounds [2 x %"class.JPH::ContactConstraintManager::ManifoldCache"], ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %17, i64 2
  br label %19

19:                                               ; preds = %19, %15
  %20 = phi ptr [ %18, %15 ], [ %21, %19 ]
  %21 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %20, i64 -1
  call void @_ZN3JPH24ContactConstraintManager13ManifoldCacheD2Ev(ptr noundef nonnull align 8 dereferenceable(81) %21) #4
  %22 = icmp eq ptr %21, %17
  br i1 %22, label %23, label %19

23:                                               ; preds = %19
  ret void

24:                                               ; preds = %9
  %25 = landingpad { ptr, i32 }
          catch ptr null
  %26 = extractvalue { ptr, i32 } %25, 0
  call void @__clang_call_terminate(ptr %26) #5
  unreachable
}

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

attributes #0 = { 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 #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 = { 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 = { noinline noreturn nounwind uwtable "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 = { nounwind }
attributes #5 = { noreturn 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, !6, i64 224}
!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 = !{i64 2159363666}


; 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"

@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3JPH24ContactConstraintManagerD2Ev(ptr noundef nonnull align 8 dereferenceable(248) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 224
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %9, label %5

5:                                                ; preds = %1
  %6 = invoke noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 679)
          to label %7 unwind label %10

7:                                                ; preds = %5
  br i1 %6, label %8, label %9

8:                                                ; preds = %7
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !13
  br label %9

9:                                                ; preds = %8, %7, %1
  %.ptr1 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @_ZN3JPH24ContactConstraintManager13ManifoldCacheD2Ev(ptr noundef nonnull align 8 dereferenceable(81) %.ptr1) #4
  %.ptr1.1 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN3JPH24ContactConstraintManager13ManifoldCacheD2Ev(ptr noundef nonnull align 8 dereferenceable(81) %.ptr1.1) #4
  ret void

10:                                               ; preds = %5
  %11 = landingpad { ptr, i32 }
          catch ptr null
  %12 = extractvalue { ptr, i32 } %11, 0
  tail call void @__clang_call_terminate(ptr %12) #5
  unreachable
}

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #3

attributes #0 = { 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 #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 = { 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 = { noinline noreturn nounwind uwtable "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 = { nounwind }
attributes #5 = { noreturn 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, !10, i64 224}
!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 = !{i64 2159363666}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass