; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (2701)

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

@r = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z4distdddd(double noundef, double noundef, double noundef, double noundef) #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %86, %0
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @r, ptr noundef @x, ptr noundef @y)
  %11 = xor i32 %10, -1
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %87

13:                                               ; preds = %9
  %14 = load i32, ptr @r, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %23

16:                                               ; preds = %13
  %17 = load i32, ptr @x, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %16
  %20 = load i32, ptr @y, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %87

23:                                               ; preds = %19, %16, %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %24 = load i32, ptr @x, align 4, !tbaa !5
  %25 = sitofp i32 %24 to double
  store double %25, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %26 = load i32, ptr @y, align 4, !tbaa !5
  %27 = sitofp i32 %26 to double
  store double %27, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %57, %40, %23
  br label %29

29:                                               ; preds = %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %5, ptr noundef %6)
  %31 = load double, ptr %5, align 8, !tbaa !9
  %32 = fcmp olt double %31, 0.000000e+00
  br i1 %32, label %33, label %37

33:                                               ; preds = %29
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = fcmp olt double %34, 0.000000e+00
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  br label %79

37:                                               ; preds = %33, %29
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  br label %28, !llvm.loop !11

41:                                               ; preds = %37
  %42 = load double, ptr %3, align 8, !tbaa !9
  %43 = load double, ptr %4, align 8, !tbaa !9
  %44 = load double, ptr %5, align 8, !tbaa !9
  %45 = load double, ptr %6, align 8, !tbaa !9
  %46 = call noundef double @_Z4distdddd(double noundef %42, double noundef %43, double noundef %44, double noundef %45)
  %47 = load i32, ptr @r, align 4, !tbaa !5
  %48 = sitofp i32 %47 to double
  %49 = fadd double %48, 1.000000e+00
  %50 = fcmp ole double %46, %49
  br i1 %50, label %51, label %57

51:                                               ; preds = %41
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %2, align 4, !tbaa !5
  %54 = load double, ptr %5, align 8, !tbaa !9
  %55 = load double, ptr %6, align 8, !tbaa !9
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %52, double noundef %54, double noundef %55)
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %51, %41
  %58 = load i32, ptr @r, align 4, !tbaa !5
  %59 = sitofp i32 %58 to double
  %60 = fmul double %59, 1.000000e+00
  %61 = load double, ptr %3, align 8, !tbaa !9
  %62 = load double, ptr %4, align 8, !tbaa !9
  %63 = load double, ptr %5, align 8, !tbaa !9
  %64 = load double, ptr %6, align 8, !tbaa !9
  %65 = call noundef double @_Z4distdddd(double noundef %61, double noundef %62, double noundef %63, double noundef %64)
  %66 = fdiv double %60, %65
  store double %66, ptr %7, align 8, !tbaa !9
  %67 = load double, ptr %3, align 8, !tbaa !9
  %68 = load double, ptr %5, align 8, !tbaa !9
  %69 = load double, ptr %3, align 8, !tbaa !9
  %70 = fsub double %68, %69
  %71 = load double, ptr %7, align 8, !tbaa !9
  %72 = call double @llvm.fmuladd.f64(double %70, double %71, double %67)
  store double %72, ptr %3, align 8, !tbaa !9
  %73 = load double, ptr %4, align 8, !tbaa !9
  %74 = load double, ptr %6, align 8, !tbaa !9
  %75 = load double, ptr %4, align 8, !tbaa !9
  %76 = fsub double %74, %75
  %77 = load double, ptr %7, align 8, !tbaa !9
  %78 = call double @llvm.fmuladd.f64(double %76, double %77, double %73)
  store double %78, ptr %4, align 8, !tbaa !9
  br label %28, !llvm.loop !11

79:                                               ; preds = %36
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %86

82:                                               ; preds = %79
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %2, align 4, !tbaa !5
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %83)
  br label %86

86:                                               ; preds = %82, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %9, !llvm.loop !13

87:                                               ; preds = %22, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

