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

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

%"struct.HybridAStar::DubinsPath" = type { [3 x double], [3 x double], double, i32 }

@_ZN11HybridAStarL7DIRDATAE = external hidden constant [6 x [3 x i32]], align 16

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11HybridAStar6mod2piEd(double noundef) #1

; 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: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11HybridAStar18dubins_path_lengthEPNS_10DubinsPathE(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef, ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN11HybridAStar18dubins_path_sampleEPNS_10DubinsPathEdPd(ptr noundef %0, double noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca [3 x double], align 16
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca [3 x double], align 16
  %14 = alloca [3 x double], align 16
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %15 = load double, ptr %6, align 8, !tbaa !9
  %16 = fcmp olt double %15, 0.000000e+00
  br i1 %16, label %22, label %17

17:                                               ; preds = %3
  %18 = load double, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call noundef double @_ZN11HybridAStar18dubins_path_lengthEPNS_10DubinsPathE(ptr noundef %19)
  %21 = fcmp oge double %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %17, %3
  store i32 2, ptr %4, align 4
  br label %131

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %24 = load double, ptr %6, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %25, i32 0, i32 2
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = fdiv double %24, %27
  store double %28, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  %29 = getelementptr inbounds double, ptr %9, i64 1
  store double 0.000000e+00, ptr %29, align 8, !tbaa !9
  %30 = getelementptr inbounds double, ptr %9, i64 2
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [3 x double], ptr %32, i64 0, i64 2
  %34 = load double, ptr %33, align 8, !tbaa !9
  store double %34, ptr %30, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 8, !tbaa !14
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [6 x [3 x i32]], ptr @_ZN11HybridAStarL7DIRDATAE, i64 0, i64 %38
  %40 = getelementptr inbounds [3 x i32], ptr %39, i64 0, i64 0
  store ptr %40, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds [3 x double], ptr %42, i64 0, i64 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  store double %44, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds [3 x double], ptr %46, i64 0, i64 1
  %48 = load double, ptr %47, align 8, !tbaa !9
  store double %48, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #3
  %49 = load double, ptr %11, align 8, !tbaa !9
  %50 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  %51 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = getelementptr inbounds i32, ptr %52, i64 0
  %54 = load i32, ptr %53, align 4, !tbaa !15
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %49, ptr noundef %50, ptr noundef %51, i32 noundef %54)
  %55 = load double, ptr %12, align 8, !tbaa !9
  %56 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %57 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds i32, ptr %58, i64 1
  %60 = load i32, ptr %59, align 4, !tbaa !15
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %55, ptr noundef %56, ptr noundef %57, i32 noundef %60)
  %61 = load double, ptr %8, align 8, !tbaa !9
  %62 = load double, ptr %11, align 8, !tbaa !9
  %63 = fcmp olt double %61, %62
  br i1 %63, label %64, label %71

64:                                               ; preds = %23
  %65 = load double, ptr %8, align 8, !tbaa !9
  %66 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds i32, ptr %68, i64 0
  %70 = load i32, ptr %69, align 4, !tbaa !15
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %65, ptr noundef %66, ptr noundef %67, i32 noundef %70)
  br label %98

71:                                               ; preds = %23
  %72 = load double, ptr %8, align 8, !tbaa !9
  %73 = load double, ptr %11, align 8, !tbaa !9
  %74 = load double, ptr %12, align 8, !tbaa !9
  %75 = fadd double %73, %74
  %76 = fcmp olt double %72, %75
  br i1 %76, label %77, label %86

77:                                               ; preds = %71
  %78 = load double, ptr %8, align 8, !tbaa !9
  %79 = load double, ptr %11, align 8, !tbaa !9
  %80 = fsub double %78, %79
  %81 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = getelementptr inbounds i32, ptr %83, i64 1
  %85 = load i32, ptr %84, align 4, !tbaa !15
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %80, ptr noundef %81, ptr noundef %82, i32 noundef %85)
  br label %97

86:                                               ; preds = %71
  %87 = load double, ptr %8, align 8, !tbaa !9
  %88 = load double, ptr %11, align 8, !tbaa !9
  %89 = fsub double %87, %88
  %90 = load double, ptr %12, align 8, !tbaa !9
  %91 = fsub double %89, %90
  %92 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = getelementptr inbounds i32, ptr %94, i64 2
  %96 = load i32, ptr %95, align 4, !tbaa !15
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %91, ptr noundef %92, ptr noundef %93, i32 noundef %96)
  br label %97

97:                                               ; preds = %86, %77
  br label %98

