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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ herror(char *);
int /*<<< orphan*/ memcpy(struct in_addr *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ print_quad(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct hostent *hent;
  int j;
  struct in_addr addrh;
  char **tmp;
  if (argc < 2) {
    printf("\nUSAGE: %s address, try again!\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  printf("\nGetting information on: %s\n", argv[1]);
  if (!(hent = gethostbyname(argv[1]))) {
    herror("Failed to get the host name");
    exit(EXIT_FAILURE);
  }
  printf("\nh_name         = %s\n", hent->h_name);
  printf("h_addrtype     = %d\n", hent->h_addrtype);
  printf("h_length       = %d\n\n", hent->h_length);
  if (*hent->h_aliases)
    for (j = 0, tmp = hent->h_aliases; *tmp != NULL; j++, tmp++)
      printf("h_aliases[%d]   = %s\n", j, *tmp);
  else
    printf("h_aliases[%d]   = %s\n", 0, "No aliases found!");
  printf("\n");
  for (j = 0; hent->h_addr_list[j] != NULL; j++) {
    memcpy(&addrh, hent->h_addr_list[j], hent->h_length);
    printf("h_addr_list[%d] = ", j);
    print_quad(addrh.s_addr);
  }
  printf("\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a3 <main+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ee <main+0x8e>
lea    0xe62(%rip),%rdi
call   1060 <herror@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
cmpq   $0x0,(%rax)
je     1297 <main+0x137>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     1292 <main+0x132>
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    1252 <main+0xf2>
jmp    12ae <main+0x14e>
lea    0xdfc(%rip),%rdi
xor    %esi,%esi
lea    0xe09(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1321 <main+0x1c1>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edx
lea    -0x20(%rbp),%rdi
call   1050 <memcpy@plt>
mov    -0x1c(%rbp),%esi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%edi
call   1080 <print_quad@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12c3 <main+0x163>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1193 <main+0x23>
mov    (%rbx),%rsi
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bf <main+0x4f>
mov    0x8(%rbx),%rsi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
call   1050 <gethostbyname@plt>
test   %rax,%rax
jne    11cd <main+0x5d>
lea    0xe83(%rip),%rdi
call   1070 <herror@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %rax,%r12
mov    (%rax),%rsi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r12),%esi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%r12),%esi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%r12),%r15
mov    (%r15),%rdx
test   %rdx,%rdx
jne    122d <main+0xbd>
lea    0xe7f(%rip),%rdi
lea    0xe8e(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125a <main+0xea>
lea    0xe66(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r15,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    1240 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x18(%r12),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     12b4 <main+0x144>
mov    %rsp,%r14
lea    0xe47(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    0xc(%r12),%edx
mov    %r14,%rdi
call   1060 <memcpy@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%edi
call   1090 <print_quad@plt>
mov    0x18(%r12),%rax
mov    0x8(%rax,%rbx,8),%rsi
add    $0x1,%rbx
test   %rsi,%rsi
jne    1280 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i8*, i32, i32, i8**, i32** }
%struct.in_addr = type { i32 }
@.str = [32 x i8] c"\0AUSAGE: %s address, try again!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"\0AGetting information on: %s\0A\00"
@.str.2 = [28 x i8] c"Failed to get the host name\00"
@.str.3 = [22 x i8] c"\0Ah_name = %s\0A\00"
@.str.4 = [21 x i8] c"h_addrtype = %d\0A\00"
@.str.5 = [22 x i8] c"h_length = %d\0A\0A\00"
@.str.6 = [22 x i8] c"h_aliases[%d] = %s\0A\00"
@.str.7 = [18 x i8] c"No aliases found!\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [19 x i8] c"h_addr_list[%d] = \00"
@EXIT_SUCCESS = 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 i32
%8 = alloca %struct.in_addr
%9 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call %struct.hostent* @gethostbyname(i8* %26)
store %struct.hostent* %27, %struct.hostent** %6
%28 = icmp ne %struct.hostent* %27, null
br i1 %28, label %33, label %29
29: ; preds = %19
%30 = call i32 @herror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %19
%34 = load %struct.hostent*, %struct.hostent** %6
%35 = getelementptr inbounds %struct.hostent, %struct.hostent* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = load %struct.hostent*, %struct.hostent** %6
%39 = getelementptr inbounds %struct.hostent, %struct.hostent* %38, i32 0, i32 1
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = load %struct.hostent*, %struct.hostent** %6
%43 = getelementptr inbounds %struct.hostent, %struct.hostent* %42, i32 0, i32 2
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = load %struct.hostent*, %struct.hostent** %6
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %46, i32 0, i32 3
%48 = load i8**, i8*** %47
%49 = load i8*, i8** %48
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %70
51: ; preds = %33
store i32 0, i32* %7
%52 = load %struct.hostent*, %struct.hostent** %6
%53 = getelementptr inbounds %struct.hostent, %struct.hostent* %52, i32 0, i32 3
%54 = load i8**, i8*** %53
store i8** %54, i8*** %9
br label %55
55: ; preds = %64, %51
%56 = load i8**, i8*** %9
%57 = load i8*, i8** %56
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %69
59: ; preds = %55
%60 = load i32, i32* %7
%61 = load i8**, i8*** %9
%62 = load i8*, i8** %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %60, i8* %62)
br label %64
64: ; preds = %59
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
%67 = load i8**, i8*** %9
%68 = getelementptr inbounds i8*, i8** %67, i32 1
store i8** %68, i8*** %9
br label %55
69: ; preds = %55
br label %72
70: ; preds = %33
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %72
72: ; preds = %70, %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %7
br label %74
74: ; preds = %100, %72
%75 = load %struct.hostent*, %struct.hostent** %6
%76 = getelementptr inbounds %struct.hostent, %struct.hostent* %75, i32 0, i32 4
%77 = load i32**, i32*** %76
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32*, i32** %77, i64 %79
%81 = load i32*, i32** %80
%82 = icmp ne i32* %81, null
br i1 %82, label %83, label %103
83: ; preds = %74
%84 = load %struct.hostent*, %struct.hostent** %6
%85 = getelementptr inbounds %struct.hostent, %struct.hostent* %84, i32 0, i32 4
%86 = load i32**, i32*** %85
%87 = load i32, i32* %7
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32*, i32** %86, i64 %88
%90 = load i32*, i32** %89
%91 = load %struct.hostent*, %struct.hostent** %6
%92 = getelementptr inbounds %struct.hostent, %struct.hostent* %91, i32 0, i32 2
%93 = load i32, i32* %92
%94 = call i32 @memcpy(%struct.in_addr* %8, i32* %90, i32 %93)
%95 = load i32, i32* %7
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %95)
%97 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%98 = load i32, i32* %97
%99 = call i32 @print_quad(i32 %98)
br label %100
100: ; preds = %83
%101 = load i32, i32* %7
%102 = add nsw i32 %101, 1
store i32 %102, i32* %7
br label %74
103: ; preds = %74
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%105 = load i32, i32* @EXIT_SUCCESS
%106 = call i32 @exit(i32 %105)
unreachable
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
%struct.hostent = type { i8*, i32, i32, i8**, i32** }
@.str = [32 x i8] c"\0AUSAGE: %s address, try again!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"\0AGetting information on: %s\0A\00"
@.str.2 = [28 x i8] c"Failed to get the host name\00"
@.str.3 = [22 x i8] c"\0Ah_name = %s\0A\00"
@.str.4 = [21 x i8] c"h_addrtype = %d\0A\00"
@.str.5 = [22 x i8] c"h_length = %d\0A\0A\00"
@.str.6 = [22 x i8] c"h_aliases[%d] = %s\0A\00"
@.str.7 = [18 x i8] c"No aliases found!\00"
@.str.9 = [19 x i8] c"h_addr_list[%d] = \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = bitcast %struct.in_addr* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %12
%16 = tail call %struct.hostent* @gethostbyname(i8* %15)
%17 = icmp eq %struct.hostent* %16, null
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = tail call i32 @herror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %11
%23 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 0
%24 = load i8*, i8** %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 1
%27 = load i32, i32* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 2
%30 = load i32, i32* %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 3
%33 = load i8**, i8*** %32
%34 = load i8*, i8** %33
%35 = icmp eq i8* %34, null
br i1 %35, label %45, label %36
36: ; preds = %22, %36
%37 = phi i8** [ %42, %36 ], [ %33, %22 ]
%38 = phi i32 [ %41, %36 ], [ 0, %22 ]
%39 = phi i8* [ %43, %36 ], [ %34, %22 ]
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %38, i8* %39)
%41 = add nuw nsw i32 %38, 1
%42 = getelementptr inbounds i8*, i8** %37, i64 1
%43 = load i8*, i8** %42
%44 = icmp eq i8* %43, null
br i1 %44, label %47, label %36
45: ; preds = %22
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %47
47: ; preds = %36, %45
%48 = tail call i32 @putchar(i32 10)
%49 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 4
%50 = load i32**, i32*** %49
%51 = load i32*, i32** %50
%52 = icmp eq i32* %51, null
br i1 %52, label %69, label %53
53: ; preds = %47
%54 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
br label %55
55: ; preds = %53, %55
%56 = phi i64 [ 0, %53 ], [ %64, %55 ]
%57 = phi i32* [ %51, %53 ], [ %67, %55 ]
%58 = load i32, i32* %29
%59 = call i32 @memcpy(%struct.in_addr* %3, i32* %57, i32 %58)
%60 = trunc i64 %56 to i32
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %54
%63 = call i32 @print_quad(i32 %62)
%64 = add nuw i64 %56, 1
%65 = load i32**, i32*** %49
%66 = getelementptr inbounds i32*, i32** %65, i64 %64
%67 = load i32*, i32** %66
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %55
69: ; preds = %55, %47
%70 = call i32 @putchar(i32 10)
%71 = load i32, i32* @EXIT_SUCCESS
%72 = call i32 @exit(i32 %71)
unreachable
}