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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; 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 noundef i32 @_ZN11HybridAStar18dubins_path_sampleEPNS_10DubinsPathEdPd(ptr noundef, double noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11HybridAStar23dubins_path_sample_manyEPNS_10DubinsPathEPFiPddPvEdS3_(ptr noundef %0, ptr noundef %1, double noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca [3 x double], align 16
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call noundef double @_ZN11HybridAStar18dubins_path_lengthEPNS_10DubinsPathE(ptr noundef %15)
  store double %16, ptr %11, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %41, %4
  %18 = load double, ptr %10, align 8, !tbaa !9
  %19 = load double, ptr %11, align 8, !tbaa !9
  %20 = fcmp olt double %18, %19
  br i1 %20, label %21, label %42

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

33:                                               ; preds = %21
  %34 = load i32, ptr %13, align 4, !tbaa !11
  store i32 %34, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %39

35:                                               ; preds = %21
  %36 = load double, ptr %8, align 8, !tbaa !9
  %37 = load double, ptr %10, align 8, !tbaa !9
  %38 = fadd double %37, %36
  store double %38, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %14, align 4
  br label %39

39:                                               ; preds = %35, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #3
  %40 = load i32, ptr %14, align 4
  switch i32 %40, label %43 [
    i32 0, label %41
  ]

41:                                               ; preds = %39
  br label %17, !llvm.loop !13

42:                                               ; preds = %17
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %43

43:                                               ; preds = %42, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %44 = load i32, ptr %5, align 4
  ret i32 %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

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

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

; 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 noundef i32 @_ZN11HybridAStar18dubins_path_sampleEPNS_10DubinsPathEdPd(ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11HybridAStar23dubins_path_sample_manyEPNS_10DubinsPathEPFiPddPvEdS3_(ptr noundef %0, ptr nocapture noundef readonly %1, double noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca [3 x double], align 16
  %6 = tail call noundef double @_ZN11HybridAStar18dubins_path_lengthEPNS_10DubinsPathE(ptr noundef %0)
  br label %7

7:                                                ; preds = %9, %4
  %.014 = phi double [ 0.000000e+00, %4 ], [ %12, %9 ]
  %8 = fcmp olt double %.014, %6
  br i1 %8, label %9, label %13

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  %10 = call noundef i32 @_ZN11HybridAStar18dubins_path_sampleEPNS_10DubinsPathEdPd(ptr noundef %0, double noundef %.014, ptr noundef nonnull %5)
  %11 = call noundef i32 %1(ptr noundef nonnull %5, double noundef %.014, ptr noundef %3)
  %.not = icmp eq i32 %11, 0
  %12 = fadd double %.014, %2
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  br i1 %.not, label %7, label %13, !llvm.loop !5

13:                                               ; preds = %7, %9
  %.2 = phi i32 [ %11, %9 ], [ 0, %7 ]
  ret i32 %.2
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass