; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/Vehicle (VehicleTest)

; 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::Color" = type { %union.anon.68 }
%union.anon.68 = type { i32 }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%class.VehicleTest = type { %class.Test, %"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::Array" = type { i64, i64, ptr }
%"struct.VehicleTest::Line" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }

@_ZN3JPH5Color6sBlackE = external global %"class.JPH::Color", align 4

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11VehicleTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 16 dereferenceable(80) %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"class.JPH::Vec3", align 16
  %10 = alloca %"class.JPH::Vec3", align 16
  %11 = alloca %"class.JPH::Color", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %13 = getelementptr inbounds %class.VehicleTest, ptr %12, i32 0, i32 1
  store ptr %13, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef ptr @_ZN3JPH5ArrayIN11VehicleTest4LineENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  store ptr %15, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN3JPH5ArrayIN11VehicleTest4LineENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  store ptr %17, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %45, %2
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %48

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.Test, ptr %12, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.VehicleTest::Line", ptr %27, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 %28, i64 16, i1 false), !tbaa.struct !18
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.VehicleTest::Line", ptr %29, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %10, ptr align 16 %30, i64 16, i1 false), !tbaa.struct !18
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 @_ZN3JPH5Color6sBlackE, i64 4, i1 false), !tbaa.struct !20
  %31 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  %32 = load double, ptr %31, align 16
  %33 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  %34 = load double, ptr %33, align 8
  %35 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  %36 = load double, ptr %35, align 16
  %37 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  %38 = load double, ptr %37, align 8
  %39 = getelementptr inbounds %"class.JPH::Color", ptr %11, i32 0, i32 0
  %40 = getelementptr inbounds %union.anon.68, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4
  %42 = load ptr, ptr %26, align 8, !tbaa !21
  %43 = getelementptr inbounds ptr, ptr %42, i64 2
  %44 = load ptr, ptr %43, align 8
  call void %44(ptr noundef nonnull align 8 dereferenceable(320) %26, double %32, double %34, double %36, double %38, i32 %41)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %45

45:                                               ; preds = %23
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.VehicleTest::Line", ptr %46, i32 1
  store ptr %47, ptr %6, align 8, !tbaa !5
  br label %18

48:                                               ; preds = %22
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !6, i64 32}
!10 = !{!"_ZTS4Test", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !12, i64 56}
!11 = !{!"bool", !7, 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", !6, i64 0, !14, i64 8, !15, i64 16, !14, i64 24, !16, i64 32, !6, i64 48}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!16 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !17, i64 0, !14, i64 8}
!17 = !{!"float", !7, i64 0}
!18 = !{i64 0, i64 16, !19}
!19 = !{!7, !7, i64 0}
!20 = !{i64 0, i64 4, !19}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !8, 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"

%"class.JPH::Color" = type { %union.anon.68 }
%union.anon.68 = type { i32 }

@_ZN3JPH5Color6sBlackE = external local_unnamed_addr global %"class.JPH::Color", align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11VehicleTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr nocapture noundef nonnull readnone align 16 dereferenceable(80) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 112
  %4 = tail call noundef ptr @_ZN3JPH5ArrayIN11VehicleTest4LineENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  %5 = tail call noundef ptr @_ZN3JPH5ArrayIN11VehicleTest4LineENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  %.not12 = icmp eq ptr %4, %5
  br i1 %.not12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  br label %7

._crit_edge:                                      ; preds = %7, %2
  ret void

7:                                                ; preds = %.lr.ph, %7
  %.013 = phi ptr [ %4, %.lr.ph ], [ %13, %7 ]
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  %.sroa.02.0.copyload = load double, ptr %.013, align 16
  %.sroa.23.0..sroa_idx = getelementptr inbounds i8, ptr %.013, i64 8
  %.sroa.23.0.copyload = load double, ptr %.sroa.23.0..sroa_idx, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %.013, i64 16
  %.sroa.01.0.copyload = load double, ptr %9, align 16
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %.013, i64 24
  %.sroa.2.0.copyload = load double, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !17
  %.sroa.0.0.copyload = load i32, ptr @_ZN3JPH5Color6sBlackE, align 4, !tbaa !17
  %10 = load ptr, ptr %8, align 8, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load ptr, ptr %11, align 8
  tail call void %12(ptr noundef nonnull align 8 dereferenceable(320) %8, double %.sroa.02.0.copyload, double %.sroa.23.0.copyload, double %.sroa.01.0.copyload, double %.sroa.2.0.copyload, i32 %.sroa.0.0.copyload)
  %13 = getelementptr inbounds i8, ptr %.013, i64 32
  %.not = icmp eq ptr %13, %5
  br i1 %.not, label %._crit_edge, label %7
}

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

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

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

!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, !7, i64 32}
!6 = !{!"_ZTS4Test", !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !11, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !12, i64 0}
!12 = !{!"_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", !7, i64 0, !13, i64 8, !14, i64 16, !13, i64 24, !15, i64 32, !7, i64 48}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !7, i64 0}
!15 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !16, i64 0, !13, i64 8}
!16 = !{!"float", !8, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass