; LLVM IR from pantor/ruckig :: src/ruckig (position_second_step1)

; 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.ruckig::PositionSecondOrderStep1" = type { double, double, double, double, double, double, double, %"struct.std::array" }
%"struct.std::array" = type { [3 x %"class.ruckig::Profile"] }
%"class.ruckig::Profile" = type <{ %"struct.std::array.0", %"struct.std::array.0", %"struct.std::array.0", %"struct.std::array.1", %"struct.std::array.1", %"struct.std::array.1", %"class.ruckig::BrakeProfile", %"class.ruckig::BrakeProfile", double, double, double, i32, i32, i32, [4 x i8] }>
%"struct.std::array.0" = type { [7 x double] }
%"struct.std::array.1" = type { [8 x double] }
%"class.ruckig::BrakeProfile" = type { double, %"struct.std::array.2", %"struct.std::array.2", %"struct.std::array.2", %"struct.std::array.2", %"struct.std::array.2" }
%"struct.std::array.2" = type { [2 x double] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6ruckig24PositionSecondOrderStep19time_acc0ERPNS_7ProfileEddddb(ptr noundef nonnull align 8 dereferenceable(1784) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, i1 noundef zeroext %6) #0 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i8, align 1
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store double %2, ptr %10, align 8, !tbaa !9
  store double %3, ptr %11, align 8, !tbaa !9
  store double %4, ptr %12, align 8, !tbaa !9
  store double %5, ptr %13, align 8, !tbaa !9
  %15 = zext i1 %6 to i8
  store i8 %15, ptr %14, align 1, !tbaa !11
  %16 = load ptr, ptr %8, align 8
  %17 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 0
  %18 = load double, ptr %17, align 8, !tbaa !13
  %19 = fneg double %18
  %20 = load double, ptr %10, align 8, !tbaa !9
  %21 = fadd double %19, %20
  %22 = load double, ptr %12, align 8, !tbaa !9
  %23 = fdiv double %21, %22
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.ruckig::Profile", ptr %25, i32 0, i32 0
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %26, i64 noundef 0) #4
  store double %23, ptr %27, align 8, !tbaa !9
  %28 = load double, ptr %13, align 8, !tbaa !9
  %29 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 0
  %30 = load double, ptr %29, align 8, !tbaa !13
  %31 = fmul double %28, %30
  %32 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !13
  %34 = load double, ptr %12, align 8, !tbaa !9
  %35 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 1
  %36 = load double, ptr %35, align 8, !tbaa !16
  %37 = fmul double %34, %36
  %38 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 1
  %39 = load double, ptr %38, align 8, !tbaa !16
  %40 = fmul double %37, %39
  %41 = fneg double %40
  %42 = call double @llvm.fmuladd.f64(double %31, double %33, double %41)
  %43 = load double, ptr %12, align 8, !tbaa !9
  %44 = fmul double 2.000000e+00, %43
  %45 = load double, ptr %13, align 8, !tbaa !9
  %46 = fmul double %44, %45
  %47 = load double, ptr %10, align 8, !tbaa !9
  %48 = fmul double %46, %47
  %49 = fdiv double %42, %48
  %50 = load double, ptr %10, align 8, !tbaa !9
  %51 = load double, ptr %12, align 8, !tbaa !9
  %52 = load double, ptr %13, align 8, !tbaa !9
  %53 = fsub double %51, %52
  %54 = fmul double %50, %53
  %55 = load double, ptr %12, align 8, !tbaa !9
  %56 = fmul double 2.000000e+00, %55
  %57 = load double, ptr %13, align 8, !tbaa !9
  %58 = fmul double %56, %57
  %59 = fdiv double %54, %58
  %60 = fadd double %49, %59
  %61 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 6
  %62 = load double, ptr %61, align 8, !tbaa !17
  %63 = load double, ptr %10, align 8, !tbaa !9
  %64 = fdiv double %62, %63
  %65 = fadd double %60, %64
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = getelementptr inbounds %"class.ruckig::Profile", ptr %67, i32 0, i32 0
  %69 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %68, i64 noundef 1) #4
  store double %65, ptr %69, align 8, !tbaa !9
  %70 = getelementptr inbounds %"class.ruckig::PositionSecondOrderStep1", ptr %16, i32 0, i32 1
  %71 = load double, ptr %70, align 8, !tbaa !16
  %72 = load double, ptr %10, align 8, !tbaa !9
  %73 = fsub double %71, %72
  %74 = load double, ptr %13, align 8, !tbaa !9
  %75 = fdiv double %73, %74
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load ptr, ptr %76, align 8, !tbaa !5
  %78 = getelementptr inbounds %"class.ruckig::Profile", ptr %77, i32 0, i32 0
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %78, i64 noundef 2) #4
  store double %75, ptr %79, align 8, !tbaa !9
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  %82 = getelementptr inbounds %"class.ruckig::Profile", ptr %81, i32 0, i32 0
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %82, i64 noundef 3) #4
  store double 0.000000e+00, ptr %83, align 8, !tbaa !9
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = load ptr, ptr %84, align 8, !tbaa !5
  %86 = getelementptr inbounds %"class.ruckig::Profile", ptr %85, i32 0, i32 0
  %87 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %86, i64 noundef 4) #4
  store double 0.000000e+00, ptr %87, align 8, !tbaa !9
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  %89 = load ptr, ptr %88, align 8, !tbaa !5
  %90 = getelementptr inbounds %"class.ruckig::Profile", ptr %89, i32 0, i32 0
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %90, i64 noundef 5) #4
  store double 0.000000e+00, ptr %91, align 8, !tbaa !9
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = getelementptr inbounds %"class.ruckig::Profile", ptr %93, i32 0, i32 0
  %95 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %94, i64 noundef 6) #4
  store double 0.000000e+00, ptr %95, align 8, !tbaa !9
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = load ptr, ptr %96, align 8, !tbaa !5
  %98 = load double, ptr %12, align 8, !tbaa !9
  %99 = load double, ptr %13, align 8, !tbaa !9
  %100 = load double, ptr %10, align 8, !tbaa !9
  %101 = load double, ptr %11, align 8, !tbaa !9
  %102 = call noundef zeroext i1 @_ZN6ruckig7Profile22check_for_second_orderILNS0_12ControlSignsE0ELNS0_13ReachedLimitsE2EEEbdddd(ptr noundef nonnull align 8 dereferenceable(572) %97, double noundef %98, double noundef %99, double noundef %100, double noundef %101)
  br i1 %102, label %103, label %105

