; LLVM IR from DionysiosB/CodeForces :: 0700-0799 (703C-ChrisAndRoad)

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

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 1.000000e+09, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %52, %0
  %15 = load i64, ptr %8, align 8, !tbaa !9
  %16 = load i64, ptr %2, align 8, !tbaa !9
  %17 = icmp slt i64 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %55

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = sitofp i64 %21 to double
  %23 = fmul double 1.000000e+00, %22
  %24 = load i64, ptr %4, align 8, !tbaa !9
  %25 = sitofp i64 %24 to double
  %26 = fdiv double %23, %25
  %27 = load i64, ptr %10, align 8, !tbaa !9
  %28 = sitofp i64 %27 to double
  %29 = fmul double 1.000000e+00, %28
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = sitofp i64 %30 to double
  %32 = fdiv double %29, %31
  %33 = fsub double %26, %32
  store double %33, ptr %11, align 8, !tbaa !5
  %34 = load double, ptr %6, align 8, !tbaa !5
  %35 = load double, ptr %11, align 8, !tbaa !5
  %36 = fcmp olt double %34, %35
  br i1 %36, label %37, label %39

37:                                               ; preds = %19
  %38 = load double, ptr %6, align 8, !tbaa !5
  br label %41

39:                                               ; preds = %19
  %40 = load double, ptr %11, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %39, %37
  %42 = phi double [ %38, %37 ], [ %40, %39 ]
  store double %42, ptr %6, align 8, !tbaa !5
  %43 = load double, ptr %7, align 8, !tbaa !5
  %44 = load double, ptr %11, align 8, !tbaa !5
  %45 = fcmp ogt double %43, %44
  br i1 %45, label %46, label %48

46:                                               ; preds = %41
  %47 = load double, ptr %7, align 8, !tbaa !5
  br label %50

48:                                               ; preds = %41
  %49 = load double, ptr %11, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %48, %46
  %51 = phi double [ %47, %46 ], [ %49, %48 ]
  store double %51, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %52

52:                                               ; preds = %50
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %8, align 8, !tbaa !9
  br label %14, !llvm.loop !11

55:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %56 = load i64, ptr %3, align 8, !tbaa !9
  %57 = sitofp i64 %56 to double
  %58 = fmul double 1.000000e+00, %57
  %59 = load i64, ptr %5, align 8, !tbaa !9
  %60 = sitofp i64 %59 to double
  %61 = fdiv double %58, %60
  store double %61, ptr %12, align 8, !tbaa !5
  %62 = load double, ptr %6, align 8, !tbaa !5
  %63 = fcmp olt double %62, 0.000000e+00
  br i1 %63, label %64, label %68

64:                                               ; preds = %55
  %65 = load double, ptr %7, align 8, !tbaa !5
  %66 = load double, ptr %12, align 8, !tbaa !5
  %67 = fadd double %66, %65
  store double %67, ptr %12, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %64, %55
  %69 = load double, ptr %12, align 8, !tbaa !5
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

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

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

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

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

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


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

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  %.pre = load i64, ptr %4, align 8, !tbaa !5
  %.pre21 = sitofp i64 %.pre to double
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = sitofp i64 %10 to double
  %12 = fdiv double %11, %.pre21
  br label %19

._crit_edge:                                      ; preds = %.lr.ph
  %13 = fcmp olt double %.fr, 0.000000e+00
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = sitofp i64 %14 to double
  %16 = fdiv double %15, %31
  br i1 %13, label %17, label %19

17:                                               ; preds = %._crit_edge
  %18 = fadd double %37, %16
  br label %19

19:                                               ; preds = %._crit_edge.thread, %._crit_edge, %17
  %20 = phi double [ %18, %17 ], [ %16, %._crit_edge ], [ %12, %._crit_edge.thread ]
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %20)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret i32 0

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01318 = phi double [ %.fr, %.lr.ph ], [ 1.000000e+09, %0 ]
  %.01417 = phi i64 [ %38, %.lr.ph ], [ 0, %0 ]
  %.01516 = phi double [ %37, %.lr.ph ], [ 0.000000e+00, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = sitofp i64 %23 to double
  %25 = load i64, ptr %3, align 8, !tbaa !5
  %26 = sitofp i64 %25 to double
  %27 = fdiv double %24, %26
  %28 = load i64, ptr %6, align 8, !tbaa !5
  %29 = sitofp i64 %28 to double
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = sitofp i64 %30 to double
  %32 = fdiv double %29, %31
  %33 = fsub double %27, %32
  %34 = fcmp olt double %.01318, %33
  %35 = select i1 %34, double %.01318, double %33
  %.fr = freeze double %35
  %36 = fcmp ogt double %.01516, %33
  %37 = select i1 %36, double %.01516, double %33
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  %38 = add nuw nsw i64 %.01417, 1
  %39 = load i64, ptr %1, align 8, !tbaa !5
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

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

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

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

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

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass