#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*/ fprintf(int /*<<< orphan*/, char *, int, char *, char *,
                           int);
int /*<<< orphan*/ stderr;
void print_bar(int total, int done) {
  static char *bar_filld = "==================================================";
  static char *bar_empty = "                                                  ";
  int percent = done * 100 / total;
  fprintf(stderr, "\r%3i%% [%s>%s] %i words", done * 100 / total,
          bar_filld + 50 - (percent >> 1), bar_empty + (percent >> 1), done);
}


x86 assembly (clang, -O0):
<print_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
imul   $0x64,-0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0xc(%rbp)
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
imul   $0x64,-0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,%edx
mov    0x2ee5(%rip),%rcx
add    $0x32,%rcx
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
movslq %eax,%rsi
xor    %eax,%eax
sub    %rsi,%rax
add    %rax,%rcx
mov    0x2ed1(%rip),%r8
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
cltq
add    %rax,%r8
mov    -0x8(%rbp),%r9d
lea    0xef1(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bar>:
mov    %esi,%r9d
imul   $0x64,%esi,%eax
cltd
idiv   %edi
mov    0x2ec0(%rip),%rcx
mov    (%rcx),%edi
mov    %eax,%ecx
sar    %ecx
movslq %ecx,%rdx
lea    0xed0(%rip),%rcx
sub    %rdx,%rcx
add    $0x32,%rcx
lea    0xef5(%rip),%r8
add    %rdx,%r8
lea    0xf1e(%rip),%rsi
mov    %eax,%edx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@print_bar.bar_filld = internal global i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i32 0, i32 0)
@.str = [51 x i8] c"==================================================\00"
@print_bar.bar_empty = internal global i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i32 0, i32 0)
@.str.1 = [51 x i8] c" \00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"\0D%3i%% [%s>%s] %i words\00"
define void @print_bar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = mul nsw i32 %6, 100
%8 = load i32, i32* %3
%9 = sdiv i32 %7, %8
store i32 %9, i32* %5
%10 = load i32, i32* @stderr
%11 = load i32, i32* %4
%12 = mul nsw i32 %11, 100
%13 = load i32, i32* %3
%14 = sdiv i32 %12, %13
%15 = load i8*, i8** @print_bar.bar_filld
%16 = getelementptr inbounds i8, i8* %15, i64 50
%17 = load i32, i32* %5
%18 = ashr i32 %17, 1
%19 = sext i32 %18 to i64
%20 = sub i64 0, %19
%21 = getelementptr inbounds i8, i8* %16, i64 %20
%22 = load i8*, i8** @print_bar.bar_empty
%23 = load i32, i32* %5
%24 = ashr i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i32, i32* %4
%28 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %14, i8* %21, i8* %26, i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"==================================================\00"
@.str.1 = [51 x i8] c" \00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"\0D%3i%% [%s>%s] %i words\00"
define void @print_bar(i32 %0, i32 %1) {
%3 = mul nsw i32 %1, 100
%4 = sdiv i32 %3, %0
%5 = load i32, i32* @stderr
%6 = ashr i32 %4, 1
%7 = sext i32 %6 to i64
%8 = sub nsw i64 0, %7
%9 = getelementptr inbounds i8, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 50), i64 %8
%10 = getelementptr inbounds [51 x i8], [51 x i8]* @.str.1, i64 0, i64 %7
%11 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %4, i8* %9, i8* %10, i32 %1)
ret void
}