#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 procs;
  int mem_unit;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sysinfo(struct sysinfo *);
int main() {
  struct sysinfo info;
  if (sysinfo(&info)) {
    printf("Error in init the sysinfo struct!!\n");
    return -1;
  }
  printf("Hello User world \n");
  printf("Uptime: %ld \n", info.uptime);
  printf("Total RAM: %lu MB\n", info.totalram / 1000000);
  printf("Free RAM: %lu MB\n", info.freeram / 1000000);
  printf("Process count %hu \n", info.procs);
  printf("Page size: %d B\n", info.mem_unit);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <sysinfo@plt>
cmp    $0x0,%rax
je     115c <main+0x3c>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <main+0xba>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0x8(%rsp),%rdi
call   1050 <sysinfo@plt>
test   %rax,%rax
je     115a <main+0x2a>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    11ec <main+0xbc>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%esi
lea    0xe8f(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x431bde83,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x32,%rsi
add    %eax,%esi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x10(%rsp),%rax
imul   $0x431bde83,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x32,%rsi
add    %eax,%esi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32, i32, i32, i32 }
@.str = [36 x i8] c"Error in init the sysinfo struct!!\0A\00"
@.str.1 = [19 x i8] c"Hello User world \0A\00"
@.str.2 = [14 x i8] c"Uptime: %ld \0A\00"
@.str.3 = [19 x i8] c"Total RAM: %lu MB\0A\00"
@.str.4 = [18 x i8] c"Free RAM: %lu MB\0A\00"
@.str.5 = [20 x i8] c"Process count %hu \0A\00"
@.str.6 = [17 x i8] c"Page size: %d B\0A\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 ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %26
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 1
%13 = load i32, i32* %12
%14 = sdiv i32 %13, 1000000
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, 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, 1000000
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 3
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i32 0, i32 4
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %24)
store i32 0, i32* %1
br label %26
26: ; preds = %7, %5
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, i32, i32, i32, i32 }
@.str.2 = [14 x i8] c"Uptime: %ld \0A\00"
@.str.3 = [19 x i8] c"Total RAM: %lu MB\0A\00"
@.str.4 = [18 x i8] c"Free RAM: %lu MB\0A\00"
@.str.5 = [20 x i8] c"Process count %hu \0A\00"
@.str.6 = [17 x i8] c"Page size: %d B\0A\00"
@str = [18 x i8] c"Hello User world \00"
@str.7 = [35 x i8] c"Error in init the sysinfo struct!!\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 %7, label %5
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.7, i64 0, i64 0))
br label %26
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%13 = load i32, i32* %12
%14 = sdiv i32 %13, 1000000
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%17 = load i32, i32* %16
%18 = sdiv i32 %17, 1000000
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 4
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %7, %5
%27 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %27
}