; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/SoftBody (SoftBodyContactListenerTest)

; 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.SoftBodyContactListenerTest = type { %class.Test, %"class.JPH::SoftBodyContactListener", float, i32, %"class.JPH::BodyID", %"class.JPH::BodyID" }
%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::SoftBodyContactListener" = type { ptr }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::SoftBodyContactSettings" = type <{ float, float, float, i8, [3 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN27SoftBodyContactListenerTest25OnSoftBodyContactValidateERKN3JPH4BodyES3_RNS0_23SoftBodyContactSettingsE(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 16 dereferenceable(122) %1, ptr noundef nonnull align 16 dereferenceable(122) %2, ptr noundef nonnull align 4 dereferenceable(13) %3) unnamed_addr #0 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  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 ptr %3, ptr %9, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8
  %11 = getelementptr inbounds %class.SoftBodyContactListenerTest, ptr %10, i32 0, i32 3
  %12 = load i32, ptr %11, align 4, !tbaa !9
  switch i32 %12, label %41 [
    i32 0, label %13
    i32 1, label %14
    i32 2, label %19
    i32 3, label %22
    i32 4, label %27
    i32 5, label %30
    i32 6, label %33
    i32 7, label %34
    i32 8, label %35
    i32 9, label %38
  ]

13:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  br label %42

14:                                               ; preds = %4
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %15, i32 0, i32 1
  store float 0x3FB99999A0000000, ptr %16, align 4, !tbaa !22
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %17, i32 0, i32 2
  store float 0x3FB99999A0000000, ptr %18, align 4, !tbaa !24
  store i32 0, ptr %5, align 4
  br label %42

19:                                               ; preds = %4
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %20, i32 0, i32 0
  store float 0x3FB99999A0000000, ptr %21, align 4, !tbaa !25
  store i32 0, ptr %5, align 4
  br label %42

22:                                               ; preds = %4
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %23, i32 0, i32 1
  store float 0.000000e+00, ptr %24, align 4, !tbaa !22
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %25, i32 0, i32 2
  store float 0.000000e+00, ptr %26, align 4, !tbaa !24
  store i32 0, ptr %5, align 4
  br label %42

27:                                               ; preds = %4
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %28, i32 0, i32 0
  store float 0.000000e+00, ptr %29, align 4, !tbaa !25
  store i32 0, ptr %5, align 4
  br label %42

30:                                               ; preds = %4
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %31, i32 0, i32 3
  store i8 1, ptr %32, align 4, !tbaa !26
  store i32 0, ptr %5, align 4
  br label %42

33:                                               ; preds = %4
  store i32 1, ptr %5, align 4
  br label %42

34:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  br label %42

35:                                               ; preds = %4
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %36, i32 0, i32 0
  store float 0.000000e+00, ptr %37, align 4, !tbaa !25
  store i32 0, ptr %5, align 4
  br label %42

38:                                               ; preds = %4
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.JPH::SoftBodyContactSettings", ptr %39, i32 0, i32 3
  store i8 1, ptr %40, align 4, !tbaa !26
  store i32 0, ptr %5, align 4
  br label %42

41:                                               ; preds = %4
  store i32 1, ptr %5, align 4
  br label %42

42:                                               ; preds = %41, %38, %35, %34, %33, %30, %27, %22, %19, %14, %13
  %43 = load i32, ptr %5, align 4
  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"}
!9 = !{!10, !20, i64 124}
!10 = !{!"_ZTS27SoftBodyContactListenerTest", !11, i64 0, !19, i64 112, !18, i64 120, !20, i64 124, !21, i64 128, !21, i64 132}
!11 = !{!"_ZTS4Test", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !13, i64 56}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !14, i64 0}
!14 = !{!"_ZTSSt10_HashtableIN3JPH6BodyIDESt4pairIKS1_NSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE", !6, i64 0, !15, i64 8, !16, i64 16, !15, i64 24, !17, i64 32, !6, i64 48}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!17 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !18, i64 0, !15, i64 8}
!18 = !{!"float", !7, i64 0}
!19 = !{!"_ZTSN3JPH23SoftBodyContactListenerE"}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTSN3JPH6BodyIDE", !20, i64 0}
!22 = !{!23, !18, i64 4}
!23 = !{!"_ZTSN3JPH23SoftBodyContactSettingsE", !18, i64 0, !18, i64 4, !18, i64 8, !12, i64 12}
!24 = !{!23, !18, i64 8}
!25 = !{!23, !18, i64 0}
!26 = !{!23, !12, i64 12}


; 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: readwrite) uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN27SoftBodyContactListenerTest25OnSoftBodyContactValidateERKN3JPH4BodyES3_RNS0_23SoftBodyContactSettingsE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(136) %0, ptr nocapture noundef nonnull readnone align 16 dereferenceable(122) %1, ptr nocapture noundef nonnull readnone align 16 dereferenceable(122) %2, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(13) %3) unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 124
  %6 = load i32, ptr %5, align 4, !tbaa !5
  switch i32 %6, label %19 [
    i32 0, label %20
    i32 1, label %7
    i32 2, label %9
    i32 3, label %10
    i32 4, label %12
    i32 5, label %13
    i32 6, label %15
    i32 7, label %20
    i32 8, label %16
    i32 9, label %17
  ]

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %3, i64 4
  store <2 x float> <float 0x3FB99999A0000000, float 0x3FB99999A0000000>, ptr %8, align 4, !tbaa !21
  br label %20

9:                                                ; preds = %4
  store float 0x3FB99999A0000000, ptr %3, align 4, !tbaa !22
  br label %20

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %3, i64 4
  store <2 x float> zeroinitializer, ptr %11, align 4, !tbaa !21
  br label %20

12:                                               ; preds = %4
  store float 0.000000e+00, ptr %3, align 4, !tbaa !22
  br label %20

13:                                               ; preds = %4
  %14 = getelementptr inbounds i8, ptr %3, i64 12
  store i8 1, ptr %14, align 4, !tbaa !24
  br label %20

15:                                               ; preds = %4
  br label %20

16:                                               ; preds = %4
  store float 0.000000e+00, ptr %3, align 4, !tbaa !22
  br label %20

17:                                               ; preds = %4
  %18 = getelementptr inbounds i8, ptr %3, i64 12
  store i8 1, ptr %18, align 4, !tbaa !24
  br label %20

19:                                               ; preds = %4
  br label %20

20:                                               ; preds = %4, %4, %19, %17, %16, %15, %13, %12, %10, %9, %7
  %.0 = phi i32 [ 1, %19 ], [ 0, %17 ], [ 0, %16 ], [ 1, %15 ], [ 0, %13 ], [ 0, %12 ], [ 0, %10 ], [ 0, %9 ], [ 0, %7 ], [ 0, %4 ], [ 0, %4 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !19, i64 124}
!6 = !{!"_ZTS27SoftBodyContactListenerTest", !7, i64 0, !18, i64 112, !17, i64 120, !19, i64 124, !20, i64 128, !20, i64 132}
!7 = !{!"_ZTS4Test", !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !11, i64 48, !12, i64 56}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !13, i64 0}
!13 = !{!"_ZTSSt10_HashtableIN3JPH6BodyIDESt4pairIKS1_NSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE", !8, i64 0, !14, i64 8, !15, i64 16, !14, i64 24, !16, i64 32, !8, i64 48}
!14 = !{!"long", !9, i64 0}
!15 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !8, i64 0}
!16 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !17, i64 0, !14, i64 8}
!17 = !{!"float", !9, i64 0}
!18 = !{!"_ZTSN3JPH23SoftBodyContactListenerE"}
!19 = !{!"int", !9, i64 0}
!20 = !{!"_ZTSN3JPH6BodyIDE", !19, i64 0}
!21 = !{!17, !17, i64 0}
!22 = !{!23, !17, i64 0}
!23 = !{!"_ZTSN3JPH23SoftBodyContactSettingsE", !17, i64 0, !17, i64 4, !17, i64 8, !11, i64 12}
!24 = !{!23, !11, i64 12}


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