#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 */
typedef int /*<<< orphan*/ hostname;

/* Variables and functions */
int /*<<< orphan*/ errno;
int gethostname(char *, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
int main() {
  char hostname[80];
  int result;
  printf("NetTest1\n");
  printf("Getting host name...\n");
  result = gethostname(hostname, sizeof(hostname));
  if (result == -1) {
    printf("Error getting host name: %s.\n", strerror(errno));
  } else {
    printf("This computers host name is %s.\n", hostname);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1040 <gethostname@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    119a <main+0x6a>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ac <main+0x7c>
lea    -0x60(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x50,%esi
call   1050 <gethostname@plt>
cmp    $0xffffffff,%eax
je     117a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    %rsp,%rsi
jmp    1192 <main+0x52>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe71(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"NetTest1\0A\00"
@.str.1 = [22 x i8] c"Getting host name...\0A\00"
@.str.2 = [30 x i8] c"Error getting host name: %s.\0A\00"
@errno = global i32 0
@.str.3 = [33 x i8] c"This computers host name is %s.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%7 = call i32 @gethostname(i8* %6, i32 80)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %17
14: ; preds = %0
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %10
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [30 x i8] c"Error getting host name: %s.\0A\00"
@errno = global i32 0
@.str.3 = [33 x i8] c"This computers host name is %s.\0A\00"
@str = [9 x i8] c"NetTest1\00"
@str.4 = [21 x i8] c"Getting host name...\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0))
%5 = call i32 @gethostname(i8* %2, i32 80)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %13
13: ; preds = %11, %7
ret i32 0
}