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

@.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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1

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

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

18:                                               ; preds = %14
  %19 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 335)
  br i1 %19, label %20, label %21

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

21:                                               ; preds = %20, %18, %14
  br label %22

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %23 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ManifoldCache", ptr %13, i32 0, i32 2
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = call noundef ptr @_ZN3JPH15LockFreeHashMapINS_8BodyPairENS_24ContactConstraintManager14CachedBodyPairEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32) %23, ptr noundef nonnull align 8 dereferenceable(20) %24, ptr noundef nonnull align 8 dereferenceable(8) %25, i64 noundef %26, i32 noundef 0)
  store ptr %27, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %34

30:                                               ; preds = %22
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ContactAllocator", ptr %31, i32 0, i32 3
  %33 = call noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4) %32, i32 noundef 2)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %40

34:                                               ; preds = %22
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.JPH::ContactConstraintManager::ContactAllocator", ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !23
  %38 = add i32 %37, 1
  store i32 %38, ptr %36, align 4, !tbaa !23
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %39, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %40

40:                                               ; preds = %34, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %41 = load ptr, ptr %5, align 8
  ret ptr %41
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH15LockFreeHashMapINS_8BodyPairENS_24ContactConstraintManager14CachedBodyPairEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) #1 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 = { 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, !19, i64 80}
!12 = !{!"_ZTSN3JPH24ContactConstraintManager13ManifoldCacheE", !13, i64 0, !17, i64 16, !18, i64 48, !19, i64 80}
!13 = !{!"_ZTSN3JPH13LFHMAllocatorE", !6, i64 0, !14, i64 8, !15, i64 12}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSSt6atomicIjE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIjE", !14, i64 0}
!17 = !{!"_ZTSN3JPH15LockFreeHashMapINS_14SubShapeIDPairENS_24ContactConstraintManager14CachedManifoldEEE", !6, i64 0, !15, i64 8, !6, i64 16, !14, i64 24, !14, i64 28}
!18 = !{!"_ZTSN3JPH15LockFreeHashMapINS_8BodyPairENS_24ContactConstraintManager14CachedBodyPairEEE", !6, i64 0, !15, i64 8, !6, i64 16, !14, i64 24, !14, i64 28}
!19 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{i64 2159361516}
!23 = !{!24, !14, i64 20}
!24 = !{!"_ZTSN3JPH24ContactConstraintManager16ContactAllocatorE", !25, i64 0, !14, i64 20, !14, i64 24, !26, i64 28}
!25 = !{!"_ZTSN3JPH20LFHMAllocatorContextE", !6, i64 0, !14, i64 8, !14, i64 12, !14, i64 16}
!26 = !{!"_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: 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 uwtable
define dso_local noundef ptr @_ZN3JPH24ContactConstraintManager13ManifoldCache6CreateERNS0_16ContactAllocatorERKNS_8BodyPairEm(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i64 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = load i8, ptr %5, align 8, !tbaa !5, !range !17, !noundef !18
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %11

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

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

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

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %1, i64 28
  %17 = tail call noundef i32 @_ZN3JPHoRERNS_19EPhysicsUpdateErrorES0_(ptr noundef nonnull align 4 dereferenceable(4) %16, i32 noundef 2)
  br label %22

18:                                               ; preds = %11
  %19 = getelementptr inbounds i8, ptr %1, i64 20
  %20 = load i32, ptr %19, align 4, !tbaa !20
  %21 = add i32 %20, 1
  store i32 %21, ptr %19, align 4, !tbaa !20
  br label %22

22:                                               ; preds = %18, %15
  ret ptr %13
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH15LockFreeHashMapINS_8BodyPairENS_24ContactConstraintManager14CachedBodyPairEE6CreateIJEEEPNS4_8KeyValueERNS_20LFHMAllocatorContextERKS1_miDpOT_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) local_unnamed_addr #0 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 = { 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 2159361516}
!20 = !{!21, !11, i64 20}
!21 = !{!"_ZTSN3JPH24ContactConstraintManager16ContactAllocatorE", !22, i64 0, !11, i64 20, !11, i64 24, !23, i64 28}
!22 = !{!"_ZTSN3JPH20LFHMAllocatorContextE", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!23 = !{!"_ZTSN3JPH19EPhysicsUpdateErrorE", !9, i64 0}


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