#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*/ memset(char *, char, int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void progressBar(long cur_size, long total_size) {
  float percent = (float)cur_size / total_size;
  const int numTotal = 50;
  int numShow = (int)(numTotal * percent);
  if (numShow == 0)
    numShow = 1;
  if (numShow > numTotal)
    numShow = numTotal;
  char sign[51] = {0};
  memset(sign, '*', numTotal);
  printf("\r%.2f%%\t[%-*.*s] %.2f/%.2fMB", percent * 100, numTotal, numShow,
         sign, cur_size / 1024.0 / 1024.0, total_size / 1024.0 / 1024.0);
  fflush(stdout);
  if (numShow == numTotal)
    printf("\n");
}


x86 assembly (clang, -O0):
<progressBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cvtsi2ssq -0x8(%rbp),%xmm0
cvtsi2ssq -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x32,-0x18(%rbp)
movss  0xe9c(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1181 <progressBar+0x51>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x32,-0x1c(%rbp)
jle    1192 <progressBar+0x62>
movl   $0x32,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x33,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    $0x2a,%esi
mov    $0x32,%edx
call   1040 <memset@plt>
movss  0xe47(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x1c(%rbp),%edx
lea    -0x50(%rbp),%rcx
cvtsi2sdq -0x8(%rbp),%xmm1
movsd  0xe2d(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe21(%rip),%xmm2
divsd  %xmm2,%xmm1
cvtsi2sdq -0x10(%rbp),%xmm2
movsd  0xe0f(%rip),%xmm3
divsd  %xmm3,%xmm2
movsd  0xe03(%rip),%xmm3
divsd  %xmm3,%xmm2
lea    0xe00(%rip),%rdi
mov    $0x32,%esi
mov    $0x3,%al
call   1030 <printf@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
cmpl   $0x32,-0x1c(%rbp)
jne    1242 <progressBar+0x112>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progressBar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%r12
cvtsi2ss %rdi,%xmm1
mov    %rsi,%r14
cvtsi2ss %rsi,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0xe92(%rip),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
test   %eax,%eax
mov    $0x1,%ebx
cmovne %eax,%ebx
cmp    $0x32,%ebx
mov    $0x32,%ebp
cmovl  %ebx,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x3f(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x2a,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
movss  0xc(%rsp),%xmm0
mulss  0xe3a(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r12,%xmm1
cvtss2sd %xmm0,%xmm0
movsd  0xe2a(%rip),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
cvtsi2sd %r14,%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm3,%xmm2
lea    0xe16(%rip),%rdi
mov    $0x32,%esi
mov    %ebp,%edx
mov    %r15,%rcx
mov    $0x3,%al
call   1040 <printf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
cmp    $0x32,%ebx
jl     1228 <progressBar+0xe8>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0D%.2f%%\09[%-*.*s] %.2f/%.2fMB\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @progressBar(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca [51 x i8]
store i64 %0, i64* %3
store i64 %1, i64* %4
%9 = load i64, i64* %3
%10 = sitofp i64 %9 to float
%11 = load i64, i64* %4
%12 = sitofp i64 %11 to float
%13 = fdiv float %10, %12
store float %13, float* %5
store i32 50, i32* %6
%14 = load float, float* %5
%15 = fmul float 5.000000e+01, %14
%16 = fptosi float %15 to i32
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 1, i32* %7
br label %20
20: ; preds = %19, %2
%21 = load i32, i32* %7
%22 = icmp sgt i32 %21, 50
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 50, i32* %7
br label %24
24: ; preds = %23, %20
%25 = bitcast [51 x i8]* %8 to i8*
%26 = getelementptr inbounds [51 x i8], [51 x i8]* %8, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i8 signext 42, i32 50)
%28 = load float, float* %5
%29 = fmul float %28, 1.000000e+02
%30 = fpext float %29 to double
%31 = load i32, i32* %7
%32 = getelementptr inbounds [51 x i8], [51 x i8]* %8, i64 0, i64 0
%33 = load i64, i64* %3
%34 = sitofp i64 %33 to double
%35 = fdiv double %34, 1.024000e+03
%36 = fdiv double %35, 1.024000e+03
%37 = load i64, i64* %4
%38 = sitofp i64 %37 to double
%39 = fdiv double %38, 1.024000e+03
%40 = fdiv double %39, 1.024000e+03
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %30, i32 50, i32 %31, i8* %32, double %36, double %40)
%42 = load i32, i32* @stdout
%43 = call i32 @fflush(i32 %42)
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, 50
br i1 %45, label %46, label %48
46: ; preds = %24
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %24
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0D%.2f%%\09[%-*.*s] %.2f/%.2fMB\00"
@stdout = global i32 0
define void @progressBar(i64 %0, i64 %1) {
%3 = alloca [51 x i8]
%4 = sitofp i64 %0 to float
%5 = sitofp i64 %1 to float
%6 = fdiv float %4, %5
%7 = fmul float %6, 5.000000e+01
%8 = fptosi float %7 to i32
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 1, i32 %8
%11 = icmp slt i32 %10, 50
%12 = select i1 %11, i32 %10, i32 50
%13 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i8 signext 42, i32 50)
%15 = fmul float %6, 1.000000e+02
%16 = fpext float %15 to double
%17 = sitofp i64 %0 to double
%18 = fmul double %17, 0x3F50000000000000
%19 = fmul double %18, 0x3F50000000000000
%20 = sitofp i64 %1 to double
%21 = fmul double %20, 0x3F50000000000000
%22 = fmul double %21, 0x3F50000000000000
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %16, i32 50, i32 %12, i8* %13, double %19, double %22)
%24 = load i32, i32* @stdout
%25 = call i32 @fflush(i32 %24)
%26 = icmp sgt i32 %10, 49
br i1 %26, label %27, label %29
27: ; preds = %2
%28 = call i32 @putchar(i32 10)
br label %29
29: ; preds = %27, %2
ret void
}