#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 printProgress(const double progress, const int barWidth) {
  printf("[");
  int pos = barWidth * progress;
  for (int i = 0; i < barWidth; ++i) {
    if (i < pos)
      printf("=");
    else if (i == pos)
      printf(">");
    else
      printf(" ");
  }
  printf("] %lg%%   \r", progress * 100.0);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<printProgress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c6 <printProgress+0xa6>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1181 <printProgress+0x61>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <printProgress+0x93>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11a0 <printProgress+0x80>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ae <printProgress+0x8e>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <printProgress+0x93>
jmp    11b8 <printProgress+0x98>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <printProgress+0x36>
movsd  0xe32(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
lea    0xe36(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProgress>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
movsd  %xmm0,0x8(%rsp)
mov    $0x5b,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    119c <printProgress+0x6c>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%ebp
xor    %ebx,%ebx
mov    $0x3e,%r15d
mov    $0x3d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %ebx,%ebp
mov    $0x20,%edi
cmove  %r15d,%edi
cmovg  %r12d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    1180 <printProgress+0x50>
movsd  0x8(%rsp),%xmm0
mulsd  0xe56(%rip),%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

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

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