// File: wenzhelu[P]RUDP/Listener.cpp
// Function: Listener::getTimeout(int)
void Listener::getTimeout(int ack)
{
    tp end=std::chrono::system_clock::now();
    tp start;
    if(master->startTimes.find(ack)==master->startTimes.end()) {
        return;
    }
    else
    {
        start=master->startTimes.at(ack);
        master->startTimes.erase(master->startTimes.begin(),++master->startTimes.find(ack));
    }
    
    
    this->sRTT=ms((end - start).count()/1000000);
    int u,phi,delta;
    u=1;
    phi=4;
    delta=2;
    this->eRTT=this->eRTT+std::chrono::milliseconds((this->sRTT.count()-this->eRTT.count())/delta);
    this->deviation=this->deviation+std::chrono::milliseconds(abs(this->sRTT.count()-this->eRTT.count())/delta-this->deviation.count());
    master->TimeOut=u*this->eRTT.count()+phi*this->deviation.count();
    master->RTT=this->eRTT.count();
//    debug_print("Timeout: %u, RTT: %u, sRTT: %u, all in ms\n", master->TimeOut, master->RTT, sRTT.count());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0x2060
movq %rax, -0x18(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x3540
movq -0xd0(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x20, %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq -0x2c(%rbp), %rsi
callq 0x35a0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq 0x20(%rax), %rdi
addq $0x20, %rdi
callq 0x35d0
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3570
testb $0x1, %al
jne 0x2f2f
jmp 0x2f34
jmp 0x3213
movq -0xd0(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x20, %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x3c(%rbp), %rsi
callq 0x3600
movq %rax, %rcx
movq -0xd0(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, -0xd8(%rbp)
movq 0x20(%rax), %rdi
addq $0x20, %rdi
callq 0x36f0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3720
movq -0xd0(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x20, %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x64(%rbp)
leaq -0x64(%rbp), %rsi
callq 0x35a0
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3740
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x3720
movq -0xd8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x36a0
movq %rax, -0x70(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3770
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x37c0
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x37e0
movq -0xd0(%rbp), %rdi
movq -0x78(%rbp), %rax
movq %rax, 0x10(%rdi)
movl $0x1, -0x8c(%rbp)
movl $0x4, -0x90(%rbp)
movl $0x2, -0x94(%rbp)
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x110(%rbp)
addq $0x10, %rdi
callq 0x3870
movq -0xd0(%rbp), %rdi
movq %rax, -0x118(%rbp)
addq $0x8, %rdi
callq 0x3870
movq %rax, %rcx
movq -0x118(%rbp), %rax
subq %rcx, %rax
movslq -0x94(%rbp), %rcx
cqto
idivq %rcx
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x37e0
movq -0x110(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3800
movq -0xd0(%rbp), %rdi
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, 0x8(%rdi)
movq %rdi, %rax
addq $0x18, %rax
movq %rax, -0xf8(%rbp)
addq $0x10, %rdi
callq 0x3870
movq -0xd0(%rbp), %rdi
movq %rax, -0x108(%rbp)
addq $0x8, %rdi
callq 0x3870
movq -0x108(%rbp), %rdi
subq %rax, %rdi
callq 0x3890
movq -0xd0(%rbp), %rdi
movslq -0x94(%rbp), %rcx
cqto
idivq %rcx
movq %rax, -0x100(%rbp)
addq $0x18, %rdi
callq 0x3870
movq %rax, %rcx
movq -0x100(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x37e0
movq -0xf8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3800
movq -0xd0(%rbp), %rdi
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, 0x18(%rdi)
movslq -0x8c(%rbp), %rax
movq %rax, -0xf0(%rbp)
addq $0x8, %rdi
callq 0x3870
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movq -0xf0(%rbp), %rax
imulq %rcx, %rax
movq %rax, -0xe0(%rbp)
movslq -0x90(%rbp), %rax
movq %rax, -0xe8(%rbp)
addq $0x18, %rdi
callq 0x3870
movq -0xe8(%rbp), %rcx
movq -0xd0(%rbp), %rdi
movq %rax, %rdx
movq -0xe0(%rbp), %rax
imulq %rdx, %rcx
addq %rcx, %rax
movl %eax, %ecx
movq 0x20(%rdi), %rax
movl %ecx, 0x18(%rax)
addq $0x8, %rdi
callq 0x3870
movq %rax, %rcx
movq -0xd0(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x14(%rax)
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)