#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 c, char **v) {
  if (c != 2) {
    return -1;
  }
  struct hostent *h;
  h = gethostbyname(v[1]);
  if (NULL == h) {
    return -1;
  }
  int i;
  for (i = 0; NULL != h->h_aliases[i]; i++) {
    printf("%s\n", h->h_aliases[i]);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
je     114c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1175 <main+0x55>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <main+0xa3>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq -0x1c(%rbp),%rdx
xor    %eax,%eax
cmp    (%rcx,%rdx,8),%rax
je     11bc <main+0x9c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <main+0x5c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
cmp    $0x2,%edi
jne    1178 <main+0x58>
mov    0x8(%rsi),%rdi
call   1040 <gethostbyname@plt>
test   %rax,%rax
je     1178 <main+0x58>
mov    %rax,%rbx
mov    (%rax),%rax
mov    (%rax),%rsi
xor    %r14d,%r14d
test   %rsi,%rsi
je     1178 <main+0x58>
mov    $0x8,%ebp
lea    0xea3(%rip),%r15
nopl   (%rax)
mov    %r15,%rdi
call   1030 <printf@plt>
mov    (%rbx),%rax
mov    (%rax,%rbp,1),%rsi
add    $0x8,%rbp
test   %rsi,%rsi
jne    1160 <main+0x40>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %42
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call %struct.hostent* @gethostbyname(i8* %14)
store %struct.hostent* %15, %struct.hostent** %6
%16 = load %struct.hostent*, %struct.hostent** %6
%17 = icmp eq %struct.hostent* null, %16
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 -1, i32* %3
br label %42
19: ; preds = %11
store i32 0, i32* %7
br label %20
20: ; preds = %38, %19
%21 = load %struct.hostent*, %struct.hostent** %6
%22 = getelementptr inbounds %struct.hostent, %struct.hostent* %21, i32 0, i32 0
%23 = load i8**, i8*** %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = icmp ne i8* null, %27
br i1 %28, label %29, label %41
29: ; preds = %20
%30 = load %struct.hostent*, %struct.hostent** %6
%31 = getelementptr inbounds %struct.hostent, %struct.hostent* %30, i32 0, i32 0
%32 = load i8**, i8*** %31
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %29
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %20
41: ; preds = %20
store i32 0, i32* %3
br label %42
42: ; preds = %41, %18, %10
%43 = load i32, i32* %3
ret i32 %43
}

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