#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ gethostname(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ uname(struct utsname *);
int main(void) {
  char my_host[64];
  struct utsname my_kernel;
  if (gethostname(my_host, 64) < 0) {
    fprintf(stderr, "Err.(%s) getting hostname\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (uname(&my_kernel) < 0) {
    fprintf(stderr, "Err.(%s) getting kernel info\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("    host: %s (gethostname)\n", my_host);
  printf(" sysname: %s\n", my_kernel.sysname);
  printf("nodename: %s\n", my_kernel.nodename);
  printf(" release: %s\n", my_kernel.release);
  printf(" version: %s\n", my_kernel.version);
  printf(" machine: %s\n", my_kernel.machine);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
call   1060 <gethostname@plt>
cmp    $0x0,%rax
jge    11c4 <main+0x64>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%rdx
lea    0xe4f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x78(%rbp),%rdi
call   1040 <uname@plt>
cmp    $0x0,%rax
jge    1211 <main+0xb1>
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x80(%rbp),%edi
mov    %rax,%rdx
lea    0xe1d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x50(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
mov    -0x68(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
mov    -0x60(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0x30(%rsp),%rdi
mov    $0x40,%esi
call   1060 <gethostname@plt>
test   %rax,%rax
js     1205 <main+0xa5>
lea    0x8(%rsp),%rdi
call   1040 <uname@plt>
test   %rax,%rax
js     1225 <main+0xc5>
lea    0xea2(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    0x28(%rsp),%rsi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbx
ret
mov    0x2dd4(%rip),%rax
mov    (%rax),%ebx
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xddd(%rip),%rsi
jmp    1243 <main+0xe3>
mov    0x2db4(%rip),%rax
mov    (%rax),%ebx
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xdd8(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@stderr = global i32 0
@.str = [27 x i8] c"Err.(%s) getting hostname\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Err.(%s) getting kernel info\0A\00"
@.str.2 = [28 x i8] c" host: %s (gethostname)\0A\00"
@.str.3 = [14 x i8] c" sysname: %s\0A\00"
@.str.4 = [14 x i8] c"nodename: %s\0A\00"
@.str.5 = [14 x i8] c" release: %s\0A\00"
@.str.6 = [14 x i8] c" version: %s\0A\00"
@.str.7 = [14 x i8] c" machine: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca %struct.utsname
store i32 0, i32* %1
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = call i64 @gethostname(i8* %4, i32 64)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call i64 @uname(%struct.utsname* %3)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %14
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%28 = load i8*, i8** %27
%29 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 1
%31 = load i8*, i8** %30
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 2
%34 = load i8*, i8** %33
%35 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 3
%37 = load i8*, i8** %36
%38 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 4
%40 = load i8*, i8** %39
%41 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@stderr = global i32 0
@.str = [27 x i8] c"Err.(%s) getting hostname\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Err.(%s) getting kernel info\0A\00"
@.str.2 = [28 x i8] c" host: %s (gethostname)\0A\00"
@.str.3 = [14 x i8] c" sysname: %s\0A\00"
@.str.4 = [14 x i8] c"nodename: %s\0A\00"
@.str.5 = [14 x i8] c" release: %s\0A\00"
@.str.6 = [14 x i8] c" version: %s\0A\00"
@.str.7 = [14 x i8] c" machine: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca %struct.utsname
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.utsname* %2 to i8*
%5 = call i64 @gethostname(i8* %3, i32 64)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call i64 @uname(%struct.utsname* %2)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %14
%25 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%26 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 1
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 2
%33 = load i8*, i8** %32
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 3
%36 = load i8*, i8** %35
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 4
%39 = load i8*, i8** %38
%40 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_SUCCESS
ret i32 %41
}