#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 utsname {
  char *sysname;
  char *nodename;
  char *release;
  char *version;
  char *machine;
};

/* Variables and functions */
int /*<<< orphan*/ err_sys(char *);
scalar_t__ gethostname(char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *, char *);
scalar_t__ uname(struct utsname *);
int main(int argc, char **argv) {
  char host[128];
  if (gethostname(host, 128) != 0) {
    err_sys("gethostname failed");
  }
  struct utsname info;
  if (uname(&info) != 0) {
    err_sys("uname error");
  }
  printf("%s, %s, %s, %s, %s\n", info.sysname, info.nodename, info.release,
         info.version, info.machine);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1060 <gethostname@plt>
cmp    $0x0,%rax
je     1180 <main+0x40>
lea    0xe85(%rip),%rdi
call   1030 <err_sys@plt>
lea    -0xb8(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0x0,%rax
je     11a2 <main+0x62>
lea    0xe76(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0xb8(%rbp),%rsi
mov    -0xb0(%rbp),%rdx
mov    -0xa8(%rbp),%rcx
mov    -0xa0(%rbp),%r8
mov    -0x98(%rbp),%r9
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xb8,%rsp
lea    0x30(%rsp),%rdi
mov    $0x80,%esi
call   1060 <gethostname@plt>
test   %rax,%rax
je     1167 <main+0x27>
lea    0xe9e(%rip),%rdi
call   1030 <err_sys@plt>
lea    0x8(%rsp),%rdi
call   1050 <uname@plt>
test   %rax,%rax
je     1182 <main+0x42>
lea    0xe96(%rip),%rdi
call   1030 <err_sys@plt>
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    0x28(%rsp),%r9
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [19 x i8] c"gethostname failed\00"
@.str.1 = [12 x i8] c"uname error\00"
@.str.2 = [20 x i8] c"%s, %s, %s, %s, %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca %struct.utsname
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%9 = call i64 @gethostname(i8* %8, i32 128)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @err_sys(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = call i64 @uname(%struct.utsname* %7)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @err_sys(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 2
%24 = load i8*, i8** %23
%25 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 3
%26 = load i8*, i8** %25
%27 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 4
%28 = load i8*, i8** %27
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %20, i8* %22, i8* %24, i8* %26, i8* %28)
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [19 x i8] c"gethostname failed\00"
@.str.1 = [12 x i8] c"uname error\00"
@.str.2 = [20 x i8] c"%s, %s, %s, %s, %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca %struct.utsname
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i64 @gethostname(i8* %5, i32 128)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @err_sys(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = bitcast %struct.utsname* %4 to i8*
%12 = call i64 @uname(%struct.utsname* %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @err_sys(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i64 0, i32 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i64 0, i32 2
%22 = load i8*, i8** %21
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i64 0, i32 3
%24 = load i8*, i8** %23
%25 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i64 0, i32 4
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %20, i8* %22, i8* %24, i8* %26)
ret i32 0
}