#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 *, unsigned long, unsigned long);
void show_counter(unsigned long i, long track_length,
                  unsigned long image_length, long pos) {
  unsigned long progress, total_progress;
  progress = (i * 100 / track_length);
  total_progress = ((pos >> 10) * 100) / (image_length >> 10);
  printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
         "[Current: %02d%%  Total: %02d%%]  ",
         progress, total_progress);
}


x86 assembly (clang, -O0):
<show_counter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
imul   $0x64,-0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sar    $0xa,%rax
imul   $0x64,%rax,%rax
mov    -0x18(%rbp),%rcx
shr    $0xa,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_counter>:
mov    %rdx,%r8
imul   $0x64,%rdi,%rax
mov    %rax,%rdx
or     %rsi,%rdx
shr    $0x20,%rdx
je     112d <show_counter+0x1d>
xor    %edx,%edx
div    %rsi
mov    %rax,%rsi
jmp    1133 <show_counter+0x23>
xor    %edx,%edx
div    %esi
mov    %eax,%esi
sar    $0xa,%rcx
imul   $0x64,%rcx,%rax
shr    $0xa,%r8
mov    %rax,%rcx
or     %r8,%rcx
shr    $0x20,%rcx
je     1152 <show_counter+0x42>
xor    %edx,%edx
div    %r8
jmp    1157 <show_counter+0x47>
xor    %edx,%edx
div    %r8d
lea    0xea2(%rip),%rdi
mov    %rax,%rdx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [64 x i8] c"\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08[Current: %02d%% Total: %02d%%] \00"
define void @show_counter(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%11 = load i64, i64* %5
%12 = mul i64 %11, 100
%13 = load i64, i64* %6
%14 = udiv i64 %12, %13
store i64 %14, i64* %9
%15 = load i64, i64* %8
%16 = ashr i64 %15, 10
%17 = mul nsw i64 %16, 100
%18 = load i64, i64* %7
%19 = lshr i64 %18, 10
%20 = udiv i64 %17, %19
store i64 %20, i64* %10
%21 = load i64, i64* %9
%22 = load i64, i64* %10
%23 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i64 %21, i64 %22)
ret void
}

LLVM IR (-O2):
@.str = [64 x i8] c"\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08[Current: %02d%% Total: %02d%%] \00"
define void @show_counter(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = mul i64 %0, 100
%6 = udiv i64 %5, %1
%7 = ashr i64 %3, 10
%8 = mul nsw i64 %7, 100
%9 = lshr i64 %2, 10
%10 = udiv i64 %8, %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i64 %6, i64 %10)
ret void
}