#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 printProgress(int pos, int full) {
  int i, bar;
  float per = (float)pos / full * 100;
  if (pos < 0 || full < pos) {
    printf("progress bar error\n");
    return 1;
  }
  bar = pos * 20 / full;
  printf("|");
  for (i = 0; i < bar; i++) {
    printf("*");
  }
  for (i = bar; i < 20; i++) {
    printf("-");
  }
  printf("|%5.1f%%    NUM:[ %d / %d ]\n", per, pos, full);
  return 0;
}


x86 assembly (clang, -O0):
<printProgress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xecc(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1153 <printProgress+0x43>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    116d <printProgress+0x5d>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1205 <printProgress+0xf5>
imul   $0x14,-0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x14(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <printProgress+0xa5>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118d <printProgress+0x7d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    11e1 <printProgress+0xd1>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bb <printProgress+0xab>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProgress>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     11e0 <printProgress+0xb0>
mov    %esi,%r14d
mov    %edi,%r15d
cmp    %edi,%esi
jl     11e0 <printProgress+0xb0>
cvtsi2ss %r15d,%xmm1
cvtsi2ss %r14d,%xmm0
divss  %xmm0,%xmm1
mulss  0xe9d(%rip),%xmm1
movss  %xmm1,0x4(%rsp)
lea    0x0(,%r15,4),%eax
lea    (%rax,%rax,4),%eax
cltd
idiv   %r14d
mov    %eax,%ebx
mov    $0x7c,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
jle    11a4 <printProgress+0x74>
mov    %ebx,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1190 <printProgress+0x60>
cmp    $0x13,%ebx
jg     11be <printProgress+0x8e>
add    $0xffffffec,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    11b0 <printProgress+0x80>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe35(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
jmp    11f1 <printProgress+0xc1>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.4 = [29 x i8] c"|%5.1f%% NUM:[ %d / %d ]\0A\00"
@str = [19 x i8] c"progress bar error\00"
define i32 @printProgress(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to float
%4 = sitofp i32 %1 to float
%5 = fdiv float %3, %4
%6 = fmul float %5, 1.000000e+02
%7 = icmp slt i32 %0, 0
%8 = icmp slt i32 %1, %0
%9 = or i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %33
12: ; preds = %2
%13 = mul nsw i32 %0, 20
%14 = sdiv i32 %13, %1
%15 = tail call i32 @putchar(i32 124)
%16 = icmp sgt i32 %14, 0
br i1 %16, label %20, label %19
17: ; preds = %20
%18 = icmp slt i32 %14, 20
br i1 %18, label %19, label %30
19: ; preds = %12, %17
br label %25
20: ; preds = %12, %20
%21 = phi i32 [ %23, %20 ], [ 0, %12 ]
%22 = tail call i32 @putchar(i32 42)
%23 = add nuw nsw i32 %21, 1
%24 = icmp eq i32 %23, %14
br i1 %24, label %17, label %20
25: ; preds = %19, %25
%26 = phi i32 [ %28, %25 ], [ %14, %19 ]
%27 = tail call i32 @putchar(i32 45)
%28 = add i32 %26, 1
%29 = icmp eq i32 %28, 20
br i1 %29, label %30, label %25
30: ; preds = %25, %17
%31 = fpext float %6 to double
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), double %31, i32 %0, i32 %1)
br label %33
33: ; preds = %30, %10
%34 = phi i32 [ 1, %10 ], [ 0, %30 ]
ret i32 %34
}