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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ stderr;
void printhsize(off_t size) {
  if (size / 1152921504606846976 > 1024) {
    fprintf(stderr, "File size too huge.");
    exit(EXIT_FAILURE);
  }
  if (size / 1152921504606846976)
    printf("%4lldE ", (long long)size / 1152921504606846976);
  else if (size / 1125899906842624)
    printf("%4lldP ", (long long)size / 1125899906842624);
  else if (size / 1099511627776)
    printf("%4lldT ", (long long)size / 1099511627776);
  else if (size / 1073741824)
    printf("%4lldG ", (long long)size / 1073741824);
  else if (size / 1048576)
    printf("%4lldM ", (long long)size / 1048576);
  else if (size / 1024)
    printf("%4lldK ", (long long)size / 1024);
  else
    printf("%4lldB ", (long long)size);
}


x86 assembly (clang, -O0):
<printhsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0x1000000000000000,%rcx
cqto
idiv   %rcx
cmp    $0x400,%rax
jle    117d <printhsize+0x4d>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movslq -0x4(%rbp),%rax
movabs $0x1000000000000000,%rcx
cqto
idiv   %rcx
cmp    $0x0,%rax
je     11c1 <printhsize+0x91>
movslq -0x4(%rbp),%rax
movabs $0x1000000000000000,%rcx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    1314 <printhsize+0x1e4>
movslq -0x4(%rbp),%rax
movabs $0x4000000000000,%rcx
cqto
idiv   %rcx
cmp    $0x0,%rax
je     1205 <printhsize+0xd5>
movslq -0x4(%rbp),%rax
movabs $0x4000000000000,%rcx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
jmp    130f <printhsize+0x1df>
movslq -0x4(%rbp),%rax
movabs $0x10000000000,%rcx
cqto
idiv   %rcx
cmp    $0x0,%rax
je     1249 <printhsize+0x119>
movslq -0x4(%rbp),%rax
movabs $0x10000000000,%rcx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xde5(%rip),%rdi
call   1030 <printf@plt>
jmp    130a <printhsize+0x1da>
mov    -0x4(%rbp),%eax
mov    $0x40000000,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     127f <printhsize+0x14f>
movslq -0x4(%rbp),%rax
mov    $0x40000000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
jmp    1305 <printhsize+0x1d5>
mov    -0x4(%rbp),%eax
mov    $0x100000,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     12b5 <printhsize+0x185>
movslq -0x4(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xd89(%rip),%rdi
call   1030 <printf@plt>
jmp    1300 <printhsize+0x1d0>
mov    -0x4(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     12eb <printhsize+0x1bb>
movslq -0x4(%rbp),%rax
mov    $0x400,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xd5b(%rip),%rdi
call   1030 <printf@plt>
jmp    12fb <printhsize+0x1cb>
movslq -0x4(%rbp),%rsi
lea    0xd4e(%rip),%rdi
call   1030 <printf@plt>
jmp    1300 <printhsize+0x1d0>
jmp    1305 <printhsize+0x1d5>
jmp    130a <printhsize+0x1da>
jmp    130f <printhsize+0x1df>
jmp    1314 <printhsize+0x1e4>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhsize>:
lea    0x3fffffff(%rdi),%eax
cmp    $0x7fffffff,%eax
jae    1146 <printhsize+0x36>
lea    0xfffff(%rdi),%eax
cmp    $0x1fffff,%eax
jae    115d <printhsize+0x4d>
lea    0x3ff(%rdi),%eax
cmp    $0x7ff,%eax
jae    1174 <printhsize+0x64>
movslq %edi,%rsi
lea    0xed7(%rip),%rdi
jmp    1030 <printf@plt>
test   %edi,%edi
cmovns %edi,%eax
sar    $0x1e,%eax
movslq %eax,%rsi
lea    0xea8(%rip),%rdi
jmp    1030 <printf@plt>
test   %edi,%edi
cmovns %edi,%eax
sar    $0x14,%eax
movslq %eax,%rsi
lea    0xe99(%rip),%rdi
jmp    1030 <printf@plt>
test   %edi,%edi
cmovns %edi,%eax
sar    $0xa,%eax
movslq %eax,%rsi
lea    0xe8a(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"File size too huge.\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"%4lldE \00"
@.str.2 = [8 x i8] c"%4lldP \00"
@.str.3 = [8 x i8] c"%4lldT \00"
@.str.4 = [8 x i8] c"%4lldG \00"
@.str.5 = [8 x i8] c"%4lldM \00"
@.str.6 = [8 x i8] c"%4lldK \00"
@.str.7 = [8 x i8] c"%4lldB \00"
define void @printhsize(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = sdiv i64 %4, 1152921504606846976
%6 = icmp sgt i64 %5, 1024
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = sdiv i64 %14, 1152921504606846976
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = sdiv i64 %19, 1152921504606846976
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %20)
br label %78
22: ; preds = %12
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = sdiv i64 %24, 1125899906842624
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = sdiv i64 %29, 1125899906842624
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %30)
br label %77
32: ; preds = %22
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = sdiv i64 %34, 1099511627776
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = sdiv i64 %39, 1099511627776
%41 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %40)
br label %76
42: ; preds = %32
%43 = load i32, i32* %2
%44 = sdiv i32 %43, 1073741824
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = sdiv i64 %48, 1073741824
%50 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %49)
br label %75
51: ; preds = %42
%52 = load i32, i32* %2
%53 = sdiv i32 %52, 1048576
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = sdiv i64 %57, 1048576
%59 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i64 %58)
br label %74
60: ; preds = %51
%61 = load i32, i32* %2
%62 = sdiv i32 %61, 1024
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i32, i32* %2
%66 = sext i32 %65 to i64
%67 = sdiv i64 %66, 1024
%68 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 %67)
br label %73
69: ; preds = %60
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 %71)
br label %73
73: ; preds = %69, %64
br label %74
74: ; preds = %73, %55
br label %75
75: ; preds = %74, %46
br label %76
76: ; preds = %75, %37
br label %77
77: ; preds = %76, %27
br label %78
78: ; preds = %77, %17
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@.str.4 = [8 x i8] c"%4lldG \00"
@.str.5 = [8 x i8] c"%4lldM \00"
@.str.6 = [8 x i8] c"%4lldK \00"
@.str.7 = [8 x i8] c"%4lldB \00"
define void @printhsize(i32 %0) {
%2 = sext i32 %0 to i64
%3 = add i32 %0, 1073741823
%4 = icmp ult i32 %3, 2147483647
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = sdiv i32 %0, 1073741824
%7 = sext i32 %6 to i64
%8 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %7)
br label %25
9: ; preds = %1
%10 = add nsw i32 %0, 1048575
%11 = icmp ult i32 %10, 2097151
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = sdiv i32 %0, 1048576
%14 = sext i32 %13 to i64
%15 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i64 %14)
br label %25
16: ; preds = %9
%17 = add nsw i32 %0, 1023
%18 = icmp ult i32 %17, 2047
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = sdiv i32 %0, 1024
%21 = sext i32 %20 to i64
%22 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 %21)
br label %25
23: ; preds = %16
%24 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 %2)
br label %25
25: ; preds = %5, %19, %23, %12
ret void
}