#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 *, char const, unsigned int, double);
int /*<<< orphan*/ stdout;
void show_progress(unsigned int n, unsigned int final_n) {
  const char *progress = "|/-\\";
  if (n % 16 == 0) {
    printf("%c %9d (%5.2f%%)\r", progress[(n / 16) % 4], n,
           100.0 * (double)n / final_n);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<show_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1196 <show_progress+0x76>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
mov    %ecx,%edx
mov    %edx,%esi
shr    $0x4,%esi
and    $0x3,%esi
mov    (%rax,%rsi,1),%al
cvtsi2sd %rcx,%xmm0
movsd  0xe97(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%ecx
cvtsi2sd %rcx,%xmm1
divsd  %xmm1,%xmm0
lea    0xe8d(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_progress>:
mov    %edi,%edx
test   $0xf,%dl
je     1128 <show_progress+0x8>
ret
push   %rax
mov    %edx,%eax
shr    $0x4,%eax
and    $0x3,%eax
lea    0xed0(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %edx,%ecx
cvtsi2sd %rcx,%xmm0
mulsd  0xeb5(%rip),%xmm0
mov    %esi,%ecx
cvtsi2sd %rcx,%xmm1
divsd  %xmm1,%xmm0
lea    0xeb0(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"|/-\\\00"
@.str.1 = [18 x i8] c"%c %9d (%5.2f%%)\0D\00"
@stdout = global i32 0
define void @show_progress(i32 %0, i32 %1) {
%3 = and i32 %0, 15
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = lshr i32 %0, 4
%7 = and i32 %6, 3
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = uitofp i32 %0 to double
%12 = fmul double %11, 1.000000e+02
%13 = uitofp i32 %1 to double
%14 = fdiv double %12, %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 signext %10, i32 %0, double %14)
%16 = load i32, i32* @stdout
%17 = tail call i32 @fflush(i32 %16)
br label %18
18: ; preds = %5, %2
ret void
}