103:                                              ; preds = %7
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZNK6ruckig24PositionSecondOrderStep111add_profileERPNS_7ProfileE(ptr noundef nonnull align 8 dereferenceable(1784) %16, ptr noundef nonnull align 8 dereferenceable(8) %104)
  br label %105

105:                                              ; preds = %103, %7
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6ruckig7Profile22check_for_second_orderILNS0_12ControlSignsE0ELNS0_13ReachedLimitsE2EEEbdddd(ptr noundef nonnull align 8 dereferenceable(572), double noundef, double noundef, double noundef, double noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6ruckig24PositionSecondOrderStep111add_profileERPNS_7ProfileE(ptr noundef nonnull align 8 dereferenceable(1784), ptr noundef nonnull align 8 dereferenceable(8)) #3 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN6ruckig24PositionSecondOrderStep1E", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !15, i64 56}
!15 = !{!"_ZTSSt5arrayIN6ruckig7ProfileELm3EE", !7, i64 0}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !10, i64 48}


; 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 void @_ZNK6ruckig24PositionSecondOrderStep19time_acc0ERPNS_7ProfileEddddb(ptr noundef nonnull align 8 dereferenceable(1784) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, i1 noundef zeroext %6) local_unnamed_addr #0 align 2 {
  %8 = load double, ptr %0, align 8, !tbaa !5
  %9 = fsub double %2, %8
  %10 = fdiv double %9, %4
  %11 = load ptr, ptr %1, align 8, !tbaa !11
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %11, i64 noundef 0) #4
  store double %10, ptr %12, align 8, !tbaa !13
  %13 = load double, ptr %0, align 8, !tbaa !5
  %14 = fmul double %13, %5
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !14
  %17 = fneg double %16
  %18 = fmul double %17, %4
  %19 = fmul double %16, %18
  %20 = tail call double @llvm.fmuladd.f64(double %14, double %13, double %19)
  %21 = fmul double %4, 2.000000e+00
  %22 = fmul double %21, %5
  %23 = fmul double %22, %2
  %24 = fdiv double %20, %23
  %25 = fsub double %4, %5
  %26 = fmul double %25, %2
  %27 = getelementptr inbounds i8, ptr %0, i64 48
  %28 = load <2 x double>, ptr %27, align 8
  %29 = insertelement <2 x double> %28, double %26, i64 1
  %30 = insertelement <2 x double> poison, double %2, i64 0
  %31 = insertelement <2 x double> %30, double %22, i64 1
  %32 = fdiv <2 x double> %29, %31
  %33 = extractelement <2 x double> %32, i64 1
  %34 = fadd double %33, %24
  %35 = extractelement <2 x double> %32, i64 0
  %36 = fadd double %35, %34
  %37 = load ptr, ptr %1, align 8, !tbaa !11
  %38 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %37, i64 noundef 1) #4
  store double %36, ptr %38, align 8, !tbaa !13
  %39 = load double, ptr %15, align 8, !tbaa !14
  %40 = fsub double %39, %2
  %41 = fdiv double %40, %5
  %42 = load ptr, ptr %1, align 8, !tbaa !11
  %43 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %42, i64 noundef 2) #4
  store double %41, ptr %43, align 8, !tbaa !13
  %44 = load ptr, ptr %1, align 8, !tbaa !11
  %45 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %44, i64 noundef 3) #4
  store double 0.000000e+00, ptr %45, align 8, !tbaa !13
  %46 = load ptr, ptr %1, align 8, !tbaa !11
  %47 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %46, i64 noundef 4) #4
  store double 0.000000e+00, ptr %47, align 8, !tbaa !13
  %48 = load ptr, ptr %1, align 8, !tbaa !11
  %49 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %48, i64 noundef 5) #4
  store double 0.000000e+00, ptr %49, align 8, !tbaa !13
  %50 = load ptr, ptr %1, align 8, !tbaa !11
  %51 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56) %50, i64 noundef 6) #4
  store double 0.000000e+00, ptr %51, align 8, !tbaa !13
  %52 = load ptr, ptr %1, align 8, !tbaa !11
  %53 = tail call noundef zeroext i1 @_ZN6ruckig7Profile22check_for_second_orderILNS0_12ControlSignsE0ELNS0_13ReachedLimitsE2EEEbdddd(ptr noundef nonnull align 8 dereferenceable(572) %52, double noundef %4, double noundef %5, double noundef %2, double noundef %3)
  br i1 %53, label %54, label %55

54:                                               ; preds = %7
  tail call void @_ZNK6ruckig24PositionSecondOrderStep111add_profileERPNS_7ProfileE(ptr noundef nonnull align 8 dereferenceable(1784) %0, ptr noundef nonnull align 8 dereferenceable(8) %1)
  br label %55

55:                                               ; preds = %54, %7
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm7EEixEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6ruckig7Profile22check_for_second_orderILNS0_12ControlSignsE0ELNS0_13ReachedLimitsE2EEEbdddd(ptr noundef nonnull align 8 dereferenceable(572), double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6ruckig24PositionSecondOrderStep111add_profileERPNS_7ProfileE(ptr noundef nonnull align 8 dereferenceable(1784), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTSN6ruckig24PositionSecondOrderStep1E", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt5arrayIN6ruckig7ProfileELm3EE", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 8}


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