// File: BrianYi[P]timer/src/AdvanceTimeWheel.h
// Function: AdvanceTimeWheel::addTimer(TimerInterface*)
void addTimer(TimerInterface* timer)
    {
        int timespan = timer->getTimeSpan();
        int passedSec = timespan / fSecFreq;
        ListNode *node = new ListNode;
        node->timer = timer;
        node->sec = fSecPtr + passedSec;
        node->min = fMinPtr + node->sec / fSecWheelSize;
        node->hour = fHourPtr + node->min / fMinWheelSize;
        node->sec %= fSecWheelSize;
        node->min %= fMinWheelSize;
        node->hour %= fHourWheelSize;
        if (node->hour > fHourPtr)
            fHourWheel[node->hour].push(node);
        else if (node->min > fMinPtr)
            fMinWheel[node->min].push(node);
        else if (node->sec > fSecPtr)
            fSecWheel[node->sec].push(node);
        else
            printf("error: %d:%s\r\n", __LINE__, __FUNCTION__);
        
        fTotalTimerNum++;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2d90
movq -0x40(%rbp), %rcx
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl 0xc(%rcx), %ecx
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movl $0x18, %edi
callq 0x20a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x38(%rbp)
callq 0x6e90
jmp 0x336f
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rax
movq %rdx, (%rax)
movl 0x14(%rcx), %edx
addl -0x18(%rbp), %edx
movq -0x20(%rbp), %rax
movl %edx, 0x10(%rax)
movl 0x1c(%rcx), %eax
movl %eax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
cltd
idivl 0x10(%rcx)
movl -0x60(%rbp), %edx
addl %eax, %edx
movq -0x20(%rbp), %rax
movl %edx, 0xc(%rax)
movl 0x24(%rcx), %eax
movl %eax, -0x5c(%rbp)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
cltd
idivl 0x18(%rcx)
movl -0x5c(%rbp), %edx
addl %eax, %edx
movq -0x20(%rbp), %rax
movl %edx, 0x8(%rax)
movl 0x10(%rcx), %esi
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movl 0x10(%rax), %eax
cltd
idivl %esi
movq -0x58(%rbp), %rax
movl %edx, 0x10(%rax)
movl 0x18(%rcx), %esi
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movl 0xc(%rax), %eax
cltd
idivl %esi
movq -0x50(%rbp), %rax
movl %edx, 0xc(%rax)
movl 0x20(%rcx), %esi
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movl 0x8(%rax), %eax
cltd
idivl %esi
movq -0x48(%rbp), %rax
movl %edx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
cmpl 0x24(%rcx), %eax
jle 0x3466
movq -0x40(%rbp), %rdi
addq $0x60, %rdi
movq -0x20(%rbp), %rax
movslq 0x8(%rax), %rsi
callq 0x6300
movq %rax, %rdi
leaq -0x20(%rbp), %rsi
callq 0x6430
jmp 0x34ea
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x18, %esi
callq 0x20b0
jmp 0x34ff
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
cmpl 0x1c(%rcx), %eax
jle 0x3499
movq -0x40(%rbp), %rdi
addq $0x48, %rdi
movq -0x20(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x6300
movq %rax, %rdi
leaq -0x20(%rbp), %rsi
callq 0x6430
jmp 0x34e8
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
cmpl 0x14(%rcx), %eax
jle 0x34cc
movq -0x40(%rbp), %rdi
addq $0x30, %rdi
movq -0x20(%rbp), %rax
movslq 0x10(%rax), %rsi
callq 0x6300
movq %rax, %rdi
leaq -0x20(%rbp), %rsi
callq 0x6430
jmp 0x34e6
leaq 0x3c8d(%rip), %rdi      # 0x7160
movl $0x5e, %esi
leaq 0x3c90(%rip), %rdx      # 0x716f
movb $0x0, %al
callq 0x2030
jmp 0x34e8
jmp 0x34ea
movq -0x40(%rbp), %rdi
addq $0x28, %rdi
xorl %esi, %esi
callq 0x6ec0
addq $0x60, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2120
nopl (%rax,%rax)