// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %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
movl %ecx, 0xc(%rsp)
movl $0x1, %r8d
callq 0x864e
movq 0x40(%rbx), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
addl $0x2, %esi
addl $0x2, %edx
movl $0x5, %ecx
movl $0x1, %r8d
callq 0x86d6
movslq 0x1c(%rbx), %r13
movl 0x10(%rbx), %eax
leal -0x3(%rax), %ecx
movl %ecx, 0x1c(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
cmpl $0x4, %eax
jl 0x8b3b
xorl %ebp, %ebp
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
movl $0x20, %edi
callq 0x32c0
movl 0x30(%rbx), %ecx
movq 0x20(%rbx), %rdx
movq 0x28(%rbx), %rsi
movl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl %ecx, 0x4(%rax)
movq %rdx, 0x8(%rax)
movq %rsi, 0x10(%rax)
movq %rax, 0x10(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x912a
incl %ebp
movl 0x1c(%rbx), %ecx
cmpl %ecx, %ebp
jl 0x8af5
cmpl %ecx, %r13d
movl %ecx, %eax
cmovll %r13d, %eax
testl %eax, %eax
jle 0x8b7d
movslq %ecx, %rcx
incl %eax
shlq $0x3, %r13
addq 0x60(%rbx), %r13
shlq $0x3, %rcx
addq 0x30(%rsp), %rcx
negq %rax
movq $-0x1, %rdx
movq (%rcx,%rdx,8), %rsi
movq (%r13,%rdx,8), %rdi
movl (%rdi), %edi
movl %edi, (%rsi)
decq %rdx
cmpq %rdx, %rax
jne 0x8b68
leaq 0x60(%rbx), %rdi
movq 0x60(%rbx), %rax
cmpq %rax, 0x68(%rbx)
je 0x8b8f
movq %rax, 0x68(%rbx)
leaq 0x30(%rsp), %rsi
callq 0x8f7e
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq $0x1, %rcx
je 0x8bc8
movl $0x1, %edx
movq -0x8(%rax,%rdx,8), %rsi
movq (%rax,%rdx,8), %rdi
movq %rdi, 0x18(%rsi)
incq %rdx
cmpq %rdx, %rcx
jne 0x8bb3
movl 0x14(%rbx), %eax
leal -0x2(%rax), %r15d
movl %r15d, 0x18(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x3, %eax
jl 0x8c78
movl $0x2, %ebp
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
leaq 0x50(%rsp), %r12
movl $0x20, %edi
callq 0x32c0
movq %rax, %r13
movl 0x8(%rbx), %ecx
movl 0x10(%rbx), %esi
addl $-0x3, %esi
incl %ecx
movl 0xc(%rbx), %edx
addl %ebp, %edx
leal (%r15,%r14), %eax
decl %r15d
movl %r15d, 0xc(%r13)
movl %eax, 0x8(%r13)
movl %edx, 0x10(%r13)
movl %ecx, 0x14(%r13)
movl $0x1, 0x18(%r13)
movl %esi, 0x1c(%r13)
movl $0x1, %edi
callq 0x32e0
movq %rax, (%r13)
movq %rax, %rdi
callq 0x3310
movq %r13, 0x50(%rsp)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x9296
movl 0x18(%rbx), %r15d
leal 0x1(%rbp), %eax
decl %ebp
decl %r14d
cmpl %r15d, %ebp
movl %eax, %ebp
jl 0x8bfd
leaq 0x48(%rbx), %rdi
movq 0x48(%rbx), %rax
cmpq %rax, 0x50(%rbx)
je 0x8c8a
movq %rax, 0x50(%rbx)
leaq 0x10(%rsp), %rsi
callq 0x9054
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 0x3150
movq %rbx, %rdi
callq 0x8d56
movq 0x38(%rbx), %rdi
callq 0x85c8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8cdc
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32d0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8cf3
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32d0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8d34
jmp 0x8d18
movq %rax, %rbx
movl $0x20, %esi
movq %r13, %rdi
callq 0x32d0
jmp 0x8d1b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8d37
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32d0
jmp 0x8d37
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8d4e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32d0
movq %rbx, %rdi
callq 0x3550