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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
void printsysinfo(void) {
  struct sysinfo s;
  sysinfo(&s);
  printf("uptime     %lu\n", s.uptime);
  printf("loads      %lu %lu %lu\n", s.loads[0], s.loads[1], s.loads[2]);
  printf("total ram  %lu\n", s.totalram);
  printf("free ram   %lu\n", s.freeram);
  printf("shared ram %lu\n", s.sharedram);
  printf("buffer ram %lu\n", s.bufferram);
  printf("total swap %lu\n", s.totalswap);
  printf("free swap  %lu\n", s.freeswap);
  printf("procs      %u\n", s.procs);
  printf("total high %lu\n", s.totalhigh);
  printf("mem unit   %u\n", s.mem_unit);
}


x86 assembly (clang, -O0):
<printsysinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x30(%rbp),%rdi
call   1040 <sysinfo@plt>
mov    -0x30(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printsysinfo>:
sub    $0x38,%rsp
lea    0x8(%rsp),%rdi
call   1040 <sysinfo@plt>
mov    0x8(%rsp),%esi
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x30(%rsp),%rax
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%esi
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c(%rsp),%esi
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32* }
@.str = [16 x i8] c"uptime %lu\0A\00"
@.str.1 = [24 x i8] c"loads %lu %lu %lu\0A\00"
@.str.2 = [16 x i8] c"total ram %lu\0A\00"
@.str.3 = [16 x i8] c"free ram %lu\0A\00"
@.str.4 = [16 x i8] c"shared ram %lu\0A\00"
@.str.5 = [16 x i8] c"buffer ram %lu\0A\00"
@.str.6 = [16 x i8] c"total swap %lu\0A\00"
@.str.7 = [16 x i8] c"free swap %lu\0A\00"
@.str.8 = [15 x i8] c"procs %u\0A\00"
@.str.9 = [16 x i8] c"total high %lu\0A\00"
@.str.10 = [15 x i8] c"mem unit %u\0A\00"
define void @printsysinfo() {
%1 = alloca %struct.sysinfo
%2 = call i32 @sysinfo(%struct.sysinfo* %1)
%3 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 0
%4 = load i32, i32* %3
%5 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 10
%7 = load i32*, i32** %6
%8 = getelementptr inbounds i32, i32* %7, i64 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 10
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 10
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 2
%17 = load i32, i32* %16
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %13, i32 %17)
%19 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 1
%20 = load i32, i32* %19
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 2
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 3
%26 = load i32, i32* %25
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 4
%29 = load i32, i32* %28
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 5
%32 = load i32, i32* %31
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 6
%35 = load i32, i32* %34
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 7
%38 = load i32, i32* %37
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 8
%41 = load i32, i32* %40
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 9
%44 = load i32, i32* %43
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %44)
ret void
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32* }
@.str = [16 x i8] c"uptime %lu\0A\00"
@.str.1 = [24 x i8] c"loads %lu %lu %lu\0A\00"
@.str.2 = [16 x i8] c"total ram %lu\0A\00"
@.str.3 = [16 x i8] c"free ram %lu\0A\00"
@.str.4 = [16 x i8] c"shared ram %lu\0A\00"
@.str.5 = [16 x i8] c"buffer ram %lu\0A\00"
@.str.6 = [16 x i8] c"total swap %lu\0A\00"
@.str.7 = [16 x i8] c"free swap %lu\0A\00"
@.str.8 = [15 x i8] c"procs %u\0A\00"
@.str.9 = [16 x i8] c"total high %lu\0A\00"
@.str.10 = [15 x i8] c"mem unit %u\0A\00"
define void @printsysinfo() {
%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 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 10
%8 = load i32*, i32** %7
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %8, i64 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %8, i64 2
%13 = load i32, i32* %12
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11, i32 %13)
%15 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%16 = load i32, i32* %15
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%19 = load i32, i32* %18
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%22 = load i32, i32* %21
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 4
%25 = load i32, i32* %24
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 5
%28 = load i32, i32* %27
%29 = call i32 (i8*, i32, ...) @printf(i8* 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*, i32, ...) @printf(i8* 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 7
%34 = load i32, i32* %33
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 8
%37 = load i32, i32* %36
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 9
%40 = load i32, i32* %39
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %40)
ret void
}