#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 */
typedef double time_t;

/* Variables and functions */
int printf(char *, ...);
int /*<<< orphan*/ time(double *);
void prettyprogress(long b, long maxb, time_t starttime) {
  time_t spent, now;
  double bpsec;
  time(&now);
  spent = now - starttime;
  printf("\r");
  if (spent > 0 && (bpsec = (double)b / spent) > 0) {
    int len, i;
    long secremain, minremain, hremain;
    secremain = (maxb - b) / bpsec;
    minremain = (secremain / 60) % 60;
    hremain = secremain / 3600;
    len = printf("Remaining: %ld files. ", maxb - b);
    len += printf(" [");
    len = 77 - len;
    for (i = 0; i < (b * (len - 1) / maxb); i++)
      printf("=");
    printf("|");
    for (; i < len - 2; i++)
      printf("-");
    printf("][K\n");
  } else
    printf("\n");
  return;
}


x86 assembly (clang, -O0):
<prettyprogress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <time@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12ab <prettyprogress+0x18b>
cvtsi2sdq -0x8(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12ab <prettyprogress+0x18b>
mov    -0x10(%rbp),%rax
sub    -0x8(%rbp),%rax
cvtsi2sd %rax,%xmm0
divsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rsi
sub    -0x8(%rbp),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x34(%rbp)
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x4d,%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movslq -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jge    125d <prettyprogress+0x13d>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1212 <prettyprogress+0xf2>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1298 <prettyprogress+0x178>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    126b <prettyprogress+0x14b>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b9 <prettyprogress+0x199>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prettyprogress>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x10(%rsp),%rdi
call   1060 <time@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xd,%edi
call   1030 <putchar@plt>
movsd  0x8(%rsp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jbe    1202 <prettyprogress+0xc2>
cvtsi2sd %rbp,%xmm1
divsd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
jbe    1202 <prettyprogress+0xc2>
mov    %rbx,%rsi
sub    %rbp,%rsi
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %eax,%r15d
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %eax,%r14d
add    %r15d,%r14d
mov    $0x4c,%eax
sub    %r14d,%eax
cltq
imul   %rbp,%rax
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
je     120e <prettyprogress+0xce>
cqto
idiv   %rbx
mov    %rax,%r15
test   %r15,%r15
jle    121a <prettyprogress+0xda>
mov    %r15,%rbx
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
jne    11f0 <prettyprogress+0xb0>
jmp    121d <prettyprogress+0xdd>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    125b <prettyprogress+0x11b>
xor    %edx,%edx
div    %ebx
mov    %eax,%r15d
test   %r15,%r15
jg     11ed <prettyprogress+0xad>
xor    %r15d,%r15d
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    $0x4b,%ebp
mov    $0x4b,%eax
sub    %r14d,%eax
cmp    %eax,%r15d
jge    124f <prettyprogress+0x10f>
add    %r14d,%r15d
sub    %r15d,%ebp
nop
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1240 <prettyprogress+0x100>
lea    0xdc4(%rip),%rdi
call   1040 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0D\00"
@.str.1 = [23 x i8] c"Remaining: %ld files. \00"
@.str.2 = [3 x i8] c" [\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [2 x i8] c"|\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [6 x i8] c"]\1B[K\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @prettyprogress(i64 %0, i64 %1, double %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store double %2, double* %6
%15 = call i32 @time(double* %8)
%16 = load double, double* %8
%17 = load double, double* %6
%18 = fsub double %16, %17
store double %18, double* %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load double, double* %7
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %22, label %80
22: ; preds = %3
%23 = load i64, i64* %4
%24 = sitofp i64 %23 to double
%25 = load double, double* %7
%26 = fdiv double %24, %25
store double %26, double* %9
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %80
28: ; preds = %22
%29 = load i64, i64* %5
%30 = load i64, i64* %4
%31 = sub nsw i64 %29, %30
%32 = sitofp i64 %31 to double
%33 = load double, double* %9
%34 = fdiv double %32, %33
%35 = fptosi double %34 to i64
store i64 %35, i64* %12
%36 = load i64, i64* %12
%37 = sdiv i64 %36, 60
%38 = srem i64 %37, 60
store i64 %38, i64* %13
%39 = load i64, i64* %12
%40 = sdiv i64 %39, 3600
store i64 %40, i64* %14
%41 = load i64, i64* %5
%42 = load i64, i64* %4
%43 = sub nsw i64 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %43)
store i32 %44, i32* %10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32, i32* %10
%47 = add nsw i32 %46, %45
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = sub nsw i32 77, %48
store i32 %49, i32* %10
store i32 0, i32* %11
br label %50
50: ; preds = %63, %28
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = load i64, i64* %4
%54 = load i32, i32* %10
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = mul nsw i64 %53, %56
%58 = load i64, i64* %5
%59 = sdiv i64 %57, %58
%60 = icmp slt i64 %52, %59
br i1 %60, label %61, label %66
61: ; preds = %50
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %61
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %50
66: ; preds = %50
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %68
68: ; preds = %75, %66
%69 = load i32, i32* %11
%70 = load i32, i32* %10
%71 = sub nsw i32 %70, 2
%72 = icmp slt i32 %69, %71
br i1 %72, label %73, label %78
73: ; preds = %68
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %73
%76 = load i32, i32* %11
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
br label %68
78: ; preds = %68
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %82
80: ; preds = %22, %3
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %82
82: ; preds = %80, %78
ret void
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"Remaining: %ld files. \00"
@.str.2 = [3 x i8] c" [\00"
@str = [5 x i8] c"]\1B[K\00"
define void @prettyprogress(i64 %0, i64 %1, double %2) {
%4 = alloca double
%5 = bitcast double* %4 to i8*
%6 = call i32 @time(double* %4)
%7 = load double, double* %4
%8 = fsub double %7, %2
%9 = call i32 @putchar(i32 13)
%10 = fcmp ogt double %8, 0.000000e+00
br i1 %10, label %11, label %44
11: ; preds = %3
%12 = sitofp i64 %0 to double
%13 = fdiv double %12, %8
%14 = fcmp ogt double %13, 0.000000e+00
br i1 %14, label %15, label %44
15: ; preds = %11
%16 = sub nsw i64 %1, %0
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = add nsw i32 %18, %17
%20 = sub i32 76, %19
%21 = sext i32 %20 to i64
%22 = mul nsw i64 %21, %0
%23 = sdiv i64 %22, %1
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %15, %25
%26 = phi i64 [ %28, %25 ], [ 0, %15 ]
%27 = call i32 @putchar(i32 61)
%28 = add nuw nsw i64 %26, 1
%29 = icmp eq i64 %28, %23
br i1 %29, label %30, label %25
30: ; preds = %25
%31 = trunc i64 %23 to i32
br label %32
32: ; preds = %30, %15
%33 = phi i32 [ 0, %15 ], [ %31, %30 ]
%34 = call i32 @putchar(i32 124)
%35 = sub i32 75, %19
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %42
37: ; preds = %32, %37
%38 = phi i32 [ %40, %37 ], [ %33, %32 ]
%39 = call i32 @putchar(i32 45)
%40 = add i32 %38, 1
%41 = icmp eq i32 %40, %35
br i1 %41, label %42, label %37
42: ; preds = %37, %32
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %46
44: ; preds = %11, %3
%45 = call i32 @putchar(i32 10)
br label %46
46: ; preds = %44, %42
ret void
}