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

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

@.str = external hidden unnamed_addr constant [48 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__._ZN11HybridAStar14dubins_segmentEdPdS0_i = external hidden unnamed_addr constant [66 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store double %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %17, label %11

11:                                               ; preds = %4
  %12 = load i32, ptr %8, align 4, !tbaa !11
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %17, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %8, align 4, !tbaa !11
  %16 = icmp eq i32 %15, 2
  br label %17

17:                                               ; preds = %14, %11, %4
  %18 = phi i1 [ true, %11 ], [ true, %4 ], [ %16, %14 ]
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  br label %22

20:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 248, ptr noundef @__PRETTY_FUNCTION__._ZN11HybridAStar14dubins_segmentEdPdS0_i) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = load i32, ptr %8, align 4, !tbaa !11
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %67

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds double, ptr %26, i64 0
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds double, ptr %29, i64 2
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = load double, ptr %5, align 8, !tbaa !5
  %33 = fadd double %31, %32
  %34 = call double @sin(double noundef %33) #5
  %35 = fadd double %28, %34
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds double, ptr %36, i64 2
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = call double @sin(double noundef %38) #5
  %40 = fsub double %35, %39
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = getelementptr inbounds double, ptr %41, i64 0
  store double %40, ptr %42, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !9
  %44 = getelementptr inbounds double, ptr %43, i64 1
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = getelementptr inbounds double, ptr %46, i64 2
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = load double, ptr %5, align 8, !tbaa !5
  %50 = fadd double %48, %49
  %51 = call double @cos(double noundef %50) #5
  %52 = fsub double %45, %51
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %53, i64 2
  %55 = load double, ptr %54, align 8, !tbaa !5
  %56 = call double @cos(double noundef %55) #5
  %57 = fadd double %52, %56
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  %59 = getelementptr inbounds double, ptr %58, i64 1
  store double %57, ptr %59, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !9
  %61 = getelementptr inbounds double, ptr %60, i64 2
  %62 = load double, ptr %61, align 8, !tbaa !5
  %63 = load double, ptr %5, align 8, !tbaa !5
  %64 = fadd double %62, %63
  %65 = load ptr, ptr %7, align 8, !tbaa !9
  %66 = getelementptr inbounds double, ptr %65, i64 2
  store double %64, ptr %66, align 8, !tbaa !5
  br label %145

67:                                               ; preds = %22
  %68 = load i32, ptr %8, align 4, !tbaa !11
  %69 = icmp eq i32 %68, 2
  br i1 %69, label %70, label %112

70:                                               ; preds = %67
  %71 = load ptr, ptr %6, align 8, !tbaa !9
  %72 = getelementptr inbounds double, ptr %71, i64 0
  %73 = load double, ptr %72, align 8, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !9
  %75 = getelementptr inbounds double, ptr %74, i64 2
  %76 = load double, ptr %75, align 8, !tbaa !5
  %77 = load double, ptr %5, align 8, !tbaa !5
  %78 = fsub double %76, %77
  %79 = call double @sin(double noundef %78) #5
  %80 = fsub double %73, %79
  %81 = load ptr, ptr %6, align 8, !tbaa !9
  %82 = getelementptr inbounds double, ptr %81, i64 2
  %83 = load double, ptr %82, align 8, !tbaa !5
  %84 = call double @sin(double noundef %83) #5
  %85 = fadd double %80, %84
  %86 = load ptr, ptr %7, align 8, !tbaa !9
  %87 = getelementptr inbounds double, ptr %86, i64 0
  store double %85, ptr %87, align 8, !tbaa !5
  %88 = load ptr, ptr %6, align 8, !tbaa !9
  %89 = getelementptr inbounds double, ptr %88, i64 1
  %90 = load double, ptr %89, align 8, !tbaa !5
  %91 = load ptr, ptr %6, align 8, !tbaa !9
  %92 = getelementptr inbounds double, ptr %91, i64 2
  %93 = load double, ptr %92, align 8, !tbaa !5
  %94 = load double, ptr %5, align 8, !tbaa !5
  %95 = fsub double %93, %94
  %96 = call double @cos(double noundef %95) #5
  %97 = fadd double %90, %96
  %98 = load ptr, ptr %6, align 8, !tbaa !9
  %99 = getelementptr inbounds double, ptr %98, i64 2
  %100 = load double, ptr %99, align 8, !tbaa !5
  %101 = call double @cos(double noundef %100) #5
  %102 = fsub double %97, %101
  %103 = load ptr, ptr %7, align 8, !tbaa !9
  %104 = getelementptr inbounds double, ptr %103, i64 1
  store double %102, ptr %104, align 8, !tbaa !5
  %105 = load ptr, ptr %6, align 8, !tbaa !9
  %106 = getelementptr inbounds double, ptr %105, i64 2
  %107 = load double, ptr %106, align 8, !tbaa !5
  %108 = load double, ptr %5, align 8, !tbaa !5
  %109 = fsub double %107, %108
  %110 = load ptr, ptr %7, align 8, !tbaa !9
  %111 = getelementptr inbounds double, ptr %110, i64 2
  store double %109, ptr %111, align 8, !tbaa !5
  br label %144

112:                                              ; preds = %67
  %113 = load i32, ptr %8, align 4, !tbaa !11
  %114 = icmp eq i32 %113, 1
  br i1 %114, label %115, label %143

115:                                              ; preds = %112
  %116 = load ptr, ptr %6, align 8, !tbaa !9
  %117 = getelementptr inbounds double, ptr %116, i64 0
  %118 = load double, ptr %117, align 8, !tbaa !5
  %119 = load ptr, ptr %6, align 8, !tbaa !9
  %120 = getelementptr inbounds double, ptr %119, i64 2
  %121 = load double, ptr %120, align 8, !tbaa !5
  %122 = call double @cos(double noundef %121) #5
  %123 = load double, ptr %5, align 8, !tbaa !5
  %124 = call double @llvm.fmuladd.f64(double %122, double %123, double %118)
  %125 = load ptr, ptr %7, align 8, !tbaa !9
  %126 = getelementptr inbounds double, ptr %125, i64 0
  store double %124, ptr %126, align 8, !tbaa !5
  %127 = load ptr, ptr %6, align 8, !tbaa !9
  %128 = getelementptr inbounds double, ptr %127, i64 1
  %129 = load double, ptr %128, align 8, !tbaa !5
  %130 = load ptr, ptr %6, align 8, !tbaa !9
  %131 = getelementptr inbounds double, ptr %130, i64 2
  %132 = load double, ptr %131, align 8, !tbaa !5
  %133 = call double @sin(double noundef %132) #5
  %134 = load double, ptr %5, align 8, !tbaa !5
  %135 = call double @llvm.fmuladd.f64(double %133, double %134, double %129)
  %136 = load ptr, ptr %7, align 8, !tbaa !9
  %137 = getelementptr inbounds double, ptr %136, i64 1
  store double %135, ptr %137, align 8, !tbaa !5
  %138 = load ptr, ptr %6, align 8, !tbaa !9
  %139 = getelementptr inbounds double, ptr %138, i64 2
  %140 = load double, ptr %139, align 8, !tbaa !5
  %141 = load ptr, ptr %7, align 8, !tbaa !9
  %142 = getelementptr inbounds double, ptr %141, i64 2
  store double %140, ptr %142, align 8, !tbaa !5
  br label %143

143:                                              ; preds = %115, %112
  br label %144

144:                                              ; preds = %143, %70
  br label %145

145:                                              ; preds = %144, %25
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 #3 = { noreturn 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 = { noreturn nounwind }
attributes #5 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [48 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__._ZN11HybridAStar14dubins_segmentEdPdS0_i = external hidden unnamed_addr constant [66 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, i32 noundef %3) local_unnamed_addr #2 {
  %or.cond3 = icmp ult i32 %3, 3
  br i1 %or.cond3, label %.critedge, label %5

5:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 248, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11HybridAStar14dubins_segmentEdPdS0_i) #4
  unreachable

.critedge:                                        ; preds = %4
  %6 = load double, ptr %1, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  switch i32 %3, label %default.unreachable [
    i32 0, label %9
    i32 2, label %28
    i32 1, label %47
  ]

9:                                                ; preds = %.critedge
  %10 = fadd double %8, %0
  %11 = tail call double @sin(double noundef %10) #5
  %12 = fadd double %6, %11
  %13 = load double, ptr %7, align 8, !tbaa !5
  %14 = tail call double @sin(double noundef %13) #5
  %15 = fsub double %12, %14
  store double %15, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = load double, ptr %7, align 8, !tbaa !5
  %19 = fadd double %18, %0
  %20 = tail call double @cos(double noundef %19) #5
  %21 = fsub double %17, %20
  %22 = load double, ptr %7, align 8, !tbaa !5
  %23 = tail call double @cos(double noundef %22) #5
  %24 = fadd double %21, %23
  %25 = getelementptr inbounds i8, ptr %2, i64 8
  store double %24, ptr %25, align 8, !tbaa !5
  %26 = load double, ptr %7, align 8, !tbaa !5
  %27 = fadd double %26, %0
  br label %57

28:                                               ; preds = %.critedge
  %29 = fsub double %8, %0
  %30 = tail call double @sin(double noundef %29) #5
  %31 = fsub double %6, %30
  %32 = load double, ptr %7, align 8, !tbaa !5
  %33 = tail call double @sin(double noundef %32) #5
  %34 = fadd double %31, %33
  store double %34, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %1, i64 8
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = load double, ptr %7, align 8, !tbaa !5
  %38 = fsub double %37, %0
  %39 = tail call double @cos(double noundef %38) #5
  %40 = fadd double %36, %39
  %41 = load double, ptr %7, align 8, !tbaa !5
  %42 = tail call double @cos(double noundef %41) #5
  %43 = fsub double %40, %42
  %44 = getelementptr inbounds i8, ptr %2, i64 8
  store double %43, ptr %44, align 8, !tbaa !5
  %45 = load double, ptr %7, align 8, !tbaa !5
  %46 = fsub double %45, %0
  br label %57

47:                                               ; preds = %.critedge
  %48 = tail call double @cos(double noundef %8) #5
  %49 = tail call double @llvm.fmuladd.f64(double %48, double %0, double %6)
  store double %49, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %1, i64 8
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = load double, ptr %7, align 8, !tbaa !5
  %53 = tail call double @sin(double noundef %52) #5
  %54 = tail call double @llvm.fmuladd.f64(double %53, double %0, double %51)
  %55 = getelementptr inbounds i8, ptr %2, i64 8
  store double %54, ptr %55, align 8, !tbaa !5
  %56 = load double, ptr %7, align 8, !tbaa !5
  br label %57

default.unreachable:                              ; preds = %.critedge
  unreachable

57:                                               ; preds = %28, %47, %9
  %.sink = phi double [ %46, %28 ], [ %56, %47 ], [ %27, %9 ]
  %58 = getelementptr inbounds i8, ptr %2, i64 16
  store double %.sink, ptr %58, align 8, !tbaa !5
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 #3 = { noreturn 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 = { noreturn nounwind }
attributes #5 = { 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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass