; 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::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::VehicleController" = type { ptr, ptr }
%"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::VehicleDifferentialSettings" = type { i32, i32, float, float, float, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZNK3JPH24WheeledVehicleController21GetWheelSpeedAtClutchEv(ptr noundef nonnull align 8 dereferenceable(256) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [2 x i32], align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %15 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store float 0.000000e+00, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %16 = getelementptr inbounds %"class.JPH::WheeledVehicleController", ptr %15, i32 0, i32 7
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef ptr @_ZNK3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  store ptr %18, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call noundef ptr @_ZNK3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %19)
  store ptr %20, ptr %7, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %68, %1
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp ne ptr %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %71

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %27, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.JPH::VehicleDifferentialSettings", ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 4, !tbaa !13
  store i32 %30, ptr %10, align 4, !tbaa !11
  %31 = getelementptr inbounds i32, ptr %10, i64 1
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.JPH::VehicleDifferentialSettings", ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !15
  store i32 %34, ptr %31, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr %10, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds [2 x i32], ptr %35, i64 0, i64 0
  store ptr %36, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds [2 x i32], ptr %37, i64 0, i64 0
  %39 = getelementptr inbounds i32, ptr %38, i64 2
  store ptr %39, ptr %13, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %64, %26
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = icmp ne ptr %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %67

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !11
  store i32 %47, ptr %14, align 4, !tbaa !11
  %48 = load i32, ptr %14, align 4, !tbaa !11
  %49 = icmp sge i32 %48, 0
  br i1 %49, label %50, label %63

50:                                               ; preds = %45
  %51 = getelementptr inbounds %"class.JPH::VehicleController", ptr %15, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load i32, ptr %14, align 4, !tbaa !11
  %54 = call noundef ptr @_ZN3JPH17VehicleConstraint8GetWheelEj(ptr noundef nonnull align 16 dereferenceable(408) %52, i32 noundef %53)
  %55 = call noundef float @_ZNK3JPH5Wheel18GetAngularVelocityEv(ptr noundef nonnull align 16 dereferenceable(404) %54)
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.JPH::VehicleDifferentialSettings", ptr %56, i32 0, i32 2
  %58 = load float, ptr %57, align 4, !tbaa !18
  %59 = load float, ptr %3, align 4, !tbaa !9
  %60 = call float @llvm.fmuladd.f32(float %55, float %58, float %59)
  store float %60, ptr %3, align 4, !tbaa !9
  %61 = load i32, ptr %4, align 4, !tbaa !11
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %50, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %64

64:                                               ; preds = %63
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds i32, ptr %65, i32 1
  store ptr %66, ptr %12, align 8, !tbaa !5
  br label %40

67:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %"class.JPH::VehicleDifferentialSettings", ptr %69, i32 1
  store ptr %70, ptr %6, align 8, !tbaa !5
  br label %21

71:                                               ; preds = %25
  %72 = load float, ptr %3, align 4, !tbaa !9
  %73 = load i32, ptr %4, align 4, !tbaa !11
  %74 = sitofp i32 %73 to float
  %75 = fdiv float %72, %74
  %76 = fmul float %75, 0x4023193D60000000
  %77 = getelementptr inbounds %"class.JPH::WheeledVehicleController", ptr %15, i32 0, i32 6
  %78 = call noundef float @_ZNK3JPH19VehicleTransmission15GetCurrentRatioEv(ptr noundef nonnull align 8 dereferenceable(100) %77)
  %79 = fmul float %76, %78
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret float %79
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH17VehicleConstraint8GetWheelEj(ptr noundef nonnull align 16 dereferenceable(408), i32 noundef) #3 align 2

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

declare noundef float @_ZNK3JPH19VehicleTransmission15GetCurrentRatioEv(ptr noundef nonnull align 8 dereferenceable(100)) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #4 = { 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 #5 = { "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 #6 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN3JPH27VehicleDifferentialSettingsE", !12, i64 0, !12, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!15 = !{!14, !12, i64 4}
!16 = !{!17, !6, i64 8}
!17 = !{!"_ZTSN3JPH17VehicleControllerE", !6, i64 8}
!18 = !{!14, !10, i64 8}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_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 @_ZNK3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZNK3JPH24WheeledVehicleController21GetWheelSpeedAtClutchEv(ptr noundef nonnull align 8 dereferenceable(256) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 192
  %3 = tail call noundef ptr @_ZNK3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %4 = tail call noundef ptr @_ZNK3JPH5ArrayINS_27VehicleDifferentialSettingsENS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %.not31 = icmp eq ptr %3, %4
  br i1 %.not31, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  br label %13

._crit_edge.loopexit:                             ; preds = %35
  %6 = sitofp i32 %.223.1 to float
  %7 = fdiv float %.2.1, %6
  %8 = fmul float %7, 0x4023193D60000000
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %9 = phi float [ 0x7FF8000000000000, %1 ], [ %8, %._crit_edge.loopexit ]
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  %11 = tail call noundef float @_ZNK3JPH19VehicleTransmission15GetCurrentRatioEv(ptr noundef nonnull align 8 dereferenceable(100) %10)
  %12 = fmul float %9, %11
  ret float %12

13:                                               ; preds = %.lr.ph, %35
  %.034 = phi float [ 0.000000e+00, %.lr.ph ], [ %.2.1, %35 ]
  %.02133 = phi i32 [ 0, %.lr.ph ], [ %.223.1, %35 ]
  %.02532 = phi ptr [ %3, %.lr.ph ], [ %36, %35 ]
  %14 = load i32, ptr %.02532, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.02532, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %.02532, i64 8
  %18 = icmp sgt i32 %14, -1
  br i1 %18, label %19, label %26

19:                                               ; preds = %13
  %20 = load ptr, ptr %5, align 8, !tbaa !12
  %21 = tail call noundef ptr @_ZN3JPH17VehicleConstraint8GetWheelEj(ptr noundef nonnull align 16 dereferenceable(408) %20, i32 noundef %14)
  %22 = tail call noundef float @_ZNK3JPH5Wheel18GetAngularVelocityEv(ptr noundef nonnull align 16 dereferenceable(404) %21)
  %23 = load float, ptr %17, align 4, !tbaa !15
  %24 = tail call float @llvm.fmuladd.f32(float %22, float %23, float %.034)
  %25 = add nsw i32 %.02133, 1
  br label %26

26:                                               ; preds = %19, %13
  %.223 = phi i32 [ %25, %19 ], [ %.02133, %13 ]
  %.2 = phi float [ %24, %19 ], [ %.034, %13 ]
  %27 = icmp sgt i32 %16, -1
  br i1 %27, label %28, label %35

28:                                               ; preds = %26
  %29 = load ptr, ptr %5, align 8, !tbaa !12
  %30 = tail call noundef ptr @_ZN3JPH17VehicleConstraint8GetWheelEj(ptr noundef nonnull align 16 dereferenceable(408) %29, i32 noundef %16)
  %31 = tail call noundef float @_ZNK3JPH5Wheel18GetAngularVelocityEv(ptr noundef nonnull align 16 dereferenceable(404) %30)
  %32 = load float, ptr %17, align 4, !tbaa !15
  %33 = tail call float @llvm.fmuladd.f32(float %31, float %32, float %.2)
  %34 = add nsw i32 %.223, 1
  br label %35

35:                                               ; preds = %28, %26
  %.223.1 = phi i32 [ %34, %28 ], [ %.223, %26 ]
  %.2.1 = phi float [ %33, %28 ], [ %.2, %26 ]
  %36 = getelementptr inbounds i8, ptr %.02532, i64 24
  %.not = icmp eq ptr %36, %4
  br i1 %.not, label %._crit_edge.loopexit, label %13
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH17VehicleConstraint8GetWheelEj(ptr noundef nonnull align 16 dereferenceable(408), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3JPH5Wheel18GetAngularVelocityEv(ptr noundef nonnull align 16 dereferenceable(404)) local_unnamed_addr #3 align 2

declare noundef float @_ZNK3JPH19VehicleTransmission15GetCurrentRatioEv(ptr noundef nonnull align 8 dereferenceable(100)) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }
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 = { 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 = { "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 0}
!6 = !{!"_ZTSN3JPH27VehicleDifferentialSettingsE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!13, !14, i64 8}
!13 = !{!"_ZTSN3JPH17VehicleControllerE", !14, i64 8}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass