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

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

@_ZN11HybridAStar12dubins_wordsE = external dso_local global [6 x ptr], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11HybridAStar22dubins_init_normalisedEdddPNS_10DubinsPathE(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 i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [3 x double], align 16
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  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) #2
  store double 0x7FF0000000000000, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 -1, ptr %11, align 4, !tbaa !11
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %67, %4
  %18 = load i32, ptr %12, align 4, !tbaa !11
  %19 = icmp slt i32 %18, 6
  br i1 %19, label %20, label %70

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %21 = load i32, ptr %12, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [6 x ptr], ptr @_ZN11HybridAStar12dubins_wordsE, i64 0, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = load double, ptr %6, align 8, !tbaa !5
  %26 = load double, ptr %7, align 8, !tbaa !5
  %27 = load double, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %29 = call noundef i32 %24(double noundef %25, double noundef %26, double noundef %27, ptr noundef %28)
  store i32 %29, ptr %14, align 4, !tbaa !11
  %30 = load i32, ptr %14, align 4, !tbaa !11
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %66

32:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %33 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %34 = load double, ptr %33, align 16, !tbaa !5
  %35 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 1
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fadd double %34, %36
  %38 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 2
  %39 = load double, ptr %38, align 16, !tbaa !5
  %40 = fadd double %37, %39
  store double %40, ptr %15, align 8, !tbaa !5
  %41 = load double, ptr %15, align 8, !tbaa !5
  %42 = load double, ptr %10, align 8, !tbaa !5
  %43 = fcmp olt double %41, %42
  br i1 %43, label %44, label %65

44:                                               ; preds = %32
  %45 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %45, ptr %11, align 4, !tbaa !11
  %46 = load double, ptr %15, align 8, !tbaa !5
  store double %46, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %48 = load double, ptr %47, align 16, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds [3 x double], ptr %50, i64 0, i64 0
  store double %48, ptr %51, align 8, !tbaa !5
  %52 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 1
  %53 = load double, ptr %52, align 8, !tbaa !5
  %54 = load ptr, ptr %9, align 8, !tbaa !9
  %55 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %54, i32 0, i32 1
  %56 = getelementptr inbounds [3 x double], ptr %55, i64 0, i64 1
  store double %53, ptr %56, align 8, !tbaa !5
  %57 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 2
  %58 = load double, ptr %57, align 16, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !9
  %60 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds [3 x double], ptr %60, i64 0, i64 2
  store double %58, ptr %61, align 8, !tbaa !5
  %62 = load i32, ptr %12, align 4, !tbaa !11
  %63 = load ptr, ptr %9, align 8, !tbaa !9
  %64 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %63, i32 0, i32 3
  store i32 %62, ptr %64, align 8, !tbaa !13
  br label %65

65:                                               ; preds = %44, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  br label %66

66:                                               ; preds = %65, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #2
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %12, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %12, align 4, !tbaa !11
  br label %17, !llvm.loop !15

70:                                               ; preds = %17
  %71 = load i32, ptr %11, align 4, !tbaa !11
  %72 = icmp eq i32 %71, -1
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  store i32 4, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %78

74:                                               ; preds = %70
  %75 = load i32, ptr %11, align 4, !tbaa !11
  %76 = load ptr, ptr %9, align 8, !tbaa !9
  %77 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %76, i32 0, i32 3
  store i32 %75, ptr %77, align 8, !tbaa !13
  store i32 0, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %78

78:                                               ; preds = %74, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %79 = load i32, ptr %5, align 4
  ret i32 %79
}

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

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

