#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 {
  int freeram;
  float uptime;
  int bufferram;
  int totalram;
  int sharedram;
  int mem_unit;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
int main() {
  struct sysinfo si;
  sysinfo(&si);
  printf("free mem      %10lu\n", si.freeram /= 1024);
  float d = si.uptime;
  printf("uptime hours  %10f\n", (d / 60) / 60);
  printf("buffer mem    %10lu\n", si.bufferram /= 1024);
  printf("total mem     %10lu\n", si.totalram /= 1024);
  printf("shared mem    %10lu\n", si.sharedram /= 1024);
  printf("mem unit      %10u\n", si.mem_unit);
  printf("used mem      %10lu\n", (si.totalram - si.freeram - si.bufferram));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <sysinfo@plt>
mov    -0x20(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    %esi,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  0xe95(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe89(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    %esi,-0x18(%rbp)
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    %esi,-0x14(%rbp)
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    %esi,-0x10(%rbp)
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
sub    -0x20(%rbp),%esi
sub    -0x18(%rbp),%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    %rsp,%rdi
call   1040 <sysinfo@plt>
mov    (%rsp),%eax
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
mov    %esi,(%rsp)
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
movss  0xea6(%rip),%xmm1
divss  %xmm1,%xmm0
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
mov    %esi,0x8(%rsp)
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
mov    %esi,0xc(%rsp)
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%eax
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
mov    %esi,0x10(%rsp)
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%eax
mov    0xc(%rsp),%esi
add    0x8(%rsp),%eax
sub    %eax,%esi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, float, i32, i32, i32, i32 }
@.str = [21 x i8] c"free mem %10lu\0A\00"
@.str.1 = [20 x i8] c"uptime hours %10f\0A\00"
@.str.2 = [21 x i8] c"buffer mem %10lu\0A\00"
@.str.3 = [21 x i8] c"total mem %10lu\0A\00"
@.str.4 = [21 x i8] c"shared mem %10lu\0A\00"
@.str.5 = [20 x i8] c"mem unit %10u\0A\00"
@.str.6 = [21 x i8] c"used mem %10lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sysinfo
%3 = alloca float
store i32 0, i32* %1
%4 = call i32 @sysinfo(%struct.sysinfo* %2)
%5 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 0
%6 = load i32, i32* %5
%7 = sdiv i32 %6, 1024
store i32 %7, i32* %5
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 1
%10 = load float, float* %9
store float %10, float* %3
%11 = load float, float* %3
%12 = fdiv float %11, 6.000000e+01
%13 = fdiv float %12, 6.000000e+01
%14 = fptosi float %13 to i32
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 2
%17 = load i32, i32* %16
%18 = sdiv i32 %17, 1024
store i32 %18, i32* %16
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 3
%21 = load i32, i32* %20
%22 = sdiv i32 %21, 1024
store i32 %22, i32* %20
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 4
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 1024
store i32 %26, i32* %24
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 5
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 3
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 0
%34 = load i32, i32* %33
%35 = sub nsw i32 %32, %34
%36 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 2
%37 = load i32, i32* %36
%38 = sub nsw i32 %35, %37
%39 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, float, i32, i32, i32, i32 }
@.str = [21 x i8] c"free mem %10lu\0A\00"
@.str.1 = [20 x i8] c"uptime hours %10f\0A\00"
@.str.2 = [21 x i8] c"buffer mem %10lu\0A\00"
@.str.3 = [21 x i8] c"total mem %10lu\0A\00"
@.str.4 = [21 x i8] c"shared mem %10lu\0A\00"
@.str.5 = [20 x i8] c"mem unit %10u\0A\00"
@.str.6 = [21 x i8] c"used mem %10lu\0A\00"
define i32 @main() {
%1 = alloca %struct.sysinfo
%2 = bitcast %struct.sysinfo* %1 to i8*
%3 = call i32 @sysinfo(%struct.sysinfo* %1)
%4 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = sdiv i32 %5, 1024
store i32 %6, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%9 = load float, float* %8
%10 = fdiv float %9, 6.000000e+01
%11 = fdiv float %10, 6.000000e+01
%12 = fptosi float %11 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%15 = load i32, i32* %14
%16 = sdiv i32 %15, 1024
store i32 %16, i32* %14
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%19 = load i32, i32* %18
%20 = sdiv i32 %19, 1024
store i32 %20, i32* %18
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 4
%23 = load i32, i32* %22
%24 = sdiv i32 %23, 1024
store i32 %24, i32* %22
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 5
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %18
%30 = load i32, i32* %4
%31 = load i32, i32* %14
%32 = add i32 %30, %31
%33 = sub i32 %29, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %33)
ret i32 0
}