; LLVM IR from karlkurzer/path_planner :: src/dubins.ll (ZN11HybridAStar10dubins_RLREdddPd)

; 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN11HybridAStar10dubins_RLREdddPd(double noundef %0, double noundef %1, double noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, 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 double, align 8
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  store double %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %20 = load double, ptr %6, align 8, !tbaa !5
  %21 = call double @sin(double noundef %20) #4
  store double %21, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %22 = load double, ptr %7, align 8, !tbaa !5
  %23 = call double @sin(double noundef %22) #4
  store double %23, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %24 = load double, ptr %6, align 8, !tbaa !5
  %25 = call double @cos(double noundef %24) #4
  store double %25, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %26 = load double, ptr %7, align 8, !tbaa !5
  %27 = call double @cos(double noundef %26) #4
  store double %27, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %28 = load double, ptr %6, align 8, !tbaa !5
  %29 = load double, ptr %7, align 8, !tbaa !5
  %30 = fsub double %28, %29
  %31 = call double @cos(double noundef %30) #4
  store double %31, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %32 = load double, ptr %8, align 8, !tbaa !5
  %33 = load double, ptr %8, align 8, !tbaa !5
  %34 = fneg double %32
  %35 = call double @llvm.fmuladd.f64(double %34, double %33, double 6.000000e+00)
  %36 = load double, ptr %14, align 8, !tbaa !5
  %37 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %36, double %35)
  %38 = load double, ptr %8, align 8, !tbaa !5
  %39 = fmul double 2.000000e+00, %38
  %40 = load double, ptr %10, align 8, !tbaa !5
  %41 = load double, ptr %11, align 8, !tbaa !5
  %42 = fsub double %40, %41
  %43 = call double @llvm.fmuladd.f64(double %39, double %42, double %37)
  %44 = fdiv double %43, 8.000000e+00
  store double %44, ptr %15, align 8, !tbaa !5
  %45 = load double, ptr %15, align 8, !tbaa !5
  %46 = call double @llvm.fabs.f64(double %45)
  %47 = fcmp ogt double %46, 1.000000e+00
  br i1 %47, label %48, label %49

48:                                               ; preds = %4
  store i32 4, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %88

49:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %50 = load double, ptr %15, align 8, !tbaa !5
  %51 = call double @acos(double noundef %50) #4
  %52 = fsub double 0x401921FB54442D18, %51
  %53 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %52)
  store double %53, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %54 = load double, ptr %6, align 8, !tbaa !5
  %55 = load double, ptr %12, align 8, !tbaa !5
  %56 = load double, ptr %13, align 8, !tbaa !5
  %57 = fsub double %55, %56
  %58 = load double, ptr %8, align 8, !tbaa !5
  %59 = load double, ptr %10, align 8, !tbaa !5
  %60 = fsub double %58, %59
  %61 = load double, ptr %11, align 8, !tbaa !5
  %62 = fadd double %60, %61
  %63 = call double @atan2(double noundef %57, double noundef %62) #4
  %64 = fsub double %54, %63
  %65 = load double, ptr %17, align 8, !tbaa !5
  %66 = fdiv double %65, 2.000000e+00
  %67 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %66)
  %68 = fadd double %64, %67
  %69 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %68)
  store double %69, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %70 = load double, ptr %6, align 8, !tbaa !5
  %71 = load double, ptr %7, align 8, !tbaa !5
  %72 = fsub double %70, %71
  %73 = load double, ptr %18, align 8, !tbaa !5
  %74 = fsub double %72, %73
  %75 = load double, ptr %17, align 8, !tbaa !5
  %76 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %75)
  %77 = fadd double %74, %76
  %78 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %77)
  store double %78, ptr %19, align 8, !tbaa !5
  %79 = load double, ptr %18, align 8, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !9
  %81 = getelementptr inbounds double, ptr %80, i64 0
  store double %79, ptr %81, align 8, !tbaa !5
  %82 = load double, ptr %17, align 8, !tbaa !5
  %83 = load ptr, ptr %9, align 8, !tbaa !9
  %84 = getelementptr inbounds double, ptr %83, i64 1
  store double %82, ptr %84, align 8, !tbaa !5
  %85 = load double, ptr %19, align 8, !tbaa !5
  %86 = load ptr, ptr %9, align 8, !tbaa !9
  %87 = getelementptr inbounds double, ptr %86, i64 2
  store double %85, ptr %87, align 8, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %88

88:                                               ; preds = %49, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %89 = load i32, ptr %5, align 4
  ret i32 %89
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11HybridAStar6mod2piEd(double noundef) #0

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

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

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #3

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

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

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

; Function Attrs: nounwind
declare double @acos(double noundef) #3

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) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, 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
define dso_local noundef range(i32 0, 5) i32 @_ZN11HybridAStar10dubins_RLREdddPd(double noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = tail call double @sin(double noundef %0) #3
  %6 = tail call double @sin(double noundef %1) #3
  %7 = tail call double @cos(double noundef %0) #3
  %8 = tail call double @cos(double noundef %1) #3
  %9 = fsub double %0, %1
  %10 = tail call double @cos(double noundef %9) #3
  %11 = fneg double %2
  %12 = tail call double @llvm.fmuladd.f64(double %11, double %2, double 6.000000e+00)
  %13 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double %12)
  %14 = fmul double %2, 2.000000e+00
  %15 = fsub double %5, %6
  %16 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %13)
  %17 = fmul double %16, 1.250000e-01
  %18 = tail call double @llvm.fabs.f64(double %17)
  %19 = fcmp ogt double %18, 1.000000e+00
  br i1 %19, label %39, label %20

20:                                               ; preds = %4
  %21 = tail call double @acos(double noundef %17) #3
  %22 = fsub double 0x401921FB54442D18, %21
  %23 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %22)
  %24 = fsub double %7, %8
  %25 = fsub double %2, %5
  %26 = fadd double %25, %6
  %27 = tail call double @atan2(double noundef %24, double noundef %26) #3
  %28 = fsub double %0, %27
  %29 = fmul double %23, 5.000000e-01
  %30 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %29)
  %31 = fadd double %28, %30
  %32 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %31)
  %33 = fsub double %9, %32
  %34 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %23)
  %35 = fadd double %33, %34
  %36 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %35)
  store double %32, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %3, i64 8
  store double %23, ptr %37, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %3, i64 16
  store double %36, ptr %38, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %4, %20
  %.0 = phi i32 [ 0, %20 ], [ 4, %4 ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11HybridAStar6mod2piEd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #2

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

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

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

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

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


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