// File: /workspace/github_cpp_makefile_star2_O1/huanghuide[P]SimpleNetworkTunnel/Main.cpp
// Function: main
int main(int argc, char *argv[])
{
    fd_set readFdSet;
    fd_set writeFdSet;
    struct timeval timeout;
    int ret;

    gLog.Write("---------------------");
    gLog.Write("BBServer start !!!!!!");
    gLog.Write("---------------------");

    signal(SIGPIPE, SIG_IGN);
    ParseParamsAndInit(argc, argv);

    while (!gStopFlag)
    {
        FD_ZERO(&readFdSet);         
        readFdSet = gReadSockFdSet;
        writeFdSet = gWriteSockFdSet;

        timeout.tv_sec = 0;
        timeout.tv_usec = 100000;

        ret = select(gMaxSockFd + 1, &readFdSet, NULL, NULL, &timeout);

        if (ret > 0)
        {
            for (int sockFd = gMaxSockFd; sockFd > 0; sockFd--)
            {
                if (FD_ISSET(sockFd, &readFdSet))
                {
                    Runner* pRunner = gRunnerManager.FindRunnerByFd(sockFd);
                    
                    if (pRunner != NULL)
                    {
                        pRunner->SocketRead(sockFd);
                    }

                    FD_CLR(sockFd, &readFdSet);
                }

                if (FD_ISSET(sockFd, &writeFdSet))
                {
                    Runner* pRunner = gRunnerManager.FindRunnerByFd(sockFd);
                    
                    if (pRunner != NULL)
                    {
                        pRunner->SocketWrite(sockFd);
                    }
                
                    FD_CLR(sockFd, &writeFdSet);
                }
            }
        }
        else if (ret == 0)
        {
            gRunnerManager.RunnerTimeout();
        }
    }

    gLog.Write("~~~~~~~~~~~~~~~~~~~");
    gLog.Write("BBServer end !!!!!!");
    gLog.Write("~~~~~~~~~~~~~~~~~~~");
    gLog.Write("                   ");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, %rbx
movl %edi, %r14d
leaq -0x108(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x257d(%rip), %rsi      # 0x6366
leaq 0x258b(%rip), %rdx      # 0x637b
leaq -0x118(%rbp), %r15
movq %r15, %rdi
callq 0x2a2c
leaq 0x7052(%rip), %rdi      # 0xae58
movq %r15, %rsi
callq 0x38c4
movq -0x118(%rbp), %rdi
cmpq %r12, %rdi
je 0x3e29
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0xe8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x2540(%rip), %rsi      # 0x637c
leaq 0x254e(%rip), %rdx      # 0x6391
leaq -0xf8(%rbp), %r15
movq %r15, %rdi
callq 0x2a2c
leaq 0x6fff(%rip), %rdi      # 0xae58
movq %r15, %rsi
callq 0x38c4
movq -0xf8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3e7c
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x24d7(%rip), %rsi      # 0x6366
leaq 0x24e5(%rip), %rdx      # 0x637b
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
callq 0x2a2c
leaq 0x6fac(%rip), %rdi      # 0xae58
movq %r15, %rsi
callq 0x38c4
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3ecf
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2290
movl $0x1, %esi
movl $0xd, %edi
callq 0x22f0
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3c02
leaq 0x5330(%rip), %rax      # 0x9220
cmpb $0x0, (%rax)
jne 0x4061
leaq 0x70a0(%rip), %rbx      # 0xafa0
xorps %xmm0, %xmm0
movaps %xmm0, -0x130(%rbp)
movaps %xmm0, -0x140(%rbp)
movaps %xmm0, -0x150(%rbp)
movaps %xmm0, -0x160(%rbp)
movaps %xmm0, -0x170(%rbp)
movaps %xmm0, -0x180(%rbp)
movaps %xmm0, -0x190(%rbp)
movaps %xmm0, -0x1a0(%rbp)
movl $0x10, %ecx
leaq -0x1a0(%rbp), %rax
movq %rax, %rdi
leaq 0x6f4f(%rip), %rsi      # 0xaea0
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
leaq -0x220(%rbp), %rdi
leaq 0x6fb9(%rip), %rsi      # 0xaf20
rep  movsq (%rsi), %es:(%rdi)
movq $0x0, -0x38(%rbp)
movq $0x186a0, -0x30(%rbp)   # imm = 0x186A0
movl (%rbx), %edi
incl %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq -0x38(%rbp), %r8
callq 0x2250
testl %eax, %eax
jle 0x403c
movl (%rbx), %r15d
testl %r15d, %r15d
jle 0x404a
movl %r15d, %r13d
shrl $0x6, %r13d
movl $0x1, %r12d
movl %r15d, %ecx
shlq %cl, %r12
movq -0x1a0(%rbp,%r13,8), %rax
btq %r15, %rax
movq %r12, %r14
notq %r14
jae 0x3ff1
leaq 0x6e90(%rip), %rdi      # 0xae60
movl %r15d, %esi
callq 0x4ca6
testq %rax, %rax
je 0x3fe9
movq (%rax), %rcx
movq %rax, %rdi
movl %r15d, %esi
callq *0x10(%rcx)
andq %r14, -0x1a0(%rbp,%r13,8)
movq -0x220(%rbp,%r13,8), %rbx
testq %r12, %rbx
je 0x4029
leaq 0x6e5b(%rip), %rdi      # 0xae60
movl %r15d, %esi
callq 0x4ca6
testq %rax, %rax
je 0x401e
movq (%rax), %rcx
movq %rax, %rdi
movl %r15d, %esi
callq *0x18(%rcx)
andq %r14, %rbx
movq %rbx, -0x220(%rbp,%r13,8)
leal -0x1(%r15), %eax
cmpl $0x1, %r15d
movl %eax, %r15d
jg 0x3fa2
jmp 0x404a
jne 0x404a
leaq 0x6e1b(%rip), %rdi      # 0xae60
callq 0x4cf4
leaq 0x51cf(%rip), %rax      # 0x9220
cmpb $0x1, (%rax)
leaq 0x6f45(%rip), %rbx      # 0xafa0
jne 0x3f00
leaq -0xa8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x231e(%rip), %rsi      # 0x6392
leaq 0x232a(%rip), %rdx      # 0x63a5
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2c
leaq 0x6dc7(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x38c4
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
je 0x40b4
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0x88(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x22df(%rip), %rsi      # 0x63a6
leaq 0x22eb(%rip), %rdx      # 0x63b9
leaq -0x98(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2c
leaq 0x6d74(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x38c4
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x4107
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x227b(%rip), %rsi      # 0x6392
leaq 0x2287(%rip), %rdx      # 0x63a5
leaq -0x78(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2c
leaq 0x6d27(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x38c4
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x414e
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0x48(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x225c(%rip), %rsi      # 0x63ba
leaq 0x2268(%rip), %rdx      # 0x63cd
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2c
leaq 0x6ce0(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x38c4
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x4195
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2290
xorl %eax, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x58(%rbp), %rdi
jmp 0x41f5
movq %rax, %rbx
movq -0x78(%rbp), %rdi
jmp 0x41f5
movq %rax, %rbx
movq -0x98(%rbp), %rdi
jmp 0x41f5
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
jmp 0x41f5
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0x41f5
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
jmp 0x41f5
movq %rax, %rbx
movq -0x118(%rbp), %rdi
cmpq %r12, %rdi
je 0x4206
movq (%r12), %rsi
incq %rsi
callq 0x2290
movq %rbx, %rdi
callq 0x2380
nop