attributes #0 = { mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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}
!13 = !{!14, !12, i64 56}
!14 = !{!"_ZTSN11HybridAStar10DubinsPathE", !7, i64 0, !7, i64 24, !6, i64 48, !12, i64 56}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@_ZN11HybridAStar12dubins_wordsE = external dso_local local_unnamed_addr global [6 x ptr], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZN11HybridAStar22dubins_init_normalisedEdddPNS_10DubinsPathE(double noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = alloca [3 x double], align 16
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  %8 = getelementptr inbounds i8, ptr %3, i64 40
  %9 = getelementptr inbounds i8, ptr %3, i64 56
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #2
  %10 = load ptr, ptr @_ZN11HybridAStar12dubins_wordsE, align 16, !tbaa !5
  %11 = call noundef i32 %10(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull %5)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %21

13:                                               ; preds = %4
  %14 = load <2 x double>, ptr %5, align 16, !tbaa !9
  %shift = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %15 = fadd <2 x double> %14, %shift
  %16 = extractelement <2 x double> %15, i64 0
  %17 = load double, ptr %6, align 16, !tbaa !9
  %18 = fadd double %16, %17
  %19 = fcmp ueq double %18, 0x7FF0000000000000
  br i1 %19, label %21, label %20

20:                                               ; preds = %13
  store <2 x double> %14, ptr %7, align 8, !tbaa !9
  store double %17, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %9, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %13, %20, %4
  %.223 = phi i32 [ -1, %4 ], [ 0, %20 ], [ -1, %13 ]
  %.2 = phi double [ 0x7FF0000000000000, %4 ], [ %18, %20 ], [ 0x7FF0000000000000, %13 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #2
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11HybridAStar12dubins_wordsE, i64 8), align 8, !tbaa !5
  %23 = call noundef i32 %22(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull %5)
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %33

25:                                               ; preds = %21
  %26 = load <2 x double>, ptr %5, align 16, !tbaa !9
  %shift31 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %27 = fadd <2 x double> %26, %shift31
  %28 = extractelement <2 x double> %27, i64 0
  %29 = load double, ptr %6, align 16, !tbaa !9
  %30 = fadd double %28, %29
  %31 = fcmp olt double %30, %.2
  br i1 %31, label %32, label %33

32:                                               ; preds = %25
  store <2 x double> %26, ptr %7, align 8, !tbaa !9
  store double %29, ptr %8, align 8, !tbaa !9
  store i32 1, ptr %9, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %32, %25, %21
  %.223.1 = phi i32 [ %.223, %21 ], [ 1, %32 ], [ %.223, %25 ]
  %.2.1 = phi double [ %.2, %21 ], [ %30, %32 ], [ %.2, %25 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #2
  %34 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11HybridAStar12dubins_wordsE, i64 16), align 16, !tbaa !5
  %35 = call noundef i32 %34(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull %5)
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %45

37:                                               ; preds = %33
  %38 = load <2 x double>, ptr %5, align 16, !tbaa !9
  %shift32 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %39 = fadd <2 x double> %38, %shift32
  %40 = extractelement <2 x double> %39, i64 0
  %41 = load double, ptr %6, align 16, !tbaa !9
  %42 = fadd double %40, %41
  %43 = fcmp olt double %42, %.2.1
  br i1 %43, label %44, label %45

44:                                               ; preds = %37
  store <2 x double> %38, ptr %7, align 8, !tbaa !9
  store double %41, ptr %8, align 8, !tbaa !9
  store i32 2, ptr %9, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %44, %37, %33
  %.223.2 = phi i32 [ %.223.1, %33 ], [ 2, %44 ], [ %.223.1, %37 ]
  %.2.2 = phi double [ %.2.1, %33 ], [ %42, %44 ], [ %.2.1, %37 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #2
  %46 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11HybridAStar12dubins_wordsE, i64 24), align 8, !tbaa !5
  %47 = call noundef i32 %46(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull %5)
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %57

49:                                               ; preds = %45
  %50 = load <2 x double>, ptr %5, align 16, !tbaa !9
  %shift33 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %51 = fadd <2 x double> %50, %shift33
  %52 = extractelement <2 x double> %51, i64 0
  %53 = load double, ptr %6, align 16, !tbaa !9
  %54 = fadd double %52, %53
  %55 = fcmp olt double %54, %.2.2
  br i1 %55, label %56, label %57

56:                                               ; preds = %49
  store <2 x double> %50, ptr %7, align 8, !tbaa !9
  store double %53, ptr %8, align 8, !tbaa !9
  store i32 3, ptr %9, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %56, %49, %45
  %.223.3 = phi i32 [ %.223.2, %45 ], [ 3, %56 ], [ %.223.2, %49 ]
  %.2.3 = phi double [ %.2.2, %45 ], [ %54, %56 ], [ %.2.2, %49 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #2
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11HybridAStar12dubins_wordsE, i64 32), align 16, !tbaa !5
  %59 = call noundef i32 %58(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull %5)
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %69

61:                                               ; preds = %57
  %62 = load <2 x double>, ptr %5, align 16, !tbaa !9
  %shift34 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %63 = fadd <2 x double> %62, %shift34
  %64 = extractelement <2 x double> %63, i64 0
  %65 = load double, ptr %6, align 16, !tbaa !9
  %66 = fadd double %64, %65
  %67 = fcmp olt double %66, %.2.3
  br i1 %67, label %68, label %69

68:                                               ; preds = %61
  store <2 x double> %62, ptr %7, align 8, !tbaa !9
  store double %65, ptr %8, align 8, !tbaa !9
  store i32 4, ptr %9, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %68, %61, %57
  %.223.4 = phi i32 [ %.223.3, %57 ], [ 4, %68 ], [ %.223.3, %61 ]
  %.2.4 = phi double [ %.2.3, %57 ], [ %66, %68 ], [ %.2.3, %61 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #2
  %70 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11HybridAStar12dubins_wordsE, i64 40), align 8, !tbaa !5
  %71 = call noundef i32 %70(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull %5)
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %80

73:                                               ; preds = %69
  %74 = load <2 x double>, ptr %5, align 16, !tbaa !9
  %shift35 = shufflevector <2 x double> %74, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %75 = fadd <2 x double> %74, %shift35
  %76 = extractelement <2 x double> %75, i64 0
  %77 = load double, ptr %6, align 16, !tbaa !9
  %78 = fadd double %76, %77
  %79 = fcmp olt double %78, %.2.4
  br i1 %79, label %.thread, label %80

.thread:                                          ; preds = %73
  store <2 x double> %74, ptr %7, align 8, !tbaa !9
  store double %77, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  br label %82

80:                                               ; preds = %73, %69
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #2
  %81 = icmp eq i32 %.223.4, -1
  br i1 %81, label %83, label %82

82:                                               ; preds = %.thread, %80
  %.223.530 = phi i32 [ 5, %.thread ], [ %.223.4, %80 ]
  store i32 %.223.530, ptr %9, align 8, !tbaa !11
  br label %83

83:                                               ; preds = %80, %82
  %.0 = phi i32 [ 0, %82 ], [ 4, %80 ]
  ret i32 %.0
}

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

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

attributes #0 = { mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !13, i64 56}
!12 = !{!"_ZTSN11HybridAStar10DubinsPathE", !7, i64 0, !7, i64 24, !10, i64 48, !13, i64 56}
!13 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass