; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/Character (CharacterVirtualTest)

; 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.CharacterVirtualTest = type { %class.CharacterBaseTest.base, %"class.JPH::CharacterContactListener", %"class.JPH::Ref.7", %"class.JPH::Vec3", i8, %"class.JPH::Array.8" }
%class.CharacterBaseTest.base = type <{ %class.Test, %"class.JPH::RefConst", %"class.JPH::RefConst", %"class.JPH::RefConst", %"class.JPH::RefConst", %"class.JPH::Array", float, %"class.JPH::BodyID", %"class.JPH::BodyID", [4 x i8], %"class.JPH::CharacterVsCharacterCollisionSimple", float, [4 x i8], %"class.JPH::Vec3", %"class.JPH::BodyID", %"class.JPH::BodyID", %"class.JPH::BodyID", %"class.JPH::BodyID", %"class.JPH::BodyID", float, %"class.JPH::BodyID", [4 x i8], %"class.JPH::Ref", %"class.JPH::Ref.7", %"class.JPH::Ref.7", [8 x i8], %"class.JPH::Vec3", i8, i8, i8, i8 }>
%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::RefConst" = type { ptr }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::CharacterVsCharacterCollisionSimple" = type { %"class.JPH::CharacterVsCharacterCollision", %"class.JPH::Array.4" }
%"class.JPH::CharacterVsCharacterCollision" = type { ptr }
%"class.JPH::Array.4" = type { i64, i64, ptr }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::Ref" = type { ptr }
%"class.JPH::CharacterContactListener" = type { ptr }
%"class.JPH::Ref.7" = type { ptr }
%"class.JPH::Array.8" = type { i64, i64, ptr }
%"class.JPH::CharacterContactSettings" = type { i8, i8 }

@_ZN20CharacterVirtualTest29sPlayerCanPushOtherCharactersE = external dso_local global i8, align 1
@_ZN20CharacterVirtualTest29sOtherCharactersCanPushPlayerE = external dso_local global i8, align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN20CharacterVirtualTest24OnCharacterContactCommonEPKN3JPH16CharacterVirtualES3_RKNS0_10SubShapeIDENS0_4Vec3ES7_RNS0_24CharacterContactSettingsE(ptr noundef nonnull align 16 dereferenceable(400) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %3, double %4, double %5, double %6, double %7, ptr noundef nonnull align 1 dereferenceable(2) %8) #1 align 2 {
  %10 = alloca %"class.JPH::Vec3", align 16
  %11 = alloca %"class.JPH::Vec3", align 16
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  store double %4, ptr %17, align 16
  %18 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  store double %5, ptr %18, align 8
  %19 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  store double %6, ptr %19, align 16
  %20 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  store double %7, ptr %20, align 8
  store ptr %0, ptr %12, align 8, !tbaa !5
  store ptr %1, ptr %13, align 8, !tbaa !5
  store ptr %2, ptr %14, align 8, !tbaa !5
  store ptr %3, ptr %15, align 8, !tbaa !5
  store ptr %8, ptr %16, align 8, !tbaa !5
  %21 = load ptr, ptr %12, align 8
  %22 = load i8, ptr @_ZN20CharacterVirtualTest29sPlayerCanPushOtherCharactersE, align 1, !tbaa !9, !range !11, !noundef !12
  %23 = trunc i8 %22 to i1
  br i1 %23, label %24, label %37

24:                                               ; preds = %9
  %25 = load i8, ptr @_ZN20CharacterVirtualTest29sOtherCharactersCanPushPlayerE, align 1, !tbaa !9, !range !11, !noundef !12
  %26 = trunc i8 %25 to i1
  br i1 %26, label %32, label %27

27:                                               ; preds = %24
  %28 = load ptr, ptr %14, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.CharacterVirtualTest, ptr %21, i32 0, i32 2
  %30 = call noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %29)
  %31 = icmp eq ptr %28, %30
  br label %32

32:                                               ; preds = %27, %24
  %33 = phi i1 [ true, %24 ], [ %31, %27 ]
  %34 = load ptr, ptr %16, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.JPH::CharacterContactSettings", ptr %34, i32 0, i32 0
  %36 = zext i1 %33 to i8
  store i8 %36, ptr %35, align 1, !tbaa !13
  br label %52

37:                                               ; preds = %9
  %38 = load i8, ptr @_ZN20CharacterVirtualTest29sOtherCharactersCanPushPlayerE, align 1, !tbaa !9, !range !11, !noundef !12
  %39 = trunc i8 %38 to i1
  br i1 %39, label %40, label %48

40:                                               ; preds = %37
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.CharacterVirtualTest, ptr %21, i32 0, i32 2
  %43 = call noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %42)
  %44 = icmp eq ptr %41, %43
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.JPH::CharacterContactSettings", ptr %45, i32 0, i32 0
  %47 = zext i1 %44 to i8
  store i8 %47, ptr %46, align 1, !tbaa !13
  br label %51

48:                                               ; preds = %37
  %49 = load ptr, ptr %16, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.JPH::CharacterContactSettings", ptr %49, i32 0, i32 0
  store i8 0, ptr %50, align 1, !tbaa !13
  br label %51

51:                                               ; preds = %48, %40
  br label %52

52:                                               ; preds = %51, %32
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds %class.CharacterVirtualTest, ptr %21, i32 0, i32 2
  %55 = call noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %54)
  %56 = icmp eq ptr %53, %55
  br i1 %56, label %57, label %64

57:                                               ; preds = %52
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.JPH::CharacterContactSettings", ptr %58, i32 0, i32 0
  %60 = load i8, ptr %59, align 1, !tbaa !13, !range !11, !noundef !12
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %64

62:                                               ; preds = %57
  %63 = getelementptr inbounds %class.CharacterVirtualTest, ptr %21, i32 0, i32 4
  store i8 1, ptr %63, align 16, !tbaa !15
  br label %64

64:                                               ; preds = %62, %57, %52
  ret void
}

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

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN3JPH24CharacterContactSettingsE", !10, i64 0, !10, i64 1}
!15 = !{!16, !10, i64 368}
!16 = !{!"_ZTS20CharacterVirtualTest", !17, i64 0, !35, i64 328, !34, i64 336, !32, i64 352, !10, i64 368, !36, i64 376}
!17 = !{!"_ZTS17CharacterBaseTest", !18, i64 0, !25, i64 112, !25, i64 120, !25, i64 128, !25, i64 136, !26, i64 144, !24, i64 168, !27, i64 172, !27, i64 176, !29, i64 184, !24, i64 216, !32, i64 224, !27, i64 240, !27, i64 244, !27, i64 248, !27, i64 252, !27, i64 256, !24, i64 260, !27, i64 264, !33, i64 272, !34, i64 280, !34, i64 288, !32, i64 304, !10, i64 320, !10, i64 321, !10, i64 322, !10, i64 323}
!18 = !{!"_ZTS4Test", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !19, i64 56}
!19 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !20, i64 0}
!20 = !{!"_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, !21, i64 8, !22, i64 16, !21, i64 24, !23, i64 32, !6, i64 48}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!23 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !24, i64 0, !21, i64 8}
!24 = !{!"float", !7, i64 0}
!25 = !{!"_ZTSN3JPH8RefConstINS_5ShapeEEE", !6, i64 0}
!26 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !21, i64 0, !21, i64 8, !6, i64 16}
!27 = !{!"_ZTSN3JPH6BodyIDE", !28, i64 0}
!28 = !{!"int", !7, i64 0}
!29 = !{!"_ZTSN3JPH35CharacterVsCharacterCollisionSimpleE", !30, i64 0, !31, i64 8}
!30 = !{!"_ZTSN3JPH29CharacterVsCharacterCollisionE"}
!31 = !{!"_ZTSN3JPH5ArrayIPNS_16CharacterVirtualENS_12STLAllocatorIS2_EEEE", !21, i64 0, !21, i64 8, !6, i64 16}
!32 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!33 = !{!"_ZTSN3JPH3RefINS_9CharacterEEE", !6, i64 0}
!34 = !{!"_ZTSN3JPH3RefINS_16CharacterVirtualEEE", !6, i64 0}
!35 = !{!"_ZTSN3JPH24CharacterContactListenerE"}
!36 = !{!"_ZTSN3JPH5ArrayINS_16CharacterVirtual10ContactKeyENS_12STLAllocatorIS2_EEEE", !21, i64 0, !21, i64 8, !6, i64 16}


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

