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

    if (edge == EMPTY) {
        return true;
    }

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

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

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

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testl %esi, %esi
js 0x32b6
movl %edx, %ebx
testl %edx, %edx
js 0x32b6
movl %esi, %r15d
movq %rdi, %r14
cmpl %esi, 0xc(%rdi)
jl 0x32b6
cmpl %ebx, 0x10(%r14)
jle 0x32b6
movl %ecx, %r13d
movb $0x1, %al
testl %ecx, %ecx
je 0x32a7
movq %r14, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x431a
testl %eax, %eax
je 0x3169
cmpl %r13d, %eax
sete %al
jmp 0x32a7
movq 0x20(%r14), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rax
movl %ebx, %ecx
movl %r13d, (%rax,%rcx,4)
cmpl $0x1, %r13d
jne 0x3192
movq %r14, %rdi
movl %r15d, %esi
movl %ebx, %edx
movl $0x1, %ecx
callq 0x32d6
cmpl $0x4, %r15d
movl $0x3, %eax
cmovgel %r15d, %eax
leal -0x3(%rax), %ecx
movq %r15, -0x48(%rbp)
leal 0x1(%r15), %esi
movq %r14, -0x40(%rbp)
movl 0xc(%r14), %edx
cmpl %esi, %edx
cmovll %edx, %esi
movslq %esi, %r14
movl %esi, -0x34(%rbp)
cmpl %esi, %ecx
jge 0x3232
cmpl $0x3, %ebx
movl $0x2, %esi
cmovgel %ebx, %esi
leal 0x1(%rbx), %r15d
movq -0x40(%rbp), %rdx
movl 0x10(%rdx), %ecx
cmpl %r15d, %ecx
cmovll %ecx, %r15d
leal -0x2(%rsi), %r12d
movq 0x30(%rdx), %rcx
movq %rcx, -0x58(%rbp)
movl %r15d, %edx
movq %rsi, -0x30(%rbp)
subl %esi, %edx
incl %edx
incq %rdx
movq %rdx, -0x50(%rbp)
movl %eax, %r13d
addq $-0x3, %r13
cmpl %r15d, %r12d
jge 0x322a
movq -0x58(%rbp), %rax
movq (%rax,%r13,8), %rax
movq -0x30(%rbp), %rcx
leaq (%rax,%rcx), %rdi
addq $-0x2, %rdi
movl $0x1, %esi
movq -0x50(%rbp), %rdx
callq 0x20e0
incq %r13
cmpq %r13, %r14
jne 0x3203
movq -0x48(%rbp), %rcx
cmpl $0x3, %ecx
movl $0x2, %eax
cmovgel %ecx, %eax
leal -0x2(%rax), %ecx
cmpl -0x34(%rbp), %ecx
jge 0x32a5
cmpl $0x2, %ebx
movl $0x1, %r12d
cmovgel %ebx, %r12d
incl %ebx
movq -0x40(%rbp), %rdx
movl 0x10(%rdx), %ecx
cmpl %ebx, %ecx
cmovll %ecx, %ebx
movq 0x38(%rdx), %rcx
movq %rcx, -0x30(%rbp)
movl %ebx, %r15d
subl %r12d, %r15d
incq %r15
movl %eax, %r13d
addq $-0x2, %r13
cmpl %ebx, %r12d
jg 0x329d
movq -0x30(%rbp), %rax
movq (%rax,%r13,8), %rax
leaq (%rax,%r12), %rdi
decq %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x20e0
incq %r13
cmpq %r13, %r14
jne 0x327c
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbd61(%rip), %rdi      # 0xf01e
leaq 0xbd81(%rip), %rsi      # 0xf045
leaq 0xbd8e(%rip), %rcx      # 0xf059
movl $0x81, %edx
callq 0x2100
nop