// File: /workspace/github_cpp_makefile_star2_O1/lega911[P]ijson/src/main.cpp
// Function: main
int main(int argc, char** argv) {
    #ifdef DEBUG
        catch_fatal();
    #endif
    generator_init();

    Server server;
    server.log = 15;

    Slice s, next;
    for(int i=1;i<argc;i++) {
        s.set(argv[i]);
        if(i + 1 < argc) next.set(argv[i + 1]);
        else next.reset();

        if(s == "--host") {
            if(next.valid()) {
                Slice _h = next.split_left(':');
                if(!_h.empty()) server.host.set(_h);
                if(!next.empty()) {
                    try {
                        server.port = next.atoi();
                    } catch(const Exception &e) {
                        std::cout << "Wrong host option\n";
                        return 1;
                    }
                }
                i++;
            } else {
                std::cout << "Wrong host\n";
                return 1;
            }
        } else if(s == "--filter") {
            if(next.valid()) {
                NetFilter nf(next);
                server.net_filter.push_back(nf);
                i++;
                if(server.host.empty()) server.host.set("0.0.0.0");
            } else {
                std::cout << "Wrong port\n";
                return 1;
            }
        } else if(s == "--log") {
            if(next.valid()) {
                try {
                    server.log = next.atoi();
                } catch(const Exception &e) {
                    std::cout << "Wrong log option\n";
                    return 1;
                }
                i++;
            } else {
                std::cout << "Wrong log option\n";
                return 1;
            }
        } else if(s == "--help") {
            std::cout << "ijson " << ijson_version << std::endl;
            std::cout << help_info;
            return 0;
        } else if(s == "--jsonrpc2") {
            server.jsonrpc2 = true;
        } else if(s == "--version") {
            std::cout << ijson_version << std::endl;
            return 0;
        } else if(s == "--threads") {
            server.threads = -1;
            if(next.valid()) {
                try {
                    server.threads = next.atoi();
                } catch(const Exception &e) {}
                i++;
            };
            if(server.threads < 0 || server.threads > 32) {
                std::cout << "Wrong thread option\n";
                return 1;
            }
        } else {
            std::cout << "Wrong option (" << s.as_string() << ")\n\nuse --help\n";
            return 1;
        }
    }

    if(server.host.empty()) {
        #ifdef DOCKER
            server.host.set("0.0.0.0");
        #else
            server.host.set("127.0.0.1");
        #endif
    }

    try {
        server.start();
    } catch (const Exception &e) {
        if(server.log & 1) e.print("Exception in server.start");
    } catch (const std::exception &e) {
        if(server.log & 1) std::cout << ltime() << "Fatal exception: " << e.what() << std::endl;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x201e8, %rsp          # imm = 0x201E8
movq %rsi, %r14
movl %edi, %r15d
callq 0xd2f9
callq 0x1688e
leaq -0x20210(%rbp), %rbx
movq %rbx, %rdi
callq 0xe500
movl $0xf, 0x20(%rbx)
xorl %r13d, %r13d
movq %r13, -0x88(%rbp)
movl %r13d, -0x80(%rbp)
movq %r13, -0x50(%rbp)
movl %r13d, -0x48(%rbp)
cmpl $0x2, %r15d
setge %r12b
jl 0xe187
movl $0x1, %eax
xorl %r13d, %r13d
movq %r14, -0x58(%rbp)
movl %r15d, -0x30(%rbp)
movq %r13, -0x40(%rbp)
movb %r12b, -0x29(%rbp)
movl %eax, -0x34(%rbp)
movslq %eax, %rbx
movq (%r14,%rbx,8), %r12
movq %r12, %rdi
callq 0x8130
movq %rax, %r13
movq %r12, -0x88(%rbp)
movl %r13d, -0x80(%rbp)
incl %ebx
cmpl %r15d, %ebx
jge 0xdde6
movslq %ebx, %rax
movq (%r14,%rax,8), %r14
movq %r14, %rdi
callq 0x8130
jmp 0xddeb
xorl %r14d, %r14d
xorl %eax, %eax
leaq 0xa333(%rip), %rsi      # 0x18125
leaq 0xa322(%rip), %rdi      # 0x1811b
leaq 0xa310(%rip), %r8       # 0x18110
leaq 0xa302(%rip), %r9       # 0x18109
leaq 0xa2e3(%rip), %r10      # 0x180f1
leaq 0xa2bf(%rip), %r11      # 0x180d4
leaq 0xa292(%rip), %r15      # 0x180ae
movq %r14, -0x50(%rbp)
movl %eax, -0x48(%rbp)
testl %r13d, %r13d
movl $0x0, %eax
cmovgl %r13d, %eax
movb $0x2d, %dl
xorl %ecx, %ecx
movq -0x58(%rbp), %r14
cmpq %rcx, %rax
je 0xdeb6
cmpb (%r12,%rcx), %dl
jne 0xdeb6
movb 0x1(%rcx,%r15), %dl
incq %rcx
cmpq $0x6, %rcx
jne 0xde37
cmpl $0x6, %r13d
jne 0xdeb6
cmpq $0x0, -0x50(%rbp)
je 0xe2c6
leaq -0x50(%rbp), %rdi
movl $0x3a, %esi
callq 0xd34e
movb -0x29(%rbp), %r12b
testl %edx, %edx
movq -0x40(%rbp), %r13
je 0xde88
movq %rax, -0x20200(%rbp)
movl %edx, -0x201f8(%rbp)
movb $0x1, %r14b
cmpl $0x0, -0x48(%rbp)
je 0xdea0
leaq -0x50(%rbp), %rdi
callq 0xc266
movl %eax, -0x201ec(%rbp)
testb %r14b, %r14b
movq -0x58(%rbp), %r14
movl -0x30(%rbp), %r15d
jne 0xe085
jmp 0xe187
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdf1d
cmpb (%r12,%rcx), %dl
jne 0xdf1d
movb 0x1(%rcx,%r11), %dl
incq %rcx
cmpq $0x8, %rcx
jne 0xdeba
cmpl $0x8, %r13d
jne 0xdf1d
cmpq $0x0, -0x50(%rbp)
je 0xe332
leaq -0x78(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xee6c
movq -0x40(%rbp), %r13
movq -0x201d0(%rbp), %rsi
cmpq -0x201c8(%rbp), %rsi
je 0xe050
movq -0x78(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, -0x201d0(%rbp)
jmp 0xe060
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdf5c
cmpb (%r12,%rcx), %dl
jne 0xdf5c
movb 0x1(%rcx,%r10), %dl
incq %rcx
cmpq $0x5, %rcx
jne 0xdf21
cmpl $0x5, %r13d
jne 0xdf5c
cmpq $0x0, -0x50(%rbp)
je 0xe340
leaq -0x50(%rbp), %rdi
callq 0xc266
movl %eax, -0x201f0(%rbp)
jmp 0xdfb2
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdf83
cmpb (%r12,%rcx), %dl
jne 0xdf83
movb 0x1(%rcx,%r9), %dl
incq %rcx
cmpq $0x6, %rcx
jne 0xdf60
cmpl $0x6, %r13d
je 0xe232
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdfbb
cmpb (%r12,%rcx), %dl
jne 0xdfbb
movb 0x1(%rcx,%r8), %dl
incq %rcx
cmpq $0xa, %rcx
jne 0xdf87
cmpl $0xa, %r13d
jne 0xdfbb
movb $0x1, -0x201e4(%rbp)
movl -0x34(%rbp), %eax
movl %eax, %ebx
movq -0x40(%rbp), %r13
jmp 0xe081
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdfe1
cmpb (%r12,%rcx), %dl
jne 0xdfe1
movb 0x1(%rcx,%rdi), %dl
incq %rcx
cmpq $0x9, %rcx
jne 0xdfbf
cmpl $0x9, %r13d
je 0xe2d8
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xe10f
cmpb (%r12,%rcx), %dl
jne 0xe10f
movb 0x1(%rcx,%rsi), %dl
incq %rcx
cmpq $0x9, %rcx
jne 0xdfe5
cmpl $0x9, %r13d
jne 0xe10f
movl $0xffffffff, -0x201e8(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x50(%rbp)
movb -0x29(%rbp), %r12b
movq -0x40(%rbp), %r13
movl -0x34(%rbp), %eax
je 0xe03c
leaq -0x50(%rbp), %rdi
callq 0xc266
movl %eax, -0x201e8(%rbp)
movl %ebx, %eax
cmpl $0x21, -0x201e8(%rbp)
movl %eax, %ebx
movl -0x30(%rbp), %r15d
jb 0xe085
jmp 0xe324
leaq -0x201d8(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0xe720
cmpl $0x0, -0x201f8(%rbp)
jne 0xe081
leaq 0xa06d(%rip), %rax      # 0x180dd
movq %rax, -0x20200(%rbp)
movl $0x7, -0x201f8(%rbp)
movl -0x30(%rbp), %r15d
incl %ebx
movl %ebx, %eax
cmpl %r15d, %ebx
setl %r12b
jl 0xdda6
jmp 0xe187
movq %rax, %r12
cmpl $0x1, %edx
jne 0xe4eb
movq %r12, %rdi
callq 0x8120
callq 0x8450
movl %ebx, %eax
movb -0x29(%rbp), %r12b
movq -0x40(%rbp), %r13
movq -0x58(%rbp), %r14
jmp 0xe03c
movq %rax, %r12
cmpl $0x1, %edx
jne 0xe4eb
movq %r12, %rdi
callq 0x8120
movl $0x12, %edx
movq 0xfee9(%rip), %rdi      # 0x1dfd0
leaq 0x9fc7(%rip), %rsi      # 0x180b5
callq 0x8350
callq 0x8450
movl $0x1, %r13d
xorl %r14d, %r14d
movl -0x34(%rbp), %eax
movl %eax, %ebx
movb -0x29(%rbp), %r12b
jmp 0xdea0
movq 0xfeba(%rip), %rdi      # 0x1dfd0
leaq 0xa027(%rip), %rsi      # 0x18144
movl $0xe, %edx
callq 0x8350
movb -0x29(%rbp), %r12b
leaq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc468
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq 0xfe81(%rip), %rdi      # 0x1dfd0
callq 0x8350
leaq 0x9ff8(%rip), %rsi      # 0x18153
movl $0xe, %edx
movq %rax, %rdi
callq 0x8350
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe181
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x8320
movl $0x1, %r13d
testb $0x1, %r12b
jne 0xe1c0
cmpl $0x0, -0x201f8(%rbp)
jne 0xe1ae
leaq 0x9fc5(%rip), %rax      # 0x18162
movq %rax, -0x20200(%rbp)
movl $0x9, -0x201f8(%rbp)
movl $0x1, %r13d
leaq -0x20210(%rbp), %rdi
callq 0xf860
leaq -0xe8(%rbp), %r14
movq %r14, %rdi
callq 0xe690
movq -0x18(%r14), %rdi
testq %rdi, %rdi
je 0xe1e7
movq -0xf0(%rbp), %rsi
subq %rdi, %rsi
callq 0x8320
movq -0x160(%rbp), %rdi
testq %rdi, %rdi
je 0xe202
movq -0x150(%rbp), %rsi
subq %rdi, %rsi
callq 0x8320
movq -0x201d8(%rbp), %rdi
testq %rdi, %rdi
je 0xe21d
movq -0x201c8(%rbp), %rsi
subq %rdi, %rsi
callq 0x8320
movl %r13d, %eax
addq $0x201e8, %rsp          # imm = 0x201E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfd97(%rip), %rdi      # 0x1dfd0
leaq 0x9461(%rip), %rsi      # 0x176a1
movl $0x6, %edx
callq 0x8350
movb -0x29(%rbp), %r12b
movq 0xfd7b(%rip), %rbx      # 0x1dfd0
leaq 0x97fd(%rip), %rsi      # 0x17a59
movl $0x6, %edx
movq %rbx, %rdi
callq 0x8350
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq 0xfd49(%rip), %rbx      # 0x1dfd0
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
movq 0x10012(%rip), %r14     # 0x1e2b0
testq %r14, %r14
je 0xe367
movq %r14, %rdi
callq 0x8130
movq 0xfd1a(%rip), %rdi      # 0x1dfd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xe37e
movl $0xb, %edx
movb -0x29(%rbp), %r12b
leaq 0x9df2(%rip), %rsi      # 0x180c8
jmp 0xe350
movq 0xfcf1(%rip), %rbx      # 0x1dfd0
leaq 0x9773(%rip), %rsi      # 0x17a59
movl $0x6, %edx
movq %rbx, %rdi
callq 0x8350
movb -0x29(%rbp), %r12b
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq 0xfcbb(%rip), %rdi      # 0x1dfd0
callq 0x8040
movq %rax, %rdi
callq 0x81f0
jmp 0xe37e
movl $0x14, %edx
leaq 0x9dff(%rip), %rsi      # 0x1812f
jmp 0xe350
movl $0xb, %edx
leaq 0x9da7(%rip), %rsi      # 0x180e5
jmp 0xe34c
movl $0x11, %edx
leaq 0x9dab(%rip), %rsi      # 0x180f7
movb -0x29(%rbp), %r12b
movl $0x1, %r13d
movq 0xfc73(%rip), %rdi      # 0x1dfd0
callq 0x8350
jmp 0xe187
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x8470
xorl %r13d, %r13d
jmp 0xe187
jmp 0xe4ca
jmp 0xe4ca
movq %rax, %r12
callq 0x8450
jmp 0xe4eb
movq %rax, %r12
cmpl $0x1, %edx
jne 0xe4eb
movq %r12, %rdi
callq 0x8120
movq 0xfc18(%rip), %rdi      # 0x1dfd0
leaq 0x9d38(%rip), %rsi      # 0x180f7
movl $0x11, %edx
callq 0x8350
movl $0x1, %r13d
callq 0x8450
movb -0x29(%rbp), %r12b
jmp 0xe187
jmp 0xe4ca
movq %rax, %r12
callq 0x8450
jmp 0xe4eb
jmp 0xe4ca
jmp 0xe4ca
jmp 0xe4ca
movq %rax, %r12
cmpl $0x1, %edx
jne 0xe436
movq %r12, %rdi
callq 0x8120
testb $0x1, -0x201f0(%rbp)
je 0xe426
leaq 0x9d60(%rip), %rsi      # 0x1817e
movq %rax, %rdi
callq 0xcf80
callq 0x8450
movl $0x1, %r13d
jmp 0xe1c0
cmpl $0x2, %edx
jne 0xe4eb
movq %r12, %rdi
callq 0x8120
testb $0x1, -0x201f0(%rbp)
je 0xe49a
movq %rax, %r14
callq 0x16531
movq 0xfb71(%rip), %rdi      # 0x1dfd0
movq %rax, %rsi
callq 0x8300
movq %rax, %r15
leaq 0x9cfb(%rip), %rsi      # 0x1816c
movl $0x11, %edx
movq %rax, %rdi
callq 0x8350
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0x8300
movq %rax, %rdi
callq 0x8160
callq 0x8450
movl $0x1, %r13d
jmp 0xe1c0
movq %rax, %r12
callq 0x8450
jmp 0xe4eb
jmp 0xe4ca
jmp 0xe4ca
movq %rax, %r12
callq 0x8450
jmp 0xe4eb
movq %rax, %rdi
callq 0xc171
movq %rax, %r12
jmp 0xe4eb
movq %rax, %r12
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe4eb
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x8320
leaq -0x20210(%rbp), %rdi
callq 0xe622
movq %r12, %rdi
callq 0x84a0
nop