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

; 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_LRLEdddPd(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 = fneg double %40
  %42 = load double, ptr %11, align 8, !tbaa !5
  %43 = fadd double %41, %42
  %44 = call double @llvm.fmuladd.f64(double %39, double %43, double %37)
  %45 = fdiv double %44, 8.000000e+00
  store double %45, ptr %15, align 8, !tbaa !5
  %46 = load double, ptr %15, align 8, !tbaa !5
  %47 = call double @llvm.fabs.f64(double %46)
  %48 = fcmp ogt double %47, 1.000000e+00
  br i1 %48, label %49, label %50

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

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

90:                                               ; preds = %50, %49
  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
  %91 = load i32, ptr %5, align 4
  ret i32 %91
}

; 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_LRLEdddPd(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 %6, %5
  %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 %41, 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 = fneg double %0
  %25 = fsub double %7, %8
  %26 = fadd double %5, %2
  %27 = fsub double %26, %6
  %28 = tail call double @atan2(double noundef %25, double noundef %27) #3
  %29 = fsub double %24, %28
  %30 = fmul double %23, 5.000000e-01
  %31 = fadd double %30, %29
  %32 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %31)
  %33 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %1)
  %34 = fsub double %33, %0
  %35 = fsub double %34, %32
  %36 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %23)
  %37 = fadd double %36, %35
  %38 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %37)
  store double %32, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %3, i64 8
  store double %23, ptr %39, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %3, i64 16
  store double %38, ptr %40, align 8, !tbaa !5
  br label %41

41:                                               ; 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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass