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

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

; 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
define dso_local noundef i32 @_ZN11HybridAStar22dubins_extract_subpathEPNS_10DubinsPathEdS1_(ptr noundef %0, double noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load double, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %9, i32 0, i32 2
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = fdiv double %8, %11
  store double %12, ptr %7, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds [3 x double], ptr %18, i64 0, i64 0
  store double %16, ptr %19, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds [3 x double], ptr %21, i64 0, i64 1
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds [3 x double], ptr %25, i64 0, i64 1
  store double %23, ptr %26, align 8, !tbaa !9
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds [3 x double], ptr %28, i64 0, i64 2
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = load ptr, ptr %6, 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
  store double %30, ptr %33, align 8, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %34, i32 0, i32 2
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %37, i32 0, i32 2
  store double %36, ptr %38, align 8, !tbaa !11
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 8, !tbaa !14
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %42, i32 0, i32 3
  store i32 %41, ptr %43, align 8, !tbaa !14
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds [3 x double], ptr %45, i64 0, i64 0
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = load double, ptr %7, align 8, !tbaa !9
  %49 = call double @llvm.minnum.f64(double %47, double %48)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds [3 x double], ptr %51, i64 0, i64 0
  store double %49, ptr %52, align 8, !tbaa !9
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds [3 x double], ptr %54, i64 0, i64 1
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = load double, ptr %7, align 8, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %58, i32 0, i32 1
  %60 = getelementptr inbounds [3 x double], ptr %59, i64 0, i64 0
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = fsub double %57, %61
  %63 = call double @llvm.minnum.f64(double %56, double %62)
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %64, i32 0, i32 1
  %66 = getelementptr inbounds [3 x double], ptr %65, i64 0, i64 1
  store double %63, ptr %66, align 8, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %67, i32 0, i32 1
  %69 = getelementptr inbounds [3 x double], ptr %68, i64 0, i64 2
  %70 = load double, ptr %69, align 8, !tbaa !9
  %71 = load double, ptr %7, align 8, !tbaa !9
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %72, i32 0, i32 1
  %74 = getelementptr inbounds [3 x double], ptr %73, i64 0, i64 0
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = fsub double %71, %75
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %77, i32 0, i32 1
  %79 = getelementptr inbounds [3 x double], ptr %78, i64 0, i64 1
  %80 = load double, ptr %79, align 8, !tbaa !9
  %81 = fsub double %76, %80
  %82 = call double @llvm.minnum.f64(double %70, double %81)
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.HybridAStar::DubinsPath", ptr %83, i32 0, i32 1
  %85 = getelementptr inbounds [3 x double], ptr %84, i64 0, i64 2
  store double %82, ptr %85, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @_ZN11HybridAStar22dubins_extract_subpathEPNS_10DubinsPathEdS1_(ptr nocapture noundef readonly %0, double noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fdiv double %1, %5
  %7 = load double, ptr %0, align 8, !tbaa !11
  store double %7, ptr %2, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  store double %9, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load double, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %2, i64 16
  store double %12, ptr %13, align 8, !tbaa !11
  %14 = load double, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 48
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = load i32, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %2, i64 56
  store i32 %17, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = tail call double @llvm.minnum.f64(double %20, double %6)
  %22 = getelementptr inbounds i8, ptr %2, i64 24
  store double %21, ptr %22, align 8, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = fsub double %6, %21
  %26 = tail call double @llvm.minnum.f64(double %24, double %25)
  %27 = getelementptr inbounds i8, ptr %2, i64 32
  store double %26, ptr %27, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = fsub double %25, %26
  %31 = tail call double @llvm.minnum.f64(double %29, double %30)
  %32 = getelementptr inbounds i8, ptr %2, i64 40
  store double %31, ptr %32, align 8, !tbaa !11
  ret i32 0
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 speculatable willreturn memory(none) }

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


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