#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 ceil(float);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void stepProgressBar(int maxbar, int maxn) {
  static int bar = 0;
  static int n = 0;
  if (maxbar == 0) {
    bar = 0;
    n = 0;
    return;
  }
  n++;
  if (bar == 0) {
    printf("[");
    bar = 1;
    fflush(stdout);
  }
  if (ceil((float)maxbar / maxn * n) > bar) {
    int d = ceil((float)maxbar / maxn * n) - bar;
    int i;
    for (i = 0; i < d; i++)
      if (bar + i + 1 == maxbar)
        printf("]\n");
      else
        printf("-");
    fflush(stdout);
    bar += d;
  }
}


x86 assembly (clang, -O0):
<stepProgressBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1161 <stepProgressBar+0x31>
movl   $0x0,0x2eea(%rip)
movl   $0x0,0x2ee4(%rip)
jmp    1269 <stepProgressBar+0x139>
mov    0x2ed9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed0(%rip)
cmpl   $0x0,0x2ec5(%rip)
jne    11a1 <stepProgressBar+0x71>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,0x2ea9(%rip)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtsi2ssl 0x2e89(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1030 <ceil@plt>
cmp    0x2e76(%rip),%eax
jle    1269 <stepProgressBar+0x139>
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtsi2ssl 0x2e5e(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1030 <ceil@plt>
sub    0x2e4b(%rip),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    124c <stepProgressBar+0x11c>
mov    0x2e2f(%rip),%eax
add    -0x10(%rbp),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
jne    122d <stepProgressBar+0xfd>
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
jmp    1239 <stepProgressBar+0x109>
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
jmp    123e <stepProgressBar+0x10e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fb <stepProgressBar+0xcb>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0xc(%rbp),%eax
add    0x2dd9(%rip),%eax
mov    %eax,0x2dd3(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stepProgressBar>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     1239 <stepProgressBar+0xf9>
mov    %esi,%ebp
mov    %edi,%r15d
mov    0x2eee(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee5(%rip)
cmpl   $0x0,0x2eda(%rip)
jne    1194 <stepProgressBar+0x54>
mov    $0x5b,%edi
call   1030 <putchar@plt>
movl   $0x1,0x2ec4(%rip)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    0x2eb4(%rip),%eax
cvtsi2ss %r15d,%xmm1
cvtsi2ss %ebp,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm1,0x4(%rsp)
mulss  %xmm1,%xmm0
call   1050 <ceil@plt>
cmp    0x2e87(%rip),%eax
jle    1263 <stepProgressBar+0x123>
xorps  %xmm1,%xmm1
cvtsi2ssl 0x2e7a(%rip),%xmm1
movss  0x4(%rsp),%xmm0
mulss  %xmm1,%xmm0
call   1050 <ceil@plt>
mov    %eax,%ebp
mov    0x2e5f(%rip),%eax
sub    %eax,%ebp
test   %ebp,%ebp
jle    124f <stepProgressBar+0x10f>
mov    $0x1,%ebx
lea    0xe09(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r15d,%ecx
sub    %eax,%ecx
cmp    %ebx,%ecx
jne    1220 <stepProgressBar+0xe0>
mov    %r14,%rdi
call   1040 <puts@plt>
cmp    %ebx,%ebp
jne    122e <stepProgressBar+0xee>
jmp    124f <stepProgressBar+0x10f>
nopw   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <putchar@plt>
cmp    %ebx,%ebp
je     124f <stepProgressBar+0x10f>
mov    0x2e10(%rip),%eax
add    $0x1,%ebx
jmp    1200 <stepProgressBar+0xc0>
movl   $0x0,0x2e01(%rip)
movl   $0x0,0x2dfb(%rip)
jmp    1263 <stepProgressBar+0x123>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    %ebp,0x2de1(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stepProgressBar.bar = internal global i32 0
@stepProgressBar.n = internal global i32 0
@.str = [2 x i8] c"[\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"]\0A\00"
@.str.2 = [2 x i8] c"-\00"
define void @stepProgressBar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* @stepProgressBar.bar
store i32 0, i32* @stepProgressBar.n
br label %68
10: ; preds = %2
%11 = load i32, i32* @stepProgressBar.n
%12 = add nsw i32 %11, 1
store i32 %12, i32* @stepProgressBar.n
%13 = load i32, i32* @stepProgressBar.bar
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* @stepProgressBar.bar
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
br label %19
19: ; preds = %15, %10
%20 = load i32, i32* %3
%21 = sitofp i32 %20 to float
%22 = load i32, i32* %4
%23 = sitofp i32 %22 to float
%24 = fdiv float %21, %23
%25 = load i32, i32* @stepProgressBar.n
%26 = sitofp i32 %25 to float
%27 = fmul float %24, %26
%28 = call i32 @ceil(float %27)
%29 = load i32, i32* @stepProgressBar.bar
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %68
31: ; preds = %19
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to float
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to float
%36 = fdiv float %33, %35
%37 = load i32, i32* @stepProgressBar.n
%38 = sitofp i32 %37 to float
%39 = fmul float %36, %38
%40 = call i32 @ceil(float %39)
%41 = load i32, i32* @stepProgressBar.bar
%42 = sub nsw i32 %40, %41
store i32 %42, i32* %5
store i32 0, i32* %6
br label %43
43: ; preds = %59, %31
%44 = load i32, i32* %6
%45 = load i32, i32* %5
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %62
47: ; preds = %43
%48 = load i32, i32* @stepProgressBar.bar
%49 = load i32, i32* %6
%50 = add nsw i32 %48, %49
%51 = add nsw i32 %50, 1
%52 = load i32, i32* %3
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %58
56: ; preds = %47
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %43
62: ; preds = %43
%63 = load i32, i32* @stdout
%64 = call i32 @fflush(i32 %63)
%65 = load i32, i32* %5
%66 = load i32, i32* @stepProgressBar.bar
%67 = add nsw i32 %66, %65
store i32 %67, i32* @stepProgressBar.bar
br label %68
68: ; preds = %9, %62, %19
ret void
}

LLVM IR (-O2):
@stepProgressBar.bar = internal unnamed_addr global i32 0
@stepProgressBar.n = internal unnamed_addr global i32 0
@stdout = global i32 0
@str = [2 x i8] c"]\00"
define void @stepProgressBar(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %5
4: ; preds = %2
store i32 0, i32* @stepProgressBar.bar
store i32 0, i32* @stepProgressBar.n
br label %52
5: ; preds = %2
%6 = load i32, i32* @stepProgressBar.n
%7 = add nsw i32 %6, 1
store i32 %7, i32* @stepProgressBar.n
%8 = load i32, i32* @stepProgressBar.bar
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = tail call i32 @putchar(i32 91)
store i32 1, i32* @stepProgressBar.bar
%12 = load i32, i32* @stdout
%13 = tail call i32 @fflush(i32 %12)
%14 = load i32, i32* @stepProgressBar.n
br label %15
15: ; preds = %10, %5
%16 = phi i32 [ %14, %10 ], [ %7, %5 ]
%17 = sitofp i32 %0 to float
%18 = sitofp i32 %1 to float
%19 = fdiv float %17, %18
%20 = sitofp i32 %16 to float
%21 = fmul float %19, %20
%22 = tail call i32 @ceil(float %21)
%23 = load i32, i32* @stepProgressBar.bar
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %52
25: ; preds = %15
%26 = load i32, i32* @stepProgressBar.n
%27 = sitofp i32 %26 to float
%28 = fmul float %19, %27
%29 = tail call i32 @ceil(float %28)
%30 = load i32, i32* @stepProgressBar.bar
%31 = sub i32 %29, %30
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %47
33: ; preds = %25, %45
%34 = phi i32 [ %46, %45 ], [ %30, %25 ]
%35 = phi i32 [ %36, %45 ], [ 0, %25 ]
%36 = add nuw nsw i32 %35, 1
%37 = add i32 %36, %34
%38 = icmp eq i32 %37, %0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %43
41: ; preds = %33
%42 = tail call i32 @putchar(i32 45)
br label %43
43: ; preds = %39, %41
%44 = icmp eq i32 %36, %31
br i1 %44, label %47, label %45
45: ; preds = %43
%46 = load i32, i32* @stepProgressBar.bar
br label %33
47: ; preds = %43, %25
%48 = load i32, i32* @stdout
%49 = tail call i32 @fflush(i32 %48)
%50 = load i32, i32* @stepProgressBar.bar
%51 = add nsw i32 %50, %31
store i32 %51, i32* @stepProgressBar.bar
br label %52
52: ; preds = %4, %47, %15
ret void
}