#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 int uint;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void printProgressBar(int a, int b) {
  int barSize = 50;
  float perc = (float)a / b;
  printf("\r%d/%d (bytes) [", a, b);
  uint i;
  for (i = 0; i < 50; ++i) {
    if (i < perc * barSize)
      printf("=");
    else
      printf(" ");
  }
  printf("] %.0f%%", perc * 100);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<printProgressBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x32,-0xc(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    11bd <printProgressBar+0x9d>
cvtsi2ssl -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jbe    119c <printProgressBar+0x7c>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <printProgressBar+0x8a>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11af <printProgressBar+0x8f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1163 <printProgressBar+0x43>
movss  0xe3b(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProgressBar>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%edx
mov    %edi,%esi
cvtsi2ss %edi,%xmm1
cvtsi2ss %edx,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
lea    0xeb6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xe9d(%rip),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    118d <printProgressBar+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0x32,%ebx
je     11ab <printProgressBar+0x7b>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
mov    $0x3d,%edi
ja     1180 <printProgressBar+0x50>
mov    $0x20,%edi
jmp    1180 <printProgressBar+0x50>
movss  0x8(%rsp),%xmm0
mulss  0xe4b(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"\0D%d/%d (bytes) [\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [9 x i8] c"] %.0f%%\00"
@stdout = global i32 0
define void @printProgressBar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 50, i32* %5
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to float
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to float
%12 = fdiv float %9, %11
store float %12, float* %6
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
store i32 0, i32* %7
br label %16
16: ; preds = %32, %2
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 50
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = load i32, i32* %7
%21 = sitofp i32 %20 to float
%22 = load float, float* %6
%23 = load i32, i32* %5
%24 = sitofp i32 %23 to float
%25 = fmul float %22, %24
%26 = fcmp olt float %21, %25
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
29: ; preds = %19
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %16
35: ; preds = %16
%36 = load float, float* %6
%37 = fmul float %36, 1.000000e+02
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %38)
%40 = load i32, i32* @stdout
%41 = call i32 @fflush(i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0D%d/%d (bytes) [\00"
@.str.3 = [9 x i8] c"] %.0f%%\00"
@stdout = global i32 0
define void @printProgressBar(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to float
%4 = sitofp i32 %1 to float
%5 = fdiv float %3, %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%7 = fmul float %5, 5.000000e+01
br label %8
8: ; preds = %2, %8
%9 = phi i32 [ 0, %2 ], [ %14, %8 ]
%10 = sitofp i32 %9 to float
%11 = fcmp ogt float %7, %10
%12 = select i1 %11, i32 61, i32 32
%13 = tail call i32 @putchar(i32 %12)
%14 = add nuw nsw i32 %9, 1
%15 = icmp eq i32 %14, 50
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = fmul float %5, 1.000000e+02
%18 = fpext float %17 to double
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = load i32, i32* @stdout
%21 = tail call i32 @fflush(i32 %20)
ret void
}