; 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::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::ContactAllocator" = type { %"class.JPH::LFHMAllocatorContext.base", i32, i32, i32 }
%"class.JPH::LFHMAllocatorContext.base" = type <{ ptr, i32, 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] }

@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 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

; 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 uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3JPH24ContactConstraintManager13ManifoldCache6CreateERNS0_16ContactAllocatorERKNS_14SubShapeIDPairEmi(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(16) %2, i64 noundef %3, i32 noundef %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca %"struct.JPH::AssertLastParam", align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  %15 = load ptr, ptr %7, align 8
  br label %16

16:                                               ; preds = %5
  %17 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %15, i32 0, i32 3
  %18 = load i8, ptr %17, align 8, !tbaa !13, !range !21, !noundef !22
  %19 = trunc i8 %18 to i1
  br i1 %19, label %20, label %23

20:                                               ; preds = %16
  %21 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 294)
  br i1 %21, label %22, label %23

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

23:                                               ; preds = %22, %20, %16
  br label %24

24:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %25 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %15, i32 0, i32 1
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = load i32, ptr %11, align 4, !tbaa !11
  %30 = call noundef i32 @_ZN3JPH24ContactConstraintManager14CachedManifold21sGetRequiredExtraSizeEi(i32 noundef %29)
  %31 = call noundef ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32) %25, ptr noundef nonnull align 8 dereferenceable(20) %26, ptr noundef nonnull align 4 dereferenceable(16) %27, i64 noundef %28, i32 noundef %30)
  store ptr %31, ptr %13, align 8, !tbaa !5
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %38

34:                                               ; preds = %24
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ContactAllocator", ptr %35, i32 0, i32 3
  %37 = call noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4) %36, i32 noundef 1)
  store ptr null, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %49

38:                                               ; preds = %24
  %39 = load i32, ptr %11, align 4, !tbaa !11
  %40 = trunc i32 %39 to i16
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = call noundef nonnull align 4 dereferenceable(56) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue8GetValueEv(ptr noundef nonnull align 4 dereferenceable(76) %41)
  %43 = getelementptr inbounds %"class.JPH::ContactConstraintManager::CachedManifold", ptr %42, i32 0, i32 3
  store i16 %40, ptr %43, align 2, !tbaa !24
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ContactAllocator", ptr %44, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !31
  %47 = add i32 %46, 1
  store i32 %47, ptr %45, align 8, !tbaa !31
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %48, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %49

49:                                               ; preds = %38, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %50 = load ptr, ptr %6, align 8
  ret ptr %50
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 4 dereferenceable(16), i64 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH24ContactConstraintManager14CachedManifold21sGetRequiredExtraSizeEi(i32 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1

; 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)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !20, i64 80}
!14 = !{!"_ZTSN3JPH24ContactConstraintManager13ManifoldCacheE", !15, i64 0, !18, i64 16, !19, i64 48, !20, i64 80}
!15 = !{!"_ZTSN3JPH13LFHMAllocatorE", !6, i64 0, !12, i64 8, !16, i64 12}
!16 = !{!"_ZTSSt6atomicIjE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIjE", !12, i64 0}
!18 = !{!"_ZTSN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEEE", !6, i64 0, !16, i64 8, !6, i64 16, !12, i64 24, !12, i64 28}
!19 = !{!"_ZTSN3JPH15LockFreeHashMapINS_8BodyPairENS_24ContactConstraintManager14CachedBodyPairEEE", !6, i64 0, !16, i64 8, !6, i64 16, !12, i64 24, !12, i64 28}
!20 = !{!"bool", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{i64 2159360160}
!24 = !{!25, !30, i64 18}
!25 = !{!"_ZTSN3JPH24ContactConstraintManager14CachedManifoldE", !12, i64 0, !26, i64 4, !28, i64 16, !30, i64 18, !7, i64 20}
!26 = !{!"_ZTSN3JPH6Float3E", !27, i64 0, !27, i64 4, !27, i64 8}
!27 = !{!"float", !7, i64 0}
!28 = !{!"_ZTSSt6atomicItE", !29, i64 0}
!29 = !{!"_ZTSSt13__atomic_baseItE", !30, i64 0}
!30 = !{!"short", !7, i64 0}
!31 = !{!32, !12, i64 24}
!32 = !{!"_ZTSN3JPH24ContactConstraintManager16ContactAllocatorE", !33, i64 0, !12, i64 20, !12, i64 24, !34, i64 28}
!33 = !{!"_ZTSN3JPH20LFHMAllocatorContextE", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!34 = !{!"_ZTSN3JPH19EPhysicsUpdateErrorE", !7, 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"

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

; 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: mustprogress uwtable
define dso_local noundef ptr @_ZN3JPH24ContactConstraintManager13ManifoldCache6CreateERNS0_16ContactAllocatorERKNS_14SubShapeIDPairEmi(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(16) %2, i64 noundef %3, i32 noundef %4) local_unnamed_addr #1 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = load i8, ptr %6, align 8, !tbaa !5, !range !17, !noundef !18
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %12

9:                                                ; preds = %5
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 294)
  br i1 %10, label %11, label %12

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

12:                                               ; preds = %5, %9, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = tail call noundef i32 @_ZN3JPH24ContactConstraintManager14CachedManifold21sGetRequiredExtraSizeEi(i32 noundef %4)
  %15 = tail call noundef ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef nonnull align 8 dereferenceable(20) %1, ptr noundef nonnull align 4 dereferenceable(16) %2, i64 noundef %3, i32 noundef %14)
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %20

17:                                               ; preds = %12
  %18 = getelementptr inbounds i8, ptr %1, i64 28
  %19 = tail call noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4) %18, i32 noundef 1)
  br label %27

