#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 */
char *ctime(void *);
int /*<<< orphan*/ errx(int, char *, ...);
int get_remote_info(char *, char *, char *, int *, char **, int);
int getopt(int, char **, char *);
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ yp_get_default_domain(char **);
int yp_master(char *, char *, char **);
int yp_order(char *, char *, int *);
int /*<<< orphan*/ yperr_string(int);
int main(int argc, char *argv[]) {
  char *domainname;
  char *hostname = NULL;
  char *inmap, *master;
  int order;
  int c, r, tcp = 0;
  (void)yp_get_default_domain(&domainname);
  while ((c = getopt(argc, argv, "Th:d:")) != -1) {
    switch (c) {
    case 'T':
      tcp = 1;
      break;
    case 'd':
      domainname = optarg;
      break;
    case 'h':
      hostname = optarg;
      break;
    default:
      usage();
    }
  }
  if (domainname == NULL)
    errx(1, "YP domain name not set");
  argc -= optind;
  argv += optind;
  if (argc != 1)
    usage();
  inmap = argv[0];
  if (hostname != NULL)
    r = get_remote_info(domainname, inmap, hostname, &order, &master, tcp);
  else {
    r = yp_order(domainname, inmap, &order);
    if (r == 0)
      r = yp_master(domainname, inmap, &master);
  }
  if (r != 0)
    errx(1, "no such map %s. Reason: %s", inmap, yperr_string(r));
  (void)printf("Map %s has order number %d. %s", inmap, order,
               ctime((void *)&order));
  (void)printf("The master server is %s.\n", master);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x40(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <yp_get_default_domain@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe24(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x38(%rbp)
cmp    $0xffffffff,%eax
je     1261 <main+0xc1>
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x54,%eax
je     1223 <main+0x83>
jmp    1201 <main+0x61>
mov    -0x44(%rbp),%eax
sub    $0x64,%eax
je     122f <main+0x8f>
jmp    1212 <main+0x72>
mov    -0x44(%rbp),%eax
sub    $0x68,%eax
je     1242 <main+0xa2>
jmp    1255 <main+0xb5>
movl   $0x1,-0x40(%rbp)
jmp    125c <main+0xbc>
mov    0x2dc2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    125c <main+0xbc>
mov    0x2daf(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    125c <main+0xbc>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    11ce <main+0x2e>
cmpq   $0x0,-0x18(%rbp)
jne    127f <main+0xdf>
mov    $0x1,%edi
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1050 <errx@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d46(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     12ba <main+0x11a>
mov    $0x0,%al
call   1090 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12f5 <main+0x155>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x40(%rbp),%r9d
lea    -0x34(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   10a0 <get_remote_info@plt>
mov    %eax,-0x3c(%rbp)
jmp    132c <main+0x18c>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10b0 <yp_order@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1327 <main+0x187>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <yp_master@plt>
mov    %eax,-0x3c(%rbp)
jmp    132c <main+0x18c>
cmpl   $0x0,-0x3c(%rbp)
je     135f <main+0x1bf>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x3c(%rbp),%edi
call   1080 <yperr_string@plt>
mov    -0x50(%rbp),%rdx
mov    %eax,%ecx
mov    $0x1,%edi
lea    0xcc5(%rip),%rsi
mov    $0x0,%al
call   1050 <errx@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x34(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x60(%rbp),%rsi
mov    -0x54(%rbp),%edx
mov    %rax,%rcx
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
call   1070 <yp_get_default_domain@plt>
lea    0xe3c(%rip),%r12
mov    0x2e2d(%rip),%r13
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11e9 <main+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13),%rax
mov    %rax,0x8(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10c0 <getopt@plt>
cmp    $0x63,%eax
jle    1210 <main+0x70>
cmp    $0x64,%eax
je     11e0 <main+0x40>
cmp    $0x68,%eax
jne    121a <main+0x7a>
mov    0x0(%r13),%r15
jmp    11e9 <main+0x49>
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     122b <main+0x8b>
cmp    $0x54,%eax
je     1223 <main+0x83>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    11e9 <main+0x49>
mov    $0x1,%r14d
jmp    11e9 <main+0x49>
cmpq   $0x0,0x8(%rsp)
jne    1246 <main+0xa6>
lea    0xdcc(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <errx@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%r12
sub    %r12d,%ebp
cmp    $0x1,%ebp
je     125f <main+0xbf>
xor    %eax,%eax
call   1090 <usage@plt>
mov    (%rbx,%r12,8),%rbx
mov    0x8(%rsp),%rdi
test   %r15,%r15
je     128b <main+0xeb>
lea    0x4(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14d,%r9d
call   10a0 <get_remote_info@plt>
test   %eax,%eax
jne    12b2 <main+0x112>
jmp    12d1 <main+0x131>
lea    0x4(%rsp),%rdx
mov    %rbx,%rsi
call   10b0 <yp_order@plt>
test   %eax,%eax
jne    12b2 <main+0x112>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <yp_master@plt>
test   %eax,%eax
je     12d1 <main+0x131>
mov    %eax,%edi
call   1080 <yperr_string@plt>
lea    0xd5d(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <errx@plt>
mov    0x4(%rsp),%ebp
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xd52(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Th:d:\00"
@optarg = global i8* null
@.str.1 = [23 x i8] c"YP domain name not set\00"
@optind = global i64 0
@.str.2 = [27 x i8] c"no such map %s. Reason: %s\00"
@.str.3 = [31 x i8] c"Map %s has order number %d. %s\00"
@.str.4 = [26 x i8] c"The master server is %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 0, i32* %13
%14 = call i32 @yp_get_default_domain(i8** %6)
br label %15
15: ; preds = %29, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %11
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = load i32, i32* %11
switch i32 %21, label %27 [
i32 84, label %22
i32 100, label %23
i32 104, label %25
]
22: ; preds = %20
store i32 1, i32* %13
br label %29
23: ; preds = %20
%24 = load i8*, i8** @optarg
store i8* %24, i8** %6
br label %29
25: ; preds = %20
%26 = load i8*, i8** @optarg
store i8* %26, i8** %7
br label %29
27: ; preds = %20
%28 = call i32 (...) @usage()
br label %29
29: ; preds = %27, %25, %23, %22
br label %15
30: ; preds = %15
%31 = load i8*, i8** %6
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
%36 = load i64, i64* @optind
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = sub nsw i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %4
%41 = load i64, i64* @optind
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 %41
store i8** %43, i8*** %5
%44 = load i32, i32* %4
%45 = icmp ne i32 %44, 1
br i1 %45, label %46, label %48
46: ; preds = %35
%47 = call i32 (...) @usage()
br label %48
48: ; preds = %46, %35
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
store i8* %51, i8** %8
%52 = load i8*, i8** %7
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %60
54: ; preds = %48
%55 = load i8*, i8** %6
%56 = load i8*, i8** %8
%57 = load i8*, i8** %7
%58 = load i32, i32* %13
%59 = call i32 @get_remote_info(i8* %55, i8* %56, i8* %57, i32* %10, i8** %9, i32 %58)
store i32 %59, i32* %12
br label %71
60: ; preds = %48
%61 = load i8*, i8** %6
%62 = load i8*, i8** %8
%63 = call i32 @yp_order(i8* %61, i8* %62, i32* %10)
store i32 %63, i32* %12
%64 = load i32, i32* %12
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %60
%67 = load i8*, i8** %6
%68 = load i8*, i8** %8
%69 = call i32 @yp_master(i8* %67, i8* %68, i8** %9)
store i32 %69, i32* %12
br label %70
70: ; preds = %66, %60
br label %71
71: ; preds = %70, %54
%72 = load i32, i32* %12
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %71
%75 = load i8*, i8** %8
%76 = load i32, i32* %12
%77 = call i32 @yperr_string(i32 %76)
%78 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %75, i32 %77)
br label %79
79: ; preds = %74, %71
%80 = load i8*, i8** %8
%81 = load i32, i32* %10
%82 = bitcast i32* %10 to i8*
%83 = call i8* @ctime(i8* %82)
%84 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %80, i32 %81, i8* %83)
%85 = load i8*, i8** %9
%86 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %85)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"Th:d:\00"
@optarg = global i8* null
@.str.1 = [23 x i8] c"YP domain name not set\00"
@optind = global i64 0
@.str.2 = [27 x i8] c"no such map %s. Reason: %s\00"
@.str.3 = [31 x i8] c"Map %s has order number %d. %s\00"
@.str.4 = [26 x i8] c"The master server is %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @yp_get_default_domain(i8** %3)
br label %10
10: ; preds = %19, %2
%11 = phi i8* [ %20, %19 ], [ null, %2 ]
%12 = phi i32 [ %14, %19 ], [ 0, %2 ]
br label %13
13: ; preds = %15, %10
%14 = phi i32 [ %12, %10 ], [ 1, %15 ]
br label %15
15: ; preds = %23, %13
%16 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %16, label %21 [
i32 -1, label %24
i32 84, label %13
i32 100, label %17
i32 104, label %19
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %3
br label %23
19: ; preds = %15
%20 = load i8*, i8** @optarg
br label %10
21: ; preds = %15
%22 = call i32 (...) @usage()
br label %23
23: ; preds = %21, %17
br label %15
24: ; preds = %15
%25 = load i8*, i8** %3
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = load i64, i64* @optind
%31 = trunc i64 %30 to i32
%32 = sub i32 %0, %31
%33 = getelementptr inbounds i8*, i8** %1, i64 %30
%34 = icmp eq i32 %32, 1
br i1 %34, label %37, label %35
35: ; preds = %29
%36 = call i32 (...) @usage()
br label %37
37: ; preds = %35, %29
%38 = load i8*, i8** %33
%39 = icmp eq i8* %11, null
%40 = load i8*, i8** %3
br i1 %39, label %43, label %41
41: ; preds = %37
%42 = call i32 @get_remote_info(i8* %40, i8* %38, i8* %11, i32* %5, i8** %4, i32 %14)
br label %49
43: ; preds = %37
%44 = call i32 @yp_order(i8* %40, i8* %38, i32* %5)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i8*, i8** %3
%48 = call i32 @yp_master(i8* %47, i8* %38, i8** %4)
br label %49
49: ; preds = %46, %41
%50 = phi i32 [ %42, %41 ], [ %48, %46 ]
%51 = icmp eq i32 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %43, %49
%53 = phi i32 [ %50, %49 ], [ %44, %43 ]
%54 = call i32 @yperr_string(i32 %53)
%55 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %38, i32 %54)
br label %56
56: ; preds = %52, %49
%57 = load i32, i32* %5
%58 = call i8* @ctime(i8* %8)
%59 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %38, i32 %57, i8* %58)
%60 = load i8*, i8** %4
%61 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %60)
ret i32 0
}