// File: juancalaca[P]dotsboxes/DotsBoard.cc
// Function: DotsBoard::DotsBoard(int, int)
DotsBoard::DotsBoard(int rows, int columns)
{
	this->rows = rows;
	this->columns = columns;
	this->claimedBoxes = 0;
	this->totalBoxes = (rows * columns);
	
	for (int r = 0; r < rows; r++)
	{
		vector<DotsBox*> newRow;
		
		for (int c = 0; c < columns; c++)
		{
			DotsBox *box = new DotsBox();
			
			DotsEdge *bottom = new DotsEdge();
			bottom->SetBox1(box);
			
			DotsEdge *right = new DotsEdge();
			right->SetBox1(box);

			DotsEdge *left;
			if (c == 0)
			{
				left = new DotsEdge();
				left->SetBox1(box);
			}
			else
			{
				left = newRow[(c - 1)]->GetRight();
				left->SetBox2(box);
			}
			
			DotsEdge *top;
			if (r == 0)
			{
				top = new DotsEdge();
				top->SetBox1(box);
			}
			else 
			{
				top = this->boxes[(r - 1)][c]->GetBottom();
				top->SetBox2(box);
			}
			
			box->SetLeft(left);
			box->SetRight(right);
			box->SetTop(top);
			box->SetBottom(bottom);
			
			newRow.push_back(box);
		}
		
		this->boxes.push_back(newRow);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
addq $0x10, %rdi
movq %rdi, -0x80(%rbp)
callq 0x3840
movq -0x78(%rbp), %rax
movl -0xc(%rbp), %ecx
movl %ecx, (%rax)
movl -0x10(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl $0x0, 0x8(%rax)
movl -0xc(%rbp), %ecx
imull -0x10(%rbp), %ecx
movl %ecx, 0xc(%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2dd8
leaq -0x30(%rbp), %rdi
callq 0x3860
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x2d9a
movl $0x48, %edi
callq 0x2160
movq %rax, -0x88(%rbp)
jmp 0x2adc
movq -0x88(%rbp), %rdi
callq 0x2720
jmp 0x2aea
movq -0x88(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x18, %edi
callq 0x2160
movq %rax, -0x90(%rbp)
jmp 0x2b08
movq -0x90(%rbp), %rdi
callq 0x24e0
jmp 0x2b16
movq -0x90(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2520
jmp 0x2b30
movl $0x18, %edi
callq 0x2160
movq %rax, -0x98(%rbp)
jmp 0x2b43
movq -0x98(%rbp), %rdi
callq 0x24e0
jmp 0x2b51
movq -0x98(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2520
jmp 0x2b6b
cmpl $0x0, -0x34(%rbp)
jne 0x2c4e
movl $0x18, %edi
callq 0x2160
movq %rax, -0xa0(%rbp)
jmp 0x2b88
movq -0xa0(%rbp), %rdi
callq 0x24e0
jmp 0x2b96
movq -0xa0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2520
jmp 0x2bb0
jmp 0x2c8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2dc4
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x48, %esi
callq 0x2170
jmp 0x2dc4
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x18, %esi
callq 0x2170
jmp 0x2dc4
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x18, %esi
callq 0x2170
jmp 0x2dc4
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x18, %esi
callq 0x2170
jmp 0x2dc4
movl -0x34(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3880
movq (%rax), %rdi
callq 0x28a0
movq %rax, -0xa8(%rbp)
jmp 0x2c70
movq -0xa8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2540
jmp 0x2c8a
jmp 0x2c8c
cmpl $0x0, -0x14(%rbp)
jne 0x2cf1
movl $0x18, %edi
callq 0x2160
movq %rax, -0xb0(%rbp)
jmp 0x2ca5
movq -0xb0(%rbp), %rdi
callq 0x24e0
jmp 0x2cb3
movq -0xb0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2520
jmp 0x2ccd
jmp 0x2d3f
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x18, %esi
callq 0x2170
jmp 0x2dc4
movq -0x78(%rbp), %rdi
addq $0x10, %rdi
movl -0x14(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x38a0
movq %rax, %rdi
movslq -0x34(%rbp), %rsi
callq 0x3880
movq (%rax), %rdi
callq 0x28c0
movq %rax, -0xb8(%rbp)
jmp 0x2d23
movq -0xb8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2540
jmp 0x2d3d
jmp 0x2d3f
movq -0x40(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x27e0
jmp 0x2d4e
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x2820
jmp 0x2d5d
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x2800
jmp 0x2d6c
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2840
jmp 0x2d7b
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x38c0
jmp 0x2d8a
jmp 0x2d8c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2abd
movq -0x78(%rbp), %rdi
addq $0x10, %rdi
leaq -0x30(%rbp), %rsi
callq 0x3930
jmp 0x2dad
leaq -0x30(%rbp), %rdi
callq 0x39a0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2aa1
leaq -0x30(%rbp), %rdi
callq 0x39a0
movq -0x80(%rbp), %rdi
callq 0x3a00
jmp 0x2de1
addq $0xc0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2260
nopw (%rax,%rax)