; LLVM IR from SakshayMahna/Robotics-Playground :: husky_ws/src/base_local_planner/src (prefer_forward_cost_function)

; 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.base_local_planner::Trajectory" = type { double, double, double, double, double, %"class.std::vector", %"class.std::vector", %"class.std::vector" }
%"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 }
%"class.base_local_planner::PreferForwardCostFunction" = type { %"class.base_local_planner::TrajectoryCostFunction", double }
%"class.base_local_planner::TrajectoryCostFunction" = type { ptr, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN18base_local_planner25PreferForwardCostFunction15scoreTrajectoryERNS_10TrajectoryE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(112) %1) unnamed_addr #0 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %"class.base_local_planner::Trajectory", ptr %7, i32 0, i32 0
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = fcmp olt double %9, 0.000000e+00
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = getelementptr inbounds %"class.base_local_planner::PreferForwardCostFunction", ptr %6, i32 0, i32 1
  %13 = load double, ptr %12, align 8, !tbaa !16
  store double %13, ptr %3, align 8
  br label %34

14:                                               ; preds = %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.base_local_planner::Trajectory", ptr %15, i32 0, i32 0
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = fcmp olt double %17, 1.000000e-01
  br i1 %18, label %19, label %28

19:                                               ; preds = %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.base_local_planner::Trajectory", ptr %20, i32 0, i32 2
  %22 = load double, ptr %21, align 8, !tbaa !19
  %23 = call double @llvm.fabs.f64(double %22)
  %24 = fcmp olt double %23, 2.000000e-01
  br i1 %24, label %25, label %28

25:                                               ; preds = %19
  %26 = getelementptr inbounds %"class.base_local_planner::PreferForwardCostFunction", ptr %6, i32 0, i32 1
  %27 = load double, ptr %26, align 8, !tbaa !16
  store double %27, ptr %3, align 8
  br label %34

28:                                               ; preds = %19, %14
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.base_local_planner::Trajectory", ptr %29, i32 0, i32 2
  %31 = load double, ptr %30, align 8, !tbaa !19
  %32 = call double @llvm.fabs.f64(double %31)
  %33 = fmul double %32, 1.000000e+01
  store double %33, ptr %3, align 8
  br label %34

34:                                               ; preds = %28, %25, %11
  %35 = load double, ptr %3, align 8
  ret double %35
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(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 = { 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, !11, i64 0}
!10 = !{!"_ZTSN18base_local_planner10TrajectoryE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !12, i64 40, !12, i64 64, !12, i64 88}
!11 = !{!"double", !7, i64 0}
!12 = !{!"_ZTSSt6vectorIdSaIdEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!17, !11, i64 16}
!17 = !{!"_ZTSN18base_local_planner25PreferForwardCostFunctionE", !18, i64 0, !11, i64 16}
!18 = !{!"_ZTSN18base_local_planner22TrajectoryCostFunctionE", !11, i64 8}
!19 = !{!10, !11, i64 16}


; 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 norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef double @_ZN18base_local_planner25PreferForwardCostFunction15scoreTrajectoryERNS_10TrajectoryE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(112) %1) unnamed_addr #0 align 2 {
  %3 = load double, ptr %1, align 8, !tbaa !5
  %4 = fcmp olt double %3, 0.000000e+00
  br i1 %4, label %5, label %8

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !15
  br label %18

8:                                                ; preds = %2
  %9 = fcmp olt double %3, 1.000000e-01
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !18
  %12 = tail call double @llvm.fabs.f64(double %11)
  %13 = fcmp olt double %12, 2.000000e-01
  %or.cond = select i1 %9, i1 %13, i1 false
  br i1 %or.cond, label %14, label %._crit_edge

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !15
  br label %18

._crit_edge:                                      ; preds = %8
  %17 = fmul double %12, 1.000000e+01
  br label %18

18:                                               ; preds = %._crit_edge, %14, %5
  %.0 = phi double [ %7, %5 ], [ %16, %14 ], [ %17, %._crit_edge ]
  ret double %.0
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 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, !7, i64 0}
!6 = !{!"_ZTSN18base_local_planner10TrajectoryE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 64, !10, i64 88}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIdSaIdEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!16, !7, i64 16}
!16 = !{!"_ZTSN18base_local_planner25PreferForwardCostFunctionE", !17, i64 0, !7, i64 16}
!17 = !{!"_ZTSN18base_local_planner22TrajectoryCostFunctionE", !7, i64 8}
!18 = !{!6, !7, i64 16}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass