; LLVM IR from DionysiosB/CodeForces :: 1850E-CardboardForPictures (main)

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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 x86_fp80, align 16
  %4 = alloca x86_fp80, align 16
  %5 = alloca x86_fp80, align 16
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca x86_fp80, align 16
  %10 = alloca x86_fp80, align 16
  %11 = alloca x86_fp80, align 16
  %12 = alloca x86_fp80, align 16
  %13 = alloca x86_fp80, align 16
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca x86_fp80, align 16
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %19

19:                                               ; preds = %100, %0
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = add nsw i64 %20, -1
  store i64 %21, ptr %2, align 8, !tbaa !5
  %22 = icmp ne i64 %20, 0
  br i1 %22, label %23, label %103

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  store x86_fp80 0xK00000000000000000000, ptr %5, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  store x86_fp80 0xK00000000000000000000, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  store x86_fp80 0xK00000000000000000000, ptr %7, align 16, !tbaa !9
  br label %25

25:                                               ; preds = %39, %23
  %26 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %27 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %28 = fcmp olt x86_fp80 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  br label %42

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %8)
  %32 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %33 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %34 = fadd x86_fp80 %33, %32
  store x86_fp80 %34, ptr %5, align 16, !tbaa !9
  %35 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %36 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %37 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %38 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %35, x86_fp80 %36, x86_fp80 %37)
  store x86_fp80 %38, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  br label %39

39:                                               ; preds = %30
  %40 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %41 = fadd x86_fp80 %40, 0xK3FFF8000000000000000
  store x86_fp80 %41, ptr %7, align 16, !tbaa !9
  br label %25, !llvm.loop !11

42:                                               ; preds = %29
  %43 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %44 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %45 = fsub x86_fp80 %44, %43
  store x86_fp80 %45, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %46 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %47 = fmul x86_fp80 0xK40018000000000000000, %46
  store x86_fp80 %47, ptr %9, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %48 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %49 = fmul x86_fp80 0xK40018000000000000000, %48
  store x86_fp80 %49, ptr %10, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %50 = load x86_fp80, ptr %6, align 16, !tbaa !9
  store x86_fp80 %50, ptr %11, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  store x86_fp80 0xK00000000000000000000, ptr %12, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  store x86_fp80 0xK40209502F901C0000000, ptr %13, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !13
  br label %51

51:                                               ; preds = %99, %42
  %52 = load x86_fp80, ptr %12, align 16, !tbaa !9
  %53 = load x86_fp80, ptr %13, align 16, !tbaa !9
  %54 = fcmp ole x86_fp80 %52, %53
  br i1 %54, label %55, label %100

55:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %56 = load x86_fp80, ptr %12, align 16, !tbaa !9
  %57 = load x86_fp80, ptr %13, align 16, !tbaa !9
  %58 = fadd x86_fp80 %56, %57
  %59 = fdiv x86_fp80 %58, 0xK40008000000000000000
  %60 = fptosi x86_fp80 %59 to i64
  store i64 %60, ptr %15, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %61 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %62 = load x86_fp80, ptr %10, align 16, !tbaa !9
  %63 = load i64, ptr %15, align 8, !tbaa !13
  %64 = sitofp i64 %63 to x86_fp80
  %65 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %62, x86_fp80 %64, x86_fp80 %61)
  %66 = load x86_fp80, ptr %9, align 16, !tbaa !9
  %67 = load i64, ptr %15, align 8, !tbaa !13
  %68 = sitofp i64 %67 to x86_fp80
  %69 = fmul x86_fp80 %66, %68
  %70 = load i64, ptr %15, align 8, !tbaa !13
  %71 = sitofp i64 %70 to x86_fp80
  %72 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %69, x86_fp80 %71, x86_fp80 %65)
  store x86_fp80 %72, ptr %16, align 16, !tbaa !9
  %73 = load x86_fp80, ptr %16, align 16, !tbaa !9
  %74 = fcmp olt x86_fp80 0xKBFFF8000000000000000, %73
  br i1 %74, label %75, label %80

75:                                               ; preds = %55
  %76 = load x86_fp80, ptr %16, align 16, !tbaa !9
  %77 = fcmp olt x86_fp80 %76, 0xK3FFF8000000000000000
  br i1 %77, label %78, label %80

78:                                               ; preds = %75
  %79 = load i64, ptr %15, align 8, !tbaa !13
  store i64 %79, ptr %14, align 8, !tbaa !13
  store i32 8, ptr %17, align 4
  br label %97

80:                                               ; preds = %75, %55
  %81 = load x86_fp80, ptr %16, align 16, !tbaa !9
  %82 = fcmp olt x86_fp80 %81, 0xK00000000000000000000
  br i1 %82, label %83, label %87

83:                                               ; preds = %80
  %84 = load i64, ptr %15, align 8, !tbaa !13
  %85 = add nsw i64 %84, 1
  %86 = sitofp i64 %85 to x86_fp80
  store x86_fp80 %86, ptr %12, align 16, !tbaa !9
  br label %95

87:                                               ; preds = %80
  %88 = load x86_fp80, ptr %16, align 16, !tbaa !9
  %89 = fcmp ogt x86_fp80 %88, 0xK00000000000000000000
  br i1 %89, label %90, label %94

90:                                               ; preds = %87
  %91 = load i64, ptr %15, align 8, !tbaa !13
  %92 = sub nsw i64 %91, 1
  %93 = sitofp i64 %92 to x86_fp80
  store x86_fp80 %93, ptr %13, align 16, !tbaa !9
  br label %94

94:                                               ; preds = %90, %87
  br label %95

95:                                               ; preds = %94, %83
  br label %96

96:                                               ; preds = %95
  store i32 0, ptr %17, align 4
  br label %97

97:                                               ; preds = %96, %78
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  %98 = load i32, ptr %17, align 4
  switch i32 %98, label %105 [
    i32 0, label %99
    i32 8, label %100
  ]

99:                                               ; preds = %97
  br label %51, !llvm.loop !15

100:                                              ; preds = %97, %51
  %101 = load i64, ptr %14, align 8, !tbaa !13
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %101)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  br label %19, !llvm.loop !16

103:                                              ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %104 = load i32, ptr %1, align 4
  ret i32 %104

105:                                              ; preds = %97
  unreachable
}

; 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 x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

; 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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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"

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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 x86_fp80, align 16
  %3 = alloca x86_fp80, align 16
  %4 = alloca x86_fp80, align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = add nsw i64 %6, -1
  store i64 %7, ptr %1, align 8, !tbaa !5
  %.not56 = icmp eq i64 %6, 0
  br i1 %.not56, label %._crit_edge59, label %.lr.ph58

.lr.ph58:                                         ; preds = %0, %.thread
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %9 = load x86_fp80, ptr %2, align 16, !tbaa !9
  %10 = fcmp ogt x86_fp80 %9, 0xK00000000000000000000
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph58
  %.033.lcssa = phi x86_fp80 [ 0xK00000000000000000000, %.lr.ph58 ], [ %18, %.lr.ph ]
  %.032.lcssa = phi x86_fp80 [ 0xK00000000000000000000, %.lr.ph58 ], [ %17, %.lr.ph ]
  %.lcssa = phi x86_fp80 [ %9, %.lr.ph58 ], [ %20, %.lr.ph ]
  %11 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %12 = fsub x86_fp80 %.033.lcssa, %11
  %13 = fmul x86_fp80 %.lcssa, 0xK40018000000000000000
  %14 = fmul x86_fp80 %.032.lcssa, 0xK40018000000000000000
  br label %22

.lr.ph:                                           ; preds = %.lr.ph58, %.lr.ph
  %.03251 = phi x86_fp80 [ %17, %.lr.ph ], [ 0xK00000000000000000000, %.lr.ph58 ]
  %.03350 = phi x86_fp80 [ %18, %.lr.ph ], [ 0xK00000000000000000000, %.lr.ph58 ]
  %.03449 = phi x86_fp80 [ %19, %.lr.ph ], [ 0xK00000000000000000000, %.lr.ph58 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %4)
  %16 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %17 = fadd x86_fp80 %.03251, %16
  %18 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %16, x86_fp80 %16, x86_fp80 %.03350)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  %19 = fadd x86_fp80 %.03449, 0xK3FFF8000000000000000
  %20 = load x86_fp80, ptr %2, align 16, !tbaa !9
  %21 = fcmp olt x86_fp80 %19, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !11

22:                                               ; preds = %._crit_edge, %41
  %.03655 = phi x86_fp80 [ 0xK40209502F901C0000000, %._crit_edge ], [ %.238, %41 ]
  %.03954 = phi x86_fp80 [ 0xK00000000000000000000, %._crit_edge ], [ %.241, %41 ]
  %23 = fadd x86_fp80 %.03954, %.03655
  %24 = fmul x86_fp80 %23, 0xK3FFE8000000000000000
  %25 = fptosi x86_fp80 %24 to i64
  %26 = sitofp i64 %25 to x86_fp80
  %27 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %26, x86_fp80 %12)
  %28 = fmul x86_fp80 %13, %26
  %29 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %28, x86_fp80 %26, x86_fp80 %27)
  %30 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %29)
  %or.cond = fcmp olt x86_fp80 %30, 0xK3FFF8000000000000000
  br i1 %or.cond, label %.thread, label %31

31:                                               ; preds = %22
  %32 = fcmp olt x86_fp80 %29, 0xK00000000000000000000
  br i1 %32, label %33, label %36

33:                                               ; preds = %31
  %34 = add nsw i64 %25, 1
  %35 = sitofp i64 %34 to x86_fp80
  br label %41

36:                                               ; preds = %31
  %37 = fcmp ogt x86_fp80 %29, 0xK00000000000000000000
  br i1 %37, label %38, label %41

38:                                               ; preds = %36
  %39 = add nsw i64 %25, -1
  %40 = sitofp i64 %39 to x86_fp80
  br label %41

41:                                               ; preds = %36, %38, %33
  %.241 = phi x86_fp80 [ %35, %33 ], [ %.03954, %38 ], [ %.03954, %36 ]
  %.238 = phi x86_fp80 [ %.03655, %33 ], [ %40, %38 ], [ %.03655, %36 ]
  %42 = fcmp ugt x86_fp80 %.241, %.238
  br i1 %42, label %.thread, label %22

.thread:                                          ; preds = %22, %41
  %.2 = phi i64 [ 0, %41 ], [ %25, %22 ]
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  %44 = load i64, ptr %1, align 8, !tbaa !5
  %45 = add nsw i64 %44, -1
  store i64 %45, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %44, 0
  br i1 %.not, label %._crit_edge59, label %.lr.ph58, !llvm.loop !13

._crit_edge59:                                    ; preds = %.thread, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 0
}

; 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 x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

; 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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fabs.f80(x86_fp80) #4

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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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