98:                                               ; preds = %97, %64
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds double, ptr %99, i64 0
  %101 = load double, ptr %100, align 8, !tbaa !9
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %102, i32 0, i32 2
  %104 = load double, ptr %103, align 8, !tbaa !11
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %105, i32 0, i32 0
  %107 = getelementptr inbounds [3 x double], ptr %106, i64 0, i64 0
  %108 = load double, ptr %107, align 8, !tbaa !9
  %109 = call double @llvm.fmuladd.f64(double %101, double %104, double %108)
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds double, ptr %110, i64 0
  store double %109, ptr %111, align 8, !tbaa !9
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = getelementptr inbounds double, ptr %112, i64 1
  %114 = load double, ptr %113, align 8, !tbaa !9
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %115, i32 0, i32 2
  %117 = load double, ptr %116, align 8, !tbaa !11
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %118, i32 0, i32 0
  %120 = getelementptr inbounds [3 x double], ptr %119, i64 0, i64 1
  %121 = load double, ptr %120, align 8, !tbaa !9
  %122 = call double @llvm.fmuladd.f64(double %114, double %117, double %121)
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds double, ptr %123, i64 1
  store double %122, ptr %124, align 8, !tbaa !9
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = getelementptr inbounds double, ptr %125, i64 2
  %127 = load double, ptr %126, align 8, !tbaa !9
  %128 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %127)
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = getelementptr inbounds double, ptr %129, i64 2
  store double %128, ptr %130, align 8, !tbaa !9
  store i32 0, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %131

131:                                              ; preds = %98, %22
  %132 = load i32, ptr %4, align 4
  ret i32 %132
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 48}
!12 = !{!"_ZTSN11HybridAStar10DubinsPathE", !7, i64 0, !7, i64 24, !10, i64 48, !13, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 56}
!15 = !{!13, !13, 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"

@_ZN11HybridAStarL7DIRDATAE = external hidden local_unnamed_addr constant [6 x [3 x i32]], align 16

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11HybridAStar6mod2piEd(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11HybridAStar18dubins_path_lengthEPNS_10DubinsPathE(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZN11HybridAStar18dubins_path_sampleEPNS_10DubinsPathEdPd(ptr noundef %0, double noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca [3 x double], align 16
  %5 = alloca [3 x double], align 16
  %6 = alloca [3 x double], align 16
  %7 = fcmp olt double %1, 0.000000e+00
  br i1 %7, label %54, label %8

8:                                                ; preds = %3
  %9 = tail call noundef double @_ZN11HybridAStar18dubins_path_lengthEPNS_10DubinsPathE(ptr noundef %0)
  %10 = fcmp ugt double %9, %1
  br i1 %10, label %11, label %54

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fdiv double %1, %13
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  %15 = getelementptr inbounds i8, ptr %4, i64 16
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  %17 = load double, ptr %16, align 8, !tbaa !11
  store double %17, ptr %15, align 16, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %0, i64 56
  %19 = load i32, ptr %18, align 8, !tbaa !12
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [6 x [3 x i32]], ptr @_ZN11HybridAStarL7DIRDATAE, i64 0, i64 %20
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %0, i64 32
  %25 = load double, ptr %24, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  %26 = load i32, ptr %21, align 4, !tbaa !13
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %23, ptr noundef nonnull %4, ptr noundef nonnull %5, i32 noundef %26)
  %27 = getelementptr inbounds i8, ptr %21, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !13
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %25, ptr noundef nonnull %5, ptr noundef nonnull %6, i32 noundef %28)
  %29 = fcmp olt double %14, %23
  br i1 %29, label %30, label %31

30:                                               ; preds = %11
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %14, ptr noundef nonnull %4, ptr noundef %2, i32 noundef %26)
  br label %40

31:                                               ; preds = %11
  %32 = fadd double %23, %25
  %33 = fcmp olt double %14, %32
  %34 = fsub double %14, %23
  br i1 %33, label %35, label %36

35:                                               ; preds = %31
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %34, ptr noundef nonnull %5, ptr noundef %2, i32 noundef %28)
  br label %40

36:                                               ; preds = %31
  %37 = fsub double %34, %25
  %38 = getelementptr inbounds i8, ptr %21, i64 8
  %39 = load i32, ptr %38, align 4, !tbaa !13
  call void @_ZN11HybridAStar14dubins_segmentEdPdS0_i(double noundef %37, ptr noundef nonnull %6, ptr noundef %2, i32 noundef %39)
  br label %40

40:                                               ; preds = %35, %36, %30
  %41 = load double, ptr %2, align 8, !tbaa !11
  %42 = load double, ptr %12, align 8, !tbaa !5
  %43 = load double, ptr %0, align 8, !tbaa !11
  %44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
  store double %44, ptr %2, align 8, !tbaa !11
  %45 = getelementptr inbounds i8, ptr %2, i64 8
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = load double, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %0, i64 8
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = call double @llvm.fmuladd.f64(double %46, double %47, double %49)
  store double %50, ptr %45, align 8, !tbaa !11
  %51 = getelementptr inbounds i8, ptr %2, i64 16
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = call noundef double @_ZN11HybridAStar6mod2piEd(double noundef %52)
  store double %53, ptr %51, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  br label %54

54:                                               ; preds = %3, %8, %40
  %.0 = phi i32 [ 0, %40 ], [ 2, %8 ], [ 2, %3 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !9, i64 48}
!6 = !{!"_ZTSN11HybridAStar10DubinsPathE", !7, i64 0, !7, i64 24, !9, i64 48, !10, i64 56}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"double", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!9, !9, i64 0}
!12 = !{!6, !10, i64 56}
!13 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass