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

; 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::TrackedVehicleController" = type { %"class.JPH::VehicleController", float, float, float, float, %"class.JPH::VehicleEngine", %"class.JPH::VehicleTransmission", [2 x %"class.JPH::VehicleTrack"] }
%"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::VehicleTrack" = type <{ %"class.JPH::VehicleTrackSettings", float, [4 x i8] }>
%"class.JPH::VehicleTrackSettings" = type { i32, %"class.JPH::Array.5", float, float, float, float }
%"class.JPH::Array.5" = type { i64, i64, ptr }

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN3JPH24TrackedVehicleController19SyncLeftRightTracksEv(ptr noundef nonnull align 8 dereferenceable(304) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 7
  %9 = getelementptr inbounds [2 x %"class.JPH::VehicleTrack"], ptr %8, i64 0, i64 0
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %10 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 7
  %11 = getelementptr inbounds [2 x %"class.JPH::VehicleTrack"], ptr %10, i64 0, i64 1
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 2
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 3
  %15 = load float, ptr %14, align 8, !tbaa !23
  %16 = fmul float %13, %15
  %17 = fcmp ogt float %16, 0.000000e+00
  br i1 %17, label %18, label %62

18:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %19 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 2
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %21, i32 0, i32 1
  %23 = load float, ptr %22, align 8, !tbaa !24
  %24 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 3
  %25 = load float, ptr %24, align 8, !tbaa !23
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 8, !tbaa !24
  %29 = fmul float %25, %28
  %30 = fneg float %29
  %31 = call float @llvm.fmuladd.f32(float %20, float %23, float %30)
  %32 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 2
  %33 = load float, ptr %32, align 4, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %34, i32 0, i32 2
  %36 = load float, ptr %35, align 8, !tbaa !28
  %37 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 3
  %38 = load float, ptr %37, align 8, !tbaa !23
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %39, i32 0, i32 2
  %41 = load float, ptr %40, align 8, !tbaa !28
  %42 = fmul float %38, %41
  %43 = call float @llvm.fmuladd.f32(float %33, float %36, float %42)
  %44 = fdiv float %31, %43
  store float %44, ptr %5, align 4, !tbaa !29
  %45 = load float, ptr %5, align 4, !tbaa !29
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %46, i32 0, i32 2
  %48 = load float, ptr %47, align 8, !tbaa !28
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %49, i32 0, i32 1
  %51 = load float, ptr %50, align 8, !tbaa !24
  %52 = call float @llvm.fmuladd.f32(float %45, float %48, float %51)
  store float %52, ptr %50, align 8, !tbaa !24
  %53 = load float, ptr %5, align 4, !tbaa !29
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %54, i32 0, i32 2
  %56 = load float, ptr %55, align 8, !tbaa !28
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %57, i32 0, i32 1
  %59 = load float, ptr %58, align 8, !tbaa !24
  %60 = fneg float %53
  %61 = call float @llvm.fmuladd.f32(float %60, float %56, float %59)
  store float %61, ptr %58, align 8, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %106

62:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %63 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 2
  %64 = load float, ptr %63, align 4, !tbaa !9
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %65, i32 0, i32 1
  %67 = load float, ptr %66, align 8, !tbaa !24
  %68 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 3
  %69 = load float, ptr %68, align 8, !tbaa !23
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %70, i32 0, i32 1
  %72 = load float, ptr %71, align 8, !tbaa !24
  %73 = fmul float %69, %72
  %74 = fneg float %73
  %75 = call float @llvm.fmuladd.f32(float %64, float %67, float %74)
  %76 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 3
  %77 = load float, ptr %76, align 8, !tbaa !23
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %78, i32 0, i32 2
  %80 = load float, ptr %79, align 8, !tbaa !28
  %81 = getelementptr inbounds %"class.JPH::TrackedVehicleController", ptr %7, i32 0, i32 2
  %82 = load float, ptr %81, align 4, !tbaa !9
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %83, i32 0, i32 2
  %85 = load float, ptr %84, align 8, !tbaa !28
  %86 = fmul float %82, %85
  %87 = fneg float %86
  %88 = call float @llvm.fmuladd.f32(float %77, float %80, float %87)
  %89 = fdiv float %75, %88
  store float %89, ptr %6, align 4, !tbaa !29
  %90 = load float, ptr %6, align 4, !tbaa !29
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %91, i32 0, i32 2
  %93 = load float, ptr %92, align 8, !tbaa !28
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %94, i32 0, i32 1
  %96 = load float, ptr %95, align 8, !tbaa !24
  %97 = call float @llvm.fmuladd.f32(float %90, float %93, float %96)
  store float %97, ptr %95, align 8, !tbaa !24
  %98 = load float, ptr %6, align 4, !tbaa !29
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %"class.JPH::VehicleTrackSettings", ptr %99, i32 0, i32 2
  %101 = load float, ptr %100, align 8, !tbaa !28
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %"class.JPH::VehicleTrack", ptr %102, i32 0, i32 1
  %104 = load float, ptr %103, align 8, !tbaa !24
  %105 = call float @llvm.fmuladd.f32(float %98, float %101, float %104)
  store float %105, ptr %103, align 8, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %106

106:                                              ; preds = %62, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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, !12, i64 20}
!10 = !{!"_ZTSN3JPH24TrackedVehicleControllerE", !11, i64 0, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !13, i64 32, !18, i64 88, !7, i64 192}
!11 = !{!"_ZTSN3JPH17VehicleControllerE", !6, i64 8}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_ZTSN3JPH13VehicleEngineE", !14, i64 0, !12, i64 48}
!14 = !{!"_ZTSN3JPH21VehicleEngineSettingsE", !12, i64 0, !12, i64 4, !12, i64 8, !15, i64 16, !12, i64 40, !12, i64 44}
!15 = !{!"_ZTSN3JPH11LinearCurveE", !16, i64 0}
!16 = !{!"_ZTSN3JPH5ArrayINS_11LinearCurve5PointENS_12STLAllocatorIS2_EEEE", !17, i64 0, !17, i64 8, !6, i64 16}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSN3JPH19VehicleTransmissionE", !19, i64 0, !22, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96}
!19 = !{!"_ZTSN3JPH27VehicleTransmissionSettingsE", !20, i64 0, !21, i64 8, !21, i64 32, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76}
!20 = !{!"_ZTSN3JPH17ETransmissionModeE", !7, i64 0}
!21 = !{!"_ZTSN3JPH5ArrayIfNS_12STLAllocatorIfEEEE", !17, i64 0, !17, i64 8, !6, i64 16}
!22 = !{!"int", !7, i64 0}
!23 = !{!10, !12, i64 24}
!24 = !{!25, !12, i64 48}
!25 = !{!"_ZTSN3JPH12VehicleTrackE", !26, i64 0, !12, i64 48}
!26 = !{!"_ZTSN3JPH20VehicleTrackSettingsE", !22, i64 0, !27, i64 8, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!27 = !{!"_ZTSN3JPH5ArrayIjNS_12STLAllocatorIjEEEE", !17, i64 0, !17, i64 8, !6, i64 16}
!28 = !{!26, !12, i64 32}
!29 = !{!12, !12, 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN3JPH24TrackedVehicleController19SyncLeftRightTracksEv(ptr nocapture noundef nonnull align 8 dereferenceable(304) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 20
  %3 = load float, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load float, ptr %4, align 8, !tbaa !22
  %6 = fmul float %3, %5
  %7 = fcmp ogt float %6, 0.000000e+00
  %8 = getelementptr inbounds i8, ptr %0, i64 296
  %9 = load float, ptr %8, align 8, !tbaa !23
  %10 = getelementptr inbounds i8, ptr %0, i64 240
  %11 = load float, ptr %10, align 8, !tbaa !23
  %12 = fneg float %5
  %13 = fmul float %11, %12
  %14 = tail call float @llvm.fmuladd.f32(float %3, float %9, float %13)
  br i1 %7, label %15, label %26

15:                                               ; preds = %1
  %16 = getelementptr inbounds i8, ptr %0, i64 280
  %17 = load float, ptr %16, align 8, !tbaa !27
  %18 = getelementptr inbounds i8, ptr %0, i64 224
  %19 = load float, ptr %18, align 8, !tbaa !27
  %20 = fmul float %5, %19
  %21 = tail call float @llvm.fmuladd.f32(float %3, float %17, float %20)
  %22 = fdiv float %14, %21
  %23 = tail call float @llvm.fmuladd.f32(float %22, float %19, float %11)
  store float %23, ptr %10, align 8, !tbaa !23
  %24 = fneg float %22
  %25 = tail call float @llvm.fmuladd.f32(float %24, float %17, float %9)
  br label %37

26:                                               ; preds = %1
  %27 = getelementptr inbounds i8, ptr %0, i64 224
  %28 = load float, ptr %27, align 8, !tbaa !27
  %29 = getelementptr inbounds i8, ptr %0, i64 280
  %30 = load float, ptr %29, align 8, !tbaa !27
  %31 = fneg float %3
  %32 = fmul float %30, %31
  %33 = tail call float @llvm.fmuladd.f32(float %5, float %28, float %32)
  %34 = fdiv float %14, %33
  %35 = tail call float @llvm.fmuladd.f32(float %34, float %28, float %11)
  store float %35, ptr %10, align 8, !tbaa !23
  %36 = tail call float @llvm.fmuladd.f32(float %34, float %30, float %9)
  br label %37

37:                                               ; preds = %26, %15
  %.sink = phi float [ %36, %26 ], [ %25, %15 ]
  store float %.sink, ptr %8, align 8, !tbaa !23
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !11, i64 20}
!6 = !{!"_ZTSN3JPH24TrackedVehicleControllerE", !7, i64 0, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !12, i64 32, !17, i64 88, !9, i64 192}
!7 = !{!"_ZTSN3JPH17VehicleControllerE", !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"_ZTSN3JPH13VehicleEngineE", !13, i64 0, !11, i64 48}
!13 = !{!"_ZTSN3JPH21VehicleEngineSettingsE", !11, i64 0, !11, i64 4, !11, i64 8, !14, i64 16, !11, i64 40, !11, i64 44}
!14 = !{!"_ZTSN3JPH11LinearCurveE", !15, i64 0}
!15 = !{!"_ZTSN3JPH5ArrayINS_11LinearCurve5PointENS_12STLAllocatorIS2_EEEE", !16, i64 0, !16, i64 8, !8, i64 16}
!16 = !{!"long", !9, i64 0}
!17 = !{!"_ZTSN3JPH19VehicleTransmissionE", !18, i64 0, !21, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96}
!18 = !{!"_ZTSN3JPH27VehicleTransmissionSettingsE", !19, i64 0, !20, i64 8, !20, i64 32, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76}
!19 = !{!"_ZTSN3JPH17ETransmissionModeE", !9, i64 0}
!20 = !{!"_ZTSN3JPH5ArrayIfNS_12STLAllocatorIfEEEE", !16, i64 0, !16, i64 8, !8, i64 16}
!21 = !{!"int", !9, i64 0}
!22 = !{!6, !11, i64 24}
!23 = !{!24, !11, i64 48}
!24 = !{!"_ZTSN3JPH12VehicleTrackE", !25, i64 0, !11, i64 48}
!25 = !{!"_ZTSN3JPH20VehicleTrackSettingsE", !21, i64 0, !26, i64 8, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!26 = !{!"_ZTSN3JPH5ArrayIjNS_12STLAllocatorIjEEEE", !16, i64 0, !16, i64 8, !8, i64 16}
!27 = !{!25, !11, i64 32}


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