#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 h_length;
  char *h_name;
  int h_addrtype;
  int /*<<< orphan*/ *h_addr_list;
  int /*<<< orphan*/ h_aliases;
};

/* Variables and functions */
int /*<<< orphan*/ pc_stringfromipv4(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int, char *,
                          int /*<<< orphan*/ *, int, char *);
void printhostent(struct hostent *hp) {
  char ipbuf[16];
  pc_stringfromipv4(hp->h_addr_list[0], ipbuf);
  printf("alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\n",
         hp->h_aliases, hp->h_length, hp->h_name, hp->h_addr_list,
         hp->h_addrtype, ipbuf);
}


x86 assembly (clang, -O0):
<printhostent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <pc_stringfromipv4@plt>
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%r8
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r9d
lea    -0x20(%rbp),%rax
lea    0xe91(%rip),%rdi
mov    %rax,(%rsp)
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhostent>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
mov    0x18(%rdi),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1030 <pc_stringfromipv4@plt>
mov    0x20(%rbx),%esi
mov    (%rbx),%edx
mov    0x8(%rbx),%rcx
mov    0x18(%rbx),%r8
mov    0x10(%rbx),%r9d
mov    %r14,(%rsp)
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.hostent = type { i32, i8*, i32, i32*, i32 }
@.str = [66 x i8] c"alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\0A\00"
define void @printhostent(%struct.hostent* %0) {
%2 = alloca %struct.hostent*
%3 = alloca [16 x i8]
store %struct.hostent* %0, %struct.hostent** %2
%4 = load %struct.hostent*, %struct.hostent** %2
%5 = getelementptr inbounds %struct.hostent, %struct.hostent* %4, i32 0, i32 3
%6 = load i32*, i32** %5
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%10 = call i32 @pc_stringfromipv4(i32 %8, i8* %9)
%11 = load %struct.hostent*, %struct.hostent** %2
%12 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i32 0, i32 4
%13 = load i32, i32* %12
%14 = load %struct.hostent*, %struct.hostent** %2
%15 = getelementptr inbounds %struct.hostent, %struct.hostent* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load %struct.hostent*, %struct.hostent** %2
%18 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i32 0, i32 1
%19 = load i8*, i8** %18
%20 = load %struct.hostent*, %struct.hostent** %2
%21 = getelementptr inbounds %struct.hostent, %struct.hostent* %20, i32 0, i32 3
%22 = load i32*, i32** %21
%23 = load %struct.hostent*, %struct.hostent** %2
%24 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i32 0, i32 2
%25 = load i32, i32* %24
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16, i8* %19, i32* %22, i32 %25, i8* %26)
ret void
}

LLVM IR (-O2):
%struct.hostent = type { i32, i8*, i32, i32*, i32 }
@.str = [66 x i8] c"alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\0A\00"
define void @printhostent(%struct.hostent* nocapture %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 3
%5 = load i32*, i32** %4
%6 = load i32, i32* %5
%7 = call i32 @pc_stringfromipv4(i32 %6, i8* %3)
%8 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 4
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 1
%13 = load i8*, i8** %12
%14 = load i32*, i32** %4
%15 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 2
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i8* %13, i32* %14, i32 %16, i8* %3)
ret void
}