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

; 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.DubinsIntermediateResults = type { double, double, double, double, double, double, double, double, double }
%struct.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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z27dubins_intermediate_resultsP25DubinsIntermediateResultsPdS1_d(ptr noundef, ptr noundef, ptr noundef, double noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z11dubins_pathP10DubinsPathPdS1_d14DubinsPathType(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3, i32 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.DubinsIntermediateResults, align 8
  %13 = alloca [3 x double], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store double %3, ptr %9, align 8, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr %12) #3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load double, ptr %9, align 8, !tbaa !9
  %17 = call noundef i32 @_Z27dubins_intermediate_resultsP25DubinsIntermediateResultsPdS1_d(ptr noundef %12, ptr noundef %14, ptr noundef %15, double noundef %16)
  store i32 %17, ptr %11, align 4, !tbaa !13
  %18 = load i32, ptr %11, align 4, !tbaa !13
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %67

20:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  %21 = load i32, ptr %10, align 4, !tbaa !11
  %22 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %23 = call noundef i32 @_Z11dubins_wordP25DubinsIntermediateResults14DubinsPathTypePd(ptr noundef %12, i32 noundef %21, ptr noundef %22)
  store i32 %23, ptr %11, align 4, !tbaa !13
  %24 = load i32, ptr %11, align 4, !tbaa !13
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %66

26:                                               ; preds = %20
  %27 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %28 = load double, ptr %27, align 16, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.DubinsPath, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds [3 x double], ptr %30, i64 0, i64 0
  store double %28, ptr %31, align 8, !tbaa !9
  %32 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 1
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.DubinsPath, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds [3 x double], ptr %35, i64 0, i64 1
  store double %33, ptr %36, align 8, !tbaa !9
  %37 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 2
  %38 = load double, ptr %37, align 16, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DubinsPath, ptr %39, i32 0, i32 1
  %41 = getelementptr inbounds [3 x double], ptr %40, i64 0, i64 2
  store double %38, ptr %41, align 8, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds double, ptr %42, i64 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.DubinsPath, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds [3 x double], ptr %46, i64 0, i64 0
  store double %44, ptr %47, align 8, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %48, i64 1
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.DubinsPath, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds [3 x double], ptr %52, i64 0, i64 1
  store double %50, ptr %53, align 8, !tbaa !9
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %54, i64 2
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.DubinsPath, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [3 x double], ptr %58, i64 0, i64 2
  store double %56, ptr %59, align 8, !tbaa !9
  %60 = load double, ptr %9, align 8, !tbaa !9
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.DubinsPath, ptr %61, i32 0, i32 2
  store double %60, ptr %62, align 8, !tbaa !15
  %63 = load i32, ptr %10, align 4, !tbaa !11
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.DubinsPath, ptr %64, i32 0, i32 3
  store i32 %63, ptr %65, align 8, !tbaa !17
  br label %66

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

67:                                               ; preds = %66, %5
  %68 = load i32, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 72, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %68
}

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

%struct.DubinsIntermediateResults = type { double, double, double, double, double, double, double, double, double }

; 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 nounwind uwtable
declare dso_local noundef i32 @_Z27dubins_intermediate_resultsP25DubinsIntermediateResultsPdS1_d(ptr noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #1

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

; 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
define dso_local noundef i32 @_Z11dubins_pathP10DubinsPathPdS1_d14DubinsPathType(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr noundef %2, double noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %struct.DubinsIntermediateResults, align 8
  %7 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %6) #2
  %8 = call noundef i32 @_Z27dubins_intermediate_resultsP25DubinsIntermediateResultsPdS1_d(ptr noundef nonnull %6, ptr noundef %1, ptr noundef %2, double noundef %3)
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %29

10:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #2
  %11 = call noundef i32 @_Z11dubins_wordP25DubinsIntermediateResults14DubinsPathTypePd(ptr noundef nonnull %6, i32 noundef %4, ptr noundef nonnull %7)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %28

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load <2 x double>, ptr %7, align 16, !tbaa !5
  store <2 x double> %15, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %7, i64 16
  %17 = load double, ptr %16, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  store double %17, ptr %18, align 8, !tbaa !5
  %19 = load double, ptr %1, align 8, !tbaa !5
  store double %19, ptr %0, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  store double %21, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 16
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  store double %24, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 48
  store double %3, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %4, ptr %27, align 8, !tbaa !12
  br label %28

28:                                               ; preds = %13, %10
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #2
  br label %29

29:                                               ; preds = %28, %5
  %.0 = phi i32 [ %11, %28 ], [ %8, %5 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %6) #2
  ret i32 %.0
}

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 = { 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, !6, i64 48}
!10 = !{!"_ZTS10DubinsPath", !7, i64 0, !7, i64 24, !6, i64 48, !11, i64 56}
!11 = !{!"_ZTS14DubinsPathType", !7, i64 0}
!12 = !{!10, !11, i64 56}


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