#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;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ makeHumanReadableSize(char *, scalar_t__);
char *makeProgressBar(scalar_t__, scalar_t__);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stdout;
void showProgress(uint64_t currentPosition, uint64_t totalSize,
                  char *readingMD4, char *storedMD4, int status,
                  int reportMode) {
  if (reportMode == 2) {
    return;
  }
  if (reportMode == 1) {
    char _currentPosHR[100];
    makeHumanReadableSize(_currentPosHR, currentPosition);
    char _totalSizeHR[100];
    makeHumanReadableSize(_totalSizeHR, totalSize);
    switch (status) {
    case 0:
      printf("%s/%s %s -> same\n", _currentPosHR, _totalSizeHR, readingMD4);
      break;
    case 1:
      printf("%s/%s %s -> %s\n", _currentPosHR, _totalSizeHR, readingMD4,
             storedMD4);
      break;
    case 2:
      printf("%s/%s %s -> added\n", _currentPosHR, _totalSizeHR, readingMD4);
      break;
    }
    return;
  }
  if (totalSize == 0) {
    char _currentPosHR[100];
    makeHumanReadableSize(_currentPosHR, currentPosition);
    printf("\rSyncing %s out of unknown size  ", _currentPosHR);
  } else {
    char *progressBar = makeProgressBar(currentPosition, totalSize);
    printf("\r%s ", progressBar);
    free(progressBar);
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<showProgress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
cmpl   $0x2,-0x28(%rbp)
jne    1182 <showProgress+0x32>
jmp    12d5 <showProgress+0x185>
cmpl   $0x1,-0x28(%rbp)
jne    125d <showProgress+0x10d>
mov    -0x8(%rbp),%rsi
lea    -0x90(%rbp),%rdi
call   1060 <makeHumanReadableSize@plt>
mov    -0x10(%rbp),%rsi
lea    -0x100(%rbp),%rdi
call   1060 <makeHumanReadableSize@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x17c(%rbp)
test   %eax,%eax
je     11ea <showProgress+0x9a>
jmp    11c2 <showProgress+0x72>
mov    -0x17c(%rbp),%eax
sub    $0x1,%eax
je     120f <showProgress+0xbf>
jmp    11d6 <showProgress+0x86>
mov    -0x17c(%rbp),%eax
sub    $0x2,%eax
je     1238 <showProgress+0xe8>
jmp    1258 <showProgress+0x108>
lea    -0x90(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1258 <showProgress+0x108>
lea    -0x90(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1258 <showProgress+0x108>
lea    -0x90(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d5 <showProgress+0x185>
cmpq   $0x0,-0x10(%rbp)
jne    1292 <showProgress+0x142>
lea    -0x170(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <makeHumanReadableSize@plt>
lea    -0x170(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c7 <showProgress+0x177>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <makeProgressBar@plt>
mov    %rax,-0x178(%rbp)
mov    -0x178(%rbp),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x178(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showProgress>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
cmp    $0x2,%r9d
je     1241 <showProgress+0xf1>
mov    %rsi,%rbx
mov    %rdi,%rsi
cmp    $0x1,%r9d
jne    11b0 <showProgress+0x60>
mov    %r8d,%ebp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsp,%rdi
call   1060 <makeHumanReadableSize@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <makeHumanReadableSize@plt>
cmp    $0x2,%ebp
je     120a <showProgress+0xba>
cmp    $0x1,%ebp
je     1225 <showProgress+0xd5>
test   %ebp,%ebp
jne    1241 <showProgress+0xf1>
lea    0xe52(%rip),%rdi
jmp    1211 <showProgress+0xc1>
test   %rbx,%rbx
je     11de <showProgress+0x8e>
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1050 <makeProgressBar@plt>
mov    %rax,%rbx
lea    0xe8d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11fa <showProgress+0xaa>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <makeHumanReadableSize@plt>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    1241 <showProgress+0xf1>
lea    0xe11(%rip),%rdi
mov    %rsp,%rsi
lea    0x70(%rsp),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1241 <showProgress+0xf1>
lea    0xde6(%rip),%rdi
mov    %rsp,%rsi
lea    0x70(%rsp),%rdx
mov    %r14,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%s/%s %s -> same\0A\00"
@.str.1 = [16 x i8] c"%s/%s %s -> %s\0A\00"
@.str.2 = [19 x i8] c"%s/%s %s -> added\0A\00"
@.str.3 = [34 x i8] c"\0DSyncing %s out of unknown size \00"
@.str.4 = [5 x i8] c"\0D%s \00"
@stdout = global i32 0
define void @showProgress(i64 %0, i64 %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [100 x i8]
%14 = alloca [100 x i8]
%15 = alloca [100 x i8]
%16 = alloca i8*
store i64 %0, i64* %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%17 = load i32, i32* %12
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %20
19: ; preds = %6
br label %68
20: ; preds = %6
%21 = load i32, i32* %12
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %48
23: ; preds = %20
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%25 = load i64, i64* %7
%26 = call i32 @makeHumanReadableSize(i8* %24, i64 %25)
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%28 = load i64, i64* %8
%29 = call i32 @makeHumanReadableSize(i8* %27, i64 %28)
%30 = load i32, i32* %11
switch i32 %30, label %47 [
i32 0, label %31
i32 1, label %36
i32 2, label %42
]
31: ; preds = %23
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%34 = load i8*, i8** %9
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33, i8* %34)
br label %47
36: ; preds = %23
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%39 = load i8*, i8** %9
%40 = load i8*, i8** %10
%41 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %37, i8* %38, i8* %39, i8* %40)
br label %47
42: ; preds = %23
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%45 = load i8*, i8** %9
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %43, i8* %44, i8* %45)
br label %47
47: ; preds = %23, %42, %36, %31
br label %68
48: ; preds = %20
%49 = load i64, i64* %8
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%53 = load i64, i64* %7
%54 = call i32 @makeHumanReadableSize(i8* %52, i64 %53)
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %55)
br label %65
57: ; preds = %48
%58 = load i64, i64* %7
%59 = load i64, i64* %8
%60 = call i8* @makeProgressBar(i64 %58, i64 %59)
store i8* %60, i8** %16
%61 = load i8*, i8** %16
%62 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %61)
%63 = load i8*, i8** %16
%64 = call i32 @free(i8* %63)
br label %65
65: ; preds = %57, %51
%66 = load i32, i32* @stdout
%67 = call i32 @fflush(i32 %66)
br label %68
68: ; preds = %65, %47, %19
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s/%s %s -> same\0A\00"
@.str.1 = [16 x i8] c"%s/%s %s -> %s\0A\00"
@.str.2 = [19 x i8] c"%s/%s %s -> added\0A\00"
@.str.3 = [34 x i8] c"\0DSyncing %s out of unknown size \00"
@.str.4 = [5 x i8] c"\0D%s \00"
@stdout = global i32 0
define void @showProgress(i64 %0, i64 %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
switch i32 %5, label %22 [
i32 2, label %35
i32 1, label %10
]
10: ; preds = %6
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%12 = call i32 @makeHumanReadableSize(i8* %11, i64 %0)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%14 = call i32 @makeHumanReadableSize(i8* %13, i64 %1)
switch i32 %4, label %21 [
i32 0, label %15
i32 1, label %17
i32 2, label %19
]
15: ; preds = %10
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13, i8* %2)
br label %21
17: ; preds = %10
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %13, i8* %2, i8* %3)
br label %21
19: ; preds = %10
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %13, i8* %2)
br label %21
21: ; preds = %10, %19, %17, %15
br label %35
22: ; preds = %6
%23 = icmp eq i64 %1, 0
br i1 %23, label %24, label %28
24: ; preds = %22
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%26 = call i32 @makeHumanReadableSize(i8* %25, i64 %0)
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %32
28: ; preds = %22
%29 = tail call i8* @makeProgressBar(i64 %0, i64 %1)
%30 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = tail call i32 @free(i8* %29)
br label %32
32: ; preds = %28, %24
%33 = load i32, i32* @stdout
%34 = call i32 @fflush(i32 %33)
br label %35
35: ; preds = %6, %32, %21
ret void
}