// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movl %esi, 0x8(%rdi)
movl %edx, 0xc(%rdi)
movl %ecx, 0x10(%rdi)
movl %r8d, 0x8(%rsp)
movl %r8d, 0x14(%rdi)
movq 0x38(%rdi), %rdi
incl %esi
pushq $0x1
popq %rbp
movl %ecx, 0xc(%rsp)
movl %ebp, %r8d
callq 0x7b52
movq 0x40(%rbx), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
addl $0x2, %esi
addl $0x2, %edx
pushq $0x5
popq %rcx
movl %ebp, %r8d
callq 0x7bd8
movslq 0x1c(%rbx), %r13
movl 0x10(%rbx), %eax
addl $-0x3, %eax
movl %eax, 0x1c(%rbx)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r14
andq $0x0, 0x10(%r14)
movaps %xmm0, (%r14)
xorl %ebp, %ebp
pushq $0x20
popq %r15
leaq 0x10(%rsp), %r12
cmpl %eax, %ebp
jge 0x7f65
movq %r15, %rdi
callq 0x32c0
movl 0x30(%rbx), %ecx
andl $0x0, (%rax)
andq $0x0, 0x18(%rax)
movl %ecx, 0x4(%rax)
movups 0x20(%rbx), %xmm0
movups %xmm0, 0x8(%rax)
movq %rax, 0x10(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x8582
incl %ebp
movl 0x1c(%rbx), %eax
jmp 0x7f2c
cmpl %eax, %r13d
movslq %eax, %rsi
cmovll %r13d, %eax
movq 0x30(%rsp), %r8
leaq 0x60(%rbx), %rdi
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
movq 0x60(%rbx), %rcx
negq %rax
leaq (%r8,%rsi,8), %rsi
addq $-0x8, %rsi
leaq (%rcx,%r13,8), %r8
addq $-0x8, %r8
cmpq %rdx, %rax
je 0x7fae
movq (%rsi,%rdx,8), %r9
movq (%r8,%rdx,8), %r10
movl (%r10), %r10d
movl %r10d, (%r9)
decq %rdx
jmp 0x7f96
cmpq %rcx, 0x68(%rbx)
je 0x7fb8
movq %rcx, 0x68(%rbx)
leaq 0x30(%rsp), %rsi
callq 0x8346
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
pushq $0x1
popq %rdx
cmpq %rdx, %rcx
je 0x7feb
movq -0x8(%rax,%rdx,8), %rsi
movq (%rax,%rdx,8), %rdi
movq %rdi, 0x18(%rsi)
incq %rdx
jmp 0x7fd4
movl 0x14(%rbx), %r15d
addl $-0x2, %r15d
movl %r15d, 0x18(%rbx)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x2
popq %r12
pushq $-0x1
popq %r13
leaq 0x28(%rsp), %r14
leal -0x2(%r12), %eax
cmpl %r15d, %eax
jge 0x806f
pushq $0x20
popq %rdi
callq 0x32c0
movq %rax, %rbp
movl 0x8(%rbx), %ecx
movl 0x10(%rbx), %edx
addl $-0x3, %edx
incl %ecx
movl 0xc(%rbx), %r8d
addl %r12d, %r8d
leal (%r15,%r13), %r9d
decl %r15d
movl %r15d, (%rsp)
movq %rax, %rdi
pushq $0x1
popq %rsi
callq 0x795c
movq %rbp, 0x28(%rsp)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x86fe
movl 0x18(%rbx), %r15d
incl %r12d
decl %r13d
jmp 0x8014
leaq 0x48(%rbx), %rdi
movq 0x48(%rbx), %rax
cmpq %rax, 0x50(%rbx)
je 0x8081
movq %rax, 0x50(%rbx)
leaq 0x10(%rsp), %rsi
callq 0x8410
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
callq 0x31f0
movq (%rbx), %rdi
movl 0xc(%rbx), %esi
incl %esi
movl 0x8(%rbx), %edx
callq 0x3140
movq %rbx, %rdi
callq 0x8118
movq 0x38(%rbx), %rdi
callq 0x7acc
leaq 0x10(%rsp), %rdi
callq 0x851a
leaq 0x30(%rsp), %rdi
callq 0x854e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8102
jmp 0x80f3
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %rbp, %rdi
callq 0x32d0
jmp 0x80f6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x851a
jmp 0x8105
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x854e
movq %rbx, %rdi
callq 0x3540
nop