// File: davidjosepha[P]slitherlink/src/shared/grid.cpp
// Function: Grid::initUpdateMatrix()
void Grid::initUpdateMatrix() {

    if (!init_) {
        updateMatrix_ = new bool*[m_];
        for (int i = 0; i < getHeight(); i++) {
            updateMatrix_[i] = new bool[n_];
            for (int j = 0; j < getWidth(); j++) {
                updateMatrix_[i][j] = true;
            }
        }
        contraMatrix_ = new bool*[m_];
        for (int i = 0; i < getHeight(); i++) {
            contraMatrix_[i] = new bool[n_];
            for (int j = 0; j < getWidth(); j++) {
                contraMatrix_[i][j] = false;
            }
        }
        contourMatrix_ = new std::pair<int,int>*[m_+1];
        for (int i = 0; i < getHeight()+1; i++) {
            contourMatrix_[i] = new std::pair<int,int>[n_+1];
            for (int j = 0; j < getWidth()+1; j++) {
                contourMatrix_[i][j] = std::make_pair<int,int>(-1,-1);
            }
        }
        numOpenLoops_ = 0;
        numClosedLoops_ = 0;
    }

    init_ = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
testb $0x1, 0x49(%rax)
jne 0x355b
movq -0x48(%rbp), %rax
movslq 0xc(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movl $0x0, -0xc(%rbp)
movq -0x48(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x4c(%rbp)
callq 0x2ad0
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jge 0x32d9
movq -0x48(%rbp), %rax
movslq 0x10(%rax), %rdi
movq $-0x1, %rax
cmpq $0x0, %rdi
cmovlq %rax, %rdi
callq 0x2030
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x10(%rbp)
movq -0x48(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, -0x50(%rbp)
callq 0x2af0
movl %eax, %ecx
movl -0x50(%rbp), %eax
cmpl %ecx, %eax
jge 0x32c9
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x328e
jmp 0x32cb
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x323c
movq -0x48(%rbp), %rax
movslq 0xc(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x38(%rax)
movl $0x0, -0x14(%rbp)
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x54(%rbp)
callq 0x2ad0
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jge 0x33b1
movq -0x48(%rbp), %rax
movslq 0x10(%rax), %rdi
movq $-0x1, %rax
cmpq $0x0, %rdi
cmovlq %rax, %rdi
callq 0x2030
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x18(%rbp)
movq -0x48(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, -0x58(%rbp)
callq 0x2af0
movl %eax, %ecx
movl -0x58(%rbp), %eax
cmpl %ecx, %eax
jge 0x33a1
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x3366
jmp 0x33a3
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3314
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x1c(%rbp)
movq -0x48(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, -0x5c(%rbp)
callq 0x2ad0
movl %eax, %ecx
movl -0x5c(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x3549
movq -0x48(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x70(%rbp)
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x68(%rbp)
cmpq $0x0, %rax
je 0x3495
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rdx
shlq $0x3, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x4a60
jmp 0x347d
movq -0x80(%rbp), %rcx
movq -0x88(%rbp), %rax
addq $0x8, %rax
cmpq %rcx, %rax
movq %rax, -0x78(%rbp)
jne 0x346b
movq -0x68(%rbp), %rdx
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x30(%rbp)
movq -0x48(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, -0x8c(%rbp)
callq 0x2af0
movl %eax, %ecx
movl -0x8c(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x3539
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
leaq -0x3c(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x49b0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq 0x40(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a80
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x34b0
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2230
jmp 0x356c
jmp 0x353b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x33f0
movq -0x48(%rbp), %rax
movl $0x0, 0x4c(%rax)
movl $0x0, 0x50(%rax)
movq -0x48(%rbp), %rax
movb $0x1, 0x49(%rax)
addq $0x90, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x22c0
nopw %cs:(%rax,%rax)