// File: renzibei[P]TSProxy/proxyserver.cpp
// Function: cleanDeadClients(std::unordered_map<int, ClientNode*, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, ClientNode*>>>&, std::unordered_map<int, HostNode, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, HostNode>>>&, fd_set&, fd_set&, int&, int&, int&)
void cleanDeadClients(ClientMap &cMap, HostMap &h2lMap, fd_set &readSet, fd_set &writeSet, int &max_read_sd, int &max_write_sd, int &max_all_sd) {
    time_t now = time(NULL);
    for (auto it = cMap.begin(); it != cMap.end(); ) {
        if (now - it->second->lastTime > constants::ClientTimeOutSeconds) {
            LogHelper::log(Debug, "Clean timeout client fd: %d", it->first);
            cleanDeadLocalFds(it->first, h2lMap, it->second->sMap, readSet, writeSet, max_read_sd, max_write_sd, max_all_sd, true);
            eraseClientFromFdSet(it->first, readSet, max_read_sd, max_write_sd, max_all_sd);
            delete it->second;
            it = cMap.erase(it);
        }
        else {
            cleanDeadLocalFds(it->first, h2lMap, it->second->sMap, readSet, writeSet, max_read_sd, max_write_sd, max_all_sd);
            it++;
        }
    }
}

// Assembly:
subq $0xa8, %rsp
movq 0xb0(%rsp), %rax
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq %rcx, 0x88(%rsp)
movq %r8, 0x80(%rsp)
movq %r9, 0x78(%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x21c0
movq %rax, 0x70(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x5b30
movq %rax, 0x68(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x5b80
movq %rax, 0x60(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x5b60
testb $0x1, %al
jne 0x40d6
jmp 0x42af
movq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq 0x8(%rcx), %rcx
subq 0x10(%rcx), %rax
cmpq $0x78, %rax
jle 0x4223
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movl (%rax), %edx
movl $0x3, %edi
leaq 0xc521(%rip), %rsi      # 0x1063d
movb $0x0, %al
callq 0x28f0
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movl 0x2c(%rsp), %edi
movq 0x30(%rsp), %rsi
movq 0x8(%rax), %rdx
addq $0x18, %rdx
movq 0x90(%rsp), %rcx
movq 0x88(%rsp), %r8
movq 0x80(%rsp), %r9
movq 0x78(%rsp), %r10
movq 0xb0(%rsp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0x3d30
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movl (%rax), %edi
movq 0x90(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x78(%rsp), %rax
movl (%rax), %ecx
movq 0xb0(%rsp), %r8
callq 0x3c20
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0x41f3
movq 0x38(%rsp), %rdi
callq 0x5bd0
movq 0x38(%rsp), %rdi
callq 0x21d0
movq 0xa0(%rsp), %rdi
movq 0x68(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rsi
callq 0x5bf0
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x42aa
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x5bb0
movl 0x1c(%rsp), %edi
movq 0x20(%rsp), %rsi
movq 0x8(%rax), %rdx
addq $0x18, %rdx
movq 0x90(%rsp), %rcx
movq 0x88(%rsp), %r8
movq 0x80(%rsp), %r9
movq 0x78(%rsp), %r10
movq 0xb0(%rsp), %rax
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x3d30
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
callq 0x5c30
movq %rax, 0x48(%rsp)
jmp 0x40ac
addq $0xa8, %rsp
retq
nopw (%rax,%rax)