#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
void progress(int x, int X, void *ptr) {
  int nummarks = ((int64_t)x * 20) / X;
  int percent = ((int64_t)x * 100) / X;
  char m[] = "-\\|/";
  char HASH_MARK;
  int i;
  char HASH_BARRIER = '>';
  char NO_HASH = ' ';
  if (percent != 100)
    HASH_MARK = '-';
  else
    HASH_MARK = '*';
  printf("%c [[34m", m[percent % 4]);
  for (i = 0; i < 20; i++) {
    if (i < nummarks)
      putchar(HASH_MARK);
    else if (i == nummarks)
      putchar(HASH_BARRIER);
    else
      putchar(NO_HASH);
  }
  printf("[m] [37;40m%3i[m%%", percent);
  if (x != X)
    for (i = 0; i < (20 + 9); i++)
      putchar('\b');
  fflush(stdout);
}


x86 assembly (clang, -O0):
<progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
imul   $0x14,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x14(%rbp)
imul   $0x64,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x18(%rbp)
mov    0xea2(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    0xe9d(%rip),%al
mov    %al,-0x19(%rbp)
movb   $0x3e,-0x25(%rbp)
movb   $0x20,-0x26(%rbp)
cmpl   $0x64,-0x18(%rbp)
je     1185 <progress+0x55>
movb   $0x2d,-0x1e(%rbp)
jmp    1189 <progress+0x59>
movb   $0x2a,-0x1e(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x1d(%rbp,%rax,1),%esi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x14,-0x24(%rbp)
jge    120e <progress+0xde>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d3 <progress+0xa3>
movsbl -0x1e(%rbp),%edi
call   1030 <putchar@plt>
jmp    11fb <progress+0xcb>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11ed <progress+0xbd>
movsbl -0x25(%rbp),%edi
call   1030 <putchar@plt>
jmp    11f6 <progress+0xc6>
movsbl -0x26(%rbp),%edi
call   1030 <putchar@plt>
jmp    11fb <progress+0xcb>
jmp    1200 <progress+0xd0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11af <progress+0x7f>
mov    -0x18(%rbp),%esi
lea    0xdf7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1257 <progress+0x127>
movl   $0x0,-0x24(%rbp)
cmpl   $0x1d,-0x24(%rbp)
jge    1252 <progress+0x122>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1230 <progress+0x100>
jmp    1257 <progress+0x127>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
lea    0x0(,%rdi,4),%eax
lea    (%rax,%rax,4),%eax
cltd
mov    %esi,0xc(%rsp)
idiv   %esi
mov    %eax,%ebx
imul   $0x64,%edi,%eax
cltd
idiv   %esi
mov    %eax,%r12d
xor    %eax,%eax
cmp    $0x64,%r12d
setne  %al
lea    (%rax,%rax,2),%r13d
add    $0x2a,%r13d
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffffc,%eax
mov    %r12d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
lea    0xe72(%rip),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
mov    $0x3e,%r14d
mov    $0x20,%eax
cmove  %r14d,%eax
cmovg  %r13d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
cmp    $0x1,%ebx
mov    $0x20,%eax
cmove  %r14d,%eax
cmp    $0x2,%ebx
cmovge %r13d,%eax
movzbl %al,%edi
mov    $0x20,%r15d
cmove  %r14d,%r15d
call   1030 <putchar@plt>
cmp    $0x3,%ebx
cmovge %r13d,%r15d
movzbl %r15b,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x4,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x5,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x6,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x7,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x8,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x9,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0xa,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0xb,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0xc,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0xd,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0xe,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0xf,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x10,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x11,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x12,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x13,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
mov    $0x20,%ebp
cmove  %r14d,%ebp
call   1030 <putchar@plt>
cmp    $0x14,%ebx
cmovge %r13d,%ebp
movzbl %bpl,%edi
call   1030 <putchar@plt>
lea    0xc6f(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    %eax,0x10(%rsp)
je     14d8 <progress+0x3a8>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    0x2b01(%rip),%rax
mov    (%rax),%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

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

LLVM IR (-O2):
@__const.progress.m = [5 x i8] c"-\\|/\00"
@.str = [10 x i8] c"%c [\1B[34m\00"
@.str.1 = [22 x i8] c"\1B[m] \1B[37;40m%3i\1B[m%%\00"
@stdout = global i32 0
define void @progress(i32 %0, i32 %1, i8* nocapture readnone %2) {
%4 = mul nsw i32 %0, 20
%5 = sdiv i32 %4, %1
%6 = mul nsw i32 %0, 100
%7 = sdiv i32 %6, %1
%8 = icmp eq i32 %7, 100
%9 = select i1 %8, i8 42, i8 45
%10 = srem i32 %7, 4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x i8], [5 x i8]* @__const.progress.m, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp sgt i32 %5, 0
%17 = icmp eq i32 %5, 0
%18 = select i1 %17, i8 62, i8 32
%19 = select i1 %16, i8 %9, i8 %18
%20 = tail call i32 @putchar(i8 signext %19)
%21 = icmp sgt i32 %5, 1
%22 = icmp eq i32 %5, 1
%23 = select i1 %22, i8 62, i8 32
%24 = select i1 %21, i8 %9, i8 %23
%25 = tail call i32 @putchar(i8 signext %24)
%26 = icmp sgt i32 %5, 2
%27 = icmp eq i32 %5, 2
%28 = select i1 %27, i8 62, i8 32
%29 = select i1 %26, i8 %9, i8 %28
%30 = tail call i32 @putchar(i8 signext %29)
%31 = icmp sgt i32 %5, 3
%32 = icmp eq i32 %5, 3
%33 = select i1 %32, i8 62, i8 32
%34 = select i1 %31, i8 %9, i8 %33
%35 = tail call i32 @putchar(i8 signext %34)
%36 = icmp sgt i32 %5, 4
%37 = icmp eq i32 %5, 4
%38 = select i1 %37, i8 62, i8 32
%39 = select i1 %36, i8 %9, i8 %38
%40 = tail call i32 @putchar(i8 signext %39)
%41 = icmp sgt i32 %5, 5
%42 = icmp eq i32 %5, 5
%43 = select i1 %42, i8 62, i8 32
%44 = select i1 %41, i8 %9, i8 %43
%45 = tail call i32 @putchar(i8 signext %44)
%46 = icmp sgt i32 %5, 6
%47 = icmp eq i32 %5, 6
%48 = select i1 %47, i8 62, i8 32
%49 = select i1 %46, i8 %9, i8 %48
%50 = tail call i32 @putchar(i8 signext %49)
%51 = icmp sgt i32 %5, 7
%52 = icmp eq i32 %5, 7
%53 = select i1 %52, i8 62, i8 32
%54 = select i1 %51, i8 %9, i8 %53
%55 = tail call i32 @putchar(i8 signext %54)
%56 = icmp sgt i32 %5, 8
%57 = icmp eq i32 %5, 8
%58 = select i1 %57, i8 62, i8 32
%59 = select i1 %56, i8 %9, i8 %58
%60 = tail call i32 @putchar(i8 signext %59)
%61 = icmp sgt i32 %5, 9
%62 = icmp eq i32 %5, 9
%63 = select i1 %62, i8 62, i8 32
%64 = select i1 %61, i8 %9, i8 %63
%65 = tail call i32 @putchar(i8 signext %64)
%66 = icmp sgt i32 %5, 10
%67 = icmp eq i32 %5, 10
%68 = select i1 %67, i8 62, i8 32
%69 = select i1 %66, i8 %9, i8 %68
%70 = tail call i32 @putchar(i8 signext %69)
%71 = icmp sgt i32 %5, 11
%72 = icmp eq i32 %5, 11
%73 = select i1 %72, i8 62, i8 32
%74 = select i1 %71, i8 %9, i8 %73
%75 = tail call i32 @putchar(i8 signext %74)
%76 = icmp sgt i32 %5, 12
%77 = icmp eq i32 %5, 12
%78 = select i1 %77, i8 62, i8 32
%79 = select i1 %76, i8 %9, i8 %78
%80 = tail call i32 @putchar(i8 signext %79)
%81 = icmp sgt i32 %5, 13
%82 = icmp eq i32 %5, 13
%83 = select i1 %82, i8 62, i8 32
%84 = select i1 %81, i8 %9, i8 %83
%85 = tail call i32 @putchar(i8 signext %84)
%86 = icmp sgt i32 %5, 14
%87 = icmp eq i32 %5, 14
%88 = select i1 %87, i8 62, i8 32
%89 = select i1 %86, i8 %9, i8 %88
%90 = tail call i32 @putchar(i8 signext %89)
%91 = icmp sgt i32 %5, 15
%92 = icmp eq i32 %5, 15
%93 = select i1 %92, i8 62, i8 32
%94 = select i1 %91, i8 %9, i8 %93
%95 = tail call i32 @putchar(i8 signext %94)
%96 = icmp sgt i32 %5, 16
%97 = icmp eq i32 %5, 16
%98 = select i1 %97, i8 62, i8 32
%99 = select i1 %96, i8 %9, i8 %98
%100 = tail call i32 @putchar(i8 signext %99)
%101 = icmp sgt i32 %5, 17
%102 = icmp eq i32 %5, 17
%103 = select i1 %102, i8 62, i8 32
%104 = select i1 %101, i8 %9, i8 %103
%105 = tail call i32 @putchar(i8 signext %104)
%106 = icmp sgt i32 %5, 18
%107 = icmp eq i32 %5, 18
%108 = select i1 %107, i8 62, i8 32
%109 = select i1 %106, i8 %9, i8 %108
%110 = tail call i32 @putchar(i8 signext %109)
%111 = icmp sgt i32 %5, 19
%112 = icmp eq i32 %5, 19
%113 = select i1 %112, i8 62, i8 32
%114 = select i1 %111, i8 %9, i8 %113
%115 = tail call i32 @putchar(i8 signext %114)
%116 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%117 = icmp eq i32 %0, %1
br i1 %117, label %148, label %118
118: ; preds = %3
%119 = tail call i32 @putchar(i8 signext 8)
%120 = tail call i32 @putchar(i8 signext 8)
%121 = tail call i32 @putchar(i8 signext 8)
%122 = tail call i32 @putchar(i8 signext 8)
%123 = tail call i32 @putchar(i8 signext 8)
%124 = tail call i32 @putchar(i8 signext 8)
%125 = tail call i32 @putchar(i8 signext 8)
%126 = tail call i32 @putchar(i8 signext 8)
%127 = tail call i32 @putchar(i8 signext 8)
%128 = tail call i32 @putchar(i8 signext 8)
%129 = tail call i32 @putchar(i8 signext 8)
%130 = tail call i32 @putchar(i8 signext 8)
%131 = tail call i32 @putchar(i8 signext 8)
%132 = tail call i32 @putchar(i8 signext 8)
%133 = tail call i32 @putchar(i8 signext 8)
%134 = tail call i32 @putchar(i8 signext 8)
%135 = tail call i32 @putchar(i8 signext 8)
%136 = tail call i32 @putchar(i8 signext 8)
%137 = tail call i32 @putchar(i8 signext 8)
%138 = tail call i32 @putchar(i8 signext 8)
%139 = tail call i32 @putchar(i8 signext 8)
%140 = tail call i32 @putchar(i8 signext 8)
%141 = tail call i32 @putchar(i8 signext 8)
%142 = tail call i32 @putchar(i8 signext 8)
%143 = tail call i32 @putchar(i8 signext 8)
%144 = tail call i32 @putchar(i8 signext 8)
%145 = tail call i32 @putchar(i8 signext 8)
%146 = tail call i32 @putchar(i8 signext 8)
%147 = tail call i32 @putchar(i8 signext 8)
br label %148
148: ; preds = %118, %3
%149 = load i32, i32* @stdout
%150 = tail call i32 @fflush(i32 %149)
ret void
}