// File: QZzcoder[P]LiveChat/SocketManager.cpp
// Function: mySelect(fd_set&, std::set<int, std::less<int>, std::allocator<int>>, int)
int mySelect(fd_set& fds,set<int> fd,int usec){
    timeval timeout = {0};
    timeout.tv_usec = usec;
    FD_ZERO(&fds);
    int maxfd = 0;
    for(int i:fd){
        maxfd = maxfd>i?maxfd:i;
        FD_SET(i,&fds);
    }
    switch(select(maxfd+1,&fds,NULL,NULL,&timeout)){
        case -1:{
            cout<<"select error";
            exit(1);
        }case 0:break;
        default:{
            for(int i:fd){
                if(FD_ISSET(i,&fds)){
                    return i;
                }
            }
        }
    }
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rsi, -0x90(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x20f0
movslq -0x1c(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpq $0x10, %rax
jae 0x4137
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4114
jmp 0x4139
movq -0x90(%rbp), %rax
movl $0x0, -0x44(%rbp)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x44f0
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x4520
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4550
testb $0x1, %al
jne 0x417b
jmp 0x420b
leaq -0x58(%rbp), %rdi
callq 0x4580
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x64(%rbp), %eax
jle 0x419c
movl -0x44(%rbp), %eax
movl %eax, -0x94(%rbp)
jmp 0x41a5
movl -0x64(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x64(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x64(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xa8(%rbp), %rdx
movl %eax, %ecx
movq -0xa0(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
leaq -0x58(%rbp), %rdi
callq 0x45b0
jmp 0x4165
movl -0x44(%rbp), %edi
incl %edi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x30(%rbp), %r8
movq %rcx, %rdx
callq 0x21a0
movl %eax, %ecx
movl %ecx, -0xac(%rbp)
subl $-0x1, %eax
je 0x423f
jmp 0x4233
movl -0xac(%rbp), %eax
testl %eax, %eax
je 0x425c
jmp 0x4261
movq 0x4d8a(%rip), %rdi      # 0x8fd0
leaq 0x1e52(%rip), %rsi      # 0x609f
callq 0x21b0
movl $0x1, %edi
callq 0x2240
jmp 0x4325
movq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x44f0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x4520
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4550
testb $0x1, %al
jne 0x429c
jmp 0x4323
leaq -0x78(%rbp), %rdi
callq 0x4580
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x84(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb8(%rbp)
movl -0x84(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xb8(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x4313
movl -0x84(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x432c
jmp 0x4315
leaq -0x78(%rbp), %rdi
callq 0x45b0
jmp 0x4286
jmp 0x4325
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)