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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z10dubins_LSLP25DubinsIntermediateResultsPd(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %10, i32 0, i32 2
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %13, i32 0, i32 3
  %15 = load double, ptr %14, align 8, !tbaa !12
  %16 = fadd double %12, %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %17, i32 0, i32 4
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = fsub double %16, %19
  store double %20, ptr %6, align 8, !tbaa !14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %21, i32 0, i32 8
  %23 = load double, ptr %22, align 8, !tbaa !15
  %24 = fadd double 2.000000e+00, %23
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %25, i32 0, i32 7
  %27 = load double, ptr %26, align 8, !tbaa !16
  %28 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %27, double %24)
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %29, i32 0, i32 2
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = fmul double 2.000000e+00, %31
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %33, i32 0, i32 3
  %35 = load double, ptr %34, align 8, !tbaa !12
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %36, i32 0, i32 4
  %38 = load double, ptr %37, align 8, !tbaa !13
  %39 = fsub double %35, %38
  %40 = call double @llvm.fmuladd.f64(double %32, double %39, double %28)
  store double %40, ptr %8, align 8, !tbaa !14
  %41 = load double, ptr %8, align 8, !tbaa !14
  %42 = fcmp oge double %41, 0.000000e+00
  br i1 %42, label %43, label %73

43:                                               ; preds = %2
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %44, i32 0, i32 6
  %46 = load double, ptr %45, align 8, !tbaa !17
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %47, i32 0, i32 5
  %49 = load double, ptr %48, align 8, !tbaa !18
  %50 = fsub double %46, %49
  %51 = load double, ptr %6, align 8, !tbaa !14
  %52 = call double @atan2(double noundef %50, double noundef %51) #4
  store double %52, ptr %7, align 8, !tbaa !14
  %53 = load double, ptr %7, align 8, !tbaa !14
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %54, i32 0, i32 0
  %56 = load double, ptr %55, align 8, !tbaa !19
  %57 = fsub double %53, %56
  %58 = call noundef double @_Z6mod2pid(double noundef %57)
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 0
  store double %58, ptr %60, align 8, !tbaa !14
  %61 = load double, ptr %8, align 8, !tbaa !14
  %62 = call double @sqrt(double noundef %61) #4
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds double, ptr %63, i64 1
  store double %62, ptr %64, align 8, !tbaa !14
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %65, i32 0, i32 1
  %67 = load double, ptr %66, align 8, !tbaa !20
  %68 = load double, ptr %7, align 8, !tbaa !14
  %69 = fsub double %67, %68
  %70 = call noundef double @_Z6mod2pid(double noundef %69)
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds double, ptr %71, i64 2
  store double %70, ptr %72, align 8, !tbaa !14
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %74

73:                                               ; preds = %2
  store i32 4, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %74

74:                                               ; preds = %73, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %75 = load i32, ptr %3, align 4
  ret i32 %75
}

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


; 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 nofree nounwind willreturn memory(write)
declare double @sqrt(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: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 5) i32 @_Z10dubins_LSLP25DubinsIntermediateResultsPd(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load double, ptr %5, align 8, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load double, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  %10 = load double, ptr %9, align 8, !tbaa !12
  %11 = fadd double %10, 2.000000e+00
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = load double, ptr %12, align 8, !tbaa !13
  %14 = tail call double @llvm.fmuladd.f64(double %13, double -2.000000e+00, double %11)
  %15 = fmul double %4, 2.000000e+00
  %16 = fsub double %6, %8
  %17 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %14)
  %18 = fcmp ult double %17, 0.000000e+00
  br i1 %18, label %38, label %19

19:                                               ; preds = %2
  %20 = fadd double %4, %6
  %21 = fsub double %20, %8
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = load double, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %0, i64 40
  %25 = load double, ptr %24, align 8, !tbaa !15
  %26 = fsub double %23, %25
  %27 = tail call double @atan2(double noundef %26, double noundef %21) #3
  %28 = load double, ptr %0, align 8, !tbaa !16
  %29 = fsub double %27, %28
  %30 = tail call noundef double @_Z6mod2pid(double noundef %29)
  store double %30, ptr %1, align 8, !tbaa !17
  %31 = tail call double @sqrt(double noundef %17) #3
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  store double %31, ptr %32, align 8, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load double, ptr %33, align 8, !tbaa !18
  %35 = fsub double %34, %27
  %36 = tail call noundef double @_Z6mod2pid(double noundef %35)
  %37 = getelementptr inbounds i8, ptr %1, i64 16
  store double %36, ptr %37, align 8, !tbaa !17
  br label %38

38:                                               ; preds = %2, %19
  %.0 = phi i32 [ 0, %19 ], [ 4, %2 ]
  ret i32 %.0
}

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 = { 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, !7, i64 16}
!6 = !{!"_ZTS25DubinsIntermediateResults", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 24}
!11 = !{!6, !7, i64 32}
!12 = !{!6, !7, i64 64}
!13 = !{!6, !7, i64 56}
!14 = !{!6, !7, i64 48}
!15 = !{!6, !7, i64 40}
!16 = !{!6, !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !7, i64 8}


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