declare i32 @printf(ptr noundef, ...) #4

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress norecurse 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@r = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z4distdddd(double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @r, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %.not27 = icmp eq i32 %3, -1
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.loopexit.thread
  %.01828 = phi i32 [ %.3, %.loopexit.thread ], [ 1, %0 ]
  %4 = load i32, ptr @r, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 0
  %6 = load i32, ptr @x, align 4
  %7 = icmp eq i32 %6, 0
  %or.cond = select i1 %5, i1 %7, i1 false
  %8 = load i32, ptr @y, align 4
  %9 = icmp eq i32 %8, 0
  %or.cond3 = select i1 %or.cond, i1 %9, i1 false
  br i1 %or.cond3, label %._crit_edge, label %10

10:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %12 = load double, ptr %1, align 8, !tbaa !9
  %13 = fcmp olt double %12, 0.000000e+00
  %14 = load double, ptr %2, align 8
  %15 = fcmp olt double %14, 0.000000e+00
  %or.cond5.peel45 = select i1 %13, i1 %15, i1 false
  br i1 %or.cond5.peel45, label %.loopexit, label %.lr.ph51

.lr.ph51:                                         ; preds = %10
  %16 = insertelement <2 x i32> poison, i32 %8, i64 0
  %17 = insertelement <2 x i32> %16, i32 %6, i64 1
  %18 = sitofp <2 x i32> %17 to <2 x double>
  br label %19

19:                                               ; preds = %.lr.ph51, %.outer
  %20 = phi double [ %14, %.lr.ph51 ], [ %56, %.outer ]
  %21 = phi double [ %12, %.lr.ph51 ], [ %54, %.outer ]
  %.0.ph49 = phi i32 [ 0, %.lr.ph51 ], [ %.1, %.outer ]
  %.119.ph48 = phi i32 [ %.01828, %.lr.ph51 ], [ %.2, %.outer ]
  %22 = phi <2 x double> [ %18, %.lr.ph51 ], [ %52, %.outer ]
  %.not22.peel = icmp eq i32 %.0.ph49, 0
  br i1 %.not22.peel, label %28, label %.peel.next

.peel.next:                                       ; preds = %19, %.peel.next
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %24 = load double, ptr %1, align 8, !tbaa !9
  %25 = fcmp olt double %24, 0.000000e+00
  %26 = load double, ptr %2, align 8
  %27 = fcmp olt double %26, 0.000000e+00
  %or.cond5 = select i1 %25, i1 %27, i1 false
  br i1 %or.cond5, label %.loopexit.thread, label %.peel.next

28:                                               ; preds = %19
  %29 = extractelement <2 x double> %22, i64 0
  %30 = extractelement <2 x double> %22, i64 1
  %31 = call noundef double @_Z4distdddd(double noundef %30, double noundef %29, double noundef %21, double noundef %20)
  %32 = load i32, ptr @r, align 4, !tbaa !5
  %33 = sitofp i32 %32 to double
  %34 = fadd double %33, 1.000000e+00
  %35 = fcmp ugt double %31, %34
  br i1 %35, label %.outer, label %36

36:                                               ; preds = %28
  %37 = add nsw i32 %.119.ph48, 1
  %38 = load double, ptr %1, align 8, !tbaa !9
  %39 = load double, ptr %2, align 8, !tbaa !9
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.119.ph48, double noundef %38, double noundef %39)
  %.pre = load i32, ptr @r, align 4, !tbaa !5
  %.pre39 = sitofp i32 %.pre to double
  br label %.outer

.outer:                                           ; preds = %36, %28
  %.pre-phi = phi double [ %.pre39, %36 ], [ %33, %28 ]
  %.2 = phi i32 [ %37, %36 ], [ %.119.ph48, %28 ]
  %.1 = phi i32 [ 1, %36 ], [ 0, %28 ]
  %41 = load double, ptr %1, align 8, !tbaa !9
  %42 = load double, ptr %2, align 8, !tbaa !9
  %43 = call noundef double @_Z4distdddd(double noundef %30, double noundef %29, double noundef %41, double noundef %42)
  %44 = fdiv double %.pre-phi, %43
  %45 = load double, ptr %1, align 8, !tbaa !9
  %46 = load double, ptr %2, align 8, !tbaa !9
  %47 = insertelement <2 x double> poison, double %46, i64 0
  %48 = insertelement <2 x double> %47, double %45, i64 1
  %49 = fsub <2 x double> %48, %22
  %50 = insertelement <2 x double> poison, double %44, i64 0
  %51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
  %52 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %49, <2 x double> %51, <2 x double> %22)
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %54 = load double, ptr %1, align 8, !tbaa !9
  %55 = fcmp olt double %54, 0.000000e+00
  %56 = load double, ptr %2, align 8
  %57 = fcmp olt double %56, 0.000000e+00
  %or.cond5.peel = select i1 %55, i1 %57, i1 false
  br i1 %or.cond5.peel, label %.loopexit, label %19, !llvm.loop !11

.loopexit:                                        ; preds = %.outer, %10
  %.119.ph.lcssa = phi i32 [ %.01828, %10 ], [ %.2, %.outer ]
  %.0.ph.lcssa = phi i32 [ 0, %10 ], [ %.1, %.outer ]
  %58 = icmp eq i32 %.0.ph.lcssa, 0
  br i1 %58, label %59, label %.loopexit.thread

59:                                               ; preds = %.loopexit
  %60 = add nsw i32 %.119.ph.lcssa, 1
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.119.ph.lcssa)
  br label %.loopexit.thread

.loopexit.thread:                                 ; preds = %.peel.next, %59, %.loopexit
  %.3 = phi i32 [ %60, %59 ], [ %.119.ph.lcssa, %.loopexit ], [ %.119.ph48, %.peel.next ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  %62 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @r, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %.not = icmp eq i32 %62, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.loopexit.thread, %.lr.ph, %0
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #0 = { 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 #1 = { mustprogress norecurse 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass