#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 /*<<< orphan*/ uptime;
};

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int sysinfo(struct sysinfo *);
int main(void) {
  struct sysinfo *info;
  int code;
  info = (struct sysinfo *)malloc(sizeof(struct sysinfo));
  if (info == NULL) {
    printf("malloc failed");
  } else {
    while (1) {
      code = sysinfo(info);
      if (code != 0) {
        printf("sysinfo failed");
      } else {
        printf("Hello User world\nUptime: %ld\n", info->uptime);
      }
      sleep(5);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117b <main+0x3b>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cc <main+0x8c>
jmp    1180 <main+0x40>
mov    -0x10(%rbp),%rdi
call   1050 <sysinfo@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a9 <main+0x69>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     119e <main+0x5e>
mov    %rax,%rbx
lea    0xebf(%rip),%r14
lea    0xea9(%rip),%r15
jmp    1186 <main+0x46>
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
call   1050 <sysinfo@plt>
test   %eax,%eax
je     1170 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    117c <main+0x3c>
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32 }
@.str = [14 x i8] c"malloc failed\00"
@.str.1 = [15 x i8] c"sysinfo failed\00"
@.str.2 = [30 x i8] c"Hello User world\0AUptime: %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sysinfo*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @malloc(i32 4)
%5 = inttoptr i64 %4 to %struct.sysinfo*
store %struct.sysinfo* %5, %struct.sysinfo** %2
%6 = load %struct.sysinfo*, %struct.sysinfo** %2
%7 = icmp eq %struct.sysinfo* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %25
10: ; preds = %0
br label %11
11: ; preds = %10, %23
%12 = load %struct.sysinfo*, %struct.sysinfo** %2
%13 = call i32 @sysinfo(%struct.sysinfo* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %23
18: ; preds = %11
%19 = load %struct.sysinfo*, %struct.sysinfo** %2
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %18, %16
%24 = call i32 @sleep(i32 5)
br label %11
25: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.sysinfo = type { i32 }
@.str = [14 x i8] c"malloc failed\00"
@.str.1 = [15 x i8] c"sysinfo failed\00"
@.str.2 = [30 x i8] c"Hello User world\0AUptime: %ld\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to %struct.sysinfo*
%3 = icmp eq i64 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i64 0, i32 0
br label %8
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i32 0
8: ; preds = %4, %16
%9 = tail call i32 @sysinfo(%struct.sysinfo* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %16
13: ; preds = %8
%14 = load i32, i32* %5
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %11
%17 = tail call i32 @sleep(i32 5)
br label %8
}