; LLVM IR from winwinashwin/GA-aided-NMPC-tuning :: src/model/differential_drive.ll (ZN5model17DifferentialDrive4stepEdd)

; 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.model::DifferentialDrive" = type { %"struct.model::State", %"struct.model::State", double }
%"struct.model::State" = type { double, double, double, double, double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5model17DifferentialDrive4stepEdd(ptr noundef nonnull align 8 dereferenceable(104) %0, double noundef %1, double noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds %"struct.model::State", ptr %8, i32 0, i32 3
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %12 = getelementptr inbounds %"struct.model::State", ptr %11, i32 0, i32 2
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = call double @cos(double noundef %13) #3
  %15 = fmul double %10, %14
  %16 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 2
  %17 = load double, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %19 = getelementptr inbounds %"struct.model::State", ptr %18, i32 0, i32 0
  %20 = load double, ptr %19, align 8, !tbaa !16
  %21 = call double @llvm.fmuladd.f64(double %15, double %17, double %20)
  store double %21, ptr %19, align 8, !tbaa !16
  %22 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %23 = getelementptr inbounds %"struct.model::State", ptr %22, i32 0, i32 3
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %26 = getelementptr inbounds %"struct.model::State", ptr %25, i32 0, i32 2
  %27 = load double, ptr %26, align 8, !tbaa !14
  %28 = call double @sin(double noundef %27) #3
  %29 = fmul double %24, %28
  %30 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 2
  %31 = load double, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %33 = getelementptr inbounds %"struct.model::State", ptr %32, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !17
  %35 = call double @llvm.fmuladd.f64(double %29, double %31, double %34)
  store double %35, ptr %33, align 8, !tbaa !17
  %36 = load double, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 2
  %38 = load double, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %40 = getelementptr inbounds %"struct.model::State", ptr %39, i32 0, i32 2
  %41 = load double, ptr %40, align 8, !tbaa !14
  %42 = call double @llvm.fmuladd.f64(double %36, double %38, double %41)
  store double %42, ptr %40, align 8, !tbaa !14
  %43 = load double, ptr %5, align 8, !tbaa !9
  %44 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %45 = getelementptr inbounds %"struct.model::State", ptr %44, i32 0, i32 3
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fsub double %43, %46
  %48 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 2
  %49 = load double, ptr %48, align 8, !tbaa !15
  %50 = fdiv double %47, %49
  %51 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %52 = getelementptr inbounds %"struct.model::State", ptr %51, i32 0, i32 5
  store double %50, ptr %52, align 8, !tbaa !18
  %53 = load double, ptr %5, align 8, !tbaa !9
  %54 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %55 = getelementptr inbounds %"struct.model::State", ptr %54, i32 0, i32 3
  store double %53, ptr %55, align 8, !tbaa !11
  %56 = load double, ptr %6, align 8, !tbaa !9
  %57 = getelementptr inbounds %"class.model::DifferentialDrive", ptr %7, i32 0, i32 0
  %58 = getelementptr inbounds %"struct.model::State", ptr %57, i32 0, i32 4
  store double %56, ptr %58, align 8, !tbaa !19
  ret void
}

; Function Attrs: nounwind
declare double @cos(double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #1

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 = { nounwind "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"_ZTSN5model17DifferentialDriveE", !13, i64 0, !13, i64 48, !10, i64 96}
!13 = !{!"_ZTSN5model5StateE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 96}
!16 = !{!12, !10, i64 0}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 40}
!19 = !{!12, !10, i64 32}


; 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 nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @_ZN5model17DifferentialDrive4stepEdd(ptr nocapture noundef nonnull align 8 dereferenceable(104) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !11
  %8 = tail call double @cos(double noundef %7) #4
  %9 = fmul double %5, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = load double, ptr %10, align 8, !tbaa !12
  %12 = load double, ptr %0, align 8, !tbaa !13
  %13 = tail call double @llvm.fmuladd.f64(double %9, double %11, double %12)
  store double %13, ptr %0, align 8, !tbaa !13
  %14 = load double, ptr %4, align 8, !tbaa !5
  %15 = load double, ptr %6, align 8, !tbaa !11
  %16 = tail call double @sin(double noundef %15) #4
  %17 = fmul double %14, %16
  %18 = load double, ptr %10, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load <2 x double>, ptr %19, align 8, !tbaa !14
  %21 = insertelement <2 x double> poison, double %17, i64 0
  %22 = insertelement <2 x double> %21, double %2, i64 1
  %23 = insertelement <2 x double> poison, double %18, i64 0
  %24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
  %25 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %24, <2 x double> %20)
  store <2 x double> %25, ptr %19, align 8, !tbaa !14
  %26 = load double, ptr %4, align 8, !tbaa !5
  %27 = fsub double %1, %26
  %28 = fdiv double %27, %18
  %29 = getelementptr inbounds i8, ptr %0, i64 40
  store double %28, ptr %29, align 8, !tbaa !15
  store double %1, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %0, i64 32
  store double %2, ptr %30, align 8, !tbaa !16
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, 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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !8, i64 24}
!6 = !{!"_ZTSN5model17DifferentialDriveE", !7, i64 0, !7, i64 48, !8, i64 96}
!7 = !{!"_ZTSN5model5StateE", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 16}
!12 = !{!6, !8, i64 96}
!13 = !{!6, !8, i64 0}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !8, i64 40}
!16 = !{!6, !8, i64 32}


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