#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_name;
  char **h_aliases;
  int h_length;
  char **h_addr_list;
};

/* Variables and functions */
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ printf(char *, char *);
void main() {
  struct hostent *a;
  a = gethostbyname("www.wikipedia.org");
  printf("%s \n", a->h_name);
  int i = 0;
  while (a->h_aliases[i] != NULL) {
    printf("%s \n", a->h_aliases[i]);
    i++;
  }
  for (i = 0; i < a->h_length; i++)
    printf("%s \n", a->h_addr_list[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1193 <main+0x73>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    0x10(%rcx),%eax
jge    11d4 <main+0xb4>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119a <main+0x7a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xed4(%rip),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,%r15
mov    (%rax),%rsi
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%r15),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1179 <main+0x59>
mov    $0x8,%ebx
lea    0xeb7(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%r15),%rax
mov    (%rax,%rbx,1),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1160 <main+0x40>
cmpl   $0x0,0x10(%r15)
jle    11ad <main+0x8d>
xor    %ebx,%ebx
lea    0xe89(%rip),%r14
nopl   0x0(%rax)
mov    0x18(%r15),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x10(%r15),%rax
cmp    %rax,%rbx
jl     1190 <main+0x70>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.hostent = type { i8*, i8**, i32, i8** }
@.str = [18 x i8] c"www.wikipedia.org\00"
@.str.1 = [5 x i8] c"%s \0A\00"
define void @main() {
%1 = alloca %struct.hostent*
%2 = alloca i32
%3 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store %struct.hostent* %3, %struct.hostent** %1
%4 = load %struct.hostent*, %struct.hostent** %1
%5 = getelementptr inbounds %struct.hostent, %struct.hostent* %4, i32 0, i32 0
%6 = load i8*, i8** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
store i32 0, i32* %2
br label %8
8: ; preds = %17, %0
%9 = load %struct.hostent*, %struct.hostent** %1
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %9, i32 0, i32 1
%11 = load i8**, i8*** %10
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %28
17: ; preds = %8
%18 = load %struct.hostent*, %struct.hostent** %1
%19 = getelementptr inbounds %struct.hostent, %struct.hostent* %18, i32 0, i32 1
%20 = load i8**, i8*** %19
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %8
28: ; preds = %8
store i32 0, i32* %2
br label %29
29: ; preds = %44, %28
%30 = load i32, i32* %2
%31 = load %struct.hostent*, %struct.hostent** %1
%32 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i32 0, i32 2
%33 = load i32, i32* %32
%34 = icmp slt i32 %30, %33
br i1 %34, label %35, label %47
35: ; preds = %29
%36 = load %struct.hostent*, %struct.hostent** %1
%37 = getelementptr inbounds %struct.hostent, %struct.hostent* %36, i32 0, i32 3
%38 = load i8**, i8*** %37
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %35
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %29
47: ; preds = %29
ret void
}

LLVM IR (-O2):
%struct.hostent = type { i8*, i8**, i32, i8** }
@.str = [18 x i8] c"www.wikipedia.org\00"
@.str.1 = [5 x i8] c"%s \0A\00"
define void @main() {
%1 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 1
%6 = load i8**, i8*** %5
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %15, %0
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 2
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 3
br label %24
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = phi i8* [ %22, %15 ], [ %7, %0 ]
%18 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = add nuw i64 %16, 1
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 %19
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %9, label %15
24: ; preds = %13, %24
%25 = phi i64 [ 0, %13 ], [ %30, %24 ]
%26 = load i8**, i8*** %14
%27 = getelementptr inbounds i8*, i8** %26, i64 %25
%28 = load i8*, i8** %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = add nuw nsw i64 %25, 1
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %24, label %34
34: ; preds = %24, %9
ret void
}