#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 procs;
  int mem_unit;
  int /*<<< orphan*/ freehigh;
  int /*<<< orphan*/ totalhigh;
  int /*<<< orphan*/ freeswap;
  int /*<<< orphan*/ totalswap;
  int /*<<< orphan*/ bufferram;
  int /*<<< orphan*/ sharedram;
  int /*<<< orphan*/ freeram;
  int /*<<< orphan*/ totalram;
  int /*<<< orphan*/ *loads;
  int /*<<< orphan*/ uptime;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sysinfo(struct sysinfo *);
int main() {
  struct sysinfo buf;
  if (sysinfo(&buf) == 0) {
    printf("uptime: %lu\n", buf.uptime);
    printf("load  1min: %lu\n", buf.loads[0]);
    printf("load  5min: %lu\n", buf.loads[1]);
    printf("load 15min: %lu\n", buf.loads[2]);
    printf("totalram: %lu\n", buf.totalram);
    printf("freeram: %lu\n", buf.freeram);
    printf("sharedram: %lu\n", buf.sharedram);
    printf("bufferram: %lu\n", buf.bufferram);
    printf("totalswap: %lu\n", buf.totalswap);
    printf("freeswap: %lu\n", buf.freeswap);
    printf("procs: %d\n", buf.procs);
    printf("totalhigh: %lu\n", buf.totalhigh);
    printf("freehigh: %lu\n", buf.freehigh);
    printf("mem_unit: %d\n", buf.mem_unit);
  } else {
    printf("error at sysinfo().");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <sysinfo@plt>
cmp    $0x0,%rax
jne    1240 <main+0x120>
mov    -0x10(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124e <main+0x12e>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
mov    %rsp,%rdi
call   1040 <sysinfo@plt>
test   %rax,%rax
je     1144 <main+0x24>
lea    0xf9c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    124a <main+0x12a>
mov    0x30(%rsp),%esi
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%rax
mov    (%rax),%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%rax
mov    0x4(%rax),%esi
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%rax
mov    0x8(%rax),%esi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%esi
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32*, i32 }
@.str = [13 x i8] c"uptime: %lu\0A\00"
@.str.1 = [17 x i8] c"load 1min: %lu\0A\00"
@.str.2 = [17 x i8] c"load 5min: %lu\0A\00"
@.str.3 = [17 x i8] c"load 15min: %lu\0A\00"
@.str.4 = [15 x i8] c"totalram: %lu\0A\00"
@.str.5 = [14 x i8] c"freeram: %lu\0A\00"
@.str.6 = [16 x i8] c"sharedram: %lu\0A\00"
@.str.7 = [16 x i8] c"bufferram: %lu\0A\00"
@.str.8 = [16 x i8] c"totalswap: %lu\0A\00"
@.str.9 = [15 x i8] c"freeswap: %lu\0A\00"
@.str.10 = [11 x i8] c"procs: %d\0A\00"
@.str.11 = [16 x i8] c"totalhigh: %lu\0A\00"
@.str.12 = [15 x i8] c"freehigh: %lu\0A\00"
@.str.13 = [14 x i8] c"mem_unit: %d\0A\00"
@.str.14 = [20 x i8] c"error at sysinfo().\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sysinfo
store i32 0, i32* %1
%3 = call i64 @sysinfo(%struct.sysinfo* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %54
5: ; preds = %0
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 11
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 10
%10 = load i32*, i32** %9
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 10
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 10
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 9
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 8
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 7
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 6
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 5
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 4
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 0
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 3
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 2
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 1
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
br label %56
56: ; preds = %54, %5
ret i32 0
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32*, i32 }
@.str = [13 x i8] c"uptime: %lu\0A\00"
@.str.1 = [17 x i8] c"load 1min: %lu\0A\00"
@.str.2 = [17 x i8] c"load 5min: %lu\0A\00"
@.str.3 = [17 x i8] c"load 15min: %lu\0A\00"
@.str.4 = [15 x i8] c"totalram: %lu\0A\00"
@.str.5 = [14 x i8] c"freeram: %lu\0A\00"
@.str.6 = [16 x i8] c"sharedram: %lu\0A\00"
@.str.7 = [16 x i8] c"bufferram: %lu\0A\00"
@.str.8 = [16 x i8] c"totalswap: %lu\0A\00"
@.str.9 = [15 x i8] c"freeswap: %lu\0A\00"
@.str.10 = [11 x i8] c"procs: %d\0A\00"
@.str.11 = [16 x i8] c"totalhigh: %lu\0A\00"
@.str.12 = [15 x i8] c"freehigh: %lu\0A\00"
@.str.13 = [14 x i8] c"mem_unit: %d\0A\00"
@.str.14 = [20 x i8] c"error at sysinfo().\00"
define i32 @main() {
%1 = alloca %struct.sysinfo
%2 = bitcast %struct.sysinfo* %1 to i8*
%3 = call i64 @sysinfo(%struct.sysinfo* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %51
5: ; preds = %0
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 11
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 10
%10 = load i32*, i32** %9
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32*, i32** %9
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %9
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 9
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 8
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 7
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 6
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 5
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 4
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 %49)
br label %53
51: ; preds = %0
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
br label %53
53: ; preds = %51, %5
ret i32 0
}