#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, long *);
int main() {
  long byte_total, byte_remain, byte_acc;
  long time, count;
  count = 0;
  while (scanf("%ld\n", &byte_total) != EOF && byte_total != 0) {
    byte_remain = byte_total;
    byte_acc = 0;
    time = 0;
    printf("Output for data set %ld, %ld bytes:\n", ++count, byte_total);
    while (byte_remain > 0) {
      long byte_trans;
      scanf("%ld\n", &byte_trans);
      byte_remain -= byte_trans;
      byte_acc += byte_trans;
      time++;
      if (time % 5 == 0) {
        if (byte_acc == 0) {
          printf("   Time remaining: stalled\n");
        } else {
          double time_remain;
          time_remain = (double)byte_remain / ((double)byte_acc / 5);
          printf("   Time remaining: %ld seconds\n",
                 (long)(time_remain + .9999999));
          byte_acc = 0;
        }
      }
    }
    printf("Total time: %ld seconds\n", time);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e95(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x41(%rbp)
je     116a <main+0x4a>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    117a <main+0x5a>
jmp    12a0 <main+0x180>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
jle    127b <main+0x15b>
lea    0xe4e(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1276 <main+0x156>
cmpq   $0x0,-0x20(%rbp)
jne    1228 <main+0x108>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1271 <main+0x151>
cvtsi2sdq -0x18(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xdcc(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdaf(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
jmp    1276 <main+0x156>
jmp    11b0 <main+0x90>
mov    -0x28(%rbp),%rsi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    0x2e84(%rip),%rcx
cmp    (%rcx),%rax
je     12a7 <main+0x167>
mov    (%rsp),%r14
test   %r14,%r14
je     12a7 <main+0x167>
lea    0xe8f(%rip),%rbx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rsi
lea    0xe7a(%rip),%rdi
mov    %rsi,0x8(%rsp)
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14,%r14
jle    1260 <main+0x120>
mov    $0x1,%ebp
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    1207 <main+0xc7>
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r13,%xmm1
divsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  0xe24(%rip),%xmm0
cvttsd2si %xmm0,%rsi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %r13d,%r13d
add    $0x1,%rbp
add    $0x1,%r12
test   %r14,%r14
jle    1263 <main+0x123>
mov    %rbp,%rax
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mul    %rcx
shr    $0x2,%rdx
lea    (%rdx,%rdx,4),%r15
add    $0xffffffffffffffff,%r15
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x10(%rsp),%rax
sub    %rax,%r14
add    %rax,%r13
cmp    %r12,%r15
jne    11fa <main+0xba>
test   %r13,%r13
jne    11c0 <main+0x80>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
jmp    11f7 <main+0xb7>
nopw   0x0(%rax,%rax,1)
xor    %r12d,%r12d
lea    0xdf0(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    0x2d58(%rip),%rcx
cmp    (%rcx),%rax
mov    0x8(%rsp),%rsi
je     12a7 <main+0x167>
mov    (%rsp),%r14
test   %r14,%r14
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\0A\00"
@EOF = global i64 0
@.str.1 = [37 x i8] c"Output for data set %ld, %ld bytes:\0A\00"
@.str.2 = [28 x i8] c" Time remaining: stalled\0A\00"
@.str.3 = [32 x i8] c" Time remaining: %ld seconds\0A\00"
@.str.4 = [25 x i8] c"Total time: %ld seconds\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
store i32 0, i32* %1
store i64 0, i64* %6
br label %9
9: ; preds = %58, %0
%10 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i64, i64* %2
%15 = icmp ne i64 %14, 0
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %62
18: ; preds = %16
%19 = load i64, i64* %2
store i64 %19, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
%20 = load i64, i64* %6
%21 = add nsw i64 %20, 1
store i64 %21, i64* %6
%22 = load i64, i64* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i64 %21, i64 %22)
br label %24
24: ; preds = %57, %18
%25 = load i64, i64* %3
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %58
27: ; preds = %24
%28 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %7)
%29 = load i64, i64* %7
%30 = load i64, i64* %3
%31 = sub nsw i64 %30, %29
store i64 %31, i64* %3
%32 = load i64, i64* %7
%33 = load i64, i64* %4
%34 = add nsw i64 %33, %32
store i64 %34, i64* %4
%35 = load i64, i64* %5
%36 = add nsw i64 %35, 1
store i64 %36, i64* %5
%37 = load i64, i64* %5
%38 = srem i64 %37, 5
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %57
40: ; preds = %27
%41 = load i64, i64* %4
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %56
45: ; preds = %40
%46 = load i64, i64* %3
%47 = sitofp i64 %46 to double
%48 = load i64, i64* %4
%49 = sitofp i64 %48 to double
%50 = fdiv double %49, 5.000000e+00
%51 = fdiv double %47, %50
store double %51, double* %8
%52 = load double, double* %8
%53 = fadd double %52, 0x3FEFFFFFCA501ACB
%54 = fptosi double %53 to i64
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %54)
store i64 0, i64* %4
br label %56
56: ; preds = %45, %43
br label %57
57: ; preds = %56, %27
br label %24
58: ; preds = %24
%59 = load i64, i64* %5
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %9
62: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
@EOF = global i64 0
@.str.1 = [37 x i8] c"Output for data set %ld, %ld bytes:\0A\00"
@.str.3 = [32 x i8] c" Time remaining: %ld seconds\0A\00"
@.str.4 = [25 x i8] c"Total time: %ld seconds\0A\00"
@str = [27 x i8] c" Time remaining: stalled\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%5 = load i64, i64* @EOF
%6 = icmp ne i64 %4, %5
%7 = load i64, i64* %1
%8 = icmp ne i64 %7, 0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %54
10: ; preds = %0
%11 = bitcast i64* %2 to i8*
br label %12
12: ; preds = %10, %44
%13 = phi i64 [ %7, %10 ], [ %51, %44 ]
%14 = phi i64 [ 0, %10 ], [ %15, %44 ]
%15 = add nuw nsw i64 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i64 %15, i64 %13)
%17 = icmp sgt i64 %13, 0
br i1 %17, label %18, label %44
18: ; preds = %12, %41
%19 = phi i64 [ %24, %41 ], [ %13, %12 ]
%20 = phi i64 [ %26, %41 ], [ 0, %12 ]
%21 = phi i64 [ %42, %41 ], [ 0, %12 ]
%22 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%23 = load i64, i64* %2
%24 = sub nsw i64 %19, %23
%25 = add nsw i64 %23, %21
%26 = add nuw nsw i64 %20, 1
%27 = urem i64 %26, 5
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %18
%30 = icmp eq i64 %25, 0
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %41
33: ; preds = %29
%34 = sitofp i64 %24 to double
%35 = sitofp i64 %25 to double
%36 = fdiv double %35, 5.000000e+00
%37 = fdiv double %34, %36
%38 = fadd double %37, 0x3FEFFFFFCA501ACB
%39 = fptosi double %38 to i64
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %39)
br label %41
41: ; preds = %31, %33, %18
%42 = phi i64 [ 0, %31 ], [ 0, %33 ], [ %25, %18 ]
%43 = icmp sgt i64 %24, 0
br i1 %43, label %18, label %44
44: ; preds = %41, %12
%45 = phi i64 [ 0, %12 ], [ %26, %41 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 %45)
%47 = call i32 @putchar(i32 10)
%48 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%49 = load i64, i64* @EOF
%50 = icmp ne i64 %48, %49
%51 = load i64, i64* %1
%52 = icmp ne i64 %51, 0
%53 = select i1 %50, i1 %52, i1 false
br i1 %53, label %12, label %54
54: ; preds = %44, %0
ret i32 0
}