// File: davidjosepha[P]slitherlink/src/shared/grid.cpp
// Function: Grid::setVLine(int, int, Edge)
bool Grid::setVLine(int i, int j, Edge edge) {
    assert(0 <= i && i < m_ && 0 <= j && j < n_+1);

    Edge prevEdge = getVLine(i, j);
    if (prevEdge == EMPTY) {
        vlines_[i][j] = edge;
    } else if (prevEdge != edge) {
        return false;
    } else if (prevEdge == edge) {
        return true;
    }

    // Update contour information
    if (edge == LINE) {
        updateContourMatrix(i, j, false);
    }

    // Update which parts of grid have possible rules that could be applied
    for (int x = std::max(0, i-2); x < std::min(i+1, getHeight()); x++) {
        for (int y = std::max(0, j-3); y < std::min(j+1, getWidth()); y++) {
            updateMatrix_[x][y] = true;
        }
    }

    // Update which parts of grid have possible contradictions
    for (int x = std::max(0, i-1); x < std::min(i+1, getHeight()); x++) {
        for (int y = std::max(0, j-2); y < std::min(j+1, getWidth()); y++) {
            contraMatrix_[x][y] = true;
        }
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl -0x14(%rbp), %ecx
movb %al, -0x71(%rbp)
jg 0x42de
movq -0x80(%rbp), %rdx
movl -0x14(%rbp), %ecx
xorl %eax, %eax
cmpl 0xc(%rdx), %ecx
movb %al, -0x71(%rbp)
jge 0x42de
xorl %eax, %eax
xorl %ecx, %ecx
cmpl -0x18(%rbp), %ecx
movb %al, -0x71(%rbp)
jg 0x42de
movq -0x80(%rbp), %rcx
movl -0x18(%rbp), %eax
movl 0x10(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x42e7
jmp 0x42e9
jmp 0x4308
leaq 0x10da5(%rip), %rdi     # 0x15095
leaq 0x10d5e(%rip), %rsi     # 0x15055
movl $0xac, %edx
leaq 0x10db9(%rip), %rcx     # 0x150bc
callq 0x2120
movq -0x80(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x5c90
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x433c
movq -0x80(%rbp), %rax
movl -0x1c(%rbp), %edx
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x4362
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x434d
movb $0x0, -0x1(%rbp)
jmp 0x4553
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x435e
movb $0x1, -0x1(%rbp)
jmp 0x4553
jmp 0x4360
jmp 0x4362
cmpl $0x1, -0x1c(%rbp)
jne 0x4379
movq -0x80(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
xorl %ecx, %ecx
callq 0x3b60
movl $0x0, -0x28(%rbp)
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x2c(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x49e0
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x80(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
callq 0x2ad0
movl %eax, -0x34(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x4a20
movq %rax, %rcx
movl -0x84(%rbp), %eax
cmpl (%rcx), %eax
jge 0x4464
movl $0x0, -0x3c(%rbp)
movl -0x18(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x40(%rbp)
leaq -0x3c(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x49e0
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x80(%rbp), %rdi
movl -0x38(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
callq 0x2af0
movl %eax, -0x48(%rbp)
leaq -0x44(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x4a20
movq %rax, %rcx
movl -0x88(%rbp), %eax
cmpl (%rcx), %eax
jge 0x4454
movq -0x80(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x43f9
jmp 0x4456
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x439b
movl $0x0, -0x50(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x49e0
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x80(%rbp), %rdi
movl -0x4c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
callq 0x2ad0
movl %eax, -0x5c(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x4a20
movq %rax, %rcx
movl -0x8c(%rbp), %eax
cmpl (%rcx), %eax
jge 0x454f
movl $0x0, -0x64(%rbp)
movl -0x18(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x68(%rbp)
leaq -0x64(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x49e0
movl (%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x80(%rbp), %rdi
movl -0x60(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
callq 0x2af0
movl %eax, -0x70(%rbp)
leaq -0x6c(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4a20
movq %rax, %rcx
movl -0x90(%rbp), %eax
cmpl (%rcx), %eax
jge 0x453f
movq -0x80(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x60(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x44e4
jmp 0x4541
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4486
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)