#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 floor(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, float);
int strlen(char *);
void printProgress(int it, int itmax, int nx) {
  char start[15], end[11];
  int indent, newNX, i;
  float percPrg = it * 100.0 / (float)itmax;
  sprintf(start, "It = %i [", it);
  sprintf(end, "] %.3f%%", percPrg);
  printf("%s", start);
  newNX = nx - strlen(end) - strlen(start);
  indent = floor(percPrg * newNX / 100.0);
  for (i = 0; i < indent - 1; i++)
    printf("=");
  if (i < newNX - 1)
    printf(">");
  for (i = indent + 1; i < newNX - 1; i++)
    printf(" ");
  printf(" %s\n", end);
}


x86 assembly (clang, -O0):
<printProgress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
lea    -0x1b(%rbp),%rdi
cvtsi2ssl -0x4(%rbp),%xmm0
lea    0xe80(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x26(%rbp),%rdi
movss  -0x38(%rbp),%xmm0
lea    0xe75(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x1b(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x26(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x3c(%rbp)
lea    -0x1b(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x30(%rbp)
movss  -0x38(%rbp),%xmm0
cvtsi2ssl -0x30(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <floor@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    123e <printProgress+0xfe>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1211 <printProgress+0xd1>
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    125d <printProgress+0x11d>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1293 <printProgress+0x153>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1266 <printProgress+0x126>
lea    -0x26(%rbp),%rsi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProgress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cvtsi2sd %edi,%xmm0
mulsd  0xe96(%rip),%xmm0
cvtsi2ss %esi,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
mov    %edx,%r13d
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
lea    0xe7b(%rip),%rsi
lea    0x19(%rsp),%r15
mov    %r15,%rdi
call   1060 <sprintf@plt>
lea    0xe71(%rip),%rsi
lea    0xe(%rsp),%r14
mov    %r14,%rdi
movss  0x8(%rsp),%xmm0
call   1060 <sprintf@plt>
lea    0xe60(%rip),%rdi
xor    %r12d,%r12d
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
sub    %eax,%r13d
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
mulss  0x8(%rsp),%xmm0
divss  0xe0f(%rip),%xmm0
call   1070 <floor@plt>
mov    %eax,%ebx
cmp    $0x2,%eax
jl     121f <printProgress+0xcf>
lea    -0x1(%rbx),%r12d
mov    %r12d,%ebp
nopl   0x0(%rax)
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1210 <printProgress+0xc0>
add    $0xffffffff,%r13d
cmp    %r13d,%r12d
jge    1239 <printProgress+0xe9>
mov    $0x3e,%edi
jmp    1234 <printProgress+0xe4>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r13d,%ebx
jl     122f <printProgress+0xdf>
lea    0xdda(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"It = %i [\00"
@.str.1 = [9 x i8] c"] %.3f%%\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [2 x i8] c">\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [5 x i8] c" %s\0A\00"
define void @printProgress(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [15 x i8]
%8 = alloca [11 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 1.000000e+02
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to float
%18 = fpext float %17 to double
%19 = fdiv double %15, %18
%20 = fptrunc double %19 to float
store float %20, float* %12
%21 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%22 = load i32, i32* %4
%23 = sitofp i32 %22 to float
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), float %23)
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%26 = load float, float* %12
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float %26)
%28 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* %6
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %30, %32
%34 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = sub nsw i32 %33, %35
store i32 %36, i32* %10
%37 = load float, float* %12
%38 = load i32, i32* %10
%39 = sitofp i32 %38 to float
%40 = fmul float %37, %39
%41 = fpext float %40 to double
%42 = fdiv double %41, 1.000000e+02
%43 = fptrunc double %42 to float
%44 = call i32 @floor(float %43)
store i32 %44, i32* %9
store i32 0, i32* %11
br label %45
45: ; preds = %52, %3
%46 = load i32, i32* %11
%47 = load i32, i32* %9
%48 = sub nsw i32 %47, 1
%49 = icmp slt i32 %46, %48
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %52
52: ; preds = %50
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %45
55: ; preds = %45
%56 = load i32, i32* %11
%57 = load i32, i32* %10
%58 = sub nsw i32 %57, 1
%59 = icmp slt i32 %56, %58
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %55
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %11
br label %65
65: ; preds = %72, %62
%66 = load i32, i32* %11
%67 = load i32, i32* %10
%68 = sub nsw i32 %67, 1
%69 = icmp slt i32 %66, %68
br i1 %69, label %70, label %75
70: ; preds = %65
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %72
72: ; preds = %70
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %65
75: ; preds = %65
%76 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %76)
ret void
}

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