// File: comptotherescue[P]Fibonacci-Heap/keywordcounter.cpp
// Function: Fibops::RemoveMax()
Fib* RemoveMax()
	{
		map<int, Fib*> l_pTreet;
		map<int, Fib*>::iterator it;
		int max = INT_MIN;
		Fib *q, *p, *l_pMax = NULL;
		q = m_pMax->m_pChild;
		//make parent pointer of all children of removed node NULL
		if (q != NULL)
		{
			do
			{
				q->m_pParent = NULL;
				q = q->m_pRightsib;
			} while (q != m_pMax->m_pChild && q != q->m_pRightsib);
			m_pMax->m_pChild->m_pLeftsib->m_pRightsib = m_pMax->m_pRightsib;
			m_pMax->m_pRightsib->m_pLeftsib = m_pMax->m_pChild->m_pLeftsib;
			m_pMax->m_pChild->m_pLeftsib = m_pMax;
			m_pMax->m_pRightsib = m_pMax->m_pChild;
			m_pMax->m_pChild = NULL;
			m_pMax->m_iDegree = 0;
		}
		q = m_pMax->m_pRightsib;
		vector<Fib*> Vec;
		map<int, Fib*>::iterator itr;
		Vec.clear();
		while (q != m_pMax)
		{
			Vec.push_back(q);
			q = q->m_pRightsib;
		}
		//Remove links for each node
		for (int i = 0; i < Vec.size(); i++)
		{
			Vec[i]->m_pLeftsib = Vec[i];
			Vec[i]->m_pRightsib = Vec[i];
		}
		Fib*y, *x;
		for (int i = 0; i<Vec.size(); i++)
		{
			it = l_pTreet.find(Vec[i]->m_iDegree);
			while (it != l_pTreet.end()) {
				if (Vec[i]->m_iData > it->second->m_iData)
				{
					y = Vec[i];
					x = it->second;
					x->m_pLeftsib->m_pRightsib = x->m_pRightsib;
					x->m_pRightsib->m_pLeftsib = x->m_pLeftsib;
					if (y->m_pChild == NULL)
					{
						x->m_pRightsib = x;
						x->m_pLeftsib = x;
						y->m_pChild = x;
						x->m_pParent = y;
						y->m_iDegree = y->m_iDegree + 1;
					}
					else
					{
						x->m_pLeftsib = y->m_pChild;
						y->m_pChild->m_pRightsib->m_pLeftsib = x;
						x->m_pRightsib = y->m_pChild->m_pRightsib;
						y->m_pChild->m_pRightsib = x;
						x->m_pParent = y;
						y->m_iDegree = y->m_iDegree + 1;
					}
				}
				else {
					x = Vec[i];
					y = it->second;
					if (y->m_pChild == NULL)
					{
						x->m_pRightsib = x;
						x->m_pLeftsib = x;
						y->m_pChild = x;
						x->m_pParent = y;
						y->m_iDegree += 1;
					}
					else
					{
						x->m_pLeftsib = y->m_pChild;
						y->m_pChild->m_pRightsib->m_pLeftsib = x;
						x->m_pRightsib = y->m_pChild->m_pRightsib;
						y->m_pChild->m_pRightsib = x;
						x->m_pParent = y;
						y->m_iDegree += 1;
					}
					Vec[i] = y;
				}
				l_pTreet.erase(it);
				it = l_pTreet.find(Vec[i]->m_iDegree);
			}
			if (it == l_pTreet.end())
			{
				l_pTreet.insert({ Vec[i]->m_iDegree,Vec[i] });
			}

		}
		itr = l_pTreet.begin();
		itr->second->m_pRightsib = itr->second;
		itr->second->m_pLeftsib = itr->second;
		l_pMax = itr->second;
		while (itr != l_pTreet.end())
		{
			l_pMax = Consolidate(l_pMax, itr->second);
			itr++;
		}
		Fib* t = m_pMax;
		m_pMax = l_pMax;
		return t;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x40e0
leaq -0x40(%rbp), %rdi
callq 0x4100
movq -0x120(%rbp), %rax
movl $0x80000000, -0x44(%rbp) # imm = 0x80000000
movq $0x0, -0x60(%rbp)
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x34b0
jmp 0x33fa
movq -0x50(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x120(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x121(%rbp)
je 0x3443
movq -0x50(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq 0x18(%rcx), %rax
setne %al
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x33fa
movq -0x120(%rbp), %rax
movq (%rax), %rcx
movq 0x18(%rcx), %rdx
movq (%rax), %rcx
movq 0x8(%rcx), %rcx
movq 0x10(%rcx), %rcx
movq %rdx, 0x18(%rcx)
movq (%rax), %rcx
movq 0x8(%rcx), %rcx
movq 0x10(%rcx), %rdx
movq (%rax), %rcx
movq 0x18(%rcx), %rcx
movq %rdx, 0x10(%rcx)
movq (%rax), %rdx
movq (%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rdx, 0x10(%rcx)
movq (%rax), %rcx
movq 0x8(%rcx), %rdx
movq (%rax), %rcx
movq %rdx, 0x18(%rcx)
movq (%rax), %rcx
movq $0x0, 0x8(%rcx)
movq (%rax), %rax
movl $0x0, (%rax)
movq -0x120(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4120
leaq -0x80(%rbp), %rdi
callq 0x4100
leaq -0x78(%rbp), %rdi
callq 0x4140
movq -0x120(%rbp), %rcx
movq -0x50(%rbp), %rax
cmpq (%rcx), %rax
je 0x3533
leaq -0x78(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4160
jmp 0x34fc
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x34dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x44d0
leaq -0x38(%rbp), %rdi
callq 0x4530
jmp 0x3bdc
movl $0x0, -0x90(%rbp)
movslq -0x90(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x41d0
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
jae 0x35eb
movslq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rax
movq %rax, -0x140(%rbp)
movslq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq -0x140(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movslq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rax
movq %rax, -0x138(%rbp)
movslq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq -0x138(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x18(%rax)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x353d
movl $0x0, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x41d0
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jae 0x3a97
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rsi
leaq -0x38(%rbp), %rdi
callq 0x4210
movq %rax, -0x150(%rbp)
jmp 0x3644
movq -0x150(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4270
movq %rax, -0xb8(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4240
testb $0x1, %al
jne 0x3686
jmp 0x39d3
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x154(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x42a0
movq %rax, %rcx
movl -0x154(%rbp), %eax
movq 0x8(%rcx), %rcx
cmpl 0x4(%rcx), %eax
jle 0x381f
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x42a0
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3793
movq -0xa0(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x98(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x98(%rbp), %rax
movl %ecx, (%rax)
jmp 0x381a
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x98(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x98(%rbp), %rax
movl %ecx, (%rax)
jmp 0x395e
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x42a0
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x38b6
movq -0xa0(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x98(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x3936
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x98(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x98(%rbp), %rax
movq %rax, -0x160(%rbp)
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq -0x160(%rbp), %rcx
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x42d0
movq %rax, -0x168(%rbp)
jmp 0x3982
movq -0x168(%rbp), %rax
movq %rax, -0xc8(%rbp)
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq (%rax), %rsi
leaq -0x38(%rbp), %rdi
callq 0x4210
movq %rax, -0x170(%rbp)
jmp 0x39b5
movq -0x170(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x365d
leaq -0x38(%rbp), %rdi
callq 0x4270
movq %rax, -0xd8(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x4310
testb $0x1, %al
jne 0x39fc
jmp 0x3a81
movslq -0xa4(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x41f0
movq -0x180(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x178(%rbp)
movslq -0xa4(%rbp), %rsi
callq 0x41f0
movq -0x178(%rbp), %rsi
movq %rax, %rdx
leaq -0xe8(%rbp), %rdi
callq 0x4380
jmp 0x3a48
leaq -0x38(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x4340
movb %dl, -0x189(%rbp)
movq %rax, -0x188(%rbp)
jmp 0x3a67
movb -0x189(%rbp), %al
movq -0x188(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movb %al, -0xf0(%rbp)
jmp 0x3a83
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x35f5
leaq -0x38(%rbp), %rdi
callq 0x43b0
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x42a0
movq 0x8(%rax), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x42a0
movq -0x1a0(%rbp), %rcx
movq 0x8(%rax), %rax
movq %rcx, 0x18(%rax)
leaq -0x80(%rbp), %rdi
callq 0x42a0
movq 0x8(%rax), %rax
movq %rax, -0x198(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x42a0
movq -0x198(%rbp), %rcx
movq 0x8(%rax), %rax
movq %rcx, 0x10(%rax)
leaq -0x80(%rbp), %rdi
callq 0x42a0
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4270
movq %rax, -0x108(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4240
testb $0x1, %al
jne 0x3b41
jmp 0x3b94
movq -0x60(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x42a0
movq -0x120(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
movq 0x8(%rax), %rdx
callq 0x43e0
movq %rax, -0x1a8(%rbp)
jmp 0x3b75
movq -0x1a8(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x4490
movq %rax, -0x110(%rbp)
jmp 0x3b1b
movq -0x120(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x118(%rbp)
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movq -0x118(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x44d0
leaq -0x38(%rbp), %rdi
callq 0x4530
movq -0x1b8(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x22c0
nopl (%rax,%rax)