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

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

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z27dubins_intermediate_resultsP25DubinsIntermediateResultsPdS1_d(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %18 = load double, ptr %9, align 8, !tbaa !9
  %19 = fcmp ole double %18, 0.000000e+00
  br i1 %19, label %20, label %21

20:                                               ; preds = %4
  store i32 3, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %102

21:                                               ; preds = %4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 0
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 0
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fsub double %24, %27
  store double %28, ptr %10, align 8, !tbaa !9
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 1
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 1
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = fsub double %31, %34
  store double %35, ptr %11, align 8, !tbaa !9
  %36 = load double, ptr %10, align 8, !tbaa !9
  %37 = load double, ptr %10, align 8, !tbaa !9
  %38 = load double, ptr %11, align 8, !tbaa !9
  %39 = load double, ptr %11, align 8, !tbaa !9
  %40 = fmul double %38, %39
  %41 = call double @llvm.fmuladd.f64(double %36, double %37, double %40)
  %42 = call double @sqrt(double noundef %41) #4
  store double %42, ptr %12, align 8, !tbaa !9
  %43 = load double, ptr %12, align 8, !tbaa !9
  %44 = load double, ptr %9, align 8, !tbaa !9
  %45 = fdiv double %43, %44
  store double %45, ptr %13, align 8, !tbaa !9
  store double 0.000000e+00, ptr %14, align 8, !tbaa !9
  %46 = load double, ptr %13, align 8, !tbaa !9
  %47 = fcmp ogt double %46, 0.000000e+00
  br i1 %47, label %48, label %53

48:                                               ; preds = %21
  %49 = load double, ptr %11, align 8, !tbaa !9
  %50 = load double, ptr %10, align 8, !tbaa !9
  %51 = call double @atan2(double noundef %49, double noundef %50) #4
  %52 = call noundef double @_Z6mod2pid(double noundef %51)
  store double %52, ptr %14, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %48, %21
  %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 double, ptr %14, align 8, !tbaa !9
  %58 = fsub double %56, %57
  %59 = call noundef double @_Z6mod2pid(double noundef %58)
  store double %59, ptr %15, align 8, !tbaa !9
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds double, ptr %60, i64 2
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = load double, ptr %14, align 8, !tbaa !9
  %64 = fsub double %62, %63
  %65 = call noundef double @_Z6mod2pid(double noundef %64)
  store double %65, ptr %16, align 8, !tbaa !9
  %66 = load double, ptr %15, align 8, !tbaa !9
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %67, i32 0, i32 0
  store double %66, ptr %68, align 8, !tbaa !11
  %69 = load double, ptr %16, align 8, !tbaa !9
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %70, i32 0, i32 1
  store double %69, ptr %71, align 8, !tbaa !13
  %72 = load double, ptr %13, align 8, !tbaa !9
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %73, i32 0, i32 2
  store double %72, ptr %74, align 8, !tbaa !14
  %75 = load double, ptr %15, align 8, !tbaa !9
  %76 = call double @sin(double noundef %75) #4
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %77, i32 0, i32 3
  store double %76, ptr %78, align 8, !tbaa !15
  %79 = load double, ptr %16, align 8, !tbaa !9
  %80 = call double @sin(double noundef %79) #4
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %81, i32 0, i32 4
  store double %80, ptr %82, align 8, !tbaa !16
  %83 = load double, ptr %15, align 8, !tbaa !9
  %84 = call double @cos(double noundef %83) #4
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %85, i32 0, i32 5
  store double %84, ptr %86, align 8, !tbaa !17
  %87 = load double, ptr %16, align 8, !tbaa !9
  %88 = call double @cos(double noundef %87) #4
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %89, i32 0, i32 6
  store double %88, ptr %90, align 8, !tbaa !18
  %91 = load double, ptr %15, align 8, !tbaa !9
  %92 = load double, ptr %16, align 8, !tbaa !9
  %93 = fsub double %91, %92
  %94 = call double @cos(double noundef %93) #4
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %95, i32 0, i32 7
  store double %94, ptr %96, align 8, !tbaa !19
  %97 = load double, ptr %13, align 8, !tbaa !9
  %98 = load double, ptr %13, align 8, !tbaa !9
  %99 = fmul double %97, %98
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %100, i32 0, i32 8
  store double %99, ptr %101, align 8, !tbaa !20
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %102

102:                                              ; preds = %53, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %103 = load i32, ptr %5, align 4
  ret i32 %103
}

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

; Function Attrs: nounwind
declare double @sin(double noundef) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #3

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 "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 #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, !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 0}
!12 = !{!"_ZTS25DubinsIntermediateResults", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !10, i64 40}
!18 = !{!12, !10, i64 48}
!19 = !{!12, !10, i64 56}
!20 = !{!12, !10, i64 64}


; 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 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 nounwind uwtable
define dso_local noundef range(i32 0, 4) i32 @_Z27dubins_intermediate_resultsP25DubinsIntermediateResultsPdS1_d(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, double noundef %3) local_unnamed_addr #1 {
  %5 = fcmp ugt double %3, 0.000000e+00
  br i1 %5, label %6, label %46

6:                                                ; preds = %4
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = load double, ptr %1, align 8, !tbaa !5
  %9 = fsub double %7, %8
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fsub double %11, %13
  %15 = fmul double %14, %14
  %16 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %15)
  %sqrt = tail call double @llvm.sqrt.f64(double %16)
  %17 = fdiv double %sqrt, %3
  %18 = fcmp ogt double %17, 0.000000e+00
  br i1 %18, label %19, label %22

19:                                               ; preds = %6
  %20 = tail call double @atan2(double noundef %14, double noundef %9) #4
  %21 = tail call noundef double @_Z6mod2pid(double noundef %20)
  br label %22

22:                                               ; preds = %19, %6
  %.038 = phi double [ %21, %19 ], [ 0.000000e+00, %6 ]
  %23 = getelementptr inbounds i8, ptr %1, i64 16
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fsub double %24, %.038
  %26 = tail call noundef double @_Z6mod2pid(double noundef %25)
  %27 = getelementptr inbounds i8, ptr %2, i64 16
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fsub double %28, %.038
  %30 = tail call noundef double @_Z6mod2pid(double noundef %29)
  store double %26, ptr %0, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  store double %30, ptr %31, align 8, !tbaa !11
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  store double %17, ptr %32, align 8, !tbaa !12
  %33 = tail call double @sin(double noundef %26) #4
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  store double %33, ptr %34, align 8, !tbaa !13
  %35 = tail call double @sin(double noundef %30) #4
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  store double %35, ptr %36, align 8, !tbaa !14
  %37 = tail call double @cos(double noundef %26) #4
  %38 = getelementptr inbounds i8, ptr %0, i64 40
  store double %37, ptr %38, align 8, !tbaa !15
  %39 = tail call double @cos(double noundef %30) #4
  %40 = getelementptr inbounds i8, ptr %0, i64 48
  store double %39, ptr %40, align 8, !tbaa !16
  %41 = fsub double %26, %30
  %42 = tail call double @cos(double noundef %41) #4
  %43 = getelementptr inbounds i8, ptr %0, i64 56
  store double %42, ptr %43, align 8, !tbaa !17
  %44 = fmul double %17, %17
  %45 = getelementptr inbounds i8, ptr %0, i64 64
  store double %44, ptr %45, align 8, !tbaa !18
  br label %46

46:                                               ; preds = %4, %22
  %.0 = phi i32 [ 0, %22 ], [ 3, %4 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #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 nofree nounwind willreturn memory(write) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS25DubinsIntermediateResults", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 32}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !6, i64 48}
!17 = !{!10, !6, i64 56}
!18 = !{!10, !6, i64 64}


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