; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/General (ContactListenerTest)

; 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.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%class.ContactListenerTest = type { %class.Test, %"class.JPH::ContactListener", [5 x ptr], %"class.JPH::Mutex", %"class.JPH::Array" }
%class.Test = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, %"class.std::unordered_map" }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.JPH::ContactListener" = type { ptr }
%"class.JPH::Mutex" = type { %"class.std::mutex", %"class.std::thread::id" }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::thread::id" = type { i64 }
%"class.JPH::Array" = type { i64, i64, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN19ContactListenerTest17OnContactValidateERKN3JPH4BodyES3_NS0_4Vec3ERKNS0_18CollideShapeResultE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef nonnull align 16 dereferenceable(122) %1, ptr noundef nonnull align 16 dereferenceable(122) %2, double %3, double %4, ptr noundef nonnull align 1 %5) unnamed_addr #0 align 2 {
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  store double %3, ptr %12, align 16
  %13 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  store double %4, ptr %13, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %5, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %8, align 8
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.ContactListenerTest, ptr %14, i32 0, i32 2
  %17 = getelementptr inbounds [5 x ptr], ptr %16, i64 0, i64 0
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = icmp eq ptr %15, %18
  br i1 %19, label %20, label %26

20:                                               ; preds = %6
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.ContactListenerTest, ptr %14, i32 0, i32 2
  %23 = getelementptr inbounds [5 x ptr], ptr %22, i64 0, i64 1
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = icmp eq ptr %21, %24
  br i1 %25, label %40, label %26

26:                                               ; preds = %20, %6
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.ContactListenerTest, ptr %14, i32 0, i32 2
  %29 = getelementptr inbounds [5 x ptr], ptr %28, i64 0, i64 1
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = icmp eq ptr %27, %30
  br i1 %31, label %32, label %38

32:                                               ; preds = %26
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.ContactListenerTest, ptr %14, i32 0, i32 2
  %35 = getelementptr inbounds [5 x ptr], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = icmp eq ptr %33, %36
  br label %38

38:                                               ; preds = %32, %26
  %39 = phi i1 [ false, %26 ], [ %37, %32 ]
  br label %40

40:                                               ; preds = %38, %20
  %41 = phi i1 [ true, %20 ], [ %39, %38 ]
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i32 3, i32 0
  ret i32 %43
}

attributes #0 = { 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" }

!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"}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef range(i32 0, 4) i32 @_ZN19ContactListenerTest17OnContactValidateERKN3JPH4BodyES3_NS0_4Vec3ERKNS0_18CollideShapeResultE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(232) %0, ptr noundef nonnull readnone align 16 dereferenceable(122) %1, ptr noundef nonnull readnone align 16 dereferenceable(122) %2, double %3, double %4, ptr nocapture noundef nonnull readnone align 1 %5) unnamed_addr #0 align 2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr %8, %1
  %10 = getelementptr inbounds i8, ptr %0, i64 128
  %11 = load ptr, ptr %10, align 8
  %12 = icmp eq ptr %11, %2
  %or.cond = select i1 %9, i1 %12, i1 false
  br i1 %or.cond, label %18, label %13

13:                                               ; preds = %6
  %14 = icmp eq ptr %11, %1
  br i1 %14, label %15, label %18

15:                                               ; preds = %13
  %16 = icmp eq ptr %8, %2
  %17 = select i1 %16, i32 3, i32 0
  br label %18

18:                                               ; preds = %6, %13, %15
  %19 = phi i32 [ 0, %13 ], [ %17, %15 ], [ 3, %6 ]
  ret i32 %19
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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"}


; Effective O3 passes: EarlyCSEPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass