; LLVM IR from shbang91/rpc :: controller/friction_compensator/karnopp_compensator.ll (ZN18KarnoppCompensator6UpdateEd)

; 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.KarnoppCompensator = type { double, double, double, double, double, double }

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN18KarnoppCompensator6UpdateEd(ptr noundef nonnull align 8 dereferenceable(48) %0, double noundef %1) #0 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load double, ptr %5, align 8, !tbaa !9
  %8 = call noundef double @_ZSt3absd(double noundef %7)
  %9 = getelementptr inbounds %class.KarnoppCompensator, ptr %6, i32 0, i32 3
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fcmp olt double %8, %10
  br i1 %11, label %12, label %22

12:                                               ; preds = %2
  %13 = call noundef i32 @_ZN5boost4math4signIdEEiRKT_(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %14 = sitofp i32 %13 to double
  %15 = getelementptr inbounds %class.KarnoppCompensator, ptr %6, i32 0, i32 4
  %16 = load double, ptr %15, align 8, !tbaa !13
  %17 = fmul double %14, %16
  %18 = load double, ptr %5, align 8, !tbaa !9
  %19 = fmul double %17, %18
  %20 = load double, ptr %5, align 8, !tbaa !9
  %21 = fmul double %19, %20
  store double %21, ptr %3, align 8
  br label %32

22:                                               ; preds = %2
  %23 = getelementptr inbounds %class.KarnoppCompensator, ptr %6, i32 0, i32 2
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = load double, ptr %5, align 8, !tbaa !9
  %26 = call noundef i32 @_ZN5boost4math4signIdEEiRKT_(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %27 = sitofp i32 %26 to double
  %28 = getelementptr inbounds %class.KarnoppCompensator, ptr %6, i32 0, i32 5
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = fmul double %27, %29
  %31 = call double @llvm.fmuladd.f64(double %24, double %25, double %30)
  store double %31, ptr %3, align 8
  br label %32

32:                                               ; preds = %22, %12
  %33 = load double, ptr %3, align 8
  ret double %33
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) #1

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

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

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 = { 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 = { inlinehint 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"_ZTS18KarnoppCompensator", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!12, !10, i64 32}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 40}


; 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
define dso_local noundef double @_ZN18KarnoppCompensator6UpdateEd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, double noundef %1) local_unnamed_addr #0 align 2 {
  %3 = alloca double, align 8
  store double %1, ptr %3, align 8, !tbaa !5
  %4 = tail call noundef double @_ZSt3absd(double noundef %1)
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load double, ptr %5, align 8, !tbaa !9
  %7 = fcmp olt double %4, %6
  br i1 %7, label %8, label %17

8:                                                ; preds = %2
  %9 = call noundef i32 @_ZN5boost4math4signIdEEiRKT_(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %10 = sitofp i32 %9 to double
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load double, ptr %11, align 8, !tbaa !11
  %13 = fmul double %12, %10
  %14 = load double, ptr %3, align 8, !tbaa !5
  %15 = fmul double %13, %14
  %16 = fmul double %14, %15
  br label %26

17:                                               ; preds = %2
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load double, ptr %18, align 8, !tbaa !12
  %20 = call noundef i32 @_ZN5boost4math4signIdEEiRKT_(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %21 = sitofp i32 %20 to double
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  %23 = load double, ptr %22, align 8, !tbaa !13
  %24 = fmul double %23, %21
  %25 = call double @llvm.fmuladd.f64(double %19, double %1, double %24)
  br label %26

26:                                               ; preds = %17, %8
  %.0 = phi double [ %16, %8 ], [ %25, %17 ]
  ret double %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) local_unnamed_addr #1

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

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

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 = { 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 = { inlinehint 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"_ZTS18KarnoppCompensator", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!10, !6, i64 32}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 40}


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