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

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

52:                                               ; preds = %4
  store i32 4, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %79

53:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %54 = load double, ptr %12, align 8, !tbaa !5
  %55 = load double, ptr %13, align 8, !tbaa !5
  %56 = fsub double %54, %55
  %57 = load double, ptr %15, align 8, !tbaa !5
  %58 = call double @atan2(double noundef %56, double noundef %57) #4
  store double %58, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %59 = load double, ptr %6, align 8, !tbaa !5
  %60 = load double, ptr %18, align 8, !tbaa !5
  %61 = fsub double %59, %60
  %62 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %61)
  store double %62, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %63 = load double, ptr %16, align 8, !tbaa !5
  %64 = call double @sqrt(double noundef %63) #4
  store double %64, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %65 = load double, ptr %7, align 8, !tbaa !5
  %66 = fneg double %65
  %67 = load double, ptr %18, align 8, !tbaa !5
  %68 = fadd double %66, %67
  %69 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %68)
  store double %69, ptr %21, align 8, !tbaa !5
  %70 = load double, ptr %19, align 8, !tbaa !5
  %71 = load ptr, ptr %9, align 8, !tbaa !9
  %72 = getelementptr inbounds double, ptr %71, i64 0
  store double %70, ptr %72, align 8, !tbaa !5
  %73 = load double, ptr %20, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !9
  %75 = getelementptr inbounds double, ptr %74, i64 1
  store double %73, ptr %75, align 8, !tbaa !5
  %76 = load double, ptr %21, align 8, !tbaa !5
  %77 = load ptr, ptr %9, align 8, !tbaa !9
  %78 = getelementptr inbounds double, ptr %77, i64 2
  store double %76, ptr %78, align 8, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #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
  br label %79

79:                                               ; preds = %53, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  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
  %80 = load i32, ptr %5, align 4
  ret i32 %80
}

; 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_RSREdddPd(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 = fsub double %6, %5
  %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 %29, label %17

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

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