// File: yahoo[P]UDPing/src/serversession.cc
// Function: ServerSessionManager::sweepServerSessions()
void ServerSessionManager::sweepServerSessions () {
    int ix;
    time_t now = time(0);
    for (map<string, ServerSession*>::iterator it = sessionMap.begin(); it != sessionMap.end(); it++) {
        ServerSession* ds = it->second;
        if (ds) {
            if (ds->getLastArrival() < now - keepalive) {
                // If the session has a successor, set the max packet index to one before the
                // successor's minimum index to detect gaps in the packet sequence between sessions
                if (sessionMap.find(ds->getSuccessor()) != sessionMap.end()) {
                    ServerSession* successor = sessionMap[ds->getSuccessor()];
                    if (successor) {
                        ds->recordSeq(successor->getMinSeq() - 1);
                    }
                }
                ds->writeStats();
                delete ds;
                sessionMap.erase(it->first);
            }
        } else {
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x22d0
movq -0xa8(%rbp), %rdi
movq %rax, -0x18(%rbp)
callq 0x5d70
movq %rax, -0x20(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x5dd0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5da0
testb $0x1, %al
jne 0x539d
jmp 0x557c
leaq -0x20(%rbp), %rdi
callq 0x5e00
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x5561
movq -0x30(%rbp), %rdi
callq 0x5e20
movq -0xa8(%rbp), %rdx
movq -0x18(%rbp), %rcx
movslq 0xa0(%rdx), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jge 0x555f
movq -0x30(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x5e70
movq -0xa8(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x5e40
movq %rax, -0xb0(%rbp)
jmp 0x5410
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq %rax, -0x38(%rbp)
callq 0x5dd0
movq %rax, -0x70(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5da0
movb %al, -0xb9(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x21e0
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x5456
jmp 0x5515
movq -0x30(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x5e70
movq -0xa8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x5c40
movq %rax, -0xc8(%rbp)
jmp 0x5489
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x21e0
movq -0xd8(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x5513
movq -0x30(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x78(%rbp), %rdi
callq 0x5ea0
movq -0xe0(%rbp), %rdi
movl %eax, %esi
subl $0x1, %esi
callq 0x4ce0
jmp 0x5513
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x21e0
jmp 0x5585
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x21e0
jmp 0x5585
jmp 0x5515
movq -0x30(%rbp), %rdi
callq 0x4c90
movq -0x30(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
je 0x5547
movq -0xe8(%rbp), %rdi
callq 0x4c20
movq -0xe8(%rbp), %rdi
callq 0x22f0
leaq -0x20(%rbp), %rdi
callq 0x5e00
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x5ec0
jmp 0x5563
jmp 0x557c
jmp 0x5565
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x5ef0
movq %rax, -0xa0(%rbp)
jmp 0x5377
addq $0xf0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x24b0
nop