// File: /workspace/github_cpp_makefile_star2_O3/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 0x25c5(%rip), %rsi      # 0x6366
leaq 0x25d3(%rip), %rdx      # 0x637b
leaq -0x118(%rbp), %r15
movq %r15, %rdi
callq 0x2a2e
leaq 0x709a(%rip), %rdi      # 0xae58
movq %r15, %rsi
callq 0x387c
movq -0x118(%rbp), %rdi
cmpq %r12, %rdi
je 0x3de1
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0xe8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x2588(%rip), %rsi      # 0x637c
leaq 0x2596(%rip), %rdx      # 0x6391
leaq -0xf8(%rbp), %r15
movq %r15, %rdi
callq 0x2a2e
leaq 0x7047(%rip), %rdi      # 0xae58
movq %r15, %rsi
callq 0x387c
movq -0xf8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3e34
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x251f(%rip), %rsi      # 0x6366
leaq 0x252d(%rip), %rdx      # 0x637b
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
callq 0x2a2e
leaq 0x6ff4(%rip), %rdi      # 0xae58
movq %r15, %rsi
callq 0x387c
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3e87
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2290
movl $0x1, %esi
movl $0xd, %edi
callq 0x22f0
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3bba
leaq 0x5378(%rip), %rax      # 0x9220
cmpb $0x0, (%rax)
jne 0x3fde
leaq 0x70e8(%rip), %rbx      # 0xafa0
movl $0x10, %ecx
leaq -0x218(%rbp), %rax
movq %rax, %rdi
leaq 0x6fd2(%rip), %rsi      # 0xaea0
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
leaq -0x198(%rbp), %rdi
leaq 0x703c(%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 0x3fb9
movl (%rbx), %r15d
testl %r15d, %r15d
jle 0x3fc7
movl %r15d, %r13d
shrl $0x6, %r13d
movl $0x1, %r12d
movl %r15d, %ecx
shlq %cl, %r12
movq -0x218(%rbp,%r13,8), %rax
btq %r15, %rax
movq %r12, %r14
notq %r14
jae 0x3f6e
leaq 0x6f13(%rip), %rdi      # 0xae60
movl %r15d, %esi
callq 0x4c02
testq %rax, %rax
je 0x3f66
movq (%rax), %rcx
movq %rax, %rdi
movl %r15d, %esi
callq *0x10(%rcx)
andq %r14, -0x218(%rbp,%r13,8)
movq -0x198(%rbp,%r13,8), %rbx
testq %r12, %rbx
je 0x3fa6
leaq 0x6ede(%rip), %rdi      # 0xae60
movl %r15d, %esi
callq 0x4c02
testq %rax, %rax
je 0x3f9b
movq (%rax), %rcx
movq %rax, %rdi
movl %r15d, %esi
callq *0x18(%rcx)
andq %r14, %rbx
movq %rbx, -0x198(%rbp,%r13,8)
leal -0x1(%r15), %eax
cmpl $0x1, %r15d
movl %eax, %r15d
jg 0x3f1f
jmp 0x3fc7
jne 0x3fc7
leaq 0x6e9e(%rip), %rdi      # 0xae60
callq 0x4c44
leaq 0x5252(%rip), %rax      # 0x9220
cmpb $0x1, (%rax)
leaq 0x6fc8(%rip), %rbx      # 0xafa0
jne 0x3eb8
leaq -0xa8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x23a1(%rip), %rsi      # 0x6392
leaq 0x23ad(%rip), %rdx      # 0x63a5
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2e
leaq 0x6e4a(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x387c
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
je 0x4031
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0x88(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x2362(%rip), %rsi      # 0x63a6
leaq 0x236e(%rip), %rdx      # 0x63b9
leaq -0x98(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2e
leaq 0x6df7(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x387c
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x4084
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x22fe(%rip), %rsi      # 0x6392
leaq 0x230a(%rip), %rdx      # 0x63a5
leaq -0x78(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2e
leaq 0x6daa(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x387c
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x40cb
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2290
leaq -0x48(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x22df(%rip), %rsi      # 0x63ba
leaq 0x22eb(%rip), %rdx      # 0x63cd
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a2e
leaq 0x6d63(%rip), %rdi      # 0xae58
movq %rbx, %rsi
callq 0x387c
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x4112
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 0x4172
movq %rax, %rbx
movq -0x78(%rbp), %rdi
jmp 0x4172
movq %rax, %rbx
movq -0x98(%rbp), %rdi
jmp 0x4172
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
jmp 0x4172
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0x4172
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
jmp 0x4172
movq %rax, %rbx
movq -0x118(%rbp), %rdi
cmpq %r12, %rdi
je 0x4183
movq (%r12), %rsi
incq %rsi
callq 0x2290
movq %rbx, %rdi
callq 0x2380
nop