#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 */

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ print_ips(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Usage: gethostbyname <address or hostname>\n");
    exit(EXIT_FAILURE);
  }
  print_ips(argv[1], AF_INET);
  print_ips(argv[1], AF_INET6);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116a <main+0x3a>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
call   1040 <print_ips@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
call   1040 <print_ips@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1150 <main+0x20>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
call   1040 <print_ips@plt>
mov    0x8(%rbx),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
call   1040 <print_ips@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"Usage: gethostbyname <address or hostname>\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @AF_INET
%17 = call i32 @print_ips(i8* %15, i32 %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @AF_INET6
%22 = call i32 @print_ips(i8* %20, i32 %21)
%23 = load i32, i32* @EXIT_SUCCESS
%24 = call i32 @exit(i32 %23)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [43 x i8] c"Usage: gethostbyname <address or hostname>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @AF_INET
%12 = tail call i32 @print_ips(i8* %10, i32 %11)
%13 = load i8*, i8** %9
%14 = load i32, i32* @AF_INET6
%15 = tail call i32 @print_ips(i8* %13, i32 %14)
%16 = load i32, i32* @EXIT_SUCCESS
%17 = tail call i32 @exit(i32 %16)
unreachable
}