; LLVM IR from junhyeokahn/PyPnC :: pnc/planner/dubins/dubins.ll (Z18dubins_path_sampleP10DubinsPathdPd)

; 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.DubinsPath = type { [3 x double], [3 x double], double, i32 }

@_ZL7DIRDATA = 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 @_Z6mod2pid(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 @_Z18dubins_path_lengthP10DubinsPath(ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z18dubins_path_sampleP10DubinsPathdPd(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 [3 x double], align 16
  %11 = alloca [3 x double], align 16
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %16 = load double, ptr %6, align 8, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.DubinsPath, ptr %17, i32 0, i32 2
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = fdiv double %16, %19
  store double %20, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DubinsPath, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [6 x [3 x i32]], ptr @_ZL7DIRDATA, i64 0, i64 %24
  %26 = getelementptr inbounds [3 x i32], ptr %25, i64 0, i64 0
  store ptr %26, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %27 = load double, ptr %6, align 8, !tbaa !9
  %28 = fcmp olt double %27, 0.000000e+00
  br i1 %28, label %34, label %29

29:                                               ; preds = %3
  %30 = load double, ptr %6, align 8, !tbaa !9
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call noundef double @_Z18dubins_path_lengthP10DubinsPath(ptr noundef %31)
  %33 = fcmp ogt double %30, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %29, %3
  store i32 2, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %133

35:                                               ; preds = %29
  %36 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  store double 0.000000e+00, ptr %36, align 16, !tbaa !9
  %37 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 1
  store double 0.000000e+00, ptr %37, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.DubinsPath, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds [3 x double], ptr %39, i64 0, i64 2
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 2
  store double %41, ptr %42, align 16, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.DubinsPath, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds [3 x double], ptr %44, i64 0, i64 0
  %46 = load double, ptr %45, align 8, !tbaa !9
  store double %46, ptr %13, align 8, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.DubinsPath, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds [3 x double], ptr %48, i64 0, i64 1
  %50 = load double, ptr %49, align 8, !tbaa !9
  store double %50, ptr %14, align 8, !tbaa !9
  %51 = load double, ptr %13, align 8, !tbaa !9
  %52 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  %53 = getelementptr inbounds [3 x double], ptr %10, i64 0, i64 0
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds i32, ptr %54, i64 0
  %56 = load i32, ptr %55, align 4, !tbaa !15
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %51, ptr noundef %52, ptr noundef %53, i32 noundef %56)
  %57 = load double, ptr %14, align 8, !tbaa !9
  %58 = getelementptr inbounds [3 x double], ptr %10, i64 0, i64 0
  %59 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 0
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds i32, ptr %60, i64 1
  %62 = load i32, ptr %61, align 4, !tbaa !15
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %57, ptr noundef %58, ptr noundef %59, i32 noundef %62)
  %63 = load double, ptr %8, align 8, !tbaa !9
  %64 = load double, ptr %13, align 8, !tbaa !9
  %65 = fcmp olt double %63, %64
  br i1 %65, label %66, label %73

66:                                               ; preds = %35
  %67 = load double, ptr %8, align 8, !tbaa !9
  %68 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = getelementptr inbounds i32, ptr %70, i64 0
  %72 = load i32, ptr %71, align 4, !tbaa !15
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %67, ptr noundef %68, ptr noundef %69, i32 noundef %72)
  br label %100

73:                                               ; preds = %35
  %74 = load double, ptr %8, align 8, !tbaa !9
  %75 = load double, ptr %13, align 8, !tbaa !9
  %76 = load double, ptr %14, align 8, !tbaa !9
  %77 = fadd double %75, %76
  %78 = fcmp olt double %74, %77
  br i1 %78, label %79, label %88

79:                                               ; preds = %73
  %80 = load double, ptr %8, align 8, !tbaa !9
  %81 = load double, ptr %13, align 8, !tbaa !9
  %82 = fsub double %80, %81
  %83 = getelementptr inbounds [3 x double], ptr %10, i64 0, i64 0
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = getelementptr inbounds i32, ptr %85, i64 1
  %87 = load i32, ptr %86, align 4, !tbaa !15
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %82, ptr noundef %83, ptr noundef %84, i32 noundef %87)
  br label %99

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

99:                                               ; preds = %88, %79
  br label %100

