#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 *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void progress_bar(int progress) {
  char bar[255];
  unsigned char i;
  strcpy(bar, "Progress | ");
  for (i = 0; i < 50; i++) {
    if ((i * 2) < progress)
      strcat(bar, "#");
    else
      strcat(bar, " ");
  }
  printf("\r");
  printf(bar);
  printf(" | %3i%%", progress);
}


x86 assembly (clang, -O0):
<progress_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <strcpy@plt>
movb   $0x0,-0x111(%rbp)
movzbl -0x111(%rbp),%eax
cmp    $0x32,%eax
jge    11be <progress_bar+0x8e>
movzbl -0x111(%rbp),%eax
shl    $0x1,%eax
cmp    -0x4(%rbp),%eax
jge    1193 <progress_bar+0x63>
lea    -0x110(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strcat@plt>
jmp    11a6 <progress_bar+0x76>
lea    -0x110(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strcat@plt>
jmp    11ab <progress_bar+0x7b>
mov    -0x111(%rbp),%al
add    $0x1,%al
mov    %al,-0x111(%rbp)
jmp    1158 <progress_bar+0x28>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress_bar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %edi,%ebx
lea    0xea8(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
xor    %ebp,%ebp
lea    0xea0(%rip),%r15
lea    0xe97(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ebx,%ebp
mov    %r12,%rsi
cmovl  %r15,%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
add    $0x2,%ebp
cmp    $0x64,%ebp
jne    1180 <progress_bar+0x40>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    %rsp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Progress | \00"
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0D\00"
@.str.4 = [9 x i8] c" | %3i%%\00"
define void @progress_bar(i32 %0) {
%2 = alloca i32
%3 = alloca [255 x i8]
%4 = alloca i8
store i32 %0, i32* %2
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %4
br label %7
7: ; preds = %24, %1
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
%10 = icmp slt i32 %9, 50
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i8, i8* %4
%13 = zext i8 %12 to i32
%14 = mul nsw i32 %13, 2
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %23
20: ; preds = %11
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23
%25 = load i8, i8* %4
%26 = add i8 %25, 1
store i8 %26, i8* %4
br label %7
27: ; preds = %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* %29)
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %31)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Progress | \00"
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [2 x i8] c" \00"
@.str.4 = [9 x i8] c" | %3i%%\00"
define void @progress_bar(i32 %0) {
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %1, %5
%6 = phi i32 [ 0, %1 ], [ %11, %5 ]
%7 = shl nuw i32 %6, 1
%8 = icmp slt i32 %7, %0
%9 = select i1 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%10 = call i32 @strcat(i8* %3, i8* %9)
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, 50
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = call i32 @putchar(i32 13)
%15 = call i32 (i8*, ...) @printf(i8* %3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %0)
ret void
}