#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ h_errno;
char *hstrerror(int /*<<< orphan*/);
int resolve(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "%s\n", "No hostname specified!");
    return EXIT_FAILURE;
  }
  int res = 0;
  for (int i = 1; i < argc; i++) {
    res = resolve(argv[i]);
    if (res != 0) {
      fprintf(stderr, "Unable to resolve '%s', reason: %s\n", argv[i],
              hstrerror(h_errno));
      return EXIT_FAILURE;
    }
  }
  return 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    117f <main+0x4f>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xed7(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1229 <main+0xf9>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121d <main+0xed>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <resolve@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     120a <main+0xda>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1050 <hstrerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1229 <main+0xf9>
jmp    120f <main+0xdf>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <main+0x5d>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jge    1167 <main+0x37>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xeea(%rip),%rsi
lea    0xeac(%rip),%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e6e(%rip),%rax
jmp    1206 <main+0xd6>
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1030 <resolve@plt>
test   %eax,%eax
je     1183 <main+0x53>
mov    $0x1,%r14b
mov    $0x1,%ebp
jmp    11b1 <main+0x81>
mov    %ebp,%ebx
mov    $0x2,%ebp
nopw   0x0(%rax,%rax,1)
cmp    %rbp,%rbx
je     11f4 <main+0xc4>
mov    (%r12,%rbp,8),%rdi
call   1030 <resolve@plt>
add    $0x1,%rbp
test   %eax,%eax
je     1190 <main+0x60>
add    $0xffffffffffffffff,%rbp
cmp    %rbx,%rbp
setb   %r14b
mov    0x2e20(%rip),%rax
mov    (%rax),%r15d
mov    (%r12,%rbp,8),%rbx
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1050 <hstrerror@plt>
lea    0xe43(%rip),%rsi
mov    %r15d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
test   %r14b,%r14b
je     11ff <main+0xcf>
jmp    1208 <main+0xd8>
seta   %r14b
xor    %eax,%eax
test   %r14b,%r14b
jne    1208 <main+0xd8>
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [23 x i8] c"No hostname specified!\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [36 x i8] c"Unable to resolve '%s', reason: %s\0A\00"
@h_errno = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %45
14: ; preds = %2
store i32 0, i32* %6
store i32 1, i32* %7
br label %15
15: ; preds = %40, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %43
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @resolve(i8* %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %39
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = load i32, i32* @h_errno
%36 = call i8* @hstrerror(i32 %35)
%37 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
store i32 %38, i32* %3
br label %45
39: ; preds = %19
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %15
43: ; preds = %15
%44 = load i32, i32* @EXIT_SUCCESS
store i32 %44, i32* %3
br label %45
45: ; preds = %43, %28, %10
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [23 x i8] c"No hostname specified!\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [36 x i8] c"Unable to resolve '%s', reason: %s\0A\00"
@h_errno = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
%6 = zext i32 %0 to i64
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @resolve(i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %33, label %23
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
br label %44
15: ; preds = %33
%16 = getelementptr inbounds i8*, i8** %1, i64 %35
%17 = load i8*, i8** %16
%18 = tail call i32 @resolve(i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %15
%21 = icmp ult i64 %35, %5
%22 = and i64 %35, 4294967295
br label %23
23: ; preds = %20, %4
%24 = phi i64 [ %22, %20 ], [ 1, %4 ]
%25 = phi i1 [ %21, %20 ], [ true, %4 ]
%26 = getelementptr inbounds i8*, i8** %1, i64 %24
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %26
%29 = load i32, i32* @h_errno
%30 = tail call i8* @hstrerror(i32 %29)
%31 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
br label %39
33: ; preds = %4, %15
%34 = phi i64 [ %35, %15 ], [ 1, %4 ]
%35 = add nuw nsw i64 %34, 1
%36 = icmp eq i64 %35, %6
br i1 %36, label %37, label %15
37: ; preds = %33
%38 = icmp ult i64 %35, %5
br label %39
39: ; preds = %37, %23
%40 = phi i1 [ %25, %23 ], [ %38, %37 ]
%41 = phi i32 [ %32, %23 ], [ 0, %37 ]
%42 = load i32, i32* @EXIT_SUCCESS
%43 = select i1 %40, i32 %41, i32 %42
br label %44
44: ; preds = %39, %11
%45 = phi i32 [ %14, %11 ], [ %43, %39 ]
ret i32 %45
}