; 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::LockFreeHashMap<JPH::SubShapeIDPair, JPH::ContactConstraintManager::CachedManifold>::Iterator" = type { ptr, i32, i32 }
%"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 }
%"class.JPH::ContactConstraintManager::CachedManifold" = type { i32, %"class.JPH::Float3", %"struct.std::atomic.5", i16, [1 x %"class.JPH::ContactConstraintManager::CachedContactPoint"] }
%"class.JPH::Float3" = type { float, float, float }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { i16 }
%"class.JPH::ContactConstraintManager::CachedContactPoint" = type { %"class.JPH::Float3", %"class.JPH::Float3", float, %"class.JPH::Vector" }
%"class.JPH::Vector" = type { [2 x float] }

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

; 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 nonnull align 4 dereferenceable(56) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue8GetValueEv(ptr noundef nonnull align 4 dereferenceable(76)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24ContactConstraintManager13ManifoldCache28ContactPointRemovedCallbacksEPNS_15ContactListenerE(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.JPH::LockFreeHashMap<JPH::SubShapeIDPair, JPH::ContactConstraintManager::CachedManifold>::Iterator", align 8
  %7 = alloca %"struct.JPH::LockFreeHashMap<JPH::SubShapeIDPair, JPH::ContactConstraintManager::CachedManifold>::Iterator", align 8
  %8 = alloca ptr, align 8
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %9, i32 0, i32 1
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE5beginEv(ptr noundef nonnull align 8 dereferenceable(32) %11)
  %13 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 0
  %14 = extractvalue { ptr, i64 } %12, 0
  store ptr %14, ptr %13, align 8
  %15 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 1
  %16 = extractvalue { ptr, i64 } %12, 1
  store i64 %16, ptr %15, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %17)
  %19 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 0
  %20 = extractvalue { ptr, i64 } %18, 0
  store ptr %20, ptr %19, align 8
  %21 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 1
  %22 = extractvalue { ptr, i64 } %18, 1
  store i64 %22, ptr %21, align 8
  br label %23

23:                                               ; preds = %43, %2
  %24 = call noundef zeroext i1 @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorneERKS5_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %7)
  br i1 %24, label %26, label %25

25:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %45

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %27 = call noundef nonnull align 4 dereferenceable(76) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = call noundef nonnull align 4 dereferenceable(56) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue8GetValueEv(ptr noundef nonnull align 4 dereferenceable(76) %28)
  %30 = getelementptr inbounds %"class.JPH::ContactConstraintManager::CachedManifold", ptr %29, i32 0, i32 2
  %31 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %30) #3
  %32 = zext i16 %31 to i32
  %33 = and i32 %32, 1
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %42

35:                                               ; preds = %26
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue6GetKeyEv(ptr noundef nonnull align 4 dereferenceable(76) %37)
  %39 = load ptr, ptr %36, align 8, !tbaa !9
  %40 = getelementptr inbounds ptr, ptr %39, i64 5
  %41 = load ptr, ptr %40, align 8
  call void %41(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 4 dereferenceable(16) %38)
  br label %42

42:                                               ; preds = %35, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %43

43:                                               ; preds = %42
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  br label %23

45:                                               ; preds = %25
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE5beginEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE3endEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorneERKS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(76) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 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 = { 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 = !{!"vtable pointer", !8, i64 0}


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

%"struct.JPH::LockFreeHashMap<JPH::SubShapeIDPair, JPH::ContactConstraintManager::CachedManifold>::Iterator" = type { 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

; 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 nonnull align 4 dereferenceable(56) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue8GetValueEv(ptr noundef nonnull align 4 dereferenceable(76)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24ContactConstraintManager13ManifoldCache28ContactPointRemovedCallbacksEPNS_15ContactListenerE(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %"struct.JPH::LockFreeHashMap<JPH::SubShapeIDPair, JPH::ContactConstraintManager::CachedManifold>::Iterator", align 8
  %4 = alloca %"struct.JPH::LockFreeHashMap<JPH::SubShapeIDPair, JPH::ContactConstraintManager::CachedManifold>::Iterator", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  %6 = tail call { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE5beginEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %7 = extractvalue { ptr, i64 } %6, 0
  store ptr %7, ptr %3, align 8
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = extractvalue { ptr, i64 } %6, 1
  store i64 %9, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  %10 = tail call { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %11 = extractvalue { ptr, i64 } %10, 0
  store ptr %11, ptr %4, align 8
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  %13 = extractvalue { ptr, i64 } %10, 1
  store i64 %13, ptr %12, align 8
  %14 = call noundef zeroext i1 @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorneERKS5_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %26, %2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  ret void

.lr.ph:                                           ; preds = %2, %26
  %15 = call noundef nonnull align 4 dereferenceable(76) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %16 = call noundef nonnull align 4 dereferenceable(56) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue8GetValueEv(ptr noundef nonnull align 4 dereferenceable(76) %15)
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = call noundef zeroext i16 @_ZNKSt13__atomic_baseItEcvtEv(ptr noundef nonnull align 2 dereferenceable(2) %17) #3
  %19 = and i16 %18, 1
  %20 = icmp eq i16 %19, 0
  br i1 %20, label %21, label %26

21:                                               ; preds = %.lr.ph
  %22 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue6GetKeyEv(ptr noundef nonnull align 4 dereferenceable(76) %15)
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 40
  %25 = load ptr, ptr %24, align 8
  call void %25(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(16) %22)
  br label %26

26:                                               ; preds = %21, %.lr.ph
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %28 = call noundef zeroext i1 @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorneERKS5_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %28, label %.lr.ph, label %._crit_edge
}

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE5beginEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE3endEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorneERKS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(76) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass