; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/Vehicle/VehicleConstraintTest.ll (ZN21VehicleConstraintTestD2Ev)

; 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.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.VehicleConstraintTest = type <{ %class.VehicleTest, ptr, %"class.JPH::Ref", [3 x %"class.JPH::Ref.4"], %"class.JPH::Mat44", float, float, float, float, float, [12 x i8] }>
%class.VehicleTest = type { %class.Test, %"class.JPH::Array" }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::Ref" = type { ptr }
%"class.JPH::Ref.4" = type { ptr }
%"class.JPH::Mat44" = type { [4 x %"class.JPH::Vec4"] }
%"class.JPH::Vec4" = type { %union.anon }
%union.anon = type { <4 x float> }

@_ZTV21VehicleConstraintTest = external dso_local unnamed_addr constant { [25 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN21VehicleConstraintTestD2Ev(ptr noundef nonnull align 16 dereferenceable(260) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 184) ({ [25 x ptr] }, ptr @_ZTV21VehicleConstraintTest, i32 0, i32 0, i32 2), ptr %3, align 16, !tbaa !9
  %4 = getelementptr inbounds %class.Test, ptr %3, i32 0, i32 2
  %5 = load ptr, ptr %4, align 16, !tbaa !11
  %6 = getelementptr inbounds %class.VehicleConstraintTest, ptr %3, i32 0, i32 2
  %7 = invoke noundef ptr @_ZNK3JPH3RefINS_17VehicleConstraintEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %8 unwind label %24

8:                                                ; preds = %1
  %9 = icmp eq ptr %7, null
  br i1 %9, label %12, label %10

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %7, i64 32
  br label %12

12:                                               ; preds = %10, %8
  %13 = phi ptr [ %11, %10 ], [ null, %8 ]
  invoke void @_ZN3JPH13PhysicsSystem18RemoveStepListenerEPNS_19PhysicsStepListenerE(ptr noundef nonnull align 16 dereferenceable(1172) %5, ptr noundef %13)
          to label %14 unwind label %24

14:                                               ; preds = %12
  %15 = getelementptr inbounds %class.VehicleConstraintTest, ptr %3, i32 0, i32 3
  %16 = getelementptr inbounds [3 x %"class.JPH::Ref.4"], ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %"class.JPH::Ref.4", ptr %16, i64 3
  br label %18

18:                                               ; preds = %18, %14
  %19 = phi ptr [ %17, %14 ], [ %20, %18 ]
  %20 = getelementptr inbounds %"class.JPH::Ref.4", ptr %19, i64 -1
  call void @_ZN3JPH3RefINS_22VehicleCollisionTesterEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %20) #4
  %21 = icmp eq ptr %20, %16
  br i1 %21, label %22, label %18

22:                                               ; preds = %18
  %23 = getelementptr inbounds %class.VehicleConstraintTest, ptr %3, i32 0, i32 2
  call void @_ZN3JPH3RefINS_17VehicleConstraintEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %23) #4
  call void @_ZN11VehicleTestD2Ev(ptr noundef nonnull align 8 dereferenceable(136) %3) #4
  ret void

24:                                               ; preds = %12, %1
  %25 = landingpad { ptr, i32 }
          catch ptr null
  %26 = extractvalue { ptr, i32 } %25, 0
  call void @__clang_call_terminate(ptr %26) #5
  unreachable
}

declare void @_ZN3JPH13PhysicsSystem18RemoveStepListenerEPNS_19PhysicsStepListenerE(ptr noundef nonnull align 16 dereferenceable(1172), ptr noundef) #1

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

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11VehicleTestD2Ev(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #2 align 2

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" }
attributes #1 = { "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 = { 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 #3 = { noinline noreturn nounwind uwtable "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 }
attributes #5 = { noreturn 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTS4Test", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !13, i64 48, !14, i64 56}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !15, i64 0}
!15 = !{!"_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, !16, i64 8, !17, i64 16, !16, i64 24, !18, i64 32, !6, i64 48}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!18 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !19, i64 0, !16, i64 8}
!19 = !{!"float", !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"

@_ZTV21VehicleConstraintTest = external dso_local unnamed_addr constant { [25 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN21VehicleConstraintTestD2Ev(ptr noundef nonnull align 16 dereferenceable(260) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 184) (i8, ptr @_ZTV21VehicleConstraintTest, i64 16), ptr %0, align 16, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 16, !tbaa !8
  %4 = getelementptr inbounds i8, ptr %0, i64 144
  %5 = tail call noundef ptr @_ZNK3JPH3RefINS_17VehicleConstraintEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %6 = icmp eq ptr %5, null
  %7 = getelementptr inbounds i8, ptr %5, i64 32
  %8 = select i1 %6, ptr null, ptr %7
  invoke void @_ZN3JPH13PhysicsSystem18RemoveStepListenerEPNS_19PhysicsStepListenerE(ptr noundef nonnull align 16 dereferenceable(1172) %3, ptr noundef %8)
          to label %.preheader.preheader unwind label %9

.preheader.preheader:                             ; preds = %1
  %.ptr1 = getelementptr inbounds i8, ptr %0, i64 168
  tail call void @_ZN3JPH3RefINS_22VehicleCollisionTesterEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr1) #4
  %.ptr1.1 = getelementptr inbounds i8, ptr %0, i64 160
  tail call void @_ZN3JPH3RefINS_22VehicleCollisionTesterEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr1.1) #4
  %.ptr1.2 = getelementptr inbounds i8, ptr %0, i64 152
  tail call void @_ZN3JPH3RefINS_22VehicleCollisionTesterEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr1.2) #4
  tail call void @_ZN3JPH3RefINS_17VehicleConstraintEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  tail call void @_ZN11VehicleTestD2Ev(ptr noundef nonnull align 8 dereferenceable(136) %0) #4
  ret void

9:                                                ; preds = %1
  %10 = landingpad { ptr, i32 }
          catch ptr null
  %11 = extractvalue { ptr, i32 } %10, 0
  tail call void @__clang_call_terminate(ptr %11) #5
  unreachable
}

declare void @_ZN3JPH13PhysicsSystem18RemoveStepListenerEPNS_19PhysicsStepListenerE(ptr noundef nonnull align 16 dereferenceable(1172), ptr noundef) local_unnamed_addr #1

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

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #3

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11VehicleTestD2Ev(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #2 align 2

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" }
attributes #1 = { "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 = { 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 #3 = { noinline noreturn nounwind uwtable "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 }
attributes #5 = { noreturn 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 16}
!9 = !{!"_ZTS4Test", !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !12, i64 48, !13, i64 56}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"bool", !11, 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", !10, i64 0, !15, i64 8, !16, i64 16, !15, i64 24, !17, i64 32, !10, i64 48}
!15 = !{!"long", !11, i64 0}
!16 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !10, i64 0}
!17 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !18, i64 0, !15, i64 8}
!18 = !{!"float", !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass