#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ freeTldTree(void *);
char *getRegisteredDomain(char *, void *);
char *getRegisteredDomainDrop(char *, void *, int);
void *loadTldTree();
int /*<<< orphan*/ printTldTree(void *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    fprintf(stderr,
            "%s [--drop-unknown] "
            "<(fully-qualified-domain-name )+>\n",
            argv[0]);
    fprintf(stderr, "%s --dump\n", argv[0]);
    return 2;
  }
  void *tree = loadTldTree();
  int error = 0;
  if (!strcmp(argv[1], "--dump"))
    printTldTree(tree, "");
  else {
    int drop_unknown = 0;
    int i = 1;
    char *result;
    if (!strcmp(argv[1], "--drop-unknown")) {
      i++;
      drop_unknown = 1;
    }
    for (; i < argc; i++) {
      if (drop_unknown)
        result = getRegisteredDomainDrop(argv[i], tree, 1);
      else
        result = getRegisteredDomain(argv[i], tree);
      if (!result) {
        printf("%s: error\n", argv[i]);
        error = 1;
      } else
        printf("%s: %s\n", argv[i], result);
    }
  }
  freeTldTree(tree);
  return error;
}


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   $0x1,-0x8(%rbp)
jne    11e4 <main+0x64>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe64(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1330 <main+0x1b0>
mov    $0x0,%al
call   1040 <loadTldTree@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1228 <main+0xa8>
mov    -0x18(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1090 <printTldTree@plt>
jmp    1321 <main+0x1a1>
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe04(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1263 <main+0xe3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1268 <main+0xe8>
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    131c <main+0x19c>
cmpl   $0x0,-0x20(%rbp)
je     12a1 <main+0x121>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <getRegisteredDomainDrop@plt>
mov    %rax,-0x30(%rbp)
jmp    12ba <main+0x13a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <getRegisteredDomain@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12eb <main+0x16b>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    1309 <main+0x189>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x30(%rbp),%rdx
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130e <main+0x18e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1268 <main+0xe8>
jmp    1321 <main+0x1a1>
mov    -0x18(%rbp),%rdi
call   1050 <freeTldTree@plt>
mov    -0x1c(%rbp),%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   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jne    11c9 <main+0x49>
mov    0x2e46(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xe59(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xe7e(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%r15d
jmp    1290 <main+0x110>
mov    %edi,%r12d
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <loadTldTree@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rbp
lea    0xe5e(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1279 <main+0xf9>
lea    0xe4e(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
mov    $0x1,%eax
adc    $0x0,%eax
cmp    %r12d,%eax
jge    1288 <main+0x108>
mov    %eax,%r13d
mov    %r12d,%r12d
xor    %r15d,%r15d
jmp    123a <main+0xba>
lea    0xe3c(%rip),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r12
je     1288 <main+0x108>
mov    (%rbx,%r13,8),%rdi
mov    %r14,%rsi
test   %ebp,%ebp
je     1250 <main+0xd0>
call   1080 <getRegisteredDomain@plt>
jmp    125a <main+0xda>
nopl   0x0(%rax)
mov    $0x1,%edx
call   10a0 <getRegisteredDomainDrop@plt>
mov    (%rbx,%r13,8),%rsi
test   %rax,%rax
jne    1220 <main+0xa0>
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%r15d
jmp    1231 <main+0xb1>
lea    0xdb6(%rip),%rsi
mov    %r14,%rdi
call   1090 <printTldTree@plt>
mov    %r14,%rdi
call   1050 <freeTldTree@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"%s [--drop-unknown] <(fully-qualified-domain-name )+>\0A\00"
@.str.1 = [11 x i8] c"%s --dump\0A\00"
@.str.2 = [7 x i8] c"--dump\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [15 x i8] c"--drop-unknown\00"
@.str.5 = [11 x i8] c"%s: error\0A\00"
@.str.6 = [8 x i8] c"%s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %24
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %22)
store i32 2, i32* %3
br label %94
24: ; preds = %2
%25 = call i8* (...) @loadTldTree()
store i8* %25, i8** %6
store i32 0, i32* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %24
%32 = load i8*, i8** %6
%33 = call i32 @printTldTree(i8* %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %90
34: ; preds = %24
store i32 0, i32* %8
store i32 1, i32* %9
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @strcmp(i8* %37, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %34
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
store i32 1, i32* %8
br label %43
43: ; preds = %40, %34
br label %44
44: ; preds = %86, %43
%45 = load i32, i32* %9
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %89
48: ; preds = %44
%49 = load i32, i32* %8
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = load i8*, i8** %6
%58 = call i8* @getRegisteredDomainDrop(i8* %56, i8* %57, i32 1)
store i8* %58, i8** %10
br label %67
59: ; preds = %48
%60 = load i8**, i8*** %5
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = load i8*, i8** %6
%66 = call i8* @getRegisteredDomain(i8* %64, i8* %65)
store i8* %66, i8** %10
br label %67
67: ; preds = %59, %51
%68 = load i8*, i8** %10
%69 = icmp ne i8* %68, null
br i1 %69, label %77, label %70
70: ; preds = %67
%71 = load i8**, i8*** %5
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %75)
store i32 1, i32* %7
br label %85
77: ; preds = %67
%78 = load i8**, i8*** %5
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = load i8*, i8** %10
%84 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %82, i8* %83)
br label %85
85: ; preds = %77, %70
br label %86
86: ; preds = %85
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %44
89: ; preds = %44
br label %90
90: ; preds = %89, %31
%91 = load i8*, i8** %6
%92 = call i32 @freeTldTree(i8* %91)
%93 = load i32, i32* %7
store i32 %93, i32* %3
br label %94
94: ; preds = %90, %13
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"%s [--drop-unknown] <(fully-qualified-domain-name )+>\0A\00"
@.str.1 = [11 x i8] c"%s --dump\0A\00"
@.str.2 = [7 x i8] c"--dump\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [15 x i8] c"--drop-unknown\00"
@.str.5 = [11 x i8] c"%s: error\0A\00"
@.str.6 = [8 x i8] c"%s: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %52
11: ; preds = %2
%12 = tail call i8* (...) @loadTldTree()
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = tail call i32 @printTldTree(i8* %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %49
19: ; preds = %11
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 2, i32 1
%23 = icmp slt i32 %22, %0
br i1 %23, label %24, label %49
24: ; preds = %19
%25 = zext i32 %22 to i64
%26 = zext i32 %0 to i64
br label %27
27: ; preds = %24, %45
%28 = phi i64 [ %25, %24 ], [ %47, %45 ]
%29 = phi i32 [ 0, %24 ], [ %46, %45 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %28
%31 = load i8*, i8** %30
br i1 %21, label %32, label %34
32: ; preds = %27
%33 = tail call i8* @getRegisteredDomainDrop(i8* %31, i8* %12, i32 1)
br label %36
34: ; preds = %27
%35 = tail call i8* @getRegisteredDomain(i8* %31, i8* %12)
br label %36
36: ; preds = %34, %32
%37 = phi i8* [ %33, %32 ], [ %35, %34 ]
%38 = icmp eq i8* %37, null
%39 = getelementptr inbounds i8*, i8** %1, i64 %28
%40 = load i8*, i8** %39
br i1 %38, label %41, label %43
41: ; preds = %36
%42 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %40)
br label %45
43: ; preds = %36
%44 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %40, i8* %37)
br label %45
45: ; preds = %41, %43
%46 = phi i32 [ %29, %43 ], [ 1, %41 ]
%47 = add nuw nsw i64 %28, 1
%48 = icmp eq i64 %47, %26
br i1 %48, label %49, label %27
49: ; preds = %45, %19, %17
%50 = phi i32 [ 0, %17 ], [ 0, %19 ], [ %46, %45 ]
%51 = tail call i32 @freeTldTree(i8* %12)
br label %52
52: ; preds = %49, %4
%53 = phi i32 [ 2, %4 ], [ %50, %49 ]
ret i32 %53
}