; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (404B-Marathon)

; 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 [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

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

9:                                                ; preds = %79, %0
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = icmp sle i64 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %82

14:                                               ; preds = %9
  %15 = load double, ptr %3, align 8, !tbaa !5
  %16 = load double, ptr %5, align 8, !tbaa !5
  %17 = fadd double %16, %15
  store double %17, ptr %5, align 8, !tbaa !5
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = load double, ptr %2, align 8, !tbaa !5
  %20 = fmul double 4.000000e+00, %19
  %21 = fcmp oge double %18, %20
  br i1 %21, label %22, label %34

22:                                               ; preds = %14
  %23 = load double, ptr %2, align 8, !tbaa !5
  %24 = fmul double 4.000000e+00, %23
  %25 = load double, ptr %5, align 8, !tbaa !5
  %26 = fdiv double %25, 4.000000e+00
  %27 = load double, ptr %2, align 8, !tbaa !5
  %28 = fdiv double %26, %27
  %29 = fptosi double %28 to i32
  %30 = sitofp i32 %29 to double
  %31 = load double, ptr %5, align 8, !tbaa !5
  %32 = fneg double %24
  %33 = call double @llvm.fmuladd.f64(double %32, double %30, double %31)
  store double %33, ptr %5, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %22, %14
  %35 = load double, ptr %5, align 8, !tbaa !5
  %36 = load double, ptr %2, align 8, !tbaa !5
  %37 = fcmp ole double %35, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = load double, ptr %5, align 8, !tbaa !5
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %39)
  br label %78

41:                                               ; preds = %34
  %42 = load double, ptr %5, align 8, !tbaa !5
  %43 = load double, ptr %2, align 8, !tbaa !5
  %44 = fmul double 2.000000e+00, %43
  %45 = fcmp ole double %42, %44
  br i1 %45, label %46, label %52

46:                                               ; preds = %41
  %47 = load double, ptr %2, align 8, !tbaa !5
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = load double, ptr %2, align 8, !tbaa !5
  %50 = fsub double %48, %49
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %47, double noundef %50)
  br label %77

52:                                               ; preds = %41
  %53 = load double, ptr %5, align 8, !tbaa !5
  %54 = load double, ptr %2, align 8, !tbaa !5
  %55 = fmul double 3.000000e+00, %54
  %56 = fcmp ole double %53, %55
  br i1 %56, label %57, label %64

57:                                               ; preds = %52
  %58 = load double, ptr %2, align 8, !tbaa !5
  %59 = load double, ptr %5, align 8, !tbaa !5
  %60 = fneg double %59
  %61 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %58, double %60)
  %62 = load double, ptr %2, align 8, !tbaa !5
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %61, double noundef %62)
  br label %76

64:                                               ; preds = %52
  %65 = load double, ptr %5, align 8, !tbaa !5
  %66 = load double, ptr %2, align 8, !tbaa !5
  %67 = fmul double 4.000000e+00, %66
  %68 = fcmp ole double %65, %67
  br i1 %68, label %69, label %75

69:                                               ; preds = %64
  %70 = load double, ptr %2, align 8, !tbaa !5
  %71 = load double, ptr %5, align 8, !tbaa !5
  %72 = fneg double %71
  %73 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %70, double %72)
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %73)
  br label %75

75:                                               ; preds = %69, %64
  br label %76

76:                                               ; preds = %75, %57
  br label %77

77:                                               ; preds = %76, %46
  br label %78

78:                                               ; preds = %77, %38
  br label %79

79:                                               ; preds = %78
  %80 = load i64, ptr %6, align 8, !tbaa !9
  %81 = add nsw i64 %80, 1
  store i64 %81, ptr %6, align 8, !tbaa !9
  br label %9, !llvm.loop !11

82:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

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

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 = { 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, !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 [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

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

._crit_edge:                                      ; preds = %42, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0

.lr.ph:                                           ; preds = %0, %42
  %.020 = phi i64 [ %43, %42 ], [ 1, %0 ]
  %.01319 = phi double [ %.1, %42 ], [ 0.000000e+00, %0 ]
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = fadd double %.01319, %7
  %9 = load double, ptr %1, align 8, !tbaa !5
  %10 = fmul double %9, 4.000000e+00
  %11 = fcmp ult double %8, %10
  br i1 %11, label %19, label %12

12:                                               ; preds = %.lr.ph
  %13 = fmul double %8, 2.500000e-01
  %14 = fdiv double %13, %9
  %15 = fptosi double %14 to i32
  %16 = sitofp i32 %15 to double
  %17 = fneg double %10
  %18 = call double @llvm.fmuladd.f64(double %17, double %16, double %8)
  br label %19

19:                                               ; preds = %12, %.lr.ph
  %.1 = phi double [ %18, %12 ], [ %8, %.lr.ph ]
  %20 = fcmp ugt double %.1, %9
  br i1 %20, label %23, label %21

21:                                               ; preds = %19
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %.1)
  br label %42

23:                                               ; preds = %19
  %24 = fmul double %9, 2.000000e+00
  %25 = fcmp ugt double %.1, %24
  br i1 %25, label %29, label %26

26:                                               ; preds = %23
  %27 = fsub double %.1, %9
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %9, double noundef %27)
  br label %42

29:                                               ; preds = %23
  %30 = fmul double %9, 3.000000e+00
  %31 = fcmp ugt double %.1, %30
  br i1 %31, label %36, label %32

32:                                               ; preds = %29
  %33 = fneg double %.1
  %34 = call double @llvm.fmuladd.f64(double %9, double 3.000000e+00, double %33)
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %34, double noundef %9)
  br label %42

36:                                               ; preds = %29
  %37 = fcmp ugt double %.1, %10
  br i1 %37, label %42, label %38

38:                                               ; preds = %36
  %39 = fneg double %.1
  %40 = call double @llvm.fmuladd.f64(double %9, double 4.000000e+00, double %39)
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %40)
  br label %42

42:                                               ; preds = %21, %32, %38, %36, %26
  %43 = add nuw nsw i64 %.020, 1
  %44 = load i64, ptr %3, align 8, !tbaa !9
  %.not.not = icmp slt i64 %.020, %44
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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

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 = { mustprogress 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass