#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 */
typedef scalar_t__ uint64_t;
typedef int /*<<< orphan*/ line;

/* Variables and functions */
scalar_t__ ceil(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
int /*<<< orphan*/ stdout;
extern void extractlib_progress(const char *filename, uint64_t done,
                                uint64_t total) {
  static char bar[30 + 1];
  static char line[80 + 1];
  size_t fill, i;
  fill = (size_t)ceil(30 * ((double)done / (double)total));
  for (i = 0; i < 30; i++) {
    bar[i] = (i < fill) ? '#' : ' ';
  }
  snprintf(line, sizeof(line), "\r[%s] %s", bar, filename);
  printf("%s", line);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<extractlib_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm1
cvtsi2sdq -0x18(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe94(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x1e,-0x28(%rbp)
jae    11c9 <extractlib_progress+0x89>
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rsi
mov    $0x20,%eax
mov    $0x23,%ecx
cmp    %rsi,%rdx
cmovb  %ecx,%eax
mov    %al,%dl
mov    -0x28(%rbp),%rcx
lea    0x2e9b(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1185 <extractlib_progress+0x45>
mov    -0x8(%rbp),%r8
lea    0x2e9c(%rip),%rdi
mov    $0x51,%esi
lea    0xe28(%rip),%rdx
lea    0x2e69(%rip),%rcx
call   1050 <snprintf@plt>
lea    0xe1b(%rip),%rdi
lea    0x2e76(%rip),%rsi
call   1040 <printf@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractlib_progress>:
push   %r14
push   %rbx
push   %rax
cvtsi2sd %rsi,%xmm0
mov    %rdi,%r14
cvtsi2sd %rdx,%xmm1
divsd  %xmm1,%xmm0
mulsd  0xea3(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
xor    %ecx,%ecx
lea    0x2ee1(%rip),%rdx
nop
xor    %esi,%esi
cmp    %rax,%rcx
setb   %sil
lea    (%rsi,%rsi,2),%esi
add    $0x20,%esi
mov    %sil,(%rcx,%rdx,1)
lea    0x1(%rcx),%rsi
xor    %edi,%edi
cmp    %rax,%rsi
setb   %dil
lea    (%rdi,%rdi,2),%esi
add    $0x20,%esi
mov    %sil,0x1(%rcx,%rdx,1)
lea    0x2(%rcx),%rsi
xor    %edi,%edi
cmp    %rax,%rsi
setb   %dil
lea    (%rdi,%rdi,2),%esi
add    $0x20,%esi
mov    %sil,0x2(%rcx,%rdx,1)
lea    0x3(%rcx),%rsi
xor    %edi,%edi
cmp    %rax,%rsi
setb   %dil
lea    (%rdi,%rdi,2),%esi
add    $0x20,%esi
mov    %sil,0x3(%rcx,%rdx,1)
lea    0x4(%rcx),%rsi
xor    %edi,%edi
cmp    %rax,%rsi
setb   %dil
lea    (%rdi,%rdi,2),%esi
add    $0x20,%esi
mov    %sil,0x4(%rcx,%rdx,1)
add    $0x5,%rcx
cmp    $0x1e,%rcx
jne    1170 <extractlib_progress+0x30>
lea    0x2e7c(%rip),%rbx
lea    0xe0d(%rip),%rdx
lea    0x2e4e(%rip),%rcx
mov    %rbx,%rdi
mov    $0x51,%esi
mov    %r14,%r8
call   1050 <snprintf@plt>
lea    0xdf5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <fflush@plt>

LLVM IR (-O0):
@extractlib_progress.bar = internal global [31 x i8] zeroinitializer
@extractlib_progress.line = internal global [81 x i8] zeroinitializer
@.str = [9 x i8] c"\0D[%s] %s\00"
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
define void @extractlib_progress(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i64, i64* %5
%10 = sitofp i64 %9 to double
%11 = load i64, i64* %6
%12 = sitofp i64 %11 to double
%13 = fdiv double %10, %12
%14 = fmul double 3.000000e+01, %13
%15 = fptosi double %14 to i32
%16 = call i64 @ceil(i32 %15)
store i64 %16, i64* %7
store i64 0, i64* %8
br label %17
17: ; preds = %29, %3
%18 = load i64, i64* %8
%19 = icmp ult i64 %18, 30
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i64, i64* %8
%22 = load i64, i64* %7
%23 = icmp ult i64 %21, %22
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 35, i32 32
%26 = trunc i32 %25 to i8
%27 = load i64, i64* %8
%28 = getelementptr inbounds [31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 %27
store i8 %26, i8* %28
br label %29
29: ; preds = %20
%30 = load i64, i64* %8
%31 = add i64 %30, 1
store i64 %31, i64* %8
br label %17
32: ; preds = %17
%33 = load i8*, i8** %4
%34 = call i32 @snprintf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @extractlib_progress.line, i64 0, i64 0), i32 81, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 0), i8* %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([81 x i8], [81 x i8]* @extractlib_progress.line, i64 0, i64 0))
%36 = load i32, i32* @stdout
%37 = call i32 @fflush(i32 %36)
ret void
}

LLVM IR (-O2):
@extractlib_progress.bar = internal global [31 x i8] zeroinitializer
@extractlib_progress.line = internal global [81 x i8] zeroinitializer
@.str = [9 x i8] c"\0D[%s] %s\00"
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
define void @extractlib_progress(i8* %0, i64 %1, i64 %2) {
%4 = sitofp i64 %1 to double
%5 = sitofp i64 %2 to double
%6 = fdiv double %4, %5
%7 = fmul double %6, 3.000000e+01
%8 = fptosi double %7 to i32
%9 = tail call i64 @ceil(i32 %8)
br label %10
10: ; preds = %10, %3
%11 = phi i64 [ 0, %3 ], [ %31, %10 ]
%12 = icmp ult i64 %11, %9
%13 = select i1 %12, i8 35, i8 32
%14 = getelementptr inbounds [31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 %11
store i8 %13, i8* %14
%15 = add nuw nsw i64 %11, 1
%16 = icmp ult i64 %15, %9
%17 = select i1 %16, i8 35, i8 32
%18 = getelementptr inbounds [31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 %15
store i8 %17, i8* %18
%19 = add nuw nsw i64 %11, 2
%20 = icmp ult i64 %19, %9
%21 = select i1 %20, i8 35, i8 32
%22 = getelementptr inbounds [31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 %19
store i8 %21, i8* %22
%23 = add nuw nsw i64 %11, 3
%24 = icmp ult i64 %23, %9
%25 = select i1 %24, i8 35, i8 32
%26 = getelementptr inbounds [31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 %23
store i8 %25, i8* %26
%27 = add nuw nsw i64 %11, 4
%28 = icmp ult i64 %27, %9
%29 = select i1 %28, i8 35, i8 32
%30 = getelementptr inbounds [31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 %27
store i8 %29, i8* %30
%31 = add nuw nsw i64 %11, 5
%32 = icmp eq i64 %31, 30
br i1 %32, label %33, label %10
33: ; preds = %10
%34 = tail call i32 @snprintf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @extractlib_progress.line, i64 0, i64 0), i32 81, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @extractlib_progress.bar, i64 0, i64 0), i8* %0)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([81 x i8], [81 x i8]* @extractlib_progress.line, i64 0, i64 0))
%36 = load i32, i32* @stdout
%37 = tail call i32 @fflush(i32 %36)
ret void
}