#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*/ printf(char *, int);
void display_progress(size_t current, size_t total) {
  if (total < 100) {
    return;
  }
  size_t one_percent = total / 100;
  if (current % one_percent == 0) {
    printf("\r%.2f%%", 100. * (double)current / (double)total);
  }
}


x86 assembly (clang, -O0):
<display_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x64,-0x10(%rbp)
jae    1130 <display_progress+0x20>
jmp    11b7 <display_progress+0xa7>
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    11b7 <display_progress+0xa7>
movq   -0x8(%rbp),%xmm0
movaps 0xe9c(%rip),%xmm3
punpckldq %xmm3,%xmm0
movapd 0xea0(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe99(%rip),%xmm1
mulsd  %xmm1,%xmm0
movq   -0x10(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_progress>:
cmp    $0x64,%rsi
jb     114a <display_progress+0x3a>
mov    %rsi,%rax
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rcx
c2 f5 28
mul    %rcx
mov    %rdx,%rcx
shr    $0x2,%rcx
mov    %rdi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     114b <display_progress+0x3b>
mov    %rdi,%rax
xor    %edx,%edx
div    %rcx
test   %rdx,%rdx
je     1156 <display_progress+0x46>
ret
mov    %edi,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    114a <display_progress+0x3a>
movq   %rdi,%xmm0
movdqa 0xe9d(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xea1(%rip),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
mulsd  0xe99(%rip),%xmm3
movq   %rsi,%xmm0
punpckldq %xmm1,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm3
cvttsd2si %xmm3,%esi
lea    0xe79(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\0D%.2f%%\00"
define void @display_progress(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = icmp ult i64 %6, 100
br i1 %7, label %8, label %9
8: ; preds = %2
br label %25
9: ; preds = %2
%10 = load i64, i64* %4
%11 = udiv i64 %10, 100
store i64 %11, i64* %5
%12 = load i64, i64* %3
%13 = load i64, i64* %5
%14 = urem i64 %12, %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %9
%17 = load i64, i64* %3
%18 = uitofp i64 %17 to double
%19 = fmul double 1.000000e+02, %18
%20 = load i64, i64* %4
%21 = uitofp i64 %20 to double
%22 = fdiv double %19, %21
%23 = fptosi double %22 to i32
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %8, %16, %9
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\0D%.2f%%\00"
define void @display_progress(i64 %0, i64 %1) {
%3 = icmp ult i64 %1, 100
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = udiv i64 %1, 100
%6 = urem i64 %0, %5
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = uitofp i64 %0 to double
%10 = fmul double %9, 1.000000e+02
%11 = uitofp i64 %1 to double
%12 = fdiv double %10, %11
%13 = fptosi double %12 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %4, %8, %2
ret void
}