#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 */
struct sysinfo {
  scalar_t__ freehigh;
  scalar_t__ totalhigh;
  scalar_t__ bufferram;
  scalar_t__ sharedram;
  scalar_t__ mem_unit;
  scalar_t__ freeram;
  scalar_t__ totalram;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
int main(int argc, char **argv) {
  struct sysinfo info;
  sysinfo(&info);
  printf("Total ram: %d\n", (long)info.totalram / 1048576);
  printf("Free ram: %d\n", (long)info.freeram / 1048576);
  printf("Mem unit %d\n", (long)info.mem_unit);
  printf("Shared: %d\n", (long)info.sharedram / 1048576);
  printf("Buffered: %d\n", (long)info.bufferram / 1048576);
  printf("Total High: %d\n", (long)info.totalhigh / 1048576);
  printf("Free high: %d\n", (long)info.freehigh / 1048576);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x48(%rbp),%rdi
call   1040 <sysinfo@plt>
mov    -0x18(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rax
mov    $0x100000,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
mov    %rsp,%rdi
call   1040 <sysinfo@plt>
mov    0x30(%rsp),%rax
lea    0xfffff(%rax),%rsi
test   %rax,%rax
cmovns %rax,%rsi
sar    $0x14,%rsi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    0x28(%rsp),%rax
lea    0xfffff(%rax),%rsi
test   %rax,%rax
cmovns %rax,%rsi
sar    $0x14,%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rax
lea    0xfffff(%rax),%rsi
test   %rax,%rax
cmovns %rax,%rsi
sar    $0x14,%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rax
lea    0xfffff(%rax),%rsi
test   %rax,%rax
cmovns %rax,%rsi
sar    $0x14,%rsi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
lea    0xfffff(%rax),%rsi
test   %rax,%rax
cmovns %rax,%rsi
sar    $0x14,%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
lea    0xfffff(%rax),%rsi
test   %rax,%rax
cmovns %rax,%rsi
sar    $0x14,%rsi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i64, i64, i64, i64, i64, i64, i64 }
@.str = [15 x i8] c"Total ram: %d\0A\00"
@.str.1 = [14 x i8] c"Free ram: %d\0A\00"
@.str.2 = [13 x i8] c"Mem unit %d\0A\00"
@.str.3 = [12 x i8] c"Shared: %d\0A\00"
@.str.4 = [14 x i8] c"Buffered: %d\0A\00"
@.str.5 = [16 x i8] c"Total High: %d\0A\00"
@.str.6 = [15 x i8] c"Free high: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sysinfo
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @sysinfo(%struct.sysinfo* %6)
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 6
%9 = load i64, i64* %8
%10 = sdiv i64 %9, 1048576
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 5
%13 = load i64, i64* %12
%14 = sdiv i64 %13, 1048576
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%16 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 4
%17 = load i64, i64* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %17)
%19 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 3
%20 = load i64, i64* %19
%21 = sdiv i64 %20, 1048576
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 %21)
%23 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 2
%24 = load i64, i64* %23
%25 = sdiv i64 %24, 1048576
%26 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 %25)
%27 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 1
%28 = load i64, i64* %27
%29 = sdiv i64 %28, 1048576
%30 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i64 %29)
%31 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%32 = load i64, i64* %31
%33 = sdiv i64 %32, 1048576
%34 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 %33)
ret i32 0
}

LLVM IR (-O2):
%struct.sysinfo = type { i64, i64, i64, i64, i64, i64, i64 }
@.str = [15 x i8] c"Total ram: %d\0A\00"
@.str.1 = [14 x i8] c"Free ram: %d\0A\00"
@.str.2 = [13 x i8] c"Mem unit %d\0A\00"
@.str.3 = [12 x i8] c"Shared: %d\0A\00"
@.str.4 = [14 x i8] c"Buffered: %d\0A\00"
@.str.5 = [16 x i8] c"Total High: %d\0A\00"
@.str.6 = [15 x i8] c"Free high: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sysinfo
%4 = bitcast %struct.sysinfo* %3 to i8*
%5 = call i32 @sysinfo(%struct.sysinfo* %3)
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 6
%7 = load i64, i64* %6
%8 = sdiv i64 %7, 1048576
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 5
%11 = load i64, i64* %10
%12 = sdiv i64 %11, 1048576
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %12)
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 4
%15 = load i64, i64* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %15)
%17 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 3
%18 = load i64, i64* %17
%19 = sdiv i64 %18, 1048576
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 %19)
%21 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 2
%22 = load i64, i64* %21
%23 = sdiv i64 %22, 1048576
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 %23)
%25 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 1
%26 = load i64, i64* %25
%27 = sdiv i64 %26, 1048576
%28 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i64 %27)
%29 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 0
%30 = load i64, i64* %29
%31 = sdiv i64 %30, 1048576
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 %31)
ret i32 0
}