#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_LOOPBACK;
scalar_t__ bind_tohost(struct sockaddr_in *, char *, char *);
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ gethostaddr(char *, TYPE_1__ *);
int getopt(int, char **, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ usage();
int /*<<< orphan*/ yp_get_default_domain(char **);
int main(int argc, char *argv[]) {
  struct sockaddr_in sin;
  char *domainname;
  int c;
  yp_get_default_domain(&domainname);
  (void)memset(&sin, 0, sizeof sin);
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  while ((c = getopt(argc, argv, "h:d:")) != -1) {
    switch (c) {
    case 'd':
      domainname = optarg;
      break;
    case 'h':
      gethostaddr(optarg, &sin.sin_addr);
      break;
    default:
      usage();
    }
  }
  if (domainname == NULL)
    errx(1, "YP domain name not set");
  argc -= optind;
  argv += optind;
  if (argc != 1)
    usage();
  return bind_tohost(&sin, domainname, argv[0]) != 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)
lea    -0x20(%rbp),%rdi
call   1080 <yp_get_default_domain@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe26(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1247 <main+0xc7>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x64,%eax
je     1210 <main+0x90>
jmp    11ff <main+0x7f>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
je     1223 <main+0xa3>
jmp    123b <main+0xbb>
mov    0x2de1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1242 <main+0xc2>
mov    0x2dce(%rip),%rax
mov    (%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <gethostaddr@plt>
jmp    1242 <main+0xc2>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    11cc <main+0x4c>
cmpq   $0x0,-0x20(%rbp)
jne    1263 <main+0xe3>
mov    $0x1,%edi
lea    0xda7(%rip),%rsi
call   1050 <errx@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     129e <main+0x11e>
mov    $0x0,%al
call   1090 <usage@plt>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x18(%rbp),%rdi
call   1030 <bind_tohost@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsp,%rdi
call   1080 <yp_get_default_domain@plt>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,0x8(%rsp)
lea    0xe2d(%rip),%r15
mov    0x2e1e(%rip),%r12
jmp    11ec <main+0x6c>
nopl   0x0(%rax)
mov    (%r12),%rdi
mov    %r14,%rsi
call   1040 <gethostaddr@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10a0 <getopt@plt>
cmp    $0x64,%eax
je     1220 <main+0xa0>
cmp    $0x68,%eax
je     11e0 <main+0x60>
cmp    $0xffffffff,%eax
je     122a <main+0xaa>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    11ec <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%rax
mov    %rax,(%rsp)
jmp    11ec <main+0x6c>
cmpq   $0x0,(%rsp)
jne    1242 <main+0xc2>
lea    0xdcd(%rip),%rsi
mov    $0x1,%edi
call   1050 <errx@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%r14
sub    %r14d,%ebp
cmp    $0x1,%ebp
je     125b <main+0xdb>
xor    %eax,%eax
call   1090 <usage@plt>
mov    (%rsp),%rsi
mov    (%rbx,%r14,8),%rdx
lea    0x8(%rsp),%rdi
call   1030 <bind_tohost@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@INADDR_LOOPBACK = global i32 0
@.str = [5 x i8] c"h:d:\00"
@optarg = global i8* null
@.str.1 = [23 x i8] c"YP domain name not set\00"
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @yp_get_default_domain(i8** %7)
%10 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 8)
%11 = load i32, i32* @AF_INET
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i32 %11, i32* %12
%13 = load i32, i32* @INADDR_LOOPBACK
%14 = call i32 @htonl(i32 %13)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 0
store i32 %14, i32* %16
br label %17
17: ; preds = %32, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %8
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %33
22: ; preds = %17
%23 = load i32, i32* %8
switch i32 %23, label %30 [
i32 100, label %24
i32 104, label %26
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
store i8* %25, i8** %7
br label %32
26: ; preds = %22
%27 = load i8*, i8** @optarg
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%29 = call i32 @gethostaddr(i8* %27, %struct.TYPE_2__* %28)
br label %32
30: ; preds = %22
%31 = call i32 (...) @usage()
br label %32
32: ; preds = %30, %26, %24
br label %17
33: ; preds = %17
%34 = load i8*, i8** %7
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
%39 = load i64, i64* @optind
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = sub nsw i64 %41, %39
%43 = trunc i64 %42 to i32
store i32 %43, i32* %4
%44 = load i64, i64* @optind
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 %44
store i8** %46, i8*** %5
%47 = load i32, i32* %4
%48 = icmp ne i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %38
%50 = call i32 (...) @usage()
br label %51
51: ; preds = %49, %38
%52 = load i8*, i8** %7
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i64 @bind_tohost(%struct.sockaddr_in* %6, i8* %52, i8* %55)
%57 = icmp ne i64 %56, 0
%58 = zext i1 %57 to i32
ret i32 %58
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@INADDR_LOOPBACK = global i32 0
@.str = [5 x i8] c"h:d:\00"
@optarg = global i8* null
@.str.1 = [23 x i8] c"YP domain name not set\00"
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i8*
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = call i32 @yp_get_default_domain(i8** %4)
%8 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 8)
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %9, i32* %10
%11 = load i32, i32* @INADDR_LOOPBACK
%12 = call i32 @htonl(i32 %11)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %12, i32* %14
br label %15
15: ; preds = %24, %2
%16 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %16, label %22 [
i32 -1, label %25
i32 100, label %17
i32 104, label %19
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %4
br label %24
19: ; preds = %15
%20 = load i8*, i8** @optarg
%21 = call i32 @gethostaddr(i8* %20, %struct.TYPE_2__* %13)
br label %24
22: ; preds = %15
%23 = call i32 (...) @usage()
br label %24
24: ; preds = %22, %19, %17
br label %15
25: ; preds = %15
%26 = load i8*, i8** %4
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = load i64, i64* @optind
%32 = trunc i64 %31 to i32
%33 = sub i32 %0, %32
%34 = icmp eq i32 %33, 1
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = call i32 (...) @usage()
br label %37
37: ; preds = %35, %30
%38 = getelementptr inbounds i8*, i8** %1, i64 %31
%39 = load i8*, i8** %4
%40 = load i8*, i8** %38
%41 = call i64 @bind_tohost(%struct.sockaddr_in* %3, i8* %39, i8* %40)
%42 = icmp ne i64 %41, 0
%43 = zext i1 %42 to i32
ret i32 %43
}