100:                                              ; preds = %99, %66
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds double, ptr %101, i64 0
  %103 = load double, ptr %102, align 8, !tbaa !9
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.DubinsPath, ptr %104, i32 0, i32 2
  %106 = load double, ptr %105, align 8, !tbaa !11
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.DubinsPath, ptr %107, i32 0, i32 0
  %109 = getelementptr inbounds [3 x double], ptr %108, i64 0, i64 0
  %110 = load double, ptr %109, align 8, !tbaa !9
  %111 = call double @llvm.fmuladd.f64(double %103, double %106, double %110)
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = getelementptr inbounds double, ptr %112, i64 0
  store double %111, ptr %113, align 8, !tbaa !9
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds double, ptr %114, i64 1
  %116 = load double, ptr %115, align 8, !tbaa !9
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.DubinsPath, ptr %117, i32 0, i32 2
  %119 = load double, ptr %118, align 8, !tbaa !11
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.DubinsPath, ptr %120, i32 0, i32 0
  %122 = getelementptr inbounds [3 x double], ptr %121, i64 0, i64 1
  %123 = load double, ptr %122, align 8, !tbaa !9
  %124 = call double @llvm.fmuladd.f64(double %116, double %119, double %123)
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = getelementptr inbounds double, ptr %125, i64 1
  store double %124, ptr %126, align 8, !tbaa !9
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = getelementptr inbounds double, ptr %127, i64 2
  %129 = load double, ptr %128, align 8, !tbaa !9
  %130 = call noundef double @_Z6mod2pid(double noundef %129)
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = getelementptr inbounds double, ptr %131, i64 2
  store double %130, ptr %132, align 8, !tbaa !9
  store i32 0, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %133

133:                                              ; preds = %100, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 24, 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
  %134 = load i32, ptr %4, align 4
  ret i32 %134
}

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 = !{!"_ZTS10DubinsPath", !7, i64 0, !7, i64 24, !10, i64 48, !13, i64 56}
!13 = !{!"_ZTS14DubinsPathType", !7, i64 0}
!14 = !{!12, !13, i64 56}
!15 = !{!16, !16, i64 0}
!16 = !{!"_ZTS11SegmentType", !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"

@_ZL7DIRDATA = 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 @_Z6mod2pid(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 @_Z18dubins_path_lengthP10DubinsPath(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z14dubins_segmentdPdS_11SegmentType(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 @_Z18dubins_path_sampleP10DubinsPathdPd(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 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = fdiv double %1, %8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds [6 x [3 x i32]], ptr @_ZL7DIRDATA, i64 0, i64 %12
  %14 = fcmp olt double %1, 0.000000e+00
  br i1 %14, label %54, label %15

15:                                               ; preds = %3
  %16 = tail call noundef double @_Z18dubins_path_lengthP10DubinsPath(ptr noundef nonnull %0)
  %17 = fcmp olt double %16, %1
  br i1 %17, label %54, label %18

18:                                               ; preds = %15
  %19 = 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)
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %4, i64 16
  store double %20, ptr %21, align 16, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load double, ptr %22, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %0, i64 32
  %25 = load double, ptr %24, align 8, !tbaa !12
  %26 = load i32, ptr %13, align 4, !tbaa !13
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %23, ptr noundef nonnull %4, ptr noundef nonnull %5, i32 noundef %26)
  %27 = getelementptr inbounds i8, ptr %13, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !13
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %25, ptr noundef nonnull %5, ptr noundef nonnull %6, i32 noundef %28)
  %29 = fcmp olt double %9, %23
  br i1 %29, label %30, label %31

30:                                               ; preds = %18
  call void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %9, ptr noundef nonnull %4, ptr noundef %2, i32 noundef %26)
  br label %40

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

35:                                               ; preds = %31
  call void @_Z14dubins_segmentdPdS_11SegmentType(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 %13, i64 8
  %39 = load i32, ptr %38, align 4, !tbaa !13
  call void @_Z14dubins_segmentdPdS_11SegmentType(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 !12
  %42 = load double, ptr %7, align 8, !tbaa !5
  %43 = load double, ptr %0, align 8, !tbaa !12
  %44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
  store double %44, ptr %2, align 8, !tbaa !12
  %45 = getelementptr inbounds i8, ptr %2, i64 8
  %46 = load double, ptr %45, align 8, !tbaa !12
  %47 = load double, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %0, i64 8
  %49 = load double, ptr %48, align 8, !tbaa !12
  %50 = call double @llvm.fmuladd.f64(double %46, double %47, double %49)
  store double %50, ptr %45, align 8, !tbaa !12
  %51 = getelementptr inbounds i8, ptr %2, i64 16
  %52 = load double, ptr %51, align 8, !tbaa !12
  %53 = call noundef double @_Z6mod2pid(double noundef %52)
  store double %53, ptr %51, align 8, !tbaa !12
  br label %54

54:                                               ; preds = %3, %15, %40
  %.0 = phi i32 [ 0, %40 ], [ 2, %15 ], [ 2, %3 ]
  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
  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 = !{!"_ZTS10DubinsPath", !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 = !{!"_ZTS14DubinsPathType", !7, i64 0}
!11 = !{!6, !10, i64 56}
!12 = !{!9, !9, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTS11SegmentType", !7, i64 0}


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