#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 + 1) != 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
add    $0x1,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     114a <loadBar+0x3a>
jmp    11fc <loadBar+0xec>
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  0xe86(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c0 <loadBar+0xb0>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <loadBar+0x88>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ee <loadBar+0xde>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c6 <loadBar+0xb6>
lea    0xe1b(%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
add    $0x1,%ecx
mov    %edi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1140 <loadBar+0x20>
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  0xe9f(%rip),%xmm0
cvttss2si %xmm0,%esi
lea    0xe98(%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 = add nsw i32 %16, 1
%18 = srem i32 %13, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %4
br label %58
21: ; preds = %4
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to float
%24 = load i32, i32* %6
%25 = sitofp i32 %24 to float
%26 = fdiv float %23, %25
store float %26, float* %9
%27 = load float, float* %9
%28 = load i32, i32* %8
%29 = sitofp i32 %28 to float
%30 = fmul float %27, %29
%31 = fptosi float %30 to i32
store i32 %31, i32* %10
%32 = load float, float* %9
%33 = fmul float %32, 1.000000e+02
%34 = fptosi float %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %34)
store i32 0, i32* %11
br label %36
36: ; preds = %42, %21
%37 = load i32, i32* %11
%38 = load i32, i32* %10
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %36
45: ; preds = %36
%46 = load i32, i32* %10
store i32 %46, i32* %12
br label %47
47: ; preds = %53, %45
%48 = load i32, i32* %12
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %56
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 1
store i32 %55, i32* %12
br label %47
56: ; preds = %47
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %20
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 = add nsw i32 %5, 1
%7 = srem i32 %0, %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %34
9: ; preds = %4
%10 = sitofp i32 %0 to float
%11 = sitofp i32 %1 to float
%12 = fdiv float %10, %11
%13 = sitofp i32 %3 to float
%14 = fmul float %12, %13
%15 = fptosi float %14 to i32
%16 = fmul float %12, 1.000000e+02
%17 = fptosi float %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = icmp sgt i32 %15, 0
br i1 %19, label %22, label %20
20: ; preds = %22, %9
%21 = icmp slt i32 %15, %3
br i1 %21, label %29, label %27
22: ; preds = %9, %22
%23 = phi i32 [ %25, %22 ], [ 0, %9 ]
%24 = tail call i32 @putchar(i32 61)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %15
br i1 %26, label %20, label %22
27: ; preds = %29, %20
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %34
29: ; preds = %20, %29
%30 = phi i32 [ %32, %29 ], [ %15, %20 ]
%31 = tail call i32 @putchar(i32 32)
%32 = add i32 %30, 1
%33 = icmp eq i32 %32, %3
br i1 %33, label %27, label %29
34: ; preds = %4, %27
ret void
}