#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 *, ...);
int /*<<< orphan*/ sleep(int);
scalar_t__ sysinfo(struct sysinfo *);
int main() {
  struct sysinfo info;
  if (sysinfo(&info)) {
    printf("Error while 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);
  sleep(1000);
  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     116c <main+0x3c>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <main+0xc4>
lea    0xeb3(%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),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1050 <sleep@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     116a <main+0x2a>
lea    0xf0f(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1206 <main+0xc6>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%esi
lea    0xe7f(%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    0xe64(%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    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1060 <sleep@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32, i32, i32, i32 }
@.str = [38 x i8] c"Error while 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 ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
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)
%26 = call i32 @sleep(i32 1000)
store i32 0, i32* %1
br label %27
27: ; preds = %7, %5
%28 = load i32, i32* %1
ret i32 %28
}

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 = [37 x i8] c"Error while 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 ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %27
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)
%26 = call i32 @sleep(i32 1000)
br label %27
27: ; preds = %7, %5
%28 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %28
}