// File: BrianYi[P]timer/src/AdvanceTimeWheel.h
// Function: AdvanceTimeWheel::run(int)
void run(int milliseconds)
    {
        fMilliSec += milliseconds;
        int passedSec = fMilliSec / fSecFreq;
        fMilliSec %= 1000;
        while (passedSec--)
        {
            fSecPtr=(fSecPtr+1)%fSecWheelSize;
#if 1
            printf("Time %02d:%02d:%02d\r\n", fHourPtr, fMinPtr, fSecPtr);
#endif
            while (!fSecWheel[fSecPtr].empty())
            {
                ListNode* node = fSecWheel[fSecPtr].front();
                fSecWheel[fSecPtr].pop();
                node->timer->callback();
                if (node->timer->needRepeat())
                {
                    addTimer(node->timer);
                }
                else
                {
                    delete node->timer;
                    fTotalTimerNum--;
                }
                delete node;
            }
            
            if ((fSecPtr+1)/fSecWheelSize)
            {
                fMinPtr=(fMinPtr+1)%fMinWheelSize;
                while (!fMinWheel[fMinPtr].empty())
                {
                    ListNode* minNode = fMinWheel[fMinPtr].front();
                    fMinWheel[fMinPtr].pop();
                    fSecWheel[minNode->sec].push(minNode);
                }

                if ((fMinPtr+1)/fMinWheelSize)
                {
                    fHourPtr=(fHourPtr+1)%fHourWheelSize;
                    while (!fHourWheel[fHourPtr].empty())
                    {
                        ListNode* hourNode = fHourWheel[fHourPtr].front();
                        fHourWheel[fHourPtr].pop();
                        fMinWheel[hourNode->min].push(hourNode);
                    }
                }
            }
        } 
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x30(%rbp)
movl -0xc(%rbp), %eax
addl 0x8(%rcx), %eax
movl %eax, 0x8(%rcx)
movl 0x8(%rcx), %eax
cltd
idivl 0xc(%rcx)
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, -0x10(%rbp)
movl 0x8(%rax), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
movq -0x30(%rbp), %rax
movl %edx, 0x8(%rax)
movl -0x10(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x10(%rbp)
cmpl $0x0, %eax
je 0x3dc0
movq -0x30(%rbp), %rcx
movl 0x14(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x10(%rcx)
movq -0x30(%rbp), %rax
movl %edx, 0x14(%rax)
movl 0x24(%rax), %esi
movl 0x1c(%rax), %edx
movl 0x14(%rax), %ecx
leaq 0x3573(%rip), %rdi      # 0x70ce
movb $0x0, %al
callq 0x2030
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x30, %rdi
movslq 0x14(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6320
xorb $-0x1, %al
testb $0x1, %al
jne 0x3b89
jmp 0x3c47
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x30, %rdi
movslq 0x14(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6340
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x18(%rbp)
movq %rax, %rdi
addq $0x30, %rdi
movslq 0x14(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6360
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x2dd0
testb $0x1, %al
jne 0x3bea
jmp 0x3bfc
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x3320
jmp 0x3c26
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x3c17
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x30(%rbp), %rdi
addq $0x28, %rdi
xorl %esi, %esi
callq 0x6380
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x3c42
movq -0x40(%rbp), %rdi
movl $0x18, %esi
callq 0x20b0
jmp 0x3b62
movq -0x30(%rbp), %rcx
movl 0x14(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x10(%rcx)
cmpl $0x0, %eax
je 0x3dbb
movq -0x30(%rbp), %rcx
movl 0x1c(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x18(%rcx)
movq -0x30(%rbp), %rax
movl %edx, 0x1c(%rax)
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x48, %rdi
movslq 0x1c(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6320
xorb $-0x1, %al
testb $0x1, %al
jne 0x3c97
jmp 0x3cff
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x48, %rdi
movslq 0x1c(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6340
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq %rax, %rdi
addq $0x48, %rdi
movslq 0x1c(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6360
movq -0x30(%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 0x3c73
movq -0x30(%rbp), %rcx
movl 0x1c(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x18(%rcx)
cmpl $0x0, %eax
je 0x3db9
movq -0x30(%rbp), %rcx
movl 0x24(%rcx), %eax
addl $0x1, %eax
cltd
idivl 0x20(%rcx)
movq -0x30(%rbp), %rax
movl %edx, 0x24(%rax)
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x60, %rdi
movslq 0x24(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6320
xorb $-0x1, %al
testb $0x1, %al
jne 0x3d4f
jmp 0x3db7
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x60, %rdi
movslq 0x24(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6340
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x28(%rbp)
movq %rax, %rdi
addq $0x60, %rdi
movslq 0x24(%rax), %rsi
callq 0x6300
movq %rax, %rdi
callq 0x6360
movq -0x30(%rbp), %rdi
addq $0x48, %rdi
movq -0x28(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x6300
movq %rax, %rdi
leaq -0x28(%rbp), %rsi
callq 0x6430
jmp 0x3d2b
jmp 0x3db9
jmp 0x3dbb
jmp 0x3b22
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)