20:                                               ; preds = %12
  %21 = trunc i32 %4 to i16
  %22 = tail call noundef nonnull align 4 dereferenceable(56) ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE8KeyValue8GetValueEv(ptr noundef nonnull align 4 dereferenceable(76) %15)
  %23 = getelementptr inbounds i8, ptr %22, i64 18
  store i16 %21, ptr %23, align 2, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %1, i64 24
  %25 = load i32, ptr %24, align 8, !tbaa !27
  %26 = add i32 %25, 1
  store i32 %26, ptr %24, align 8, !tbaa !27
  br label %27

27:                                               ; preds = %20, %17
  ret ptr %15
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 4 dereferenceable(16), i64 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH24ContactConstraintManager14CachedManifold21sGetRequiredExtraSizeEi(i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #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 #2 align 2

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 = { 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 = { 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, !16, i64 80}
!6 = !{!"_ZTSN3JPH24ContactConstraintManager13ManifoldCacheE", !7, i64 0, !14, i64 16, !15, i64 48, !16, i64 80}
!7 = !{!"_ZTSN3JPH13LFHMAllocatorE", !8, i64 0, !11, i64 8, !12, i64 12}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTSSt6atomicIjE", !13, i64 0}
!13 = !{!"_ZTSSt13__atomic_baseIjE", !11, i64 0}
!14 = !{!"_ZTSN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEEE", !8, i64 0, !12, i64 8, !8, i64 16, !11, i64 24, !11, i64 28}
!15 = !{!"_ZTSN3JPH15LockFreeHashMapINS_8BodyPairENS_24ContactConstraintManager14CachedBodyPairEEE", !8, i64 0, !12, i64 8, !8, i64 16, !11, i64 24, !11, i64 28}
!16 = !{!"bool", !9, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{i64 2159360160}
!20 = !{!21, !26, i64 18}
!21 = !{!"_ZTSN3JPH24ContactConstraintManager14CachedManifoldE", !11, i64 0, !22, i64 4, !24, i64 16, !26, i64 18, !9, i64 20}
!22 = !{!"_ZTSN3JPH6Float3E", !23, i64 0, !23, i64 4, !23, i64 8}
!23 = !{!"float", !9, i64 0}
!24 = !{!"_ZTSSt6atomicItE", !25, i64 0}
!25 = !{!"_ZTSSt13__atomic_baseItE", !26, i64 0}
!26 = !{!"short", !9, i64 0}
!27 = !{!28, !11, i64 24}
!28 = !{!"_ZTSN3JPH24ContactConstraintManager16ContactAllocatorE", !29, i64 0, !11, i64 20, !11, i64 24, !30, i64 28}
!29 = !{!"_ZTSN3JPH20LFHMAllocatorContextE", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!30 = !{!"_ZTSN3JPH19EPhysicsUpdateErrorE", !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass