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

; 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_RSLP25DubinsIntermediateResultsPd(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
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %10, i32 0, i32 8
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = fadd double -2.000000e+00, %12
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %14, i32 0, i32 7
  %16 = load double, ptr %15, align 8, !tbaa !12
  %17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double %13)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %18, i32 0, i32 2
  %20 = load double, ptr %19, align 8, !tbaa !13
  %21 = fmul double 2.000000e+00, %20
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %22, i32 0, i32 3
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %25, i32 0, i32 4
  %27 = load double, ptr %26, align 8, !tbaa !15
  %28 = fadd double %24, %27
  %29 = fneg double %21
  %30 = call double @llvm.fmuladd.f64(double %29, double %28, double %17)
  store double %30, ptr %6, align 8, !tbaa !16
  %31 = load double, ptr %6, align 8, !tbaa !16
  %32 = fcmp oge double %31, 0.000000e+00
  br i1 %32, label %33, label %77

33:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %34 = load double, ptr %6, align 8, !tbaa !16
  %35 = call double @sqrt(double noundef %34) #4
  store double %35, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %36, i32 0, i32 5
  %38 = load double, ptr %37, align 8, !tbaa !17
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %39, i32 0, i32 6
  %41 = load double, ptr %40, align 8, !tbaa !18
  %42 = fadd double %38, %41
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %43, i32 0, i32 2
  %45 = load double, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %46, i32 0, i32 3
  %48 = load double, ptr %47, align 8, !tbaa !14
  %49 = fsub double %45, %48
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %50, i32 0, i32 4
  %52 = load double, ptr %51, align 8, !tbaa !15
  %53 = fsub double %49, %52
  %54 = call double @atan2(double noundef %42, double noundef %53) #4
  %55 = load double, ptr %7, align 8, !tbaa !16
  %56 = call double @atan2(double noundef 2.000000e+00, double noundef %55) #4
  %57 = fsub double %54, %56
  store double %57, ptr %8, align 8, !tbaa !16
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %58, i32 0, i32 0
  %60 = load double, ptr %59, align 8, !tbaa !19
  %61 = load double, ptr %8, align 8, !tbaa !16
  %62 = fsub double %60, %61
  %63 = call noundef double @_Z6mod2pid(double noundef %62)
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds double, ptr %64, i64 0
  store double %63, ptr %65, align 8, !tbaa !16
  %66 = load double, ptr %7, align 8, !tbaa !16
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 1
  store double %66, ptr %68, align 8, !tbaa !16
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %69, i32 0, i32 1
  %71 = load double, ptr %70, align 8, !tbaa !20
  %72 = load double, ptr %8, align 8, !tbaa !16
  %73 = fsub double %71, %72
  %74 = call noundef double @_Z6mod2pid(double noundef %73)
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds double, ptr %75, i64 2
  store double %74, ptr %76, align 8, !tbaa !16
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %78

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

78:                                               ; preds = %77, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %79 = load i32, ptr %3, align 4
  ret i32 %79
}

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 64}
!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 56}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !11, i64 32}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 40}
!18 = !{!10, !11, i64 48}
!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_RSLP25DubinsIntermediateResultsPd(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 64
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fadd double %4, -2.000000e+00
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load double, ptr %6, align 8, !tbaa !10
  %8 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double %5)
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load double, ptr %13, align 8, !tbaa !13
  %15 = fadd double %12, %14
  %16 = fmul double %10, -2.000000e+00
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %8)
  %18 = fcmp ult double %17, 0.000000e+00
  br i1 %18, label %43, label %19

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

43:                                               ; 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 64}
!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 56}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !7, i64 48}
!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