// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movl %edi, %r15d
leaq 0x1954(%rip), %rsi      # 0x531e
leaq -0x120(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x6487(%rip), %rdi      # 0x9e68
leaq -0x120(%rbp), %rsi
callq 0x355c
leaq -0x120(%rbp), %rdi
callq 0x2140
leaq 0x1934(%rip), %rsi      # 0x5334
leaq -0x100(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x6451(%rip), %rdi      # 0x9e68
leaq -0x100(%rbp), %rsi
callq 0x355c
leaq -0x100(%rbp), %rdi
callq 0x2140
leaq 0x18e8(%rip), %rsi      # 0x531e
leaq -0xe0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x641b(%rip), %rdi      # 0x9e68
leaq -0xe0(%rbp), %rsi
callq 0x355c
leaq -0xe0(%rbp), %rdi
callq 0x2140
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x2300
movl %r15d, %edi
movq %r14, %rsi
callq 0x3814
leaq 0x47ae(%rip), %rax      # 0x8230
cmpb $0x0, (%rax)
jne 0x3bae
xorl %eax, %eax
leaq 0x651c(%rip), %rbx      # 0x9fb0
cmpq $0x10, %rax
je 0x3aa8
andq $0x0, -0x1a0(%rbp,%rax,8)
incq %rax
jmp 0x3a94
pushq $0x10
popq %rax
movq %rax, %rcx
leaq -0x1a0(%rbp), %rdx
movq %rdx, %rdi
leaq 0x63f1(%rip), %rsi      # 0x9eb0
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rcx
leaq -0x220(%rbp), %rdi
leaq 0x645d(%rip), %rsi      # 0x9f30
rep  movsq (%rsi), %es:(%rdi)
andq $0x0, -0x40(%rbp)
movq $0x186a0, -0x38(%rbp)   # imm = 0x186A0
movl (%rbx), %edi
incl %edi
movq %rdx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq -0x40(%rbp), %r8
callq 0x2260
testl %eax, %eax
jle 0x3b97
movl (%rbx), %r13d
testl %r13d, %r13d
jle 0x3a7b
movl %r13d, %r15d
shrl $0x6, %r15d
pushq $0x1
popq %rbx
movl %r13d, %ecx
shlq %cl, %rbx
movq -0x1a0(%rbp,%r15,8), %rax
btq %r13, %rax
movq %rbx, %r12
notq %r12
jae 0x3b57
leaq 0x633a(%rip), %rdi      # 0x9e70
movl %r13d, %esi
callq 0x45dc
testq %rax, %rax
je 0x3b4f
movq (%rax), %rcx
movq %rax, %rdi
movl %r13d, %esi
callq *0x10(%rcx)
andq %r12, -0x1a0(%rbp,%r15,8)
movq -0x220(%rbp,%r15,8), %r14
testq %rbx, %r14
je 0x3b8f
leaq 0x6305(%rip), %rdi      # 0x9e70
movl %r13d, %esi
callq 0x45dc
testq %rax, %rax
je 0x3b84
movq (%rax), %rcx
movq %rax, %rdi
movl %r13d, %esi
callq *0x18(%rcx)
andq %r12, %r14
movq %r14, -0x220(%rbp,%r15,8)
decl %r13d
jmp 0x3b02
jne 0x3a7b
leaq 0x62cc(%rip), %rdi      # 0x9e70
callq 0x4610
jmp 0x3a7b
leaq 0x1795(%rip), %rsi      # 0x534a
leaq -0xc0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x629c(%rip), %rdi      # 0x9e68
leaq -0xc0(%rbp), %rsi
callq 0x355c
leaq -0xc0(%rbp), %rdi
callq 0x2140
leaq 0x1773(%rip), %rsi      # 0x535e
leaq -0xa0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x6266(%rip), %rdi      # 0x9e68
leaq -0xa0(%rbp), %rsi
callq 0x355c
leaq -0xa0(%rbp), %rdi
callq 0x2140
leaq 0x1729(%rip), %rsi      # 0x534a
leaq -0x80(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x6233(%rip), %rdi      # 0x9e68
leaq -0x80(%rbp), %rsi
callq 0x355c
leaq -0x80(%rbp), %rdi
callq 0x2140
leaq 0x1724(%rip), %rsi      # 0x5372
leaq -0x60(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x28e4
leaq 0x6206(%rip), %rdi      # 0x9e68
leaq -0x60(%rbp), %rsi
callq 0x355c
leaq -0x60(%rbp), %rdi
callq 0x2140
xorl %eax, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
jmp 0x3ce0
jmp 0x3ce7
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
jmp 0x3ce0
jmp 0x3ce7
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0x3ce0
jmp 0x3ce7
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x3ce0
jmp 0x3ce7
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x3ce0
jmp 0x3ce7
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
jmp 0x3ce0
jmp 0x3ce7
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x2140
jmp 0x3cea
movq %rax, %rbx
movq %rbx, %rdi
callq 0x23a0
nop