#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 {
  char **h_aliases;
};

/* Variables and functions */
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  struct hostent *he = gethostbyname(argv[1]);
  char **p = he->h_aliases;
  for (; *p; p++) {
    printf("%s\n", *p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1184 <main+0x64>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <gethostbyname@plt>
mov    (%rax),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1164 <main+0x44>
add    $0x8,%rbx
lea    0xebd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.hostent = type { i8** }
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.hostent*
%7 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call %struct.hostent* @gethostbyname(i8* %10)
store %struct.hostent* %11, %struct.hostent** %6
%12 = load %struct.hostent*, %struct.hostent** %6
%13 = getelementptr inbounds %struct.hostent, %struct.hostent* %12, i32 0, i32 0
%14 = load i8**, i8*** %13
store i8** %14, i8*** %7
br label %15
15: ; preds = %23, %2
%16 = load i8**, i8*** %7
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i8**, i8*** %7
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19
%24 = load i8**, i8*** %7
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %7
br label %15
26: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
%struct.hostent = type { i8** }
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call %struct.hostent* @gethostbyname(i8* %4)
%6 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 0
%7 = load i8**, i8*** %6
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %17, label %10
10: ; preds = %2, %10
%11 = phi i8* [ %15, %10 ], [ %8, %2 ]
%12 = phi i8** [ %14, %10 ], [ %7, %2 ]
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
%14 = getelementptr inbounds i8*, i8** %12, i64 1
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %10
17: ; preds = %10, %2
ret i32 0
}