@_ZN20CharacterVirtualTest29sPlayerCanPushOtherCharactersE = external dso_local local_unnamed_addr global i8, align 1
@_ZN20CharacterVirtualTest29sOtherCharactersCanPushPlayerE = external dso_local local_unnamed_addr global i8, align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN20CharacterVirtualTest24OnCharacterContactCommonEPKN3JPH16CharacterVirtualES3_RKNS0_10SubShapeIDENS0_4Vec3ES7_RNS0_24CharacterContactSettingsE(ptr noundef nonnull align 16 dereferenceable(400) %0, ptr noundef readnone %1, ptr noundef readnone %2, ptr nocapture noundef nonnull readnone align 4 dereferenceable(4) %3, double %4, double %5, double %6, double %7, ptr nocapture noundef nonnull align 1 dereferenceable(2) %8) local_unnamed_addr #1 align 2 {
  %10 = load i8, ptr @_ZN20CharacterVirtualTest29sPlayerCanPushOtherCharactersE, align 1, !tbaa !5, !range !9, !noundef !10
  %11 = trunc nuw i8 %10 to i1
  %12 = load i8, ptr @_ZN20CharacterVirtualTest29sOtherCharactersCanPushPlayerE, align 1, !tbaa !5, !range !9, !noundef !10
  %13 = trunc nuw i8 %12 to i1
  br i1 %11, label %14, label %15

14:                                               ; preds = %9
  br i1 %13, label %20, label %.sink.split

15:                                               ; preds = %9
  br i1 %13, label %.sink.split, label %20

.sink.split:                                      ; preds = %15, %14
  %.sink12 = phi ptr [ %2, %14 ], [ %1, %15 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 336
  %17 = tail call noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %16)
  %18 = icmp eq ptr %17, %.sink12
  %19 = zext i1 %18 to i8
  br label %20

20:                                               ; preds = %.sink.split, %15, %14
  %.sink = phi i8 [ 1, %14 ], [ 0, %15 ], [ %19, %.sink.split ]
  store i8 %.sink, ptr %8, align 1, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %0, i64 336
  %22 = tail call noundef ptr @_ZNK3JPH3RefINS_16CharacterVirtualEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %21)
  %23 = icmp eq ptr %22, %1
  br i1 %23, label %24, label %29

24:                                               ; preds = %20
  %25 = load i8, ptr %8, align 1, !tbaa !11, !range !9, !noundef !10
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %27, label %29

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 368
  store i8 1, ptr %28, align 16, !tbaa !13
  br label %29

29:                                               ; preds = %27, %24, %20
  ret void
}

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

!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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN3JPH24CharacterContactSettingsE", !6, i64 0, !6, i64 1}
!13 = !{!14, !6, i64 368}
!14 = !{!"_ZTS20CharacterVirtualTest", !15, i64 0, !34, i64 328, !33, i64 336, !31, i64 352, !6, i64 368, !35, i64 376}
!15 = !{!"_ZTS17CharacterBaseTest", !16, i64 0, !24, i64 112, !24, i64 120, !24, i64 128, !24, i64 136, !25, i64 144, !23, i64 168, !26, i64 172, !26, i64 176, !28, i64 184, !23, i64 216, !31, i64 224, !26, i64 240, !26, i64 244, !26, i64 248, !26, i64 252, !26, i64 256, !23, i64 260, !26, i64 264, !32, i64 272, !33, i64 280, !33, i64 288, !31, i64 304, !6, i64 320, !6, i64 321, !6, i64 322, !6, i64 323}
!16 = !{!"_ZTS4Test", !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !6, i64 48, !18, i64 56}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !19, i64 0}
!19 = !{!"_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", !17, i64 0, !20, i64 8, !21, i64 16, !20, i64 24, !22, i64 32, !17, i64 48}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !17, i64 0}
!22 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !23, i64 0, !20, i64 8}
!23 = !{!"float", !7, i64 0}
!24 = !{!"_ZTSN3JPH8RefConstINS_5ShapeEEE", !17, i64 0}
!25 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !20, i64 0, !20, i64 8, !17, i64 16}
!26 = !{!"_ZTSN3JPH6BodyIDE", !27, i64 0}
!27 = !{!"int", !7, i64 0}
!28 = !{!"_ZTSN3JPH35CharacterVsCharacterCollisionSimpleE", !29, i64 0, !30, i64 8}
!29 = !{!"_ZTSN3JPH29CharacterVsCharacterCollisionE"}
!30 = !{!"_ZTSN3JPH5ArrayIPNS_16CharacterVirtualENS_12STLAllocatorIS2_EEEE", !20, i64 0, !20, i64 8, !17, i64 16}
!31 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!32 = !{!"_ZTSN3JPH3RefINS_9CharacterEEE", !17, i64 0}
!33 = !{!"_ZTSN3JPH3RefINS_16CharacterVirtualEEE", !17, i64 0}
!34 = !{!"_ZTSN3JPH24CharacterContactListenerE"}
!35 = !{!"_ZTSN3JPH5ArrayINS_16CharacterVirtual10ContactKeyENS_12STLAllocatorIS2_EEEE", !20, i64 0, !20, i64 8, !17, i64 16}


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