// File: fieryzig[P]GameServer/GateServer/GateServer.cpp
// Function: fieryzig::GateServer::Run()
void GateServer::Run()
{
    int n = epoll_wait(epfd, events, 20, 500);
	for (int i = 0; i < n; i++) {
	    if (events[i].data.fd == listenfd) {
		    acceptConnect();
	    }
        else if (events[i].events & EPOLLERR) {
            close(((Client*)events[i].data.ptr)->fd);
        }
	    else {
            Client *cli = (Client*)events[i].data.ptr;
            int ret = cli->Recv();
            PacketInfo pi; string content = "";
            while ( cli->hasMsg(&pi,content) ) {
                Dispatch(cli, &pi, content);
            }
	    }
	}

	set<Client*>::iterator it;

	for (it = Clients.begin(); it != Clients.end(); it++) {
	    (*it)->SendRemain();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xb8(%rbp)
movl 0x10(%rsi), %edi
addq $0x28, %rsi
movl $0x14, %edx
movl $0x1f4, %ecx            # imm = 0x1F4
callq 0x2150
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2a0d
movq -0xb8(%rbp), %rcx
movq %rcx, %rax
addq $0x28, %rax
movslq -0x10(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl 0x4(%rax), %eax
cmpl 0x14(%rcx), %eax
jne 0x2889
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x29fd
movq -0xb8(%rbp), %rax
addq $0x28, %rax
movslq -0x10(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x28d3
movq -0xb8(%rbp), %rax
addq $0x28, %rax
movslq -0x10(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq 0x4(%rax), %rax
movl 0x2020(%rax), %edi
callq 0x2440
jmp 0x29fb
movq -0xb8(%rbp), %rax
movslq -0x10(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x2c(%rax,%rcx,4), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0xc7d0
movl %eax, -0x1c(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x23e0
movq -0xc0(%rbp), %rdx
leaq 0xe52f(%rip), %rsi      # 0x10e44
leaq -0x58(%rbp), %rdi
callq 0x2320
jmp 0x2920
leaq -0x59(%rbp), %rdi
callq 0x2290
movq -0x18(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xc860
movb %al, -0xc1(%rbp)
jmp 0x2942
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x2951
jmp 0x29e2
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2120
jmp 0x296e
movq -0xd0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
leaq -0x34(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq *%rax
jmp 0x2992
leaq -0x90(%rbp), %rdi
callq 0x21a0
jmp 0x2929
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x2290
jmp 0x2aa8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x29ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x21a0
jmp 0x29ed
leaq -0x58(%rbp), %rdi
callq 0x21a0
jmp 0x29fb
leaq -0x58(%rbp), %rdi
callq 0x21a0
jmp 0x2aa8
jmp 0x29fd
jmp 0x29ff
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x284a
leaq -0x98(%rbp), %rdi
callq 0x3a30
movq -0xb8(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x3a50
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xb8(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x3ab0
movq %rax, -0xa8(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3a80
testb $0x1, %al
jne 0x2a74
jmp 0x2a9f
leaq -0x98(%rbp), %rdi
callq 0x3ae0
movq (%rax), %rdi
callq 0xcb40
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x3b10
movq %rax, -0xb0(%rbp)
jmp 0x2a41
addq $0xd0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x23d0
nopw %cs:(%rax,%rax)