#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*/ Log_Print(char *, ...);
void PrintMemorySize(unsigned long size) {
  unsigned long number1, number2, number3;
  number1 = size >> 20;
  number2 = (size & 0xFFFFF) >> 10;
  number3 = (size & 0x3FF);
  if (number1) {
    Log_Print("%ld MB", number1);
  }
  if (number1 && number2) {
    Log_Print(" and ");
  }
  if (number2) {
    Log_Print("%ld KB", number2);
  }
  if (number2 && number3) {
    Log_Print(" and ");
  }
  if (number3) {
    Log_Print("%ld bytes", number3);
  }
}


x86 assembly (clang, -O0):
<PrintMemorySize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x14,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0xfffff,%rax
shr    $0xa,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3ff,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1165 <PrintMemorySize+0x55>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <Log_Print@plt>
cmpq   $0x0,-0x10(%rbp)
je     1189 <PrintMemorySize+0x79>
cmpq   $0x0,-0x18(%rbp)
je     1189 <PrintMemorySize+0x79>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <Log_Print@plt>
cmpq   $0x0,-0x18(%rbp)
je     11a6 <PrintMemorySize+0x96>
mov    -0x18(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <Log_Print@plt>
cmpq   $0x0,-0x18(%rbp)
je     11ca <PrintMemorySize+0xba>
cmpq   $0x0,-0x20(%rbp)
je     11ca <PrintMemorySize+0xba>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <Log_Print@plt>
cmpq   $0x0,-0x20(%rbp)
je     11e7 <PrintMemorySize+0xd7>
mov    -0x20(%rbp),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <Log_Print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintMemorySize>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
mov    %esi,%ebx
shr    $0xa,%ebx
and    $0x3ff,%ebx
mov    %esi,%r14d
and    $0x3ff,%r14d
cmp    $0xfffff,%rdi
jbe    115c <PrintMemorySize+0x4c>
shr    $0x14,%rsi
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1030 <Log_Print@plt>
test   %rbx,%rbx
je     1187 <PrintMemorySize+0x77>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1030 <Log_Print@plt>
jmp    1161 <PrintMemorySize+0x51>
test   %rbx,%rbx
je     1187 <PrintMemorySize+0x77>
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <Log_Print@plt>
test   %r14,%r14
je     11a4 <PrintMemorySize+0x94>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1030 <Log_Print@plt>
jmp    118c <PrintMemorySize+0x7c>
test   %r14,%r14
je     11a4 <PrintMemorySize+0x94>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <Log_Print@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%ld MB\00"
@.str.1 = [6 x i8] c" and \00"
@.str.2 = [7 x i8] c"%ld KB\00"
@.str.3 = [10 x i8] c"%ld bytes\00"
define void @PrintMemorySize(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = lshr i64 %6, 20
store i64 %7, i64* %3
%8 = load i64, i64* %2
%9 = and i64 %8, 1048575
%10 = lshr i64 %9, 10
store i64 %10, i64* %4
%11 = load i64, i64* %2
%12 = and i64 %11, 1023
store i64 %12, i64* %5
%13 = load i64, i64* %3
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i64, i64* %3
%17 = call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %15, %1
%19 = load i64, i64* %3
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i64, i64* %4
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %18
%27 = load i64, i64* %4
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i64, i64* %4
%31 = call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %30)
br label %32
32: ; preds = %29, %26
%33 = load i64, i64* %4
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i64, i64* %5
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %35, %32
%41 = load i64, i64* %5
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i64, i64* %5
%45 = call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 %44)
br label %46
46: ; preds = %43, %40
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%ld MB\00"
@.str.1 = [6 x i8] c" and \00"
@.str.2 = [7 x i8] c"%ld KB\00"
@.str.3 = [10 x i8] c"%ld bytes\00"
define void @PrintMemorySize(i64 %0) {
%2 = lshr i64 %0, 10
%3 = and i64 %2, 1023
%4 = and i64 %0, 1023
%5 = icmp ugt i64 %0, 1048575
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = icmp eq i64 %3, 0
br i1 %7, label %14, label %16
8: ; preds = %1
%9 = lshr i64 %0, 20
%10 = tail call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = icmp eq i64 %3, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %8, %6
%15 = icmp eq i64 %4, 0
br i1 %15, label %23, label %21
16: ; preds = %12, %6
%17 = tail call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %3)
%18 = icmp eq i64 %4, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = tail call i32 (i8*, ...) @Log_Print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 %4)
br label %23
23: ; preds = %16, %14, %21
ret void
}