#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);
int /*<<< orphan*/ putchar(char);
void updateProgressBar(float cur, float tot) {
  float rat;
  int ndot, i;
  static float prev = -1;
  rat = cur / tot;
  ndot = (int)(rat * 100);
  if ((ndot < prev + 5) && (ndot != 100))
    return;
  for (i = 0; i < ndot; i += 2)
    putchar('.');
  for (i = ndot - 1; i < 100; i += 2)
    putchar(' ');
  printf("[%d%% completed]\n", ndot);
  prev = ndot;
}


x86 assembly (clang, -O0):
<updateProgressBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xebb(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm1
movss  0xe9e(%rip),%xmm0
addss  0x2ec6(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    1182 <updateProgressBar+0x62>
cmpl   $0x64,-0x10(%rbp)
je     1182 <updateProgressBar+0x62>
jmp    11f4 <updateProgressBar+0xd4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ad <updateProgressBar+0x8d>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <updateProgressBar+0x69>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11d8 <updateProgressBar+0xb8>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <updateProgressBar+0x96>
mov    -0x10(%rbp),%esi
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
movss  %xmm0,0x2e3c(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updateProgressBar>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
divss  %xmm1,%xmm0
mulss  0xece(%rip),%xmm0
cvttss2si %xmm0,%ebx
cvttps2dq %xmm0,%xmm0
cvtdq2ps %xmm0,%xmm1
cmp    $0x64,%ebx
je     1157 <updateProgressBar+0x37>
movss  0x2ee6(%rip),%xmm0
addss  0xeb2(%rip),%xmm0
ucomiss %xmm1,%xmm0
ja     11bc <updateProgressBar+0x9c>
movaps %xmm1,(%rsp)
test   %ebx,%ebx
jle    1186 <updateProgressBar+0x66>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x2,%ebp
cmp    %ebx,%ebp
jl     1170 <updateProgressBar+0x50>
cmp    $0x64,%ebx
jg     11a2 <updateProgressBar+0x82>
lea    -0x3(%rbx),%ebp
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x2,%ebp
cmp    $0x62,%ebp
jl     1190 <updateProgressBar+0x70>
lea    0xe5f(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
movaps (%rsp),%xmm0
movss  %xmm0,0x2e74(%rip)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@updateProgressBar.prev = internal global float -1.000000e+00
@.str = [18 x i8] c"[%d%% completed]\0A\00"
define void @updateProgressBar(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
store float %0, float* %3
store float %1, float* %4
%8 = load float, float* %3
%9 = load float, float* %4
%10 = fdiv float %8, %9
store float %10, float* %5
%11 = load float, float* %5
%12 = fmul float %11, 1.000000e+02
%13 = fptosi float %12 to i32
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to float
%16 = load float, float* @updateProgressBar.prev
%17 = fadd float %16, 5.000000e+00
%18 = fcmp olt float %15, %17
br i1 %18, label %19, label %23
19: ; preds = %2
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 100
br i1 %21, label %22, label %23
22: ; preds = %19
br label %49
23: ; preds = %19, %2
store i32 0, i32* %7
br label %24
24: ; preds = %30, %23
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = call i32 @putchar(i8 signext 46)
br label %30
30: ; preds = %28
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 2
store i32 %32, i32* %7
br label %24
33: ; preds = %24
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 1
store i32 %35, i32* %7
br label %36
36: ; preds = %41, %33
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 100
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = call i32 @putchar(i8 signext 32)
br label %41
41: ; preds = %39
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 2
store i32 %43, i32* %7
br label %36
44: ; preds = %36
%45 = load i32, i32* %6
%46 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %6
%48 = sitofp i32 %47 to float
store float %48, float* @updateProgressBar.prev
br label %49
49: ; preds = %44, %22
ret void
}

LLVM IR (-O2):
@updateProgressBar.prev = internal unnamed_addr global float -1.000000e+00
@.str = [18 x i8] c"[%d%% completed]\0A\00"
define void @updateProgressBar(float %0, float %1) {
%3 = fdiv float %0, %1
%4 = fmul float %3, 1.000000e+02
%5 = fptosi float %4 to i32
%6 = sitofp i32 %5 to float
%7 = load float, float* @updateProgressBar.prev
%8 = fadd float %7, 5.000000e+00
%9 = fcmp ogt float %8, %6
%10 = icmp ne i32 %5, 100
%11 = and i1 %10, %9
br i1 %11, label %30, label %12
12: ; preds = %2
%13 = icmp sgt i32 %5, 0
br i1 %13, label %14, label %21
14: ; preds = %12, %14
%15 = phi i32 [ %17, %14 ], [ 0, %12 ]
%16 = tail call i32 @putchar(i8 signext 46)
%17 = add nuw nsw i32 %15, 2
%18 = icmp slt i32 %17, %5
br i1 %18, label %14, label %19
19: ; preds = %14
%20 = icmp slt i32 %5, 101
br i1 %20, label %21, label %28
21: ; preds = %12, %19
%22 = add nsw i32 %5, -1
br label %23
23: ; preds = %21, %23
%24 = phi i32 [ %26, %23 ], [ %22, %21 ]
%25 = tail call i32 @putchar(i8 signext 32)
%26 = add nsw i32 %24, 2
%27 = icmp slt i32 %24, 98
br i1 %27, label %23, label %28
28: ; preds = %23, %19
%29 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %5)
store float %6, float* @updateProgressBar.prev
br label %30
30: ; preds = %2, %28
ret void
}