// File: shuhaosun[P]Splitter-Windowed-CountMin/./Splitter.h
// Function: Splitter::Expire(Node*, int, int, int)
void Expire(DLNode *head, int t, int i, int j)
	{
		DLNode *p, *q;
		double ratio;
		double scale;

		p = head->next;

		while(p != head && ((p->init < t - WINDOW_SIZE) || (p->init == t - WINDOW_SIZE)))
		{
			if (p->last > t - WINDOW_SIZE)//the second node is totally in the window
			{
				ratio = (t - WINDOW_SIZE) - p->init + 1;
				scale = p->count / (p->last - p->init + 1);
				counter[i][j] = counter[i][j] - ratio*scale;

				p->count = p->count - ratio*scale;
				p->init = p->init + ratio;
				p = p->next;
			}
			else
			{
				counter[i][j] = counter[i][j] - p->count;

				//delete p node
				q = p;
				p = p->next;
			    q->prior->next = q->next;
				q->next->prior = q->prior;
				free(q);
				if (p == head)
				{
					counter[i][j] = 0;
				}
				memoryusage = memoryusage - 2*12 - 16;
			}
		}
	}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl %edx, 0x44(%rsp)
movl %ecx, 0x40(%rsp)
movl %r8d, 0x3c(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rcx
xorl %eax, %eax
cmpq 0x48(%rsp), %rcx
movb %al, 0xf(%rsp)
je 0x431f
movq 0x30(%rsp), %rax
movsd (%rax), %xmm1
cvtsi2sdl 0x44(%rsp), %xmm0
movsd 0x1da4(%rip), %xmm2     # 0x6080
subsd %xmm2, %xmm0
movb $0x1, %al
ucomisd %xmm1, %xmm0
movb %al, 0xe(%rsp)
ja 0x4317
movq 0x30(%rsp), %rax
movsd (%rax), %xmm0
cvtsi2sdl 0x44(%rsp), %xmm1
movsd 0x1d7d(%rip), %xmm2     # 0x6080
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x432c
jmp 0x454c
movq 0x30(%rsp), %rax
movsd 0x8(%rax), %xmm0
cvtsi2sdl 0x44(%rsp), %xmm1
movsd 0x1d3c(%rip), %xmm2     # 0x6080
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x447a
movq 0x10(%rsp), %rax
cvtsi2sdl 0x44(%rsp), %xmm0
movsd 0x1d1b(%rip), %xmm1     # 0x6080
subsd %xmm1, %xmm0
movq 0x30(%rsp), %rcx
subsd (%rcx), %xmm0
movsd 0x1cee(%rip), %xmm1     # 0x6068
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x30(%rsp), %rcx
movsd 0x10(%rcx), %xmm0
movq 0x30(%rsp), %rcx
movsd 0x8(%rcx), %xmm1
movq 0x30(%rsp), %rcx
subsd (%rcx), %xmm1
movsd 0x1cbf(%rip), %xmm2     # 0x6068
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movslq 0x40(%rsp), %rcx
movq 0xf0(%rax,%rcx,8), %rcx
movslq 0x3c(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm1
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movslq 0x40(%rsp), %rcx
movq 0xf0(%rax,%rcx,8), %rax
movslq 0x3c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
movsd 0x10(%rax), %xmm1
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x30(%rsp), %rax
movsd %xmm0, 0x10(%rax)
movq 0x30(%rsp), %rax
movsd (%rax), %xmm0
addsd 0x20(%rsp), %xmm0
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0x4547
movq 0x10(%rsp), %rax
movslq 0x40(%rsp), %rcx
movq 0xf0(%rax,%rcx,8), %rcx
movslq 0x3c(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x30(%rsp), %rcx
subsd 0x10(%rcx), %xmm0
movslq 0x40(%rsp), %rcx
movq 0xf0(%rax,%rcx,8), %rax
movslq 0x3c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x18(%rax)
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x20(%rax)
movq 0x28(%rsp), %rdi
callq 0x2180
movq 0x30(%rsp), %rax
cmpq 0x48(%rsp), %rax
jne 0x4530
movq 0x10(%rsp), %rax
movslq 0x40(%rsp), %rcx
movq 0xf0(%rax,%rcx,8), %rax
movslq 0x3c(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movl 0x7a13ac(%rax), %ecx
subl $0x18, %ecx
subl $0x10, %ecx
movl %ecx, 0x7a13ac(%rax)
jmp 0x42b3
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)