#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*/ snprintf(char *, int, char *, size_t);
int /*<<< orphan*/ strncpy(char *, char *, int);
const char *size_to_string(size_t size) {
  static char buffer[8];
  if (!size)
    strncpy(buffer, "unknown", 8);
  else if (size >= (1 << 20))
    snprintf(buffer, 8, "%zu MB", size >> 20);
  else
    snprintf(buffer, 8, "%zu KB", size >> 10);
  return buffer;
}


x86 assembly (clang, -O0):
<size_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1154 <size_to_string+0x34>
lea    0x2ef3(%rip),%rdi
lea    0xebb(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
jmp    11ac <size_to_string+0x8c>
cmpq   $0x100000,-0x8(%rbp)
jb     1187 <size_to_string+0x67>
mov    -0x8(%rbp),%rcx
shr    $0x14,%rcx
lea    0x2ec0(%rip),%rdi
mov    $0x8,%esi
lea    0xe8b(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11a7 <size_to_string+0x87>
mov    -0x8(%rbp),%rcx
shr    $0xa,%rcx
lea    0x2e9b(%rip),%rdi
mov    $0x8,%esi
lea    0xe6d(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11ac <size_to_string+0x8c>
lea    0x2e7e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<size_to_string>:
push   %rax
test   %rdi,%rdi
je     1146 <size_to_string+0x26>
mov    %rdi,%rcx
cmp    $0x100000,%rdi
jb     1160 <size_to_string+0x40>
shr    $0x14,%rcx
lea    0x2ef4(%rip),%rdi
lea    0xec4(%rip),%rdx
jmp    1172 <size_to_string+0x52>
lea    0x2ee4(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
jmp    117c <size_to_string+0x5c>
shr    $0xa,%rcx
lea    0x2ec6(%rip),%rdi
lea    0xe9d(%rip),%rdx
mov    $0x8,%esi
call   1040 <snprintf@plt>
lea    0x2eae(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@size_to_string.buffer = internal global [8 x i8] zeroinitializer
@.str = [8 x i8] c"unknown\00"
@.str.1 = [7 x i8] c"%zu MB\00"
@.str.2 = [7 x i8] c"%zu KB\00"
define i8* @size_to_string(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp ne i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = call i32 @strncpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 8)
br label %19
7: ; preds = %1
%8 = load i64, i64* %2
%9 = icmp uge i64 %8, 1048576
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i64, i64* %2
%12 = lshr i64 %11, 20
%13 = call i32 @snprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %12)
br label %18
14: ; preds = %7
%15 = load i64, i64* %2
%16 = lshr i64 %15, 10
%17 = call i32 @snprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %14, %10
br label %19
19: ; preds = %18, %5
ret i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@size_to_string.buffer = internal global [8 x i8] zeroinitializer
@.str = [8 x i8] c"unknown\00"
@.str.1 = [7 x i8] c"%zu MB\00"
@.str.2 = [7 x i8] c"%zu KB\00"
define i8* @size_to_string(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @strncpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 8)
br label %13
5: ; preds = %1
%6 = icmp ugt i64 %0, 1048575
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = lshr i64 %0, 20
%9 = tail call i32 @snprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %8)
br label %13
10: ; preds = %5
%11 = lshr i64 %0, 10
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %11)
br label %13
13: ; preds = %7, %10, %3
ret i8* getelementptr inbounds ([8 x i8], [8 x i8]* @size_to_string.buffer, i64 0, i64 0)
}