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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ h_errno;
char *hstrerror(int /*<<< orphan*/);
char *inet_ntop(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct hostent *ent;
  char **paliase;
  char **addrlist;
  char *pname;
  char buf[48];
  while (--argc > 0) {
    pname = *++argv;
    if ((ent = gethostbyname(pname)) == NULL) {
      fprintf(stderr, "error occur:%s\n", hstrerror(h_errno));
      continue;
    }
    fprintf(stderr, "the official name:\n");
    fprintf(stderr, "	%s\n", ent->h_name);
    fprintf(stderr, "alias:\n");
    paliase = ent->h_aliases;
    while (*paliase != NULL) {
      fprintf(stderr, "	%s\n", *paliase);
      paliase++;
    }
    fprintf(stderr, "addresses:\n");
    addrlist = ent->h_addr_list;
    while (*addrlist != NULL) {
      fprintf(stderr, "	%s\n", inet_ntop(AF_INET, *addrlist, buf, 48));
      addrlist++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    12e3 <main+0x1a3>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11c9 <main+0x89>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1060 <hstrerror@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1156 <main+0x16>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     125e <main+0x11e>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1221 <main+0xe1>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     12de <main+0x19e>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x30,%ecx
call   1030 <inet_ntop@plt>
mov    -0x68(%rbp),%edi
mov    %rax,%rdx
lea    0xd5e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    1281 <main+0x141>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jl     12a6 <main+0x166>
mov    %edi,%ebx
mov    0x2e70(%rip),%r14
lea    0xebd(%rip),%r12
lea    0x10(%rsp),%rdx
jmp    11b0 <main+0x70>
xchg   %ax,%ax
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1060 <hstrerror@plt>
mov    %r15d,%edi
lea    0xe78(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r13,%rdx
mov    0x8(%rsp),%rcx
lea    -0x1(%rcx),%eax
mov    (%rsp),%rsi
add    $0x8,%rsi
cmp    $0x2,%ecx
mov    %eax,%ebx
jle    12a6 <main+0x166>
mov    %rdx,%r13
mov    %rsi,(%rsp)
mov    0x8(%rsi),%rdi
call   1040 <gethostbyname@plt>
mov    (%r14),%r15d
test   %rax,%rax
mov    %rbx,0x8(%rsp)
je     1170 <main+0x30>
mov    %rax,%rbp
mov    %r15d,%edi
lea    0xe36(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
mov    0x0(%rbp),%rdx
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xe2d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%rbp),%rbx
mov    (%rbx),%rdx
test   %rdx,%rdx
je     1239 <main+0xf9>
add    $0x8,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%rdx
add    $0x8,%rbx
test   %rdx,%rdx
jne    1220 <main+0xe0>
mov    (%r14),%edi
lea    0xdee(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x10(%rbp),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
mov    0x2d8d(%rip),%r15
mov    %r13,%rdx
je     1195 <main+0x55>
add    $0x8,%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r14),%ebp
mov    (%r15),%edi
mov    %r13,%rdx
mov    $0x30,%ecx
call   1030 <inet_ntop@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r13,%rdx
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1270 <main+0x130>
jmp    1195 <main+0x55>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i8*, i8**, i8** }
@stderr = global i32 0
@.str = [16 x i8] c"error occur:%s\0A\00"
@h_errno = global i32 0
@.str.1 = [20 x i8] c"the official name:\0A\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
@.str.3 = [8 x i8] c"alias:\0A\00"
@.str.4 = [12 x i8] c"addresses:\0A\00"
@AF_INET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.hostent*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca [48 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %11
11: ; preds = %71, %22, %2
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %72
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i32 1
store i8** %17, i8*** %5
%18 = load i8*, i8** %17
store i8* %18, i8** %9
%19 = load i8*, i8** %9
%20 = call %struct.hostent* @gethostbyname(i8* %19)
store %struct.hostent* %20, %struct.hostent** %6
%21 = icmp eq %struct.hostent* %20, null
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = load i32, i32* @h_errno
%25 = call i8* @hstrerror(i32 %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %11
27: ; preds = %15
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = load %struct.hostent*, %struct.hostent** %6
%32 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i32 0, i32 0
%33 = load i8*, i8** %32
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%37 = load %struct.hostent*, %struct.hostent** %6
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %37, i32 0, i32 1
%39 = load i8**, i8*** %38
store i8** %39, i8*** %7
br label %40
40: ; preds = %44, %27
%41 = load i8**, i8*** %7
%42 = load i8*, i8** %41
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %7
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = load i8**, i8*** %7
%50 = getelementptr inbounds i8*, i8** %49, i32 1
store i8** %50, i8*** %7
br label %40
51: ; preds = %40
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%54 = load %struct.hostent*, %struct.hostent** %6
%55 = getelementptr inbounds %struct.hostent, %struct.hostent* %54, i32 0, i32 2
%56 = load i8**, i8*** %55
store i8** %56, i8*** %8
br label %57
57: ; preds = %61, %51
%58 = load i8**, i8*** %8
%59 = load i8*, i8** %58
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = load i32, i32* @AF_INET
%64 = load i8**, i8*** %8
%65 = load i8*, i8** %64
%66 = getelementptr inbounds [48 x i8], [48 x i8]* %10, i64 0, i64 0
%67 = call i8* @inet_ntop(i32 %63, i8* %65, i8* %66, i32 48)
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %67)
%69 = load i8**, i8*** %8
%70 = getelementptr inbounds i8*, i8** %69, i32 1
store i8** %70, i8*** %8
br label %57
71: ; preds = %57
br label %11
72: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
%struct.hostent = type { i8*, i8**, i8** }
@stderr = global i32 0
@.str = [16 x i8] c"error occur:%s\0A\00"
@h_errno = global i32 0
@.str.1 = [20 x i8] c"the official name:\0A\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
@.str.3 = [8 x i8] c"alias:\0A\00"
@.str.4 = [12 x i8] c"addresses:\0A\00"
@AF_INET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [48 x i8]
%4 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %58
6: ; preds = %2, %19
%7 = phi i32 [ %9, %19 ], [ %0, %2 ]
%8 = phi i8** [ %10, %19 ], [ %1, %2 ]
%9 = add nsw i32 %7, -1
%10 = getelementptr inbounds i8*, i8** %8, i64 1
%11 = load i8*, i8** %10
%12 = call %struct.hostent* @gethostbyname(i8* %11)
%13 = icmp eq %struct.hostent* %12, null
%14 = load i32, i32* @stderr
br i1 %13, label %15, label %21
15: ; preds = %6
%16 = load i32, i32* @h_errno
%17 = call i8* @hstrerror(i32 %16)
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %48, %41, %15
%20 = icmp sgt i32 %7, 2
br i1 %20, label %6, label %58
21: ; preds = %6
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = getelementptr inbounds %struct.hostent, %struct.hostent* %12, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%29 = getelementptr inbounds %struct.hostent, %struct.hostent* %12, i64 0, i32 1
%30 = load i8**, i8*** %29
%31 = load i8*, i8** %30
%32 = icmp eq i8* %31, null
br i1 %32, label %41, label %33
33: ; preds = %21, %33
%34 = phi i8* [ %39, %33 ], [ %31, %21 ]
%35 = phi i8** [ %38, %33 ], [ %30, %21 ]
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%38 = getelementptr inbounds i8*, i8** %35, i64 1
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %33
41: ; preds = %33, %21
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%44 = getelementptr inbounds %struct.hostent, %struct.hostent* %12, i64 0, i32 2
%45 = load i8**, i8*** %44
%46 = load i8*, i8** %45
%47 = icmp eq i8* %46, null
br i1 %47, label %19, label %48
48: ; preds = %41, %48
%49 = phi i8* [ %56, %48 ], [ %46, %41 ]
%50 = phi i8** [ %55, %48 ], [ %45, %41 ]
%51 = load i32, i32* @stderr
%52 = load i32, i32* @AF_INET
%53 = call i8* @inet_ntop(i32 %52, i8* %49, i8* %4, i32 48)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds i8*, i8** %50, i64 1
%56 = load i8*, i8** %55
%57 = icmp eq i8* %56, null
br i1 %57, label %19, label %48
58: ; preds = %19, %2
ret i32 0
}