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

; 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_LSREdddPd(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
  %20 = 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
  %21 = load double, ptr %6, align 8, !tbaa !5
  %22 = call double @sin(double noundef %21) #4
  store double %22, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %23 = load double, ptr %7, align 8, !tbaa !5
  %24 = call double @sin(double noundef %23) #4
  store double %24, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %25 = load double, ptr %6, align 8, !tbaa !5
  %26 = call double @cos(double noundef %25) #4
  store double %26, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %27 = load double, ptr %7, align 8, !tbaa !5
  %28 = call double @cos(double noundef %27) #4
  store double %28, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %29 = load double, ptr %6, align 8, !tbaa !5
  %30 = load double, ptr %7, align 8, !tbaa !5
  %31 = fsub double %29, %30
  %32 = call double @cos(double noundef %31) #4
  store double %32, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %33 = load double, ptr %8, align 8, !tbaa !5
  %34 = load double, ptr %8, align 8, !tbaa !5
  %35 = call double @llvm.fmuladd.f64(double %33, double %34, double -2.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 = fadd double %40, %41
  %43 = call double @llvm.fmuladd.f64(double %39, double %42, double %37)
  store double %43, ptr %15, align 8, !tbaa !5
  %44 = load double, ptr %15, align 8, !tbaa !5
  %45 = fcmp olt double %44, 0.000000e+00
  br i1 %45, label %46, label %47

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

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

83:                                               ; preds = %47, %46
  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
  %84 = load i32, ptr %5, align 4
  ret i32 %84
}

; 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 @sqrt(double noundef) #3

; 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

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_LSREdddPd(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 = tail call double @llvm.fmuladd.f64(double %2, double %2, double -2.000000e+00)
  %12 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double %11)
  %13 = fmul double %2, 2.000000e+00
  %14 = fadd double %5, %6
  %15 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %12)
  %16 = fcmp olt double %15, 0.000000e+00
  br i1 %16, label %33, label %17

17:                                               ; preds = %4
  %18 = tail call double @sqrt(double noundef %15) #3
  %19 = fneg double %7
  %20 = fsub double %19, %8
  %21 = fadd double %5, %2
  %22 = fadd double %21, %6
  %23 = tail call double @atan2(double noundef %20, double noundef %22) #3
  %24 = tail call double @atan2(double noundef -2.000000e+00, double noundef %18) #3
  %25 = fsub double %23, %24
  %26 = fsub double %25, %0
  %27 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %26)
  %28 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %1)
  %29 = fsub double %25, %28
  %30 = tail call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %29)
  store double %27, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %3, i64 8
  store double %18, ptr %31, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %3, i64 16
  store double %30, ptr %32, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %4, %17
  %.0 = phi i32 [ 0, %17 ], [ 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 @sqrt(double noundef) local_unnamed_addr #2

; 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

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