; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Vehicle (WheeledVehicleController)

; 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::VehicleController" = type { ptr, ptr }
%"class.JPH::WheeledVehicleController" = type { %"class.JPH::VehicleController", float, float, float, float, %"class.JPH::VehicleEngine", %"class.JPH::VehicleTransmission", %"class.JPH::Array.5", float, float, %"class.std::function.29" }
%"class.JPH::VehicleEngine" = type <{ %"class.JPH::VehicleEngineSettings", float, [4 x i8] }>
%"class.JPH::VehicleEngineSettings" = type { float, float, float, %"class.JPH::LinearCurve", float, float }
%"class.JPH::LinearCurve" = type { %"class.JPH::Array" }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::VehicleTransmission" = type <{ %"class.JPH::VehicleTransmissionSettings", i32, float, float, float, float, [4 x i8] }>
%"class.JPH::VehicleTransmissionSettings" = type { i8, %"class.JPH::Array.2", %"class.JPH::Array.2", float, float, float, float, float, float }
%"class.JPH::Array.2" = type { i64, i64, ptr }
%"class.JPH::Array.5" = type { i64, i64, ptr }
%"class.std::function.29" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.JPH::WheelSettingsWV" = type { %"class.JPH::WheelSettings.base", float, float, float, %"class.JPH::LinearCurve", %"class.JPH::LinearCurve", float, float, [8 x i8] }
%"class.JPH::WheelSettings.base" = type <{ %"class.JPH::SerializableObject", %"class.JPH::RefTarget.12", [4 x i8], %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", float, float, float, %"class.JPH::SpringSettings", float, float, i8 }>
%"class.JPH::SerializableObject" = type { ptr }
%"class.JPH::RefTarget.12" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::SpringSettings" = type { i8, %union.anon.13, float }
%union.anon.13 = type { float }

; 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: mustprogress uwtable
declare dso_local noundef ptr @_ZNK3JPH7WheelWV11GetSettingsEv(ptr noundef nonnull align 16 dereferenceable(424)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24WheeledVehicleController10PreCollideEfRNS_13PhysicsSystemE(ptr noundef nonnull align 8 dereferenceable(256) %0, float noundef %1, ptr noundef nonnull align 16 dereferenceable(1172) %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %13 = getelementptr inbounds %"class.JPH::VehicleController", ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH17VehicleConstraint9GetWheelsEv(ptr noundef nonnull align 16 dereferenceable(408) %14)
  store ptr %15, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN3JPH5ArrayIPNS_5WheelENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  store ptr %17, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call noundef ptr @_ZN3JPH5ArrayIPNS_5WheelENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %18)
  store ptr %19, ptr %9, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %38, %3
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ne ptr %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %41

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  store ptr %27, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %28, ptr %11, align 8, !tbaa !5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.JPH::WheeledVehicleController", ptr %12, i32 0, i32 2
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = fneg float %31
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = call noundef ptr @_ZNK3JPH7WheelWV11GetSettingsEv(ptr noundef nonnull align 16 dereferenceable(424) %33)
  %35 = getelementptr inbounds %"class.JPH::WheelSettingsWV", ptr %34, i32 0, i32 3
  %36 = load float, ptr %35, align 4, !tbaa !28
  %37 = fmul float %32, %36
  call void @_ZN3JPH5Wheel13SetSteerAngleEf(ptr noundef nonnull align 16 dereferenceable(404) %29, float noundef %37)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %38

38:                                               ; preds = %25
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %39, i32 1
  store ptr %40, ptr %8, align 8, !tbaa !5
  br label %20

41:                                               ; preds = %24
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH17VehicleConstraint9GetWheelsEv(ptr noundef nonnull align 16 dereferenceable(408)) #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH5Wheel13SetSteerAngleEf(ptr noundef nonnull align 16 dereferenceable(404), float noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 = { 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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN3JPH17VehicleControllerE", !6, i64 8}
!13 = !{!14, !10, i64 20}
!14 = !{!"_ZTSN3JPH24WheeledVehicleControllerE", !12, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !15, i64 32, !20, i64 88, !25, i64 192, !10, i64 216, !10, i64 220, !26, i64 224}
!15 = !{!"_ZTSN3JPH13VehicleEngineE", !16, i64 0, !10, i64 48}
!16 = !{!"_ZTSN3JPH21VehicleEngineSettingsE", !10, i64 0, !10, i64 4, !10, i64 8, !17, i64 16, !10, i64 40, !10, i64 44}
!17 = !{!"_ZTSN3JPH11LinearCurveE", !18, i64 0}
!18 = !{!"_ZTSN3JPH5ArrayINS_11LinearCurve5PointENS_12STLAllocatorIS2_EEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTSN3JPH19VehicleTransmissionE", !21, i64 0, !24, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96}
!21 = !{!"_ZTSN3JPH27VehicleTransmissionSettingsE", !22, i64 0, !23, i64 8, !23, i64 32, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76}
!22 = !{!"_ZTSN3JPH17ETransmissionModeE", !7, i64 0}
!23 = !{!"_ZTSN3JPH5ArrayIfNS_12STLAllocatorIfEEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!24 = !{!"int", !7, i64 0}
!25 = !{!"_ZTSN3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!26 = !{!"_ZTSSt8functionIFvjRfS0_ffffffEE", !27, i64 0, !6, i64 24}
!27 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!28 = !{!29, !10, i64 156}
!29 = !{!"_ZTSN3JPH15WheelSettingsWVE", !30, i64 0, !10, i64 148, !10, i64 152, !10, i64 156, !17, i64 160, !17, i64 184, !10, i64 208, !10, i64 212}
!30 = !{!"_ZTSN3JPH13WheelSettingsE", !31, i64 0, !32, i64 8, !35, i64 16, !35, i64 32, !35, i64 48, !35, i64 64, !35, i64 80, !35, i64 96, !10, i64 112, !10, i64 116, !10, i64 120, !36, i64 124, !10, i64 136, !10, i64 140, !38, i64 144}
!31 = !{!"_ZTSN3JPH18SerializableObjectE"}
!32 = !{!"_ZTSN3JPH9RefTargetINS_13WheelSettingsEEE", !33, i64 0}
!33 = !{!"_ZTSSt6atomicIjE", !34, i64 0}
!34 = !{!"_ZTSSt13__atomic_baseIjE", !24, i64 0}
!35 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!36 = !{!"_ZTSN3JPH14SpringSettingsE", !37, i64 0, !7, i64 4, !10, i64 8}
!37 = !{!"_ZTSN3JPH11ESpringModeE", !7, i64 0}
!38 = !{!"bool", !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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK3JPH7WheelWV11GetSettingsEv(ptr noundef nonnull align 16 dereferenceable(424)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24WheeledVehicleController10PreCollideEfRNS_13PhysicsSystemE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(256) %0, float noundef %1, ptr nocapture noundef nonnull readnone align 16 dereferenceable(1172) %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH17VehicleConstraint9GetWheelsEv(ptr noundef nonnull align 16 dereferenceable(408) %5)
  %7 = tail call noundef ptr @_ZN3JPH5ArrayIPNS_5WheelENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %8 = tail call noundef ptr @_ZN3JPH5ArrayIPNS_5WheelENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %.not10 = icmp eq ptr %7, %8
  br i1 %.not10, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  br label %10

._crit_edge:                                      ; preds = %10, %3
  ret void

10:                                               ; preds = %.lr.ph, %10
  %.011 = phi ptr [ %7, %.lr.ph ], [ %18, %10 ]
  %11 = load ptr, ptr %.011, align 8, !tbaa !10
  %12 = load float, ptr %9, align 4, !tbaa !11
  %13 = fneg float %12
  %14 = tail call noundef ptr @_ZNK3JPH7WheelWV11GetSettingsEv(ptr noundef nonnull align 16 dereferenceable(424) %11)
  %15 = getelementptr inbounds i8, ptr %14, i64 156
  %16 = load float, ptr %15, align 4, !tbaa !27
  %17 = fmul float %16, %13
  tail call void @_ZN3JPH5Wheel13SetSteerAngleEf(ptr noundef nonnull align 16 dereferenceable(404) %11, float noundef %17)
  %18 = getelementptr inbounds i8, ptr %.011, i64 8
  %.not = icmp eq ptr %18, %8
  br i1 %.not, label %._crit_edge, label %10
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH5Wheel13SetSteerAngleEf(ptr noundef nonnull align 16 dereferenceable(404), float noundef) 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 = { 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 #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" }

!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 8}
!6 = !{!"_ZTSN3JPH17VehicleControllerE", !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !13, i64 20}
!12 = !{!"_ZTSN3JPH24WheeledVehicleControllerE", !6, i64 0, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !14, i64 32, !19, i64 88, !24, i64 192, !13, i64 216, !13, i64 220, !25, i64 224}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTSN3JPH13VehicleEngineE", !15, i64 0, !13, i64 48}
!15 = !{!"_ZTSN3JPH21VehicleEngineSettingsE", !13, i64 0, !13, i64 4, !13, i64 8, !16, i64 16, !13, i64 40, !13, i64 44}
!16 = !{!"_ZTSN3JPH11LinearCurveE", !17, i64 0}
!17 = !{!"_ZTSN3JPH5ArrayINS_11LinearCurve5PointENS_12STLAllocatorIS2_EEEE", !18, i64 0, !18, i64 8, !7, i64 16}
!18 = !{!"long", !8, i64 0}
!19 = !{!"_ZTSN3JPH19VehicleTransmissionE", !20, i64 0, !23, i64 80, !13, i64 84, !13, i64 88, !13, i64 92, !13, i64 96}
!20 = !{!"_ZTSN3JPH27VehicleTransmissionSettingsE", !21, i64 0, !22, i64 8, !22, i64 32, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !13, i64 76}
!21 = !{!"_ZTSN3JPH17ETransmissionModeE", !8, i64 0}
!22 = !{!"_ZTSN3JPH5ArrayIfNS_12STLAllocatorIfEEEE", !18, i64 0, !18, i64 8, !7, i64 16}
!23 = !{!"int", !8, i64 0}
!24 = !{!"_ZTSN3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEEE", !18, i64 0, !18, i64 8, !7, i64 16}
!25 = !{!"_ZTSSt8functionIFvjRfS0_ffffffEE", !26, i64 0, !7, i64 24}
!26 = !{!"_ZTSSt14_Function_base", !8, i64 0, !7, i64 16}
!27 = !{!28, !13, i64 156}
!28 = !{!"_ZTSN3JPH15WheelSettingsWVE", !29, i64 0, !13, i64 148, !13, i64 152, !13, i64 156, !16, i64 160, !16, i64 184, !13, i64 208, !13, i64 212}
!29 = !{!"_ZTSN3JPH13WheelSettingsE", !30, i64 0, !31, i64 8, !34, i64 16, !34, i64 32, !34, i64 48, !34, i64 64, !34, i64 80, !34, i64 96, !13, i64 112, !13, i64 116, !13, i64 120, !35, i64 124, !13, i64 136, !13, i64 140, !37, i64 144}
!30 = !{!"_ZTSN3JPH18SerializableObjectE"}
!31 = !{!"_ZTSN3JPH9RefTargetINS_13WheelSettingsEEE", !32, i64 0}
!32 = !{!"_ZTSSt6atomicIjE", !33, i64 0}
!33 = !{!"_ZTSSt13__atomic_baseIjE", !23, i64 0}
!34 = !{!"_ZTSN3JPH4Vec3E", !8, i64 0}
!35 = !{!"_ZTSN3JPH14SpringSettingsE", !36, i64 0, !8, i64 4, !13, i64 8}
!36 = !{!"_ZTSN3JPH11ESpringModeE", !8, i64 0}
!37 = !{!"bool", !8, i64 0}


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