#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 bufferram;
  int totalswap;
  int freeswap;
  int procs;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
void sysinfo_test() {
  struct sysinfo sys_info;
  if (!sysinfo(&sys_info)) {
    printf("uptime = %ld\n", sys_info.uptime);
    printf("totalram = %d\n", sys_info.totalram);
    printf("freeram = %d\n", sys_info.freeram);
    printf("bufferram = %d\n", sys_info.bufferram);
    printf("totalswap = %d\n", sys_info.totalswap);
    printf("freeswap = %d\n", sys_info.freeswap);
    printf("procs = %d\n", sys_info.procs);
  }
}


x86 assembly (clang, -O0):
<sysinfo_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x20(%rbp),%rdi
call   1040 <sysinfo@plt>
cmp    $0x0,%eax
jne    11a3 <sysinfo_test+0x83>
mov    -0x20(%rbp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysinfo_test>:
sub    $0x28,%rsp
lea    0x8(%rsp),%rdi
call   1040 <sysinfo@plt>
test   %eax,%eax
je     1137 <sysinfo_test+0x17>
add    $0x28,%rsp
ret
mov    0x8(%rsp),%esi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [14 x i8] c"uptime = %ld\0A\00"
@.str.1 = [15 x i8] c"totalram = %d\0A\00"
@.str.2 = [14 x i8] c"freeram = %d\0A\00"
@.str.3 = [16 x i8] c"bufferram = %d\0A\00"
@.str.4 = [16 x i8] c"totalswap = %d\0A\00"
@.str.5 = [15 x i8] c"freeswap = %d\0A\00"
@.str.6 = [12 x i8] c"procs = %d\0A\00"
define void @sysinfo_test() {
%1 = alloca %struct.sysinfo
%2 = call i32 @sysinfo(%struct.sysinfo* %1)
%3 = icmp ne i32 %2, 0
br i1 %3, label %26, label %4
4: ; preds = %0
%5 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 0
%6 = load i32, i32* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 1
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 2
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 3
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 4
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 5
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 6
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %4, %0
ret void
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [14 x i8] c"uptime = %ld\0A\00"
@.str.1 = [15 x i8] c"totalram = %d\0A\00"
@.str.2 = [14 x i8] c"freeram = %d\0A\00"
@.str.3 = [16 x i8] c"bufferram = %d\0A\00"
@.str.4 = [16 x i8] c"totalswap = %d\0A\00"
@.str.5 = [15 x i8] c"freeswap = %d\0A\00"
@.str.6 = [12 x i8] c"procs = %d\0A\00"
define void @sysinfo_test() {
%1 = alloca %struct.sysinfo
%2 = bitcast %struct.sysinfo* %1 to i8*
%3 = call i32 @sysinfo(%struct.sysinfo* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %27
5: ; preds = %0
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%13 = load i32, i32* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 4
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 5
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 6
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %5, %0
ret void
}