#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 hostent {
  int /*<<< orphan*/ h_name;
  int /*<<< orphan*/ h_aliases;
  int /*<<< orphan*/ h_addr;
  int /*<<< orphan*/ h_addrtype;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ *inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                              int);
int /*<<< orphan*/ printfmtstrings(int /*<<< orphan*/, char *, char *, char *,
                                   char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlcpy(char *, char *, int);
void hostsprint(const struct hostent *he) {
  char buf[INET6_ADDRSTRLEN];
  if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL)
    (void)strlcpy(buf, "# unknown", sizeof(buf));
  printfmtstrings(he->h_aliases, "  ", " ", "%-16s  %s", buf, he->h_name);
}


x86 assembly (clang, -O0):
<hostsprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x28(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
mov    0xc(%rcx),%edi
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%esi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    11a1 <hostsprint+0x71>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xe64(%rip),%rsi
call   1050 <strlcpy@plt>
mov    -0x20(%rbp),%r8
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%r9d
lea    0xe50(%rip),%rsi
lea    0xe4a(%rip),%rdx
lea    0xe45(%rip),%rcx
call   1040 <printfmtstrings@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hostsprint>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2ea4(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x8(%rdi),%esi
mov    0xc(%rdi),%edi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
jne    1183 <hostsprint+0x53>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <strlcpy@plt>
mov    (%r14),%r9d
mov    0x4(%r14),%edi
lea    0xe79(%rip),%rsi
lea    0xe73(%rip),%rdx
lea    0xe6e(%rip),%rcx
mov    %rbx,%r8
call   1040 <printfmtstrings@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i32, i32, i32, i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [10 x i8] c"# unknown\00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [10 x i8] c"%-16s %s\00"
define void @hostsprint(%struct.hostent* %0) {
%2 = alloca %struct.hostent*
%3 = alloca i8*
%4 = alloca i64
store %struct.hostent* %0, %struct.hostent** %2
%5 = load i32, i32* @INET6_ADDRSTRLEN
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
%9 = load %struct.hostent*, %struct.hostent** %2
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %9, i32 0, i32 3
%11 = load i32, i32* %10
%12 = load %struct.hostent*, %struct.hostent** %2
%13 = getelementptr inbounds %struct.hostent, %struct.hostent* %12, i32 0, i32 2
%14 = load i32, i32* %13
%15 = trunc i64 %6 to i32
%16 = call i32* @inet_ntop(i32 %11, i32 %14, i8* %8, i32 %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = trunc i64 %6 to i32
%20 = call i32 @strlcpy(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %1
%22 = load %struct.hostent*, %struct.hostent** %2
%23 = getelementptr inbounds %struct.hostent, %struct.hostent* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = load %struct.hostent*, %struct.hostent** %2
%26 = getelementptr inbounds %struct.hostent, %struct.hostent* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @printfmtstrings(i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %27)
%29 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
%struct.hostent = type { i32, i32, i32, i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [10 x i8] c"# unknown\00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [10 x i8] c"%-16s %s\00"
define void @hostsprint(%struct.hostent* nocapture %0) {
%2 = load i32, i32* @INET6_ADDRSTRLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 3
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 2
%8 = load i32, i32* %7
%9 = call i32* @inet_ntop(i32 %6, i32 %8, i8* %4, i32 %2)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @strlcpy(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %13
13: ; preds = %11, %1
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @printfmtstrings(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %17)
ret void
}