#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void printProg(float progress, int images) {
  int barWidth = 70;
  printf("Rendering: [");
  int pos = barWidth * progress;
  for (int p = 0; p < barWidth; ++p) {
    if (p < pos) {
      printf("=");
    } else if (p == pos) {
      printf(">");
    } else
      printf(" ");
  }
  int print_prog = progress * 100.0;
  printf("] %d%% \r", print_prog);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<printProg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
movl   $0x46,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0xc(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <printProg+0xad>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1188 <printProg+0x68>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ba <printProg+0x9a>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11a7 <printProg+0x87>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b5 <printProg+0x95>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ba <printProg+0x9a>
jmp    11bf <printProg+0x9f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <printProg+0x3d>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe22(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
lea    0xecc(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xeab(%rip),%xmm0
mulss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%ebp
mov    $0x3e,%r14d
mov    $0x3d,%r15d
nopl   0x0(%rax,%rax,1)
cmp    %ebx,%ebp
mov    $0x20,%edi
cmove  %r14d,%edi
cmovg  %r15d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0x46,%ebx
jne    1170 <printProg+0x40>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe6a(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Rendering: [\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c">\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [9 x i8] c"] %d%% \0D\00"
@stdout = global i32 0
define void @printProg(float %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store float %0, float* %3
store i32 %1, i32* %4
store i32 70, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %5
%11 = sitofp i32 %10 to float
%12 = load float, float* %3
%13 = fmul float %11, %12
%14 = fptosi float %13 to i32
store i32 %14, i32* %6
store i32 0, i32* %7
br label %15
15: ; preds = %35, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %38
19: ; preds = %15
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %34
25: ; preds = %19
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
br label %34
34: ; preds = %33, %23
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %15
38: ; preds = %15
%39 = load float, float* %3
%40 = fpext float %39 to double
%41 = fmul double %40, 1.000000e+02
%42 = fptosi double %41 to i32
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = load i32, i32* @stdout
%46 = call i32 @fflush(i32 %45)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Rendering: [\00"
@.str.4 = [9 x i8] c"] %d%% \0D\00"
@stdout = global i32 0
define void @printProg(float %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = fmul float %0, 7.000000e+01
%5 = fptosi float %4 to i32
br label %13
6: ; preds = %13
%7 = fpext float %0 to double
%8 = fmul double %7, 1.000000e+02
%9 = fptosi double %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
ret void
13: ; preds = %2, %13
%14 = phi i32 [ 0, %2 ], [ %20, %13 ]
%15 = icmp slt i32 %14, %5
%16 = icmp eq i32 %14, %5
%17 = select i1 %16, i32 62, i32 32
%18 = select i1 %15, i32 61, i32 %17
%19 = tail call i32 @putchar(i32 %18)
%20 = add nuw nsw i32 %14, 1
%21 = icmp eq i32 %20, 70
br i1 %21, label %6, label %13
}