#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 get_columns();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void print_bar(int cur, int total) {
  int bar_width;
  int i;
  float progress = cur * 100.0 / total;
  int pos;
  bar_width = get_columns() - 33;
  pos = bar_width * cur / total;
  printf(" %3.0f%% [", progress);
  for (i = 0; i < bar_width; i++) {
    if (i < pos)
      putchar('=');
    else if (i == pos)
      putchar('>');
    else
      putchar(' ');
  }
  printf("] ");
}


x86 assembly (clang, -O0):
<print_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <get_columns@plt>
sub    $0x21,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fe <print_bar+0xce>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c1 <print_bar+0x91>
mov    $0x3d,%edi
call   1030 <putchar@plt>
jmp    11eb <print_bar+0xbb>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11dc <print_bar+0xac>
mov    $0x3e,%edi
call   1030 <putchar@plt>
jmp    11e6 <print_bar+0xb6>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11eb <print_bar+0xbb>
jmp    11f0 <print_bar+0xc0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119a <print_bar+0x6a>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
mov    %edi,%ebx
cvtsi2sd %edi,%xmm0
mulsd  0xeb3(%rip),%xmm0
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <get_columns@plt>
mov    %eax,%r14d
lea    -0x21(%r14),%r12d
imul   %r12d,%ebx
mov    %ebx,%eax
cltd
idiv   %r15d
mov    %eax,%ebx
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    $0x22,%r14d
jl     11cc <print_bar+0x9c>
mov    $0x3e,%r14d
mov    $0x3d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %ebp,%ebx
mov    $0x20,%edi
cmove  %r14d,%edi
cmovg  %r15d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    11b0 <print_bar+0x80>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c" %3.0f%% [\00"
@.str.1 = [3 x i8] c"] \00"
define void @print_bar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 1.000000e+02
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to double
%14 = fdiv double %11, %13
%15 = fptrunc double %14 to float
store float %15, float* %7
%16 = call i32 (...) @get_columns()
%17 = sub nsw i32 %16, 33
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %4
%22 = sdiv i32 %20, %21
store i32 %22, i32* %8
%23 = load float, float* %7
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %24)
store i32 0, i32* %6
br label %26
26: ; preds = %46, %2
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %49
30: ; preds = %26
%31 = load i32, i32* %6
%32 = load i32, i32* %8
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @putchar(i8 signext 61)
br label %45
36: ; preds = %30
%37 = load i32, i32* %6
%38 = load i32, i32* %8
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @putchar(i8 signext 62)
br label %44
42: ; preds = %36
%43 = call i32 @putchar(i8 signext 32)
br label %44
44: ; preds = %42, %40
br label %45
45: ; preds = %44, %34
br label %46
46: ; preds = %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %26
49: ; preds = %26
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c" %3.0f%% [\00"
@.str.1 = [3 x i8] c"] \00"
define void @print_bar(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to double
%4 = fmul double %3, 1.000000e+02
%5 = sitofp i32 %1 to double
%6 = fdiv double %4, %5
%7 = fptrunc double %6 to float
%8 = tail call i32 (...) @get_columns()
%9 = add i32 %8, -33
%10 = mul nsw i32 %9, %0
%11 = sdiv i32 %10, %1
%12 = fpext float %7 to double
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %12)
%14 = icmp sgt i32 %8, 33
br i1 %14, label %15, label %24
15: ; preds = %2, %15
%16 = phi i32 [ %22, %15 ], [ 0, %2 ]
%17 = icmp slt i32 %16, %11
%18 = icmp eq i32 %16, %11
%19 = select i1 %18, i8 62, i8 32
%20 = select i1 %17, i8 61, i8 %19
%21 = tail call i32 @putchar(i8 signext %20)
%22 = add nuw nsw i32 %16, 1
%23 = icmp eq i32 %22, %9
br i1 %23, label %24, label %15
24: ; preds = %15, %2
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}