#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*/ fprintf(int /*<<< orphan*/, char *, unsigned int, char,
                           unsigned long, unsigned long);
int /*<<< orphan*/ stderr;
void progress(unsigned long done, unsigned long total, size_t used, size_t size,
              unsigned int *lastpc, size_t *lastused) {
  unsigned int pc = 400 * done / total;
  static char *spinner = "-\\|/";
  if (pc != *lastpc || used / 100 != *lastused / 100 ||
      (used == size && *lastused != size)) {
    fprintf(stderr, "\r[%3u%%] %c correlations: %10lu / %10lu", pc / 4,
            spinner[pc % 4], (unsigned long)used, (unsigned long)size);
    fflush(stderr);
    *lastpc = pc;
    *lastused = used;
  }
}


x86 assembly (clang, -O0):
<progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
imul   $0x190,-0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jne    11b4 <progress+0x94>
mov    -0x18(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jne    11b4 <progress+0x94>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    120e <progress+0xee>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
je     120e <progress+0xee>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
shr    $0x2,%edx
mov    0x2e66(%rip),%rax
mov    -0x34(%rbp),%ecx
and    $0x3,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    0xe21(%rip),%rsi
movsbl %al,%ecx
call   1030 <fprintf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r9
mov    %rdx,%r12
imul   $0x190,%rdi,%rax
mov    %rax,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     1157 <progress+0x37>
xor    %edx,%edx
div    %rsi
mov    %rax,%rbx
cmp    %ebx,(%r15)
je     1162 <progress+0x42>
jmp    119d <progress+0x7d>
xor    %edx,%edx
div    %esi
mov    %eax,%ebx
cmp    %ebx,(%r15)
jne    119d <progress+0x7d>
mov    %r12,%rax
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rdi
c2 f5 28
mul    %rdi
mov    %rdx,%rcx
shr    $0x2,%rcx
mov    (%r14),%rsi
mov    %rsi,%rax
shr    $0x2,%rax
mul    %rdi
shr    $0x2,%rdx
cmp    %rdx,%rcx
jne    119d <progress+0x7d>
cmp    %r9,%r12
jne    11db <progress+0xbb>
cmp    %r9,%rsi
je     11db <progress+0xbb>
mov    0x2e3c(%rip),%r13
mov    0x0(%r13),%edi
mov    %ebx,%edx
shr    $0x2,%edx
mov    %ebx,%eax
and    $0x3,%eax
lea    0xe47(%rip),%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0xe41(%rip),%rsi
mov    %r12,%r8
call   1030 <fprintf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    %ebx,(%r15)
mov    %r12,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@progress.spinner = internal global i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0)
@.str = [5 x i8] c"-\\|/\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"\0D[%3u%%] %c correlations: %10lu / %10lu\00"
define void @progress(i64 %0, i64 %1, i64 %2, i64 %3, i32* %4, i64* %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i64*
%13 = alloca i32
store i64 %0, i64* %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i32* %4, i32** %11
store i64* %5, i64** %12
%14 = load i64, i64* %7
%15 = mul i64 400, %14
%16 = load i64, i64* %8
%17 = udiv i64 %15, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %13
%19 = load i32, i32* %13
%20 = load i32*, i32** %11
%21 = load i32, i32* %20
%22 = icmp ne i32 %19, %21
br i1 %22, label %39, label %23
23: ; preds = %6
%24 = load i64, i64* %9
%25 = udiv i64 %24, 100
%26 = load i64*, i64** %12
%27 = load i64, i64* %26
%28 = udiv i64 %27, 100
%29 = icmp ne i64 %25, %28
br i1 %29, label %39, label %30
30: ; preds = %23
%31 = load i64, i64* %9
%32 = load i64, i64* %10
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %58
34: ; preds = %30
%35 = load i64*, i64** %12
%36 = load i64, i64* %35
%37 = load i64, i64* %10
%38 = icmp ne i64 %36, %37
br i1 %38, label %39, label %58
39: ; preds = %34, %23, %6
%40 = load i32, i32* @stderr
%41 = load i32, i32* %13
%42 = udiv i32 %41, 4
%43 = load i8*, i8** @progress.spinner
%44 = load i32, i32* %13
%45 = urem i32 %44, 4
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = load i8, i8* %47
%49 = load i64, i64* %9
%50 = load i64, i64* %10
%51 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %42, i8 signext %48, i64 %49, i64 %50)
%52 = load i32, i32* @stderr
%53 = call i32 @fflush(i32 %52)
%54 = load i32, i32* %13
%55 = load i32*, i32** %11
store i32 %54, i32* %55
%56 = load i64, i64* %9
%57 = load i64*, i64** %12
store i64 %56, i64* %57
br label %58
58: ; preds = %39, %34, %30
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"-\\|/\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"\0D[%3u%%] %c correlations: %10lu / %10lu\00"
define void @progress(i64 %0, i64 %1, i64 %2, i64 %3, i32* nocapture %4, i64* nocapture %5) {
%7 = mul i64 %0, 400
%8 = udiv i64 %7, %1
%9 = trunc i64 %8 to i32
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, %9
br i1 %11, label %12, label %21
12: ; preds = %6
%13 = udiv i64 %2, 100
%14 = load i64, i64* %5
%15 = udiv i64 %14, 100
%16 = icmp eq i64 %13, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = icmp ne i64 %2, %3
%19 = icmp eq i64 %14, %3
%20 = select i1 %18, i1 true, i1 %19
br i1 %20, label %30, label %21
21: ; preds = %17, %12, %6
%22 = load i32, i32* @stderr
%23 = lshr i32 %9, 2
%24 = and i64 %8, 3
%25 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8 signext %26, i64 %2, i64 %3)
%28 = load i32, i32* @stderr
%29 = tail call i32 @fflush(i32 %28)
store i32 %9, i32* %4
store i64 %2, i64* %5
br label %30
30: ; preds = %21, %17
ret void
}