; LLVM IR from SakshayMahna/Robotics-Playground :: driving_ws/src/Frenet_Planner_Simulation/Frenet_Planner_AGV/frenet_planner_agv/s_4e89a619 (ZN6Spline4calcEd)

; 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.Spline = type <{ %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6Spline12search_indexEd(ptr noundef nonnull align 8 dereferenceable(172), double noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN6Spline4calcEd(ptr noundef nonnull align 8 dereferenceable(172) %0, double noundef %1) #2 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 5
  %12 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #4
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store double -1.000000e+09, ptr %3, align 8
  br label %86

15:                                               ; preds = %2
  %16 = load double, ptr %5, align 8, !tbaa !9
  %17 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 5
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef 0) #4
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fcmp olt double %16, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %15
  store double -1.000000e+09, ptr %3, align 8
  br label %86

22:                                               ; preds = %15
  %23 = load double, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 5
  %25 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 7
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %28) #4
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = fcmp ogt double %23, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %22
  store double -1.000000e+09, ptr %3, align 8
  br label %86

33:                                               ; preds = %22
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %36 = load double, ptr %5, align 8, !tbaa !9
  %37 = call noundef i32 @_ZN6Spline12search_indexEd(ptr noundef nonnull align 8 dereferenceable(172) %10, double noundef %36)
  store i32 %37, ptr %6, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 5
  %40 = load i32, ptr %6, align 4, !tbaa !18
  %41 = sext i32 %40 to i64
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %41) #4
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fsub double %38, %43
  store double %44, ptr %7, align 8, !tbaa !9
  %45 = load i32, ptr %6, align 4, !tbaa !18
  %46 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 7
  %47 = load i32, ptr %46, align 8, !tbaa !11
  %48 = sub nsw i32 %47, 1
  %49 = icmp sgt i32 %45, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %35
  store double -1.000000e+09, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %85

51:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %52 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 0
  %53 = load i32, ptr %6, align 4, !tbaa !18
  %54 = sext i32 %53 to i64
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %52, i64 noundef %54) #4
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 1
  %58 = load i32, ptr %6, align 4, !tbaa !18
  %59 = sext i32 %58 to i64
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %57, i64 noundef %59) #4
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load double, ptr %7, align 8, !tbaa !9
  %63 = call double @llvm.fmuladd.f64(double %61, double %62, double %56)
  %64 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 2
  %65 = load i32, ptr %6, align 4, !tbaa !18
  %66 = sext i32 %65 to i64
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %64, i64 noundef %66) #4
  %68 = load double, ptr %67, align 8, !tbaa !9
  %69 = load double, ptr %7, align 8, !tbaa !9
  %70 = fmul double %68, %69
  %71 = load double, ptr %7, align 8, !tbaa !9
  %72 = call double @llvm.fmuladd.f64(double %70, double %71, double %63)
  %73 = getelementptr inbounds %class.Spline, ptr %10, i32 0, i32 3
  %74 = load i32, ptr %6, align 4, !tbaa !18
  %75 = sext i32 %74 to i64
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %73, i64 noundef %75) #4
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = load double, ptr %7, align 8, !tbaa !9
  %79 = fmul double %77, %78
  %80 = load double, ptr %7, align 8, !tbaa !9
  %81 = fmul double %79, %80
  %82 = load double, ptr %7, align 8, !tbaa !9
  %83 = call double @llvm.fmuladd.f64(double %81, double %82, double %72)
  store double %83, ptr %9, align 8, !tbaa !9
  %84 = load double, ptr %9, align 8, !tbaa !9
  store double %84, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %85

85:                                               ; preds = %51, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %86

86:                                               ; preds = %85, %32, %21, %14
  %87 = load double, ptr %3, align 8
  ret double %87
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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) }
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, !17, i64 168}
!12 = !{!"_ZTS6Spline", !13, i64 0, !13, i64 24, !13, i64 48, !13, i64 72, !13, i64 96, !13, i64 120, !13, i64 144, !17, i64 168}
!13 = !{!"_ZTSSt6vectorIdSaIdEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"int", !7, i64 0}
!18 = !{!17, !17, 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6Spline12search_indexEd(ptr noundef nonnull align 8 dereferenceable(172), double 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 uwtable
define dso_local noundef double @_ZN6Spline4calcEd(ptr noundef nonnull align 8 dereferenceable(172) %0, double noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 120
  %4 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #3
  %5 = icmp eq i64 %4, 0
  br i1 %5, label %43, label %6

6:                                                ; preds = %2
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef 0) #3
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = fcmp ogt double %8, %1
  br i1 %9, label %43, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 168
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = add nsw i32 %12, -1
  %14 = sext i32 %13 to i64
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %14) #3
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp olt double %16, %1
  br i1 %17, label %43, label %18

18:                                               ; preds = %10
  %19 = tail call noundef i32 @_ZN6Spline12search_indexEd(ptr noundef nonnull align 8 dereferenceable(172) %0, double noundef %1)
  %20 = sext i32 %19 to i64
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %20) #3
  %22 = load i32, ptr %11, align 8, !tbaa !9
  %.not = icmp slt i32 %19, %22
  br i1 %.not, label %23, label %43

23:                                               ; preds = %18
  %24 = load double, ptr %21, align 8, !tbaa !5
  %25 = fsub double %1, %24
  %26 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %20) #3
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %20) #3
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = tail call double @llvm.fmuladd.f64(double %30, double %25, double %27)
  %32 = getelementptr inbounds i8, ptr %0, i64 48
  %33 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %20) #3
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fmul double %25, %34
  %36 = tail call double @llvm.fmuladd.f64(double %35, double %25, double %31)
  %37 = getelementptr inbounds i8, ptr %0, i64 72
  %38 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %20) #3
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fmul double %25, %39
  %41 = fmul double %25, %40
  %42 = tail call double @llvm.fmuladd.f64(double %41, double %25, double %36)
  br label %43

43:                                               ; preds = %23, %18, %10, %6, %2
  %.1 = phi double [ -1.000000e+09, %2 ], [ -1.000000e+09, %6 ], [ -1.000000e+09, %10 ], [ %42, %23 ], [ -1.000000e+09, %18 ]
  ret double %.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 = { 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 #2 = { mustprogress 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !16, i64 168}
!10 = !{!"_ZTS6Spline", !11, i64 0, !11, i64 24, !11, i64 48, !11, i64 72, !11, i64 96, !11, i64 120, !11, i64 144, !16, i64 168}
!11 = !{!"_ZTSSt6vectorIdSaIdEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!"int", !7, i64 0}


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