#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 AF_INET;
int AF_INET6;
int AF_UNSPEC;
scalar_t__ _host(int, char *);
int _host_usage();
int getopt(int, char **, char *);
int optind;
int main(int argc, char *argv[]) {
  int o;
  int family = AF_UNSPEC;
  while ((o = getopt(argc, argv, "46")) != -1)
    switch (o) {
    case '4':
      family = AF_INET;
      break;
    case '6':
      family = AF_INET6;
      break;
    default:
      return _host_usage();
    }
  if (optind != argc - 1)
    return _host_usage();
  return (_host(family, argv[optind]) == 0) ? 0 : 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea0(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11cc <main+0x9c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x34,%eax
je     1196 <main+0x66>
jmp    1185 <main+0x55>
mov    -0x1c(%rbp),%eax
sub    $0x36,%eax
je     11a7 <main+0x77>
jmp    11b8 <main+0x88>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <main+0x97>
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <main+0x97>
mov    $0x0,%al
call   1030 <_host_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1220 <main+0xf0>
jmp    1152 <main+0x22>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11f2 <main+0xc2>
mov    $0x0,%al
call   1030 <_host_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1220 <main+0xf0>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x2dd8(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <_host@plt>
mov    %rax,%rdx
mov    $0x2,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e99(%rip),%rcx
lea    0xeb2(%rip),%r15
mov    0x2e93(%rip),%r12
mov    0x2e74(%rip),%r13
nopl   0x0(%rax)
mov    (%rcx),%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <getopt@plt>
mov    %r12,%rcx
cmp    $0x34,%eax
je     1160 <main+0x30>
cmp    $0x36,%eax
jne    1181 <main+0x51>
mov    %r13,%rcx
jmp    1160 <main+0x30>
cmp    $0xffffffff,%eax
jne    11bd <main+0x8d>
mov    0x2e4b(%rip),%rax
movslq (%rax),%rax
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jne    11bd <main+0x8d>
mov    (%r14,%rax,8),%rsi
mov    %ebx,%edi
call   1050 <_host@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_host_usage@plt>

LLVM IR (-O0):
@AF_UNSPEC = global i32 0
@.str = [3 x i8] c"46\00"
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@optind = 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* @AF_UNSPEC
store i32 %8, i32* %7
br label %9
9: ; preds = %22, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %20 [
i32 52, label %16
i32 54, label %18
]
16: ; preds = %14
%17 = load i32, i32* @AF_INET
store i32 %17, i32* %7
br label %22
18: ; preds = %14
%19 = load i32, i32* @AF_INET6
store i32 %19, i32* %7
br label %22
20: ; preds = %14
%21 = call i32 (...) @_host_usage()
store i32 %21, i32* %3
br label %41
22: ; preds = %18, %16
br label %9
23: ; preds = %9
%24 = load i32, i32* @optind
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (...) @_host_usage()
store i32 %29, i32* %3
br label %41
30: ; preds = %23
%31 = load i32, i32* %7
%32 = load i8**, i8*** %5
%33 = load i32, i32* @optind
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i64 @_host(i32 %31, i8* %36)
%38 = icmp eq i64 %37, 0
%39 = zext i1 %38 to i64
%40 = select i1 %38, i32 0, i32 2
store i32 %40, i32* %3
br label %41
41: ; preds = %30, %28, %20
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@AF_UNSPEC = global i32 0
@.str = [3 x i8] c"46\00"
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i32* [ @AF_UNSPEC, %2 ], [ %8, %7 ]
%5 = load i32, i32* %4
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %10 [
i32 -1, label %12
i32 52, label %7
i32 54, label %9
]
7: ; preds = %3, %9
%8 = phi i32* [ @AF_INET6, %9 ], [ @AF_INET, %3 ]
br label %3
9: ; preds = %3
br label %7
10: ; preds = %3
%11 = tail call i32 (...) @_host_usage()
br label %25
12: ; preds = %3
%13 = load i32, i32* @optind
%14 = add nsw i32 %0, -1
%15 = icmp eq i32 %13, %14
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = tail call i32 (...) @_host_usage()
br label %25
18: ; preds = %12
%19 = sext i32 %13 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i64 @_host(i32 %5, i8* %21)
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i32 0, i32 2
br label %25
25: ; preds = %18, %16, %10
%26 = phi i32 [ %11, %10 ], [ %17, %16 ], [ %24, %18 ]
ret i32 %26
}