#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 */

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int gethostname(char *, int);
int /*<<< orphan*/ printf(char *, char *);
char *strerror(int /*<<< orphan*/);
int main(void) {
  char buffer[128];
  if (gethostname(buffer, 128) == -1) {
    printf("error: %s\n", strerror(errno));
  } else {
    printf("host name: %s\n", buffer);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1040 <gethostname@plt>
cmp    $0xffffffff,%eax
jne    118e <main+0x4e>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <main+0x61>
lea    -0x90(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x88,%rsp
mov    %rsp,%rdi
mov    $0x80,%esi
call   1040 <gethostname@plt>
cmp    $0xffffffff,%eax
jne    1173 <main+0x33>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe92(%rip),%rdi
mov    %rax,%rsi
jmp    117d <main+0x3d>
lea    0xe91(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"error: %s\0A\00"
@errno = global i32 0
@.str.1 = [15 x i8] c"host name: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = call i32 @gethostname(i8* %3, i32 128)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %13
10: ; preds = %0
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %6
%14 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"error: %s\0A\00"
@errno = global i32 0
@.str.1 = [15 x i8] c"host name: %s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 @gethostname(i8* %2, i32 128)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = call i8* @strerror(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %11
11: ; preds = %9, %5
%12 = call i32 @exit(i32 0)
unreachable
}