#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 */
long long get_mem_size();
long long get_mem_size_iomem();
long long get_mem_size_meminfo();
long long get_mem_size_stat();
long long get_mem_size_sysinfo();
int /*<<< orphan*/ print_mem(long long);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  long long mem_size = 0;
  mem_size = 1024 * 1024;
  mem_size = get_mem_size_iomem();
  printf("IOMEM:\n");
  printf("\traw:    %lld\n", mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  mem_size = get_mem_size_stat();
  printf("KCORE:\n");
  printf("\traw:    %lld\n", mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  mem_size = get_mem_size_sysinfo();
  printf("SYSINFO:\n");
  printf("\traw:    %lld\n", mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  mem_size = get_mem_size_meminfo();
  printf("MEMINFO:\n");
  printf("\traw:    %lld\n", mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  mem_size = get_mem_size();
  printf("DEFAULT:\n");
  printf("\traw:    %lld\n", mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x100000,-0x18(%rbp)
mov    $0x0,%al
call   1080 <get_mem_size_iomem@plt>
mov    %rax,-0x18(%rbp)
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_mem@plt>
mov    $0x0,%al
call   1050 <get_mem_size_stat@plt>
mov    %rax,-0x18(%rbp)
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_mem@plt>
mov    $0x0,%al
call   1040 <get_mem_size_sysinfo@plt>
mov    %rax,-0x18(%rbp)
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_mem@plt>
mov    $0x0,%al
call   1070 <get_mem_size_meminfo@plt>
mov    %rax,-0x18(%rbp)
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_mem@plt>
mov    $0x0,%al
call   1090 <get_mem_size@plt>
mov    %rax,-0x18(%rbp)
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_mem@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1090 <get_mem_size_iomem@plt>
mov    %rax,%rbx
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5e(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_mem@plt>
xor    %eax,%eax
call   1060 <get_mem_size_stat@plt>
mov    %rax,%rbx
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_mem@plt>
xor    %eax,%eax
call   1050 <get_mem_size_sysinfo@plt>
mov    %rax,%rbx
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_mem@plt>
xor    %eax,%eax
call   1080 <get_mem_size_meminfo@plt>
mov    %rax,%rbx
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_mem@plt>
xor    %eax,%eax
call   10a0 <get_mem_size@plt>
mov    %rax,%rbx
lea    0xdc1(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_mem@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"IOMEM:\0A\00"
@.str.1 = [15 x i8] c"\09raw: %lld\0A\00"
@.str.2 = [10 x i8] c"\09pretty: \00"
@.str.3 = [8 x i8] c"KCORE:\0A\00"
@.str.4 = [10 x i8] c"SYSINFO:\0A\00"
@.str.5 = [10 x i8] c"MEMINFO:\0A\00"
@.str.6 = [10 x i8] c"DEFAULT:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 1048576, i64* %6
%7 = call i64 (...) @get_mem_size_iomem()
store i64 %7, i64* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = load i64, i64* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = load i64, i64* %6
%13 = call i32 @print_mem(i64 %12)
%14 = call i64 (...) @get_mem_size_stat()
store i64 %14, i64* %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = load i64, i64* %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%19 = load i64, i64* %6
%20 = call i32 @print_mem(i64 %19)
%21 = call i64 (...) @get_mem_size_sysinfo()
store i64 %21, i64* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%23 = load i64, i64* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%26 = load i64, i64* %6
%27 = call i32 @print_mem(i64 %26)
%28 = call i64 (...) @get_mem_size_meminfo()
store i64 %28, i64* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%30 = load i64, i64* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%33 = load i64, i64* %6
%34 = call i32 @print_mem(i64 %33)
%35 = call i64 (...) @get_mem_size()
store i64 %35, i64* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%37 = load i64, i64* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%40 = load i64, i64* %6
%41 = call i32 @print_mem(i64 %40)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"\09raw: %lld\0A\00"
@.str.2 = [10 x i8] c"\09pretty: \00"
@str = [7 x i8] c"IOMEM:\00"
@str.7 = [7 x i8] c"KCORE:\00"
@str.8 = [9 x i8] c"SYSINFO:\00"
@str.9 = [9 x i8] c"MEMINFO:\00"
@str.10 = [9 x i8] c"DEFAULT:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @get_mem_size_iomem()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @print_mem(i64 %3)
%8 = tail call i64 (...) @get_mem_size_stat()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %8)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @print_mem(i64 %8)
%13 = tail call i64 (...) @get_mem_size_sysinfo()
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @print_mem(i64 %13)
%18 = tail call i64 (...) @get_mem_size_meminfo()
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %18)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @print_mem(i64 %18)
%23 = tail call i64 (...) @get_mem_size()
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.10, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @print_mem(i64 %23)
ret i32 0
}