#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 {
  int /*<<< orphan*/ nodename;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ pm_error(char *, int /*<<< orphan*/, int /*<<< orphan*/);
char const *strdup(int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int uname(struct utsname *);
const char *GetHostName(void) {
  struct utsname utsname;
  int rc;
  rc = uname(&utsname);
  if (rc < 0)
    pm_error("Unable to find out host name.  "
             "uname() failed with errno %d (%s)",
             errno, strerror(errno));
  return strdup(utsname.nodename);
}


x86 assembly (clang, -O0):
<GetHostName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1030 <uname@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1189 <GetHostName+0x49>
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe7c(%rip),%rdi
call   1060 <pm_error@plt>
mov    -0x8(%rbp),%edi
call   1040 <strdup@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetHostName>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
test   %eax,%eax
jns    1173 <GetHostName+0x33>
mov    0x2e86(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1050 <strerror@plt>
lea    0xe96(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <pm_error@plt>
mov    0x8(%rsp),%edi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <strdup@plt>

LLVM IR (-O0):
%struct.utsname = type { i32 }
@.str = [65 x i8] c"Unable to find out host name. uname() failed with errno %d (%s)\00"
@errno = global i32 0
define i8* @GetHostName() {
%1 = alloca %struct.utsname
%2 = alloca i32
%3 = call i32 @uname(%struct.utsname* %1)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @errno
%8 = load i32, i32* @errno
%9 = call i32 @strerror(i32 %8)
%10 = call i32 @pm_error(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
br label %11
11: ; preds = %6, %0
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i8* @strdup(i32 %13)
ret i8* %14
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@.str = [65 x i8] c"Unable to find out host name. uname() failed with errno %d (%s)\00"
@errno = global i32 0
define i8* @GetHostName() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i32 @uname(%struct.utsname* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @pm_error(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
br label %9
9: ; preds = %5, %0
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i8* @strdup(i32 %11)
ret i8* %12
}