#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 *, float);
int /*<<< orphan*/ stdout;
void progress_gauge(size_t total, size_t done) {
  if (total > 0) {
    printf("%.0f\n", (float)done / total * 100);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<progress_gauge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jbe    11f3 <progress_gauge+0xd3>
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x18(%rbp)
test   %rax,%rax
movss  %xmm0,-0x14(%rbp)
js     1178 <progress_gauge+0x58>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x20(%rbp)
test   %rax,%rax
movss  %xmm0,-0x1c(%rbp)
js     11bf <progress_gauge+0x9f>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xe2b(%rip),%xmm1
mulss  %xmm1,%xmm0
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress_gauge>:
test   %rdi,%rdi
je     114b <progress_gauge+0x2b>
test   %rsi,%rsi
js     114c <progress_gauge+0x2c>
cvtsi2ss %rsi,%xmm0
test   %rdi,%rdi
jns    1166 <progress_gauge+0x46>
mov    %rdi,%rax
shr    %rax
and    $0x1,%edi
or     %rax,%rdi
cvtsi2ss %rdi,%xmm1
addss  %xmm1,%xmm1
jmp    116b <progress_gauge+0x4b>
ret
mov    %rsi,%rax
shr    %rax
and    $0x1,%esi
or     %rax,%rsi
cvtsi2ss %rsi,%xmm0
addss  %xmm0,%xmm0
test   %rdi,%rdi
js     1134 <progress_gauge+0x14>
cvtsi2ss %rdi,%xmm1
push   %rax
divss  %xmm1,%xmm0
mulss  0xe88(%rip),%xmm0
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%.0f\0A\00"
@stdout = global i32 0
define void @progress_gauge(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = icmp ugt i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = load i64, i64* %4
%9 = uitofp i64 %8 to float
%10 = load i64, i64* %3
%11 = uitofp i64 %10 to float
%12 = fdiv float %9, %11
%13 = fmul float %12, 1.000000e+02
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
br label %17
17: ; preds = %7, %2
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.0f\0A\00"
@stdout = global i32 0
define void @progress_gauge(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = uitofp i64 %1 to float
%6 = uitofp i64 %0 to float
%7 = fdiv float %5, %6
%8 = fmul float %7, 1.000000e+02
%9 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float %8)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fflush(i32 %10)
br label %12
12: ; preds = %4, %2
ret void
}