#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 */
int /*<<< orphan*/ printf(char *, ...);
void progress_bar(long total, long remaining) {
  int i;
  printf("\r|");
  for (i = 0; i < 60; i++) {
    if (i * (total / 60) > total - remaining)
      printf(" ");
    else
      printf("#");
  }
  printf("| %lu/%lu", total - remaining, total);
  if (remaining == 0)
    printf("\n");
}


x86 assembly (clang, -O0):
<progress_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3c,-0x14(%rbp)
jge    11a5 <progress_bar+0x95>
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
imul   %rcx,%rax
mov    -0x8(%rbp),%rcx
sub    -0x10(%rbp),%rcx
cmp    %rcx,%rax
jle    1184 <progress_bar+0x74>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1192 <progress_bar+0x82>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <progress_bar+0x87>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <progress_bar+0x25>
mov    -0x8(%rbp),%rsi
sub    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11d8 <progress_bar+0xc8>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress_bar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xec8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movabs $0x8888888888888889,%rcx
88 88 88
mov    %r15,%rax
imul   %rcx
mov    %rdx,%r13
add    %r15,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x5,%r13
add    %rax,%r13
mov    %r15,%r12
sub    %r14,%r12
mov    $0x3c,%ebp
xor    %eax,%eax
cmp    %r12,%rbx
setle  %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
add    %r13,%rbx
add    $0xffffffffffffffff,%rbp
jne    1170 <progress_bar+0x50>
lea    0xe70(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14,%r14
je     11b4 <progress_bar+0x94>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\0D|\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"#\00"
@.str.3 = [10 x i8] c"| %lu/%lu\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @progress_bar(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %25, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 60
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = load i64, i64* %3
%14 = sdiv i64 %13, 60
%15 = mul nsw i64 %12, %14
%16 = load i64, i64* %3
%17 = load i64, i64* %4
%18 = sub nsw i64 %16, %17
%19 = icmp sgt i64 %15, %18
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %7
28: ; preds = %7
%29 = load i64, i64* %3
%30 = load i64, i64* %4
%31 = sub nsw i64 %29, %30
%32 = load i64, i64* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 %31, i64 %32)
%34 = load i64, i64* %4
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %28
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %36, %28
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D|\00"
@.str.3 = [10 x i8] c"| %lu/%lu\00"
define void @progress_bar(i64 %0, i64 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = sdiv i64 %0, 60
%5 = sub nsw i64 %0, %1
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %12, %6 ]
%8 = mul nsw i64 %4, %7
%9 = icmp sgt i64 %8, %5
%10 = select i1 %9, i32 32, i32 35
%11 = tail call i32 @putchar(i32 %10)
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, 60
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 %5, i64 %0)
%16 = icmp eq i64 %1, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @putchar(i32 10)
br label %19
19: ; preds = %17, %14
ret void
}