#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*/ assert(char *);
char *malloc(int);
char *progress_bar(int current, int full) {
  int bars = (int)(((float)(current + 1) / full) * 50), b = 0;
  char *bar = malloc(53 * sizeof(*bar));
  assert(bar);
  bar[0] = '[';
  for (b = 0; b < 50; b++)
    bar[b + 1] = b < bars ? '|' : ' ';
  bar[51] = ']';
  bar[52] = '\0';
  return bar;
}


x86 assembly (clang, -O0):
<progress_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xeb7(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x35,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
movb   $0x5b,(%rax)
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jge    11bf <progress_bar+0x9f>
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%esi
mov    $0x20,%eax
mov    $0x7c,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1180 <progress_bar+0x60>
mov    -0x18(%rbp),%rax
movb   $0x5d,0x33(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x34(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress_bar>:
push   %rbp
push   %rbx
push   %rax
add    $0x1,%edi
cvtsi2ss %edi,%xmm0
cvtsi2ss %esi,%xmm1
divss  %xmm1,%xmm0
mulss  0xec6(%rip),%xmm0
cvttss2si %xmm0,%ebp
mov    $0x35,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <assert@plt>
movb   $0x5b,(%rbx)
movslq %ebp,%rax
xor    %ecx,%ecx
mov    $0x7c,%edx
cmp    %rax,%rcx
mov    $0x20,%esi
cmovl  %edx,%esi
mov    %sil,0x1(%rbx,%rcx,1)
lea    0x1(%rcx),%rsi
cmp    %rax,%rsi
mov    $0x20,%esi
cmovl  %edx,%esi
lea    0x2(%rcx),%rdi
cmp    %rax,%rdi
mov    $0x20,%edi
cmovl  %edx,%edi
mov    %sil,0x2(%rbx,%rcx,1)
mov    %dil,0x3(%rbx,%rcx,1)
lea    0x3(%rcx),%rsi
cmp    %rax,%rsi
mov    $0x20,%esi
cmovl  %edx,%esi
lea    0x4(%rcx),%rdi
cmp    %rax,%rdi
mov    $0x20,%edi
cmovl  %edx,%edi
mov    %sil,0x4(%rbx,%rcx,1)
mov    %dil,0x5(%rbx,%rcx,1)
add    $0x5,%rcx
cmp    $0x32,%rcx
jne    1160 <progress_bar+0x40>
movw   $0x5d,0x33(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @progress_bar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = sitofp i32 %9 to float
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to float
%13 = fdiv float %10, %12
%14 = fmul float %13, 5.000000e+01
%15 = fptosi float %14 to i32
store i32 %15, i32* %5
store i32 0, i32* %6
%16 = call i8* @malloc(i32 53)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32 @assert(i8* %17)
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 0
store i8 91, i8* %20
store i32 0, i32* %6
br label %21
21: ; preds = %36, %2
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 50
br i1 %23, label %24, label %39
24: ; preds = %21
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 124, i32 32
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %7
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 %30, i8* %35
br label %36
36: ; preds = %24
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %21
39: ; preds = %21
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i64 51
store i8 93, i8* %41
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 52
store i8 0, i8* %43
%44 = load i8*, i8** %7
ret i8* %44
}

LLVM IR (-O2):
define i8* @progress_bar(i32 %0, i32 %1) {
%3 = add nsw i32 %0, 1
%4 = sitofp i32 %3 to float
%5 = sitofp i32 %1 to float
%6 = fdiv float %4, %5
%7 = fmul float %6, 5.000000e+01
%8 = fptosi float %7 to i32
%9 = tail call dereferenceable_or_null(53) i8* @malloc(i32 53)
%10 = tail call i32 @assert(i8* %9)
store i8 91, i8* %9
%11 = sext i32 %8 to i64
br label %12
12: ; preds = %12, %2
%13 = phi i64 [ 0, %2 ], [ %32, %12 ]
%14 = icmp slt i64 %13, %11
%15 = select i1 %14, i8 124, i8 32
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds i8, i8* %9, i64 %16
store i8 %15, i8* %17
%18 = icmp slt i64 %16, %11
%19 = select i1 %18, i8 124, i8 32
%20 = add nuw nsw i64 %13, 2
%21 = getelementptr inbounds i8, i8* %9, i64 %20
store i8 %19, i8* %21
%22 = icmp slt i64 %20, %11
%23 = select i1 %22, i8 124, i8 32
%24 = add nuw nsw i64 %13, 3
%25 = getelementptr inbounds i8, i8* %9, i64 %24
store i8 %23, i8* %25
%26 = icmp slt i64 %24, %11
%27 = select i1 %26, i8 124, i8 32
%28 = add nuw nsw i64 %13, 4
%29 = getelementptr inbounds i8, i8* %9, i64 %28
store i8 %27, i8* %29
%30 = icmp slt i64 %28, %11
%31 = select i1 %30, i8 124, i8 32
%32 = add nuw nsw i64 %13, 5
%33 = getelementptr inbounds i8, i8* %9, i64 %32
store i8 %31, i8* %33
%34 = icmp eq i64 %32, 50
br i1 %34, label %35, label %12
35: ; preds = %12
%36 = getelementptr inbounds i8, i8* %9, i64 51
store i8 93, i8* %36
%37 = getelementptr inbounds i8, i8* %9, i64 52
store i8 0, i8* %37
ret i8* %9
}