#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 dummy;
};
struct hostent {
  int /*<<< orphan*/ **h_addr_list;
};

/* Variables and functions */
struct hostent *gethostbyname(char *);
char *inet_ntoa(struct in_addr);
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_addr_list[i]; i++) {
    struct in_addr *a = (struct in_addr *)h->h_addr_list[i];
    printf("%s\n", inet_ntoa(*a));
  }
  return 0;
}


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)
je     115c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1185 <main+0x55>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <main+0xb5>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq -0x1c(%rbp),%rdx
xor    %eax,%eax
cmp    (%rcx,%rdx,8),%rax
je     11de <main+0xae>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118c <main+0x5c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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    1192 <main+0x62>
mov    0x8(%rsi),%rdi
call   1050 <gethostbyname@plt>
test   %rax,%rax
je     1192 <main+0x62>
mov    %rax,%rbx
mov    (%rax),%rax
mov    (%rax),%rax
xor    %r14d,%r14d
test   %rax,%rax
je     1192 <main+0x62>
mov    $0x8,%ebp
lea    0xe93(%rip),%r15
nopl   (%rax)
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    (%rbx),%rax
mov    (%rax,%rbp,1),%rax
add    $0x8,%rbp
test   %rax,%rax
jne    1170 <main+0x40>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i32** }
%struct.in_addr = type { i32 }
@.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
%8 = alloca %struct.in_addr*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %48
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.hostent* @gethostbyname(i8* %15)
store %struct.hostent* %16, %struct.hostent** %6
%17 = load %struct.hostent*, %struct.hostent** %6
%18 = icmp eq %struct.hostent* null, %17
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 -1, i32* %3
br label %48
20: ; preds = %12
store i32 0, i32* %7
br label %21
21: ; preds = %44, %20
%22 = load %struct.hostent*, %struct.hostent** %6
%23 = getelementptr inbounds %struct.hostent, %struct.hostent* %22, i32 0, i32 0
%24 = load i32**, i32*** %23
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32*, i32** %24, i64 %26
%28 = load i32*, i32** %27
%29 = icmp ne i32* null, %28
br i1 %29, label %30, label %47
30: ; preds = %21
%31 = load %struct.hostent*, %struct.hostent** %6
%32 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i32 0, i32 0
%33 = load i32**, i32*** %32
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32*, i32** %33, i64 %35
%37 = load i32*, i32** %36
%38 = bitcast i32* %37 to %struct.in_addr*
store %struct.in_addr* %38, %struct.in_addr** %8
%39 = load %struct.in_addr*, %struct.in_addr** %8
%40 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call i8* @inet_ntoa(i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %30
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %21
47: ; preds = %21
store i32 0, i32* %3
br label %48
48: ; preds = %47, %19, %11
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
%struct.hostent = type { i32** }
@.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 %25
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 %25, label %9
9: ; preds = %4
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %7, i64 0, i32 0
%11 = load i32**, i32*** %10
%12 = load i32*, i32** %11
%13 = icmp eq i32* %12, null
br i1 %13, label %25, label %14
14: ; preds = %9, %14
%15 = phi i64 [ %20, %14 ], [ 0, %9 ]
%16 = phi i32* [ %23, %14 ], [ %12, %9 ]
%17 = load i32, i32* %16
%18 = tail call i8* @inet_ntoa(i32 %17)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = add nuw i64 %15, 1
%21 = load i32**, i32*** %10
%22 = getelementptr inbounds i32*, i32** %21, i64 %20
%23 = load i32*, i32** %22
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %14
25: ; preds = %14, %9, %4, %2
%26 = phi i32 [ -1, %2 ], [ -1, %4 ], [ 0, %9 ], [ 0, %14 ]
ret i32 %26
}