#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void set_hostname_info(char *arg, char **vec) {
  if ((*vec = malloc(strlen(arg))) == NULL) {
    fprintf(stderr, "Err. malloc(), %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  strcpy(*vec, arg);
}


x86 assembly (clang, -O0):
<set_hostname_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11cb <set_hostname_info+0x6b>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe48(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_hostname_info>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1190 <set_hostname_info+0x30>
mov    %rax,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%ebx
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe52(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Err. malloc(), %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @set_hostname_info(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
store i8* %0, i8** %3
store i8** %1, i8*** %4
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = call i8* @malloc(i32 %6)
%8 = load i8**, i8*** %4
store i8* %7, i8** %8
%9 = icmp eq i8* %7, null
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %4
%19 = load i8*, i8** %18
%20 = load i8*, i8** %3
%21 = call i32 @strcpy(i8* %19, i8* %20)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Err. malloc(), %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @set_hostname_info(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i8* @malloc(i32 %3)
store i8* %4, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = tail call i32 @strcpy(i8* %4, i8* %0)
ret void
}