// File: /workspace/github_cpp_makefile_star2_O2/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 $0x201d8, %rsp          # imm = 0x201D8
movq %rsi, %r12
movl %edi, %r14d
callq 0xe500
callq 0x16cd6
leaq -0x201f8(%rbp), %r13
movq %r13, %rdi
callq 0xf1da
leaq -0x50(%rbp), %rax
andq $0x0, (%rax)
andl $0x0, 0x8(%rax)
leaq -0x38(%rbp), %rcx
andq $0x0, (%rcx)
movl $0xf, 0x20(%r13)
movq %rax, %r13
andl $0x0, 0x8(%rcx)
pushq $0x1
popq %r15
movq %r12, -0x40(%rbp)
cmpl %r14d, %r15d
jge 0xef3b
movq %r13, %rbx
movslq %r15d, %rax
movq (%r12,%rax,8), %r13
movq %r13, %rdi
callq 0xa120
movq %r13, -0x50(%rbp)
movl %eax, -0x48(%rbp)
movq %r12, %rcx
leal 0x1(%r15), %r12d
cmpl %r14d, %r12d
jge 0xed79
movslq %r12d, %rax
movq (%rcx,%rax,8), %r13
movq %r13, %rdi
callq 0xa120
jmp 0xed7e
xorl %r13d, %r13d
xorl %eax, %eax
movq %r13, -0x38(%rbp)
movl %eax, -0x30(%rbp)
movq %rbx, %r13
movq %rbx, %rdi
leaq 0xa320(%rip), %rsi      # 0x190b2
callq 0xd9a0
testb %al, %al
je 0xede1
cmpq $0x0, -0x38(%rbp)
je 0xef6d
leaq -0x38(%rbp), %rdi
pushq $0x3a
popq %rsi
callq 0xe552
testl %edx, %edx
je 0xedc3
movq %rax, -0x201e8(%rbp)
movl %edx, -0x201e0(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0xef08
leaq -0x38(%rbp), %rdi
callq 0xd466
movl %eax, -0x201d4(%rbp)
jmp 0xef08
movq %r13, %rdi
leaq 0xa2ed(%rip), %rsi      # 0x190d8
callq 0xd9a0
testb %al, %al
je 0xee48
cmpq $0x0, -0x38(%rbp)
je 0xef76
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
leaq -0x38(%rbp), %rsi
callq 0xfb4c
leaq -0x201c0(%rbp), %rdi
movq %rbx, %rsi
callq 0xf2ee
cmpl $0x0, -0x201e0(%rbp)
jne 0xef08
leaq 0xa2af(%rip), %rax      # 0x190e1
movq %rax, -0x201e8(%rbp)
movl $0x7, -0x201e0(%rbp)
jmp 0xef08
movq %r13, %rdi
leaq 0xa2a3(%rip), %rsi      # 0x190f5
callq 0xd9a0
testb %al, %al
je 0xee7a
cmpq $0x0, -0x38(%rbp)
je 0xef7f
leaq -0x38(%rbp), %rdi
callq 0xd466
movl %eax, -0x201d8(%rbp)
jmp 0xef08
movq %r13, %rdi
leaq 0xa289(%rip), %rsi      # 0x1910d
callq 0xd9a0
testb %al, %al
jne 0xef88
movq %r13, %rdi
leaq 0xa279(%rip), %rsi      # 0x19114
callq 0xd9a0
testb %al, %al
je 0xeeb0
movb $0x1, -0x201cc(%rbp)
movl %r15d, %r12d
jmp 0xef08
movq %r13, %rdi
leaq 0xa265(%rip), %rsi      # 0x1911f
callq 0xd9a0
testb %al, %al
jne 0xeffd
movq %r13, %rdi
leaq 0xa258(%rip), %rsi      # 0x19129
callq 0xd9a0
testb %al, %al
je 0xf01c
orl $-0x1, -0x201d0(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xefc7
leaq -0x38(%rbp), %rdi
callq 0xd466
movl %eax, -0x201d0(%rbp)
cmpl $0x21, %eax
jae 0xefc7
incl %r12d
movl %r12d, %r15d
movq -0x40(%rbp), %r12
jmp 0xed3a
movq %rax, %r15
cmpl $0x2, %edx
jne 0xf1c6
movq %r15, %rdi
callq 0xa110
callq 0xa430
movl -0x201d0(%rbp), %eax
movq %rbx, %r13
jmp 0xeeff
cmpl $0x0, -0x201e0(%rbp)
jne 0xef5c
leaq 0xa21b(%rip), %rax      # 0x19166
movq %rax, -0x201e8(%rbp)
movl $0x9, -0x201e0(%rbp)
pushq $0x1
popq %rbx
leaq -0x201f8(%rbp), %rdi
callq 0x10328
jmp 0xefdd
leaq 0xa158(%rip), %rsi      # 0x190cc
jmp 0xefce
leaq 0xa16c(%rip), %rsi      # 0x190e9
jmp 0xefce
leaq 0xa175(%rip), %rsi      # 0x190fb
jmp 0xefce
movq 0x11041(%rip), %rdi     # 0x1ffd0
leaq 0x970e(%rip), %rsi      # 0x186a4
callq 0xa2e0
leaq 0x9aba(%rip), %rsi      # 0x18a5c
movq %rax, %rdi
callq 0xa2e0
movq %rax, %rdi
callq 0xa160
movq 0x112d7(%rip), %rsi     # 0x20290
movq 0x11010(%rip), %rdi     # 0x1ffd0
callq 0xa2e0
jmp 0xf018
leaq 0xa165(%rip), %rsi      # 0x19133
movq 0x10ffb(%rip), %rdi     # 0x1ffd0
callq 0xa2e0
pushq $0x1
popq %rbx
leaq -0x201f8(%rbp), %rdi
callq 0xf312
movl %ebx, %eax
addq $0x201d8, %rsp          # imm = 0x201D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10fcc(%rip), %rdi     # 0x1ffd0
leaq 0x9a51(%rip), %rsi      # 0x18a5c
callq 0xa2e0
movq %rax, %rdi
callq 0xa160
xorl %ebx, %ebx
jmp 0xefdd
movq 0x10fad(%rip), %rdi     # 0x1ffd0
leaq 0xa11e(%rip), %rsi      # 0x19148
callq 0xa2e0
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
pushq $-0x1
popq %rdx
callq 0xd636
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0xa280
leaq 0xa102(%rip), %rsi      # 0x19157
movq %rax, %rdi
callq 0xa2e0
leaq -0x70(%rbp), %rdi
callq 0xa130
jmp 0xefda
jmp 0xf1c3
jmp 0xf1c3
movq %rax, %r15
leaq -0x70(%rbp), %rdi
callq 0xa130
jmp 0xf1c6
movq %rax, %r15
cmpl $0x2, %edx
jne 0xf0b8
movq %r15, %rdi
callq 0xa110
testb $0x1, -0x201d8(%rbp)
je 0xf0ae
leaq 0xa0dc(%rip), %rsi      # 0x19182
movq %rax, %rdi
callq 0xe38e
callq 0xa430
jmp 0xefdd
cmpl $0x1, %edx
jne 0xf1c6
movq %r15, %rdi
callq 0xa110
testb $0x1, -0x201d8(%rbp)
je 0xf117
movq %rax, %r14
callq 0x16a89
movq 0x10eef(%rip), %rdi     # 0x1ffd0
movq %rax, %rsi
callq 0xa2e0
leaq 0xa080(%rip), %rsi      # 0x19170
movq %rax, %rdi
callq 0xa2e0
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0xa2e0
movq %rax, %rdi
callq 0xa160
callq 0xa430
jmp 0xefdd
movq %rax, %r15
callq 0xa430
jmp 0xf1c6
jmp 0xf1c3
jmp 0xf1c3
movq %rax, %r15
callq 0xa430
jmp 0xf1c6
jmp 0xf1c3
movq %rax, %r15
cmpl $0x2, %edx
jne 0xf1c6
movq %r15, %rdi
callq 0xa110
movq 0x10e72(%rip), %rdi     # 0x1ffd0
leaq 0x9f96(%rip), %rsi      # 0x190fb
callq 0xa2e0
callq 0xa430
jmp 0xefda
jmp 0xf1c3
movq %rax, %r15
callq 0xa430
jmp 0xf1c6
movq %rax, %r15
cmpl $0x2, %edx
jne 0xf1c6
movq %r15, %rdi
callq 0xa110
movq 0x10e39(%rip), %rdi     # 0x1ffd0
leaq 0x9f1b(%rip), %rsi      # 0x190b9
callq 0xa2e0
callq 0xa430
jmp 0xefda
jmp 0xf1c3
movq %rax, %r15
callq 0xa430
jmp 0xf1c6
movq %rax, %rdi
callq 0xd334
jmp 0xf1c3
movq %rax, %r15
leaq -0x201f8(%rbp), %rdi
callq 0xf312
movq %r15, %rdi
callq 0xa470