// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movl %edi, %ebx
callq 0xd2f9
callq 0x16762
leaq -0x20208(%rbp), %r15
movq %r15, %rdi
callq 0xe426
movl $0xf, 0x20(%r15)
xorl %eax, %eax
movq %rax, -0x78(%rbp)
movl %eax, -0x70(%rbp)
movq %rax, -0x38(%rbp)
movl %eax, -0x30(%rbp)
cmpl $0x2, %ebx
jl 0xe02e
movl $0x1, %eax
movq %r13, -0x80(%rbp)
movl %ebx, -0x44(%rbp)
movl %eax, -0x48(%rbp)
movslq %eax, %r14
movq (%r13,%r14,8), %r12
movq %r12, %rdi
callq 0x8130
movq %rax, %r15
movq %r12, -0x78(%rbp)
movl %r15d, -0x70(%rbp)
incl %r14d
cmpl %ebx, %r14d
movq %r14, -0x40(%rbp)
jge 0xdd77
movslq %r14d, %rax
movq (%r13,%rax,8), %rbx
movq %rbx, %rdi
callq 0x8130
jmp 0xdd7b
xorl %ebx, %ebx
xorl %eax, %eax
movq %rbx, %r14
movq %rbx, -0x38(%rbp)
movl %eax, -0x30(%rbp)
testl %r15d, %r15d
movl $0x0, %eax
cmovgl %r15d, %eax
movb $0x2d, %dl
xorl %ecx, %ecx
leaq 0xa32c(%rip), %rsi      # 0x180c8
leaq 0xa382(%rip), %rdi      # 0x18125
leaq 0xa371(%rip), %r8       # 0x1811b
leaq 0xa35f(%rip), %r9       # 0x18110
leaq 0xa351(%rip), %r10      # 0x18109
leaq 0xa332(%rip), %r11      # 0x180f1
leaq 0xa30e(%rip), %rbx      # 0x180d4
leaq 0xa2e1(%rip), %r13      # 0x180ae
cmpq %rcx, %rax
je 0xde36
cmpb (%r12,%rcx), %dl
jne 0xde36
movb 0x1(%rcx,%r13), %dl
incq %rcx
cmpq $0x6, %rcx
jne 0xddcd
cmpl $0x6, %r15d
jne 0xde36
testq %r14, %r14
je 0xe1df
leaq -0x38(%rbp), %rdi
movl $0x3a, %esi
callq 0xd34e
testl %edx, %edx
movq -0x40(%rbp), %r14
je 0xde18
movq %rax, -0x201f8(%rbp)
movl %edx, -0x201f0(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0xdff5
leaq -0x38(%rbp), %rdi
callq 0xc282
movl %eax, -0x201e4(%rbp)
jmp 0xdff5
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xde9a
cmpb (%r12,%rcx), %dl
jne 0xde9a
movb 0x1(%rcx,%rbx), %dl
incq %rcx
cmpq $0x8, %rcx
jne 0xde3a
cmpl $0x8, %r15d
jne 0xde9a
testq %r14, %r14
je 0xe22f
leaq -0x68(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xed70
movq -0x40(%rbp), %r14
movq -0x201c8(%rbp), %rsi
cmpq -0x201c0(%rbp), %rsi
je 0xdfc4
movq -0x68(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, -0x201c8(%rbp)
jmp 0xdfd4
movb $0x2d, %dl
xorl %ecx, %ecx
movq %r14, %rsi
movq -0x40(%rbp), %r14
cmpq %rcx, %rax
je 0xdee1
cmpb (%r12,%rcx), %dl
jne 0xdee1
movb 0x1(%rcx,%r11), %dl
incq %rcx
cmpq $0x5, %rcx
jne 0xdea5
cmpl $0x5, %r15d
jne 0xdee1
testq %rsi, %rsi
je 0xe23e
leaq -0x38(%rbp), %rdi
callq 0xc282
movl %eax, -0x201e8(%rbp)
jmp 0xdff5
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdf08
cmpb (%r12,%rcx), %dl
jne 0xdf08
movb 0x1(%rcx,%r10), %dl
incq %rcx
cmpq $0x6, %rcx
jne 0xdee5
cmpl $0x6, %r15d
je 0xe14f
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdf3d
cmpb (%r12,%rcx), %dl
jne 0xdf3d
movb 0x1(%rcx,%r9), %dl
incq %rcx
cmpq $0xa, %rcx
jne 0xdf0c
cmpl $0xa, %r15d
jne 0xdf3d
movb $0x1, -0x201dc(%rbp)
movl -0x48(%rbp), %eax
movl %eax, %r14d
jmp 0xdff5
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xdf64
cmpb (%r12,%rcx), %dl
jne 0xdf64
movb 0x1(%rcx,%r8), %dl
incq %rcx
cmpq $0x9, %rcx
jne 0xdf41
cmpl $0x9, %r15d
je 0xe1e7
movb $0x2d, %dl
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xe062
cmpb (%r12,%rcx), %dl
jne 0xe062
movb 0x1(%rcx,%rdi), %dl
incq %rcx
cmpq $0x9, %rcx
jne 0xdf68
cmpl $0x9, %r15d
jne 0xe062
movl $0xffffffff, -0x201e0(%rbp) # imm = 0xFFFFFFFF
movl $0x14, %r12d
testq %rsi, %rsi
je 0xe143
leaq -0x38(%rbp), %rdi
callq 0xc282
movl %eax, -0x201e0(%rbp)
cmpl $0x21, %eax
jb 0xdff5
jmp 0xe143
leaq -0x201d0(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe646
cmpl $0x0, -0x201f0(%rbp)
jne 0xdff5
leaq 0xa0f9(%rip), %rax      # 0x180dd
movq %rax, -0x201f8(%rbp)
movl $0x7, -0x201f0(%rbp)
incl %r14d
movl %r14d, %eax
movl -0x44(%rbp), %ebx
cmpl %ebx, %r14d
movq -0x80(%rbp), %r13
jl 0xdd3b
jmp 0xe02e
movq %rax, %r15
cmpl $0x1, %edx
jne 0xe411
movq %r15, %rdi
callq 0x8120
callq 0x8450
movl -0x201e0(%rbp), %eax
jmp 0xdfba
cmpl $0x0, -0x201f0(%rbp)
jne 0xe04f
leaq 0xa124(%rip), %rax      # 0x18162
movq %rax, -0x201f8(%rbp)
movl $0x9, -0x201f0(%rbp)
movl $0x1, %ebx
leaq -0x20208(%rbp), %rdi
callq 0xf75a
jmp 0xe0d2
movq 0xff67(%rip), %rdi      # 0x1dfd0
leaq 0xa0d4(%rip), %rsi      # 0x18144
movl $0xe, %edx
callq 0x8350
leaq -0x68(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc49c
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0xff35(%rip), %rdi      # 0x1dfd0
callq 0x8350
leaq 0xa0ac(%rip), %rsi      # 0x18153
movl $0xe, %edx
movq %rax, %rdi
callq 0x8350
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe0cd
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x8320
movl $0x1, %ebx
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0xe5b6
movq -0x18(%r14), %rdi
testq %rdi, %rdi
je 0xe0f9
movq -0xe8(%rbp), %rsi
subq %rdi, %rsi
callq 0x8320
movq -0x158(%rbp), %rdi
testq %rdi, %rdi
je 0xe114
movq -0x148(%rbp), %rsi
subq %rdi, %rsi
callq 0x8320
movq -0x201d0(%rbp), %rdi
testq %rdi, %rdi
je 0xe12f
movq -0x201c0(%rbp), %rsi
subq %rdi, %rsi
callq 0x8320
movl %ebx, %eax
addq $0x201e8, %rsp          # imm = 0x201E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9fe5(%rip), %rsi      # 0x1812f
jmp 0xe24b
movq 0xfe7a(%rip), %rdi      # 0x1dfd0
leaq 0x9544(%rip), %rsi      # 0x176a1
movl $0x6, %edx
callq 0x8350
movq 0xfe62(%rip), %rbx      # 0x1dfd0
leaq 0x98e4(%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 0xfe30(%rip), %rbx      # 0x1dfd0
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
movq 0x100f9(%rip), %r14     # 0x1e2b0
testq %r14, %r14
je 0xe264
movq %r14, %rdi
callq 0x8130
movq 0xfe01(%rip), %rdi      # 0x1dfd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xe27b
movl $0xb, %r12d
jmp 0xe24b
movq 0xfde2(%rip), %rbx      # 0x1dfd0
leaq 0x9864(%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 0xfdb0(%rip), %rdi      # 0x1dfd0
callq 0x8040
movq %rax, %rdi
callq 0x81f0
jmp 0xe27b
movl $0xb, %r12d
leaq 0x9ea9(%rip), %rsi      # 0x180e5
jmp 0xe24b
movl $0x11, %r12d
leaq 0x9eac(%rip), %rsi      # 0x180f7
movl $0x1, %ebx
movq 0xfd79(%rip), %rdi      # 0x1dfd0
movq %r12, %rdx
callq 0x8350
jmp 0xe0d2
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x8470
xorl %ebx, %ebx
jmp 0xe0d2
jmp 0xe3f0
movq %rax, %r15
cmpl $0x1, %edx
jne 0xe411
movq %r15, %rdi
callq 0x8120
movq 0xfd2e(%rip), %rdi      # 0x1dfd0
leaq 0x9e0c(%rip), %rsi      # 0x180b5
movl $0x12, %edx
callq 0x8350
movl $0x1, %ebx
callq 0x8450
jmp 0xe0d2
jmp 0xe3f0
movq %rax, %r15
callq 0x8450
jmp 0xe411
movq %rax, %r15
cmpl $0x1, %edx
jne 0xe411
movq %r15, %rdi
callq 0x8120
movq 0xfce1(%rip), %rdi      # 0x1dfd0
leaq 0x9e01(%rip), %rsi      # 0x180f7
movl $0x11, %edx
callq 0x8350
movl $0x1, %ebx
callq 0x8450
jmp 0xe0d2
jmp 0xe3f0
movq %rax, %r15
callq 0x8450
jmp 0xe411
jmp 0xe3f0
jmp 0xe3f0
jmp 0xe3f0
movq %rax, %r15
cmpl $0x1, %edx
jne 0xe362
movq %r15, %rdi
callq 0x8120
testb $0x1, -0x201e8(%rbp)
je 0xe358
leaq 0x9e2e(%rip), %rsi      # 0x1817e
movq %rax, %rdi
callq 0xcf80
callq 0x8450
jmp 0xe0d2
cmpl $0x2, %edx
jne 0xe411
movq %r15, %rdi
callq 0x8120
testb $0x1, -0x201e8(%rbp)
je 0xe3c6
movq %rax, %r14
callq 0x163f5
movq 0xfc45(%rip), %rdi      # 0x1dfd0
movq %rax, %rsi
callq 0x8300
movq %rax, %r15
leaq 0x9dcf(%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
jmp 0xe0d2
movq %rax, %r15
callq 0x8450
jmp 0xe411
jmp 0xe3f0
jmp 0xe3f0
movq %rax, %r15
callq 0x8450
jmp 0xe411
movq %rax, %rdi
callq 0xc1cb
movq %rax, %r15
jmp 0xe411
movq %rax, %r15
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe411
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x8320
leaq -0x20208(%rbp), %rdi
callq 0xe548
movq %r15, %rdi
callq 0x84a0
nop