// File: /workspace/github_cpp_makefile_star2_O2/loadzero[P]geoloc/geoloc/geoloc.cpp
// Function: main
int main(int argc, char** argv)
{
    if (argc < 2)
    {
        usage(0);
    }

    Args args(argc, argv);

    std::set<std::string> flags;

    flags.insert("-f");
    flags.insert("--import");
    flags.insert("--headers");
    flags.insert("-q");
    flags.insert("-o");

    std::vector<std::string> input_list;
    std::string import;
    std::string output;

    std::string data_file_name = default_file();
    bool show_headers = false;

    while (!args.empty())
    {
        if (strcmp(args.peek(), "-f") == 0)
        {
            args.pop();

            while (true)
            {
                const char* fn = args.pop();

                if (!fn)
                {
                    usage("empty file arg");
                }

                input_list.push_back(std::string("file:") + fn);

                if (args.empty() || flags.count(args.peek()))
                    break;
            }
        }
        else if (strcmp(args.peek(), "--headers") == 0)
        {
            show_headers = true;
            args.pop();
        }
        else if (strcmp(args.peek(), "-o") == 0)
        {
            args.pop();

            const char* arg = args.pop();

            if (!arg)
            {
                usage("empty output arg");
            }

            output = arg;
        }
        else if (strcmp(args.peek(), "--import") == 0)
        {
            args.pop();

            if (!import.empty())
            {
                usage("too many import options");
            }

            const char* arg = args.pop();

            if (!arg)
            {
                usage("empty import arg");
            }

            import = arg;
        }
        else if (strcmp(args.peek(), "-q") == 0)
        {
            args.pop();

            std::string query = "query:";

            while (true)
            {
                const char* arg = args.pop();

                if (!arg)
                {
                    usage("empty query arg");
                }

                query += arg + std::string(",");

                if (args.empty() || flags.count(args.peek()))
                    break;
            }

            input_list.push_back(query);
        }
        else
        {
            fprintf(stderr, "unrecognized option %s\n", args.peek());
            usage(0);
        }
    }

    if (!import.empty())
    {
        if (!input_list.empty())
        {
            usage("import and query are mutually exclusive");
        }

        if (output.empty())
        {
            usage("no output specified with import");
        }

        std::string city_blocks = import + "/blocks.csv";
        std::string city_locs = import + "/location.csv";
        std::string geo_asns = import + "/asnum.csv";

        etl(city_blocks.c_str(), city_locs.c_str(), geo_asns.c_str(), 
            output.c_str());
    }
    else
    {
        if (input_list.empty())
        {
            usage("query has no input");
        }

        if (!import.empty())
        {
            usage("import and query are mutually exclusive");
        }

        query(data_file_name.c_str(), input_list, show_headers);
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
cmpl $0x1, %edi
jle 0x3bf0
movq %rsi, %rbx
movl %edi, %r14d
leaq 0xf0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x6af4(%rip), %rsi      # 0xa034
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f8c
leaq 0x8(%rsp), %rdi
callq 0x3260
leaq 0x6ac5(%rip), %rsi      # 0xa037
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f8c
leaq 0x8(%rsp), %rdi
callq 0x3260
leaq 0x6a9c(%rip), %rsi      # 0xa040
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f8c
leaq 0x8(%rsp), %rdi
callq 0x3260
leaq 0x6a74(%rip), %rsi      # 0xa04a
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f8c
leaq 0x8(%rsp), %rdi
callq 0x3260
leaq 0x6a45(%rip), %rsi      # 0xa04d
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f8c
leaq 0x8(%rsp), %rdi
callq 0x3260
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x128(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x6b74(%rip), %rdi      # 0xa1ea
callq 0x3250
testq %rax, %rax
leaq 0x6b05(%rip), %rsi      # 0xa18a
cmovneq %rax, %rsi
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x30c0
cmpq $0x0, 0x10(%rsp)
jne 0x36b8
leaq 0x6b48(%rip), %rdi      # 0xa1ef
leaq 0x6b53(%rip), %rdx      # 0xa201
pushq $0x33
popq %rsi
xorl %eax, %eax
callq 0x94d0
leaq 0x6b59(%rip), %rdx      # 0xa218
leaq 0x138(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3ec6
leaq 0x8(%rsp), %rdi
callq 0x3260
movl %r14d, %eax
movq %rax, 0xc0(%rsp)
leaq 0x8(%rbx), %rax
movq %rax, 0xb8(%rsp)
leal -0x2(%r14), %eax
movl %eax, 0x3c(%rsp)
pushq $0x1
popq %r13
movq $0x0, 0xb0(%rsp)
leaq 0x48(%rsp), %r12
leaq 0x8(%rsp), %rbp
movq %r14, 0x40(%rsp)
movq %rbx, 0x30(%rsp)
cmpl %r14d, %r13d
je 0x3a87
movslq %r13d, %rax
movq (%rbx,%rax,8), %r15
movb (%r15), %bl
cmpb $0x2d, %bl
jne 0x3748
cmpb $0x66, 0x1(%r15)
jne 0x3748
cmpb $0x0, 0x2(%r15)
je 0x392a
movq %r15, %rdi
leaq 0x68ee(%rip), %rsi      # 0xa040
callq 0x32f0
testl %eax, %eax
je 0x3a70
cmpb $0x2d, %bl
jne 0x3776
cmpb $0x6f, 0x1(%r15)
jne 0x3776
cmpb $0x0, 0x2(%r15)
je 0x3a1d
movq %r15, %rdi
leaq 0x68b7(%rip), %rsi      # 0xa037
callq 0x32f0
testl %eax, %eax
je 0x38b6
cmpb $0x2d, %bl
jne 0x3bd5
cmpb $0x71, 0x1(%r15)
jne 0x3bd5
cmpb $0x0, 0x2(%r15)
jne 0x3bd5
movq %rbp, %rdi
leaq 0x68e9(%rip), %rsi      # 0xa09f
movq %r12, %rdx
callq 0x30c0
leal 0x1(%r13), %eax
movl %eax, 0x28(%rsp)
cltq
movq 0xc0(%rsp), %rbx
subq %rax, %rbx
movq %rbx, 0x68(%rsp)
movq 0xb8(%rsp), %rcx
leaq (%rcx,%rax,8), %rbp
movl 0x3c(%rsp), %eax
movl %eax, %r14d
subl %r13d, %r14d
xorl %r13d, %r13d
cmpq %r13, 0x68(%rsp)
je 0x3bbd
movq -0x8(%rbp,%r13,8), %r15
testq %r15, %r15
je 0x3bbd
leaq 0xc8(%rsp), %r12
movq %r12, %rdi
leaq 0x689a(%rip), %rsi      # 0xa0b6
leaq 0x2f(%rsp), %rdx
callq 0x30c0
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3f20
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x33e0
movq %rbx, %rdi
callq 0x3260
leaq 0xc8(%rsp), %rdi
callq 0x3260
cmpl %r13d, %r14d
je 0x38f6
movq (%rbp,%r13,8), %rsi
leaq 0x48(%rsp), %r12
movq %r12, %rdi
leaq 0xc8(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
movq %r12, %rsi
callq 0x3f06
movq %rax, %r15
movq %r12, %rdi
callq 0x3260
incq %r13
testq %r15, %r15
je 0x37f1
movl 0x28(%rsp), %eax
addl %r13d, %eax
movl %eax, %r13d
movq 0x40(%rsp), %r14
jmp 0x38fe
cmpq $0x0, 0x78(%rsp)
jne 0x3c03
leal 0x1(%r13), %eax
cmpl %r14d, %eax
movq 0x30(%rsp), %rbx
je 0x3bf7
cltq
movq (%rbx,%rax,8), %rsi
testq %rsi, %rsi
je 0x3bf7
addl $0x2, %r13d
leaq 0x70(%rsp), %rdi
callq 0x33c0
jmp 0x371e
movq 0x40(%rsp), %r14
movl %r14d, %r13d
leaq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rbp
movq %rbp, %rsi
callq 0x3e9a
movq 0x30(%rsp), %rbx
leaq 0x48(%rsp), %r12
movq %rbp, %rdi
callq 0x3260
jmp 0x371e
leal 0x1(%r13), %eax
movl %eax, 0x28(%rsp)
cltq
movq 0xc0(%rsp), %rcx
subq %rax, %rcx
movq %rcx, 0x68(%rsp)
movq 0xb8(%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
movl 0x3c(%rsp), %eax
movl %eax, %ebp
subl %r13d, %ebp
xorl %r14d, %r14d
cmpq %r14, 0x68(%rsp)
je 0x3bc9
movq -0x8(%rbx,%r14,8), %r15
testq %r15, %r15
je 0x3bc9
leaq 0x48(%rsp), %r12
movq %r12, %rdi
leaq 0x66db(%rip), %rsi      # 0xa05f
leaq 0xc8(%rsp), %rdx
callq 0x30c0
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3ec6
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x3e9a
movq %r13, %rdi
callq 0x3260
leaq 0x48(%rsp), %rdi
callq 0x3260
cmpl %r14d, %ebp
je 0x3a54
movq (%rbx,%r14,8), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
leaq 0x48(%rsp), %rdx
callq 0x30c0
leaq 0xe8(%rsp), %rdi
movq %r12, %rsi
callq 0x3f06
movq %rax, %r15
movq %r12, %rdi
callq 0x3260
incq %r14
testq %r15, %r15
je 0x395c
movl 0x28(%rsp), %eax
addl %r14d, %eax
movl %eax, %r13d
movq 0x40(%rsp), %r14
jmp 0x3a5c
leal 0x1(%r13), %eax
cmpl %r14d, %eax
movq 0x30(%rsp), %rbx
je 0x3c0f
cltq
movq (%rbx,%rax,8), %rsi
testq %rsi, %rsi
je 0x3c0f
addl $0x2, %r13d
leaq 0x118(%rsp), %rdi
callq 0x33c0
jmp 0x371e
movq 0x40(%rsp), %r14
movl %r14d, %r13d
leaq 0x48(%rsp), %r12
leaq 0x8(%rsp), %rbp
movq 0x30(%rsp), %rbx
jmp 0x371e
incl %r13d
movb $0x1, %al
movq %rax, 0xb0(%rsp)
movq 0x30(%rsp), %rbx
jmp 0x371e
cmpq $0x0, 0x78(%rsp)
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
je 0x3b42
cmpq %rcx, %rax
jne 0x3c1b
cmpq $0x0, 0x120(%rsp)
je 0x3c27
leaq 0x6656(%rip), %rdx      # 0xa118
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3ec6
leaq 0x664c(%rip), %rdx      # 0xa124
leaq 0x48(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3ec6
leaq 0x6644(%rip), %rdx      # 0xa132
leaq 0xc8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3ec6
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0x118(%rsp), %rcx
callq 0x3f9e
leaq 0xc8(%rsp), %rdi
callq 0x3260
leaq 0x48(%rsp), %rdi
callq 0x3260
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3b6b
cmpq %rcx, %rax
je 0x3c33
movq 0x138(%rsp), %rdi
movzbl 0xb0(%rsp), %edx
andl $0x1, %edx
leaq 0x90(%rsp), %rsi
callq 0x4077
leaq 0x138(%rsp), %rdi
callq 0x3260
leaq 0x118(%rsp), %rdi
callq 0x3260
leaq 0x70(%rsp), %rdi
callq 0x3260
leaq 0x90(%rsp), %rdi
callq 0x4142
leaq 0xe8(%rsp), %rdi
callq 0x8f28
xorl %eax, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x64e2(%rip), %rdi      # 0xa0a6
callq 0x3de5
leaq 0x6480(%rip), %rdi      # 0xa050
callq 0x3de5
movq 0xc3fc(%rip), %rax      # 0xffd8
movq (%rax), %rdi
leaq 0x64d2(%rip), %rsi      # 0xa0b8
movq %r15, %rdx
xorl %eax, %eax
callq 0x3300
xorl %edi, %edi
callq 0x3de5
leaq 0x6490(%rip), %rdi      # 0xa08e
callq 0x3de5
leaq 0x646c(%rip), %rdi      # 0xa076
callq 0x3de5
leaq 0x644f(%rip), %rdi      # 0xa065
callq 0x3de5
leaq 0x64ae(%rip), %rdi      # 0xa0d0
callq 0x3de5
leaq 0x64ca(%rip), %rdi      # 0xa0f8
callq 0x3de5
leaq 0x6503(%rip), %rdi      # 0xa13d
callq 0x3de5
jmp 0x3d53
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x3260
jmp 0x3cd2
jmp 0x3d0a
movq %rax, %rbx
jmp 0x3dbb
movq %rax, %rbx
jmp 0x3db1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3dc8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3dc8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3dc8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3dc8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3dc8
jmp 0x3d53
movq %rax, %rbx
jmp 0x3cdc
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3260
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3d97
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3da4
jmp 0x3ddd
jmp 0x3d0a
jmp 0x3d0a
jmp 0x3d0a
jmp 0x3d0a
movq %rax, %rbx
jmp 0x3dc8
jmp 0x3d53
movq %rax, %rbx
jmp 0x3da4
jmp 0x3d53
jmp 0x3d53
jmp 0x3d78
jmp 0x3d53
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3d97
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3260
jmp 0x3d47
jmp 0x3d53
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3260
jmp 0x3d97
movq %rax, %rbx
jmp 0x3d97
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3260
jmp 0x3d8d
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3260
jmp 0x3d80
jmp 0x3d78
movq %rax, %rbx
jmp 0x3d8d
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x3260
leaq 0x8(%rsp), %rdi
callq 0x3260
leaq 0x138(%rsp), %rdi
callq 0x3260
leaq 0x118(%rsp), %rdi
callq 0x3260
leaq 0x70(%rsp), %rdi
callq 0x3260
leaq 0x90(%rsp), %rdi
callq 0x4142
leaq 0xe8(%rsp), %rdi
callq 0x8f28
movq %rbx, %rdi
callq 0x3370
movq %rax, %rdi
callq 0x3e8f