#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 *);
void update_progress(float percent) {
  int i;
  static float last = -1;
  const int actualWidth = 80 - 2;
  if (percent - last < 1.0 / actualWidth)
    return;
  printf("\r[");
  for (i = 0; i < actualWidth; i++) {
    if ((float)i / (float)actualWidth < percent) {
      printf("=");
    } else {
      printf(" ");
    }
  }
  printf("]");
  last = percent;
}


x86 assembly (clang, -O0):
<update_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movl   $0x4e,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
subss  0x2ef7(%rip),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xec3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    114c <update_progress+0x3c>
jmp    11d1 <update_progress+0xc1>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4e,-0x8(%rbp)
jge    11b8 <update_progress+0xa8>
cvtsi2ssl -0x8(%rbp),%xmm1
movss  0xe92(%rip),%xmm0
divss  %xmm0,%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1199 <update_progress+0x89>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    11a5 <update_progress+0x95>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
jmp    11aa <update_progress+0x9a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115f <update_progress+0x4f>
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,0x2e57(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_progress>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
subss  0x2efd(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec1(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11ab <update_progress+0x8b>
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    116d <update_progress+0x4d>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0x4e,%ebx
je     1193 <update_progress+0x73>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
divss  0xe8c(%rip),%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
mov    $0x3d,%edi
ja     1160 <update_progress+0x40>
mov    $0x20,%edi
jmp    1160 <update_progress+0x40>
mov    $0x5d,%edi
call   1030 <putchar@plt>
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x2e85(%rip)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@update_progress.last = internal global float -1.000000e+00
@.str = [3 x i8] c"\0D[\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"]\00"
define void @update_progress(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
store float %0, float* %2
store i32 78, i32* %4
%5 = load float, float* %2
%6 = load float, float* @update_progress.last
%7 = fsub float %5, %6
%8 = fpext float %7 to double
%9 = fcmp olt double %8, 0x3F8A41A41A41A41A
br i1 %9, label %10, label %11
10: ; preds = %1
br label %33
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %13
13: ; preds = %27, %11
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 78
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sitofp i32 %17 to float
%19 = fdiv float %18, 7.800000e+01
%20 = load float, float* %2
%21 = fcmp olt float %19, %20
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %26
24: ; preds = %16
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %13
30: ; preds = %13
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = load float, float* %2
store float %32, float* @update_progress.last
br label %33
33: ; preds = %30, %10
ret void
}

LLVM IR (-O2):
@update_progress.last = internal unnamed_addr global float -1.000000e+00
@.str = [3 x i8] c"\0D[\00"
define void @update_progress(float %0) {
%2 = load float, float* @update_progress.last
%3 = fsub float %0, %2
%4 = fpext float %3 to double
%5 = fcmp olt double %4, 0x3F8A41A41A41A41A
br i1 %5, label %19, label %6
6: ; preds = %1
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ 0, %6 ], [ %15, %8 ]
%10 = sitofp i32 %9 to float
%11 = fdiv float %10, 7.800000e+01
%12 = fcmp olt float %11, %0
%13 = select i1 %12, i32 61, i32 32
%14 = tail call i32 @putchar(i32 %13)
%15 = add nuw nsw i32 %9, 1
%16 = icmp eq i32 %15, 78
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = tail call i32 @putchar(i32 93)
store float %0, float* @update_progress.last
br label %19
19: ; preds = %1, %17
ret void
}