#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 *, ...);
void loadBar(int x, int n, int r, int w) {
  if (x % (n / r) != 0)
    return;
  float ratio = x / (float)n;
  int c = ratio * w;
  printf("%3d%% [", (int)(ratio * 100));
  for (int x = 0; x < c; x++)
    printf("=");
  for (int x = c; x < w; x++)
    printf(" ");
  printf("]\n\033[F\033[J");
}


x86 assembly (clang, -O0):
<loadBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1147 <loadBar+0x37>
jmp    11f9 <loadBar+0xe9>
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
movss  0xe89(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11bd <loadBar+0xad>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1195 <loadBar+0x85>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11eb <loadBar+0xdb>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c3 <loadBar+0xb3>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadBar>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebx
mov    %edx,%ecx
mov    %esi,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    %edi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     113d <loadBar+0x1d>
pop    %rbx
pop    %r14
pop    %rbp
ret
cvtsi2ss %edi,%xmm0
cvtsi2ss %esi,%xmm1
cvtsi2ss %ebx,%xmm2
divss  %xmm1,%xmm0
mulss  %xmm0,%xmm2
cvttss2si %xmm2,%r14d
mulss  0xea2(%rip),%xmm0
cvttss2si %xmm0,%esi
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
jle    118f <loadBar+0x6f>
mov    %r14d,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1180 <loadBar+0x60>
cmp    %ebx,%r14d
jge    11af <loadBar+0x8f>
sub    %r14d,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11a0 <loadBar+0x80>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%3d%% [\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [9 x i8] c"]\0A\1B[F\1B[J\00"
define void @loadBar(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = sdiv i32 %14, %15
%17 = srem i32 %13, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %4
br label %57
20: ; preds = %4
%21 = load i32, i32* %5
%22 = sitofp i32 %21 to float
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
store float %25, float* %9
%26 = load float, float* %9
%27 = load i32, i32* %8
%28 = sitofp i32 %27 to float
%29 = fmul float %26, %28
%30 = fptosi float %29 to i32
store i32 %30, i32* %10
%31 = load float, float* %9
%32 = fmul float %31, 1.000000e+02
%33 = fptosi float %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %33)
store i32 0, i32* %11
br label %35
35: ; preds = %41, %20
%36 = load i32, i32* %11
%37 = load i32, i32* %10
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %35
44: ; preds = %35
%45 = load i32, i32* %10
store i32 %45, i32* %12
br label %46
46: ; preds = %52, %44
%47 = load i32, i32* %12
%48 = load i32, i32* %8
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
store i32 %54, i32* %12
br label %46
55: ; preds = %46
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %19
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%3d%% [\00"
@.str.3 = [9 x i8] c"]\0A\1B[F\1B[J\00"
define void @loadBar(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sdiv i32 %1, %2
%6 = srem i32 %0, %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %4
%9 = sitofp i32 %0 to float
%10 = sitofp i32 %1 to float
%11 = fdiv float %9, %10
%12 = sitofp i32 %3 to float
%13 = fmul float %11, %12
%14 = fptosi float %13 to i32
%15 = fmul float %11, 1.000000e+02
%16 = fptosi float %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = icmp sgt i32 %14, 0
br i1 %18, label %21, label %19
19: ; preds = %21, %8
%20 = icmp slt i32 %14, %3
br i1 %20, label %28, label %26
21: ; preds = %8, %21
%22 = phi i32 [ %24, %21 ], [ 0, %8 ]
%23 = tail call i32 @putchar(i32 61)
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, %14
br i1 %25, label %19, label %21
26: ; preds = %28, %19
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %33
28: ; preds = %19, %28
%29 = phi i32 [ %31, %28 ], [ %14, %19 ]
%30 = tail call i32 @putchar(i32 32)
%31 = add i32 %29, 1
%32 = icmp eq i32 %31, %3
br i1 %32, label %26, label %28
33: ; preds = %4, %26
ret void
}