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

; 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_RSLEdddPd(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 = fneg double %39
  %44 = call double @llvm.fmuladd.f64(double %43, double %42, double %37)
  store double %44, ptr %15, align 8, !tbaa !5
  %45 = load double, ptr %15, align 8, !tbaa !5
  %46 = fcmp olt double %45, 0.000000e+00
  br i1 %46, label %47, label %48

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

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

80:                                               ; preds = %48, %47
  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
  %81 = load i32, ptr %5, align 4
  ret i32 %81
}

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

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

31:                                               ; 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