#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*/ fflush(int /*<<< orphan*/);
int printf(char *, ...);
int /*<<< orphan*/ stdout;
int display_progress(int progress, int last_char_count) {
  int i = 0;
  for (i = 0; i < last_char_count; i++) {
    printf("\b");
  }
  for (i = 0; i < progress; i++) {
    printf("=");
  }
  printf(">>");
  for (i += 2; i < 104; i++) {
    printf(" ");
  }
  i = i + printf("[%d%%]", progress);
  fflush(stdout);
  return i;
}


x86 assembly (clang, -O0):
<display_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1164 <display_progress+0x44>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <display_progress+0x1c>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1193 <display_progress+0x73>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <display_progress+0x4b>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x68,-0xc(%rbp)
jge    11d0 <display_progress+0xb0>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11aa <display_progress+0x8a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_progress>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
test   %esi,%esi
jle    114f <display_progress+0x1f>
mov    %esi,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x8,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1140 <display_progress+0x10>
test   %ebx,%ebx
jle    1187 <display_progress+0x57>
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1160 <display_progress+0x30>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2(%rbx),%ebp
cmp    $0x65,%ebx
jbe    119a <display_progress+0x6a>
jmp    11b3 <display_progress+0x83>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebp
add    $0xffffff98,%ebp
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %ebp
jne    11a0 <display_progress+0x70>
mov    $0x68,%ebp
lea    0xe49(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\08\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [3 x i8] c">>\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [7 x i8] c"[%d%%]\00"
@stdout = global i32 0
define i32 @display_progress(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %6
6: ; preds = %12, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
store i32 %14, i32* %5
br label %6
15: ; preds = %6
store i32 0, i32* %5
br label %16
16: ; preds = %22, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %16
25: ; preds = %16
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 2
store i32 %28, i32* %5
br label %29
29: ; preds = %34, %25
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 104
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %29
37: ; preds = %29
%38 = load i32, i32* %5
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = add nsw i32 %38, %40
store i32 %41, i32* %5
%42 = load i32, i32* @stdout
%43 = call i32 @fflush(i32 %42)
%44 = load i32, i32* %5
ret i32 %44
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c">>\00"
@.str.4 = [7 x i8] c"[%d%%]\00"
@stdout = global i32 0
define i32 @display_progress(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %8, label %4
4: ; preds = %8, %2
%5 = icmp sgt i32 %0, 0
br i1 %5, label %13, label %6
6: ; preds = %4
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %22
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ 0, %2 ]
%10 = tail call i32 @putchar(i32 8)
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, %1
br i1 %12, label %4, label %8
13: ; preds = %4, %13
%14 = phi i32 [ %16, %13 ], [ 0, %4 ]
%15 = tail call i32 @putchar(i32 61)
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %13
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = add nuw nsw i32 %0, 2
%21 = icmp ult i32 %0, 102
br i1 %21, label %22, label %29
22: ; preds = %6, %18
%23 = phi i32 [ %20, %18 ], [ 2, %6 ]
br label %24
24: ; preds = %22, %24
%25 = phi i32 [ %27, %24 ], [ %23, %22 ]
%26 = tail call i32 @putchar(i32 32)
%27 = add nuw i32 %25, 1
%28 = icmp eq i32 %27, 104
br i1 %28, label %29, label %24
29: ; preds = %24, %18
%30 = phi i32 [ %20, %18 ], [ 104, %24 ]
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %0)
%32 = add nsw i32 %31, %30
%33 = load i32, i32* @stdout
%34 = tail call i32 @fflush(i32 %33)
ret i32 %32
}