#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 *, ...);
int /*<<< orphan*/ stdout;
int ProgressBar(int pcn, int pco, int len, int tics) {
  int pc_n = (pcn * len) / 100;
  int pc = pco, tic;
  int i;
  pco = (pco * len) / 100;
  if (pco == len)
    return pc;
  tic = len / tics;
  for (i = pco + 1; i <= pc_n; i++) {
    if (i % tic == 0) {
      if (i == 0)
        printf("|");
      else {
        printf("\b\b\b\b");
        printf("|");
      }
    } else {
      printf("\b\b\b\b");
      printf("=");
    }
    pc = pcn;
    printf("%3i%%", pc);
  }
  if (pcn > pc) {
    printf("\b\b\b\b");
    printf("%3i%%", pcn);
    pc = pcn;
  }
  if (pc_n == len)
    printf("\n");
  fflush(stdout);
  return pc;
}


x86 assembly (clang, -O0):
<ProgressBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1175 <ProgressBar+0x55>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1282 <ProgressBar+0x162>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1223 <ProgressBar+0x103>
mov    -0x24(%rbp),%eax
cltd
idivl  -0x20(%rbp)
cmp    $0x0,%edx
jne    11e2 <ProgressBar+0xc2>
cmpl   $0x0,-0x24(%rbp)
jne    11c1 <ProgressBar+0xa1>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dd <ProgressBar+0xbd>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fe <ProgressBar+0xde>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1188 <ProgressBar+0x68>
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1254 <ProgressBar+0x134>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    126e <ProgressBar+0x14e>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProgressBar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r15d
mov    %edx,%eax
imul   %esi,%eax
cltq
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x25,%rbx
add    %eax,%ebx
cmp    %edx,%ebx
je     1254 <ProgressBar+0x124>
mov    %edx,%r14d
mov    %edi,%r12d
mov    %edx,%eax
imul   %edi,%eax
cltq
imul   $0x51eb851f,%rax,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x25,%r13
add    %eax,%r13d
mov    %edx,%eax
cltd
idiv   %ecx
cmp    %r13d,%ebx
jge    1201 <ProgressBar+0xd1>
mov    %eax,%ebp
mov    %r14d,0xc(%rsp)
mov    %r13,0x10(%rsp)
neg    %r13d
add    $0x1,%ebx
lea    0xe5c(%rip),%r15
jmp    11e6 <ProgressBar+0xb6>
nopl   0x0(%rax,%rax,1)
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     122a <ProgressBar+0xfa>
mov    %ebx,%eax
cltd
idiv   %ebp
mov    $0x3d,%r14d
test   %edx,%edx
jne    11b0 <ProgressBar+0x80>
mov    $0x7c,%r14d
test   %ebx,%ebx
jne    11b0 <ProgressBar+0x80>
jmp    11be <ProgressBar+0x8e>
cmp    %r12d,%r15d
jge    1237 <ProgressBar+0x107>
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdea(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%r15d
jmp    1237 <ProgressBar+0x107>
mov    %r12d,%r15d
mov    0xc(%rsp),%r14d
mov    0x10(%rsp),%r13
cmp    %r14d,%r13d
jne    1246 <ProgressBar+0x116>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
@.str.1 = [5 x i8] c"\08\08\08\08\00"
@.str.2 = [2 x i8] c"=\00"
@.str.3 = [6 x i8] c"%3i%%\00"
@.str.4 = [2 x i8] c"\0A\00"
@stdout = global i32 0
define i32 @ProgressBar(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%14 = load i32, i32* %6
%15 = load i32, i32* %8
%16 = mul nsw i32 %14, %15
%17 = sdiv i32 %16, 100
store i32 %17, i32* %10
%18 = load i32, i32* %7
store i32 %18, i32* %11
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = mul nsw i32 %19, %20
%22 = sdiv i32 %21, 100
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %4
%27 = load i32, i32* %11
store i32 %27, i32* %5
br label %81
28: ; preds = %4
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = sdiv i32 %29, %30
store i32 %31, i32* %12
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %13
br label %34
34: ; preds = %59, %28
%35 = load i32, i32* %13
%36 = load i32, i32* %10
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %62
38: ; preds = %34
%39 = load i32, i32* %13
%40 = load i32, i32* %12
%41 = srem i32 %39, %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %38
%44 = load i32, i32* %13
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %51
48: ; preds = %43
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %51
51: ; preds = %48, %46
br label %55
52: ; preds = %38
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %52, %51
%56 = load i32, i32* %6
store i32 %56, i32* %11
%57 = load i32, i32* %11
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %55
%60 = load i32, i32* %13
%61 = add nsw i32 %60, 1
store i32 %61, i32* %13
br label %34
62: ; preds = %34
%63 = load i32, i32* %6
%64 = load i32, i32* %11
%65 = icmp sgt i32 %63, %64
br i1 %65, label %66, label %71
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%68 = load i32, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %6
store i32 %70, i32* %11
br label %71
71: ; preds = %66, %62
%72 = load i32, i32* %10
%73 = load i32, i32* %8
%74 = icmp eq i32 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %77
77: ; preds = %75, %71
%78 = load i32, i32* @stdout
%79 = call i32 @fflush(i32 %78)
%80 = load i32, i32* %11
store i32 %80, i32* %5
br label %81
81: ; preds = %77, %26
%82 = load i32, i32* %5
ret i32 %82
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"\08\08\08\08\00"
@.str.3 = [6 x i8] c"%3i%%\00"
@stdout = global i32 0
define i32 @ProgressBar(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %2, %0
%6 = sdiv i32 %5, 100
%7 = mul nsw i32 %2, %1
%8 = sdiv i32 %7, 100
%9 = icmp eq i32 %8, %2
br i1 %9, label %41, label %10
10: ; preds = %4
%11 = sdiv i32 %2, %3
%12 = icmp slt i32 %8, %6
br i1 %12, label %13, label %28
13: ; preds = %10, %23
%14 = phi i32 [ %15, %23 ], [ %8, %10 ]
%15 = add nsw i32 %14, 1
%16 = srem i32 %15, %11
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = icmp eq i32 %15, 0
br i1 %19, label %23, label %20
20: ; preds = %13, %18
%21 = phi i32 [ 124, %18 ], [ 61, %13 ]
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %18
%24 = phi i32 [ 124, %18 ], [ %21, %20 ]
%25 = tail call i32 @putchar(i32 %24)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%27 = icmp eq i32 %15, %6
br i1 %27, label %33, label %13
28: ; preds = %10
%29 = icmp slt i32 %1, %0
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %33
33: ; preds = %23, %30, %28
%34 = phi i32 [ %0, %30 ], [ %1, %28 ], [ %0, %23 ]
%35 = icmp eq i32 %6, %2
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = tail call i32 @putchar(i32 10)
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* @stdout
%40 = tail call i32 @fflush(i32 %39)
br label %41
41: ; preds = %4, %38
%42 = phi i32 [ %34, %38 ], [ %1, %4 ]
ret i32 %42
}