// File: Stygain[P]bandwidth-monitor/src/graph.cpp
// Function: Graph::Resize(int, int, int, int)
void Graph::Resize(int placementX, int placementY, int width, int height)
{
	this->placementX = placementX;
	this->placementY = placementY;
	this->width = width;
	this->height = height;

	this->graphTitle->Resize(this->placementX + 1, this->placementY, this->width, 1);
	this->graphMaxItem->Resize(this->placementX + 2, this->placementY + 2, 5, 1);

	//TODO update the rows and columns as well
	int oldCols = this->numCols;
	this->numCols = (this->width - 3);
	std::vector<GraphDataColumn *> newCols;
	for (int i = 0; i < this->numCols; i++)
	{
		newCols.push_back(new GraphDataColumn(this->graphType, this->interfaces, this->interface));
	}

	int smallerCols = oldCols < this->numCols ? oldCols : this->numCols;
	for (int i = 1; i < smallerCols + 1; i++)
	{
		newCols[this->numCols - i]->SetValue(this->gDataCols[oldCols - i]->GetValue());
	}
	this->gDataCols.clear();
	this->gDataCols = newCols;

	for (size_t i = 0; i < (this->gDataCols.size() - 1); i++)
	{
		this->gDataCols[i]->SetNext(gDataCols[i+1]);
	}

	int oldRows = this->numRows;
	this->numRows = (this->height - 2);
	std::vector<GraphRow *> newRows;
	for (int i = 0; i < this->numRows; i++)
	{
		newRows.push_back(
			new GraphRow(
				1,
				(this->width - 3),
				(this->placementX + 1),
				(this->placementY + 1 + ((i * 1) + 1)),
				(this->numRows - i - 1),
				(this->numRows - 1)
			)
		);
	}

	this->gRows.clear();
	this->gRows = newRows;

	wresize(this->win, height, width);
	mvwin(this->win, this->placementY + 1, this->placementX);

	this->Update();

	this->graphTitle->Update();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x10(%rbp), %ecx
movl %ecx, 0xc(%rax)
movl -0x14(%rbp), %ecx
movl %ecx, 0x10(%rax)
movl -0x18(%rbp), %ecx
movl %ecx, 0x14(%rax)
movq 0x38(%rax), %rdi
movl 0x8(%rax), %esi
addl $0x1, %esi
movl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
movl $0x1, %r8d
callq 0xe380
movq -0xa0(%rbp), %rax
movq 0x40(%rax), %rdi
movl 0x8(%rax), %esi
addl $0x2, %esi
movl 0xc(%rax), %edx
addl $0x2, %edx
movl $0x5, %ecx
movl $0x1, %r8d
callq 0xe510
movq -0xa0(%rbp), %rax
movl 0x1c(%rax), %ecx
movl %ecx, -0x1c(%rbp)
movl 0x10(%rax), %ecx
subl $0x3, %ecx
movl %ecx, 0x1c(%rax)
leaq -0x38(%rbp), %rdi
callq 0xf3f0
movl $0x0, -0x3c(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x3c(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jge 0xebb7
movl $0x20, %edi
callq 0x3320
movq %rax, -0xa8(%rbp)
jmp 0xeb3d
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rax
movl 0x30(%rax), %esi
movq 0x20(%rax), %rdx
movq 0x28(%rax), %rcx
callq 0xda40
jmp 0xeb5d
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xf510
jmp 0xeb77
jmp 0xeb79
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xeb17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xeec2
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x20, %esi
callq 0x3330
jmp 0xeec2
movq -0xa0(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jge 0xebd1
movl -0x1c(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0xebe1
movq -0xa0(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x58(%rbp)
movl $0x1, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl -0x58(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0xec5b
movq -0xa0(%rbp), %rax
movl 0x1c(%rax), %eax
subl -0x5c(%rbp), %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0xf540
movq -0xa0(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
addq $0x60, %rdi
movl -0x1c(%rbp), %eax
subl -0x5c(%rbp), %eax
movslq %eax, %rsi
callq 0xf540
movq (%rax), %rdi
callq 0xdf90
movq -0xb8(%rbp), %rdi
movl %eax, %esi
callq 0xdff0
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xebf1
movq -0xa0(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0xc0(%rbp)
callq 0xf4d0
movq -0xc0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xf590
jmp 0xec84
movq $0x0, -0x68(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x68(%rbp), %rax
movq %rax, -0xc8(%rbp)
addq $0x60, %rdi
callq 0xf370
movq %rax, %rcx
movq -0xc8(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0xed10
movq -0xa0(%rbp), %rdi
addq $0x60, %rdi
movq -0x68(%rbp), %rsi
callq 0xf540
movq -0xa0(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
addq $0x60, %rdi
movq -0x68(%rbp), %rsi
addq $0x1, %rsi
callq 0xf540
movq -0xd0(%rbp), %rdi
movq (%rax), %rsi
callq 0xda90
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0xec8c
movq -0xa0(%rbp), %rax
movl 0x18(%rax), %ecx
movl %ecx, -0x6c(%rbp)
movl 0x14(%rax), %ecx
subl $0x2, %ecx
movl %ecx, 0x18(%rax)
leaq -0x88(%rbp), %rdi
callq 0xf3d0
movl $0x0, -0x8c(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x8c(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0xee1c
movl $0x20, %edi
callq 0x3320
movq %rax, -0xd8(%rbp)
jmp 0xed65
movq -0xd8(%rbp), %rdi
movq -0xa0(%rbp), %rax
movl 0x10(%rax), %edx
addl $-0x3, %edx
movl 0x8(%rax), %ecx
movl 0xc(%rax), %r10d
incl %ecx
movl -0x8c(%rbp), %r9d
movl %r9d, %esi
movl %r10d, %r8d
leal 0x2(%rsi,%r8), %r8d
movl 0x18(%rax), %esi
notl %r9d
addl %esi, %r9d
decl %esi
movq %rsp, %rax
movl %esi, (%rax)
movl $0x1, %esi
callq 0xe010
jmp 0xedb0
movq -0xd8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xf560
jmp 0xedd3
jmp 0xedd5
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xed3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xeeb6
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x20, %esi
callq 0x3330
jmp 0xeeb6
movq -0xa0(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0xe0(%rbp)
callq 0xf4f0
movq -0xe0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xf7e0
jmp 0xee48
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
movl -0x18(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x3220
jmp 0xee5f
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
movl 0xc(%rax), %esi
incl %esi
movl 0x8(%rax), %edx
callq 0x3170
jmp 0xee78
movq -0xa0(%rbp), %rdi
callq 0xeee0
jmp 0xee86
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0xe2b0
jmp 0xee98
leaq -0x88(%rbp), %rdi
callq 0xf470
leaq -0x38(%rbp), %rdi
callq 0xf410
addq $0xf0, %rsp
popq %rbp
retq
leaq -0x88(%rbp), %rdi
callq 0xf470
leaq -0x38(%rbp), %rdi
callq 0xf410
movq -0x50(%rbp), %rdi
callq 0x35c0
nopw %cs:(%rax,%rax)