#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void print_progress_bar(int current, int total) {
  int numTicks = current * 40 / total;
  int i;
  printf("\rLoading [");
  for (i = 0; i < numTicks; i++)
    printf("=");
  for (; i < 40; i++)
    printf(" ");
  printf("] (%d%%)", current * 100 / total);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<print_progress_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
imul   $0x28,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0xc(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1176 <print_progress_bar+0x56>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114e <print_progress_bar+0x2e>
jmp    117b <print_progress_bar+0x5b>
cmpl   $0x28,-0x10(%rbp)
jge    11a1 <print_progress_bar+0x81>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117b <print_progress_bar+0x5b>
imul   $0x64,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_progress_bar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x0(,%r15,8),%eax
lea    (%rax,%rax,4),%eax
cltd
idiv   %esi
mov    %eax,%r12d
lea    0xeaa(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
jle    1185 <print_progress_bar+0x55>
mov    %r12d,%ebx
mov    %r12d,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1170 <print_progress_bar+0x40>
cmp    $0x27,%r12d
ja     119e <print_progress_bar+0x6e>
add    $0xffffffd8,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    1190 <print_progress_bar+0x60>
imul   $0x64,%r15d,%eax
cltd
idiv   %r14d
lea    0xe5e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

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

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