// File: /workspace/github_cpp_makefile_star2_O1/davidjosepha[P]slitherlink/src/solver/solver.cpp
// Function: Solver::makeHLineGuess(int, int, int)
void Solver::makeHLineGuess(int i, int j, int depth) {
    assert(0 <= i && i < grid_->getHeight()+1 && 0 <= j && j < grid_->getWidth());
    assert(depth >= 0);

    if (grid_->getHLine(i, j) == EMPTY) {
        /* there is only one case where the grid
         * will not be updated, which is handled
         * at the end of this iteration. */
        grid_->setUpdated(true);

        Grid lineGuess;
        grid_->copy(lineGuess);

        /* make a LINE guess */
        lineGuess.setHLine(i, j, LINE);
        Solver lineSolver = Solver(lineGuess, rules_, contradictions_, selectedRules_, selectLength_, depth, epq_);
        ruleCounts_ = ruleCounts_ + lineSolver.ruleCounts_;

        /* If this guess happens to solve the puzzle we need to make sure that
         * the opposite guess leads to a contradiction, otherwise we know that
         * there might be multiple solutions */
        if (lineGuess.isSolved()) {
            Grid nLineGuess;
            grid_->copy(nLineGuess);
            nLineGuess.setHLine(i, j, NLINE);
            Solver nLineSolver = Solver(nLineGuess, rules_, contradictions_, selectedRules_, selectLength_, MAX_DEPTH, epq_);
            ruleCounts_ = ruleCounts_ + nLineSolver.ruleCounts_;
            if (nLineSolver.testContradictions()) {
                /* The opposite guess leads to a contradiction
                 * so the previous found solution is the only one */
                lineGuess.copy(*grid_);
            } else if (nLineGuess.isSolved() || nLineSolver.hasMultipleSolutions()) {
                /* The opposite guess also led to a solution
                 * so there are multiple solutions */
                multipleSolutions_ = true;
            } else {
                /* The opposite guess led to neither a solution or
                 * a contradiction, which can only happen if the subPuzzle
                 * is unsolvable for our maximum depth. We can learn nothing
                 * from this result. */
                grid_->setUpdated(false);
            }
            return;
        }
        /* test for contradictions; if we encounter one we set the opposite line */
        else if (lineSolver.testContradictions()) {
            grid_->setHLine(i, j, NLINE);
            return;
        } else {
            Grid nLineGuess;
            grid_->copy(nLineGuess);

            /* make an NLINE guess */
            nLineGuess.setHLine(i, j, NLINE);
            Solver nLineSolver = Solver(nLineGuess, rules_, contradictions_, selectedRules_, selectLength_, depth, epq_);
            ruleCounts_ = ruleCounts_ + nLineSolver.ruleCounts_;

            /* if both guesses led to multiple solutions, we know this puzzle
             * must also lead to another solution */
            if (nLineSolver.hasMultipleSolutions() || lineSolver.hasMultipleSolutions()) {
                multipleSolutions_ = true;
                return;
            }
            /* again check if solved. In this case we already know that we can't
             * get to a solution or contradiction with the opposite guess, so
             * we know we can't conclude whether this is the single solution */
            else if (nLineGuess.isSolved()) {
                lineSolver = Solver(lineGuess, rules_, contradictions_, selectedRules_, selectLength_, MAX_DEPTH, epq_);
                ruleCounts_ = ruleCounts_ + lineSolver.ruleCounts_;
                if (lineSolver.testContradictions()) {
                    /* The opposite guess leads to a contradiction
                     * so the previous found solution is the only one */
                    nLineGuess.copy(*grid_);
                } else if (lineGuess.isSolved() || lineSolver.hasMultipleSolutions()) {
                    /* The opposite guess also led to a solution
                     * so there are multiple solutions */
                    multipleSolutions_ = true;
                } else {
                    /* The opposite guess led to neither a solution or
                     * a contradiction, which can only happen if the subPuzzle
                     * is unsolvable for our maximum depth. We can learn nothing
                     * from this result. */
                    grid_->setUpdated(false);
                }
                return;
            }
            /* again check for contradictions */
            else if (nLineSolver.testContradictions()) {
                grid_->setHLine(i, j, LINE);
                return;
            } else {
                grid_->setUpdated(false);

                /* check for things that happen when we make both
                 * guesses; if we find any, we know they must happen */
                intersectGrids(lineGuess, nLineGuess);

                if (grid_->getUpdated()) {
                    return;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, -0x30(%rbp)
testl %esi, %esi
js 0xbb92
movl %edx, %r14d
testl %edx, %edx
js 0xbb92
movl %esi, %r15d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
cmpl %esi, 0xc(%rdi)
jl 0xbb92
cmpl %r14d, 0x10(%rdi)
jle 0xbb92
movl %ecx, %ebx
testl %ecx, %ecx
js 0xbbb1
movl %r15d, %esi
movl %r14d, %edx
callq 0x431a
testl %eax, %eax
jne 0xbb02
movq %rbx, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movb $0x1, 0x9(%rdi)
leaq -0x178(%rbp), %rsi
movw $0x100, 0x8(%rsi)       # imm = 0x100
leaq 0x76a2(%rip), %rax      # 0x12d38
addq $0x10, %rax
movq %rax, -0x48(%rbp)
movq %rax, (%rsi)
movw $0x1, 0x48(%rsi)
callq 0x2c4c
leaq -0x178(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x3104
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %r13
movq 0x20(%rcx), %rax
movq %rax, -0x40(%rbp)
movq 0x30(%rcx), %r12
movl 0x28(%rcx), %ebx
movq 0x38(%rcx), %rax
leaq -0x278(%rbp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x40(%rcx), %rsi
movq %rsi, -0x38(%rbp)
callq 0xc9d6
leaq -0x280(%rbp), %rax
leaq -0x120(%rbp), %rdi
leaq -0x178(%rbp), %rsi
movq %r13, %rdx
movq %r12, %rcx
movq -0x40(%rbp), %r8
movl %ebx, %r9d
pushq %rax
pushq -0x50(%rbp)
callq 0xad40
addq $0x10, %rsp
movq -0x278(%rbp), %rdi
testq %rdi, %rdi
je 0xb736
callq 0x2180
movl -0x120(%rbp), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
leaq -0x178(%rbp), %rdi
callq 0x376a
testb %al, %al
je 0xb833
leaq -0xb8(%rbp), %rsi
movw $0x100, 0x8(%rsi)       # imm = 0x100
movq -0x48(%rbp), %rax
movq %rax, (%rsi)
movw $0x1, 0x48(%rsi)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2c4c
leaq -0xb8(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl $0x2, %ecx
callq 0x3104
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %rbx
movq 0x30(%rax), %r12
movl 0x28(%rax), %r15d
movq 0x38(%rax), %rax
leaq -0x250(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq -0x38(%rbp), %rsi
callq 0xc9d6
leaq -0x258(%rbp), %rax
leaq -0x1e0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
movl %r15d, %r9d
pushq %rax
pushq $0x64
callq 0xad40
addq $0x10, %rsp
movq -0x250(%rbp), %rdi
testq %rdi, %rdi
je 0xb7fe
callq 0x2180
leaq -0x1e0(%rbp), %rdi
movl (%rdi), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
callq 0xae2e
testb %al, %al
je 0xb951
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2c4c
jmp 0xbac8
leaq -0x120(%rbp), %rdi
callq 0xae2e
testb %al, %al
je 0xb860
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl %r15d, %esi
movl %r14d, %edx
movl $0x2, %ecx
callq *(%rax)
jmp 0xbae5
leaq -0x2d8(%rbp), %rsi
movw $0x100, 0x8(%rsi)       # imm = 0x100
movq -0x48(%rbp), %rax
movq %rax, (%rsi)
movw $0x1, 0x48(%rsi)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2c4c
leaq -0x2d8(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl $0x2, %ecx
callq 0x3104
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r12
movq 0x20(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x30(%rax), %rbx
movl 0x28(%rax), %r13d
movq 0x38(%rax), %rax
leaq -0x228(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq -0x38(%rbp), %rsi
callq 0xc9d6
leaq -0x230(%rbp), %rax
leaq -0x1e0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
movq -0x40(%rbp), %r8
movl %r13d, %r9d
pushq %rax
pushq -0x50(%rbp)
callq 0xad40
addq $0x10, %rsp
movq -0x228(%rbp), %rdi
testq %rdi, %rdi
je 0xb90e
callq 0x2180
movl -0x1e0(%rbp), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
cmpb $0x0, -0x17c(%rbp)
jne 0xb92c
cmpb $0x1, -0xbc(%rbp)
jne 0xb97b
movq -0x30(%rbp), %rax
movb $0x1, 0x64(%rax)
movq -0x1a0(%rbp), %rdi
testq %rdi, %rdi
je 0xb945
callq 0x2180
leaq -0x2d8(%rbp), %rdi
jmp 0xbae0
leaq -0xb8(%rbp), %rdi
callq 0x376a
testb %al, %al
jne 0xb96e
cmpb $0x1, -0x17c(%rbp)
jne 0xbabc
movq -0x30(%rbp), %rax
movb $0x1, 0x64(%rax)
jmp 0xbac8
leaq -0x2d8(%rbp), %rdi
callq 0x376a
testb %al, %al
je 0xbb14
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %rbx
movq 0x30(%rax), %r12
movl 0x28(%rax), %r15d
movq 0x38(%rax), %rax
leaq -0x200(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq -0x38(%rbp), %rsi
callq 0xc9d6
leaq -0x208(%rbp), %rax
leaq -0xb8(%rbp), %rdi
leaq -0x178(%rbp), %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
movl %r15d, %r9d
pushq %rax
pushq $0x64
callq 0xad40
addq $0x10, %rsp
movups -0xb8(%rbp), %xmm0
movups -0xa8(%rbp), %xmm1
movups -0x98(%rbp), %xmm2
movups -0x88(%rbp), %xmm3
movaps %xmm2, -0x100(%rbp)
movaps %xmm1, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movaps %xmm3, -0xf0(%rbp)
movq -0xe0(%rbp), %rdi
movups -0x78(%rbp), %xmm0
movaps %xmm0, -0xe0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xd0(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, -0x78(%rbp)
movq $0x0, -0x68(%rbp)
testq %rdi, %rdi
je 0xba56
callq 0x2180
movb -0x54(%rbp), %al
movb %al, -0xbc(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0xc0(%rbp)
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0xba76
callq 0x2180
movq -0x200(%rbp), %rdi
testq %rdi, %rdi
je 0xba87
callq 0x2180
leaq -0x120(%rbp), %rdi
movl (%rdi), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
callq 0xae2e
testb %al, %al
je 0xbb60
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x2c4c
jmp 0xb934
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x0, 0x9(%rax)
movq -0x1a0(%rbp), %rdi
testq %rdi, %rdi
je 0xbad9
callq 0x2180
leaq -0xb8(%rbp), %rdi
callq 0x2a40
movq -0xe0(%rbp), %rdi
testq %rdi, %rdi
je 0xbaf6
callq 0x2180
leaq -0x178(%rbp), %rdi
callq 0x2a40
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x1e0(%rbp), %rdi
callq 0xae2e
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rdi
testb %al, %al
je 0xbb41
movq (%rdi), %rax
movl %r15d, %esi
movl %r14d, %edx
movl $0x1, %ecx
callq *(%rax)
jmp 0xb934
movb $0x0, 0x9(%rdi)
leaq -0x178(%rbp), %rsi
leaq -0x2d8(%rbp), %rdx
movq %rcx, %rdi
callq 0xc326
jmp 0xb934
leaq -0x178(%rbp), %rdi
callq 0x376a
testb %al, %al
jne 0xb92c
cmpb $0x1, -0xbc(%rbp)
je 0xb92c
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x0, 0x9(%rax)
jmp 0xb934
leaq 0x3897(%rip), %rdi      # 0xf430
leaq 0x38d6(%rip), %rsi      # 0xf476
leaq 0x38e5(%rip), %rcx      # 0xf48c
movl $0xc8, %edx
callq 0x2100
leaq 0x38ff(%rip), %rdi      # 0xf4b7
leaq 0x38b7(%rip), %rsi      # 0xf476
leaq 0x38c6(%rip), %rcx      # 0xf48c
movl $0xc9, %edx
callq 0x2100
movq %rax, %rbx
movq -0x200(%rbp), %rdi
testq %rdi, %rdi
je 0xbbeb
callq 0x2180
jmp 0xbbeb
jmp 0xbbe8
movq %rax, %rbx
movq -0x1a0(%rbp), %rdi
testq %rdi, %rdi
je 0xbc27
jmp 0xbc08
movq %rax, %rbx
movq -0x228(%rbp), %rdi
testq %rdi, %rdi
je 0xbc27
callq 0x2180
jmp 0xbc27
jmp 0xbc24
movq %rax, %rbx
movq -0x250(%rbp), %rdi
testq %rdi, %rdi
je 0xbc49
jmp 0xbc3f
jmp 0xbc46
movq %rax, %rbx
leaq -0x2d8(%rbp), %rdi
jmp 0xbc50
movq %rax, %rbx
movq -0x1a0(%rbp), %rdi
testq %rdi, %rdi
je 0xbc49
callq 0x2180
jmp 0xbc49
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x2a40
jmp 0xbc6d
movq %rax, %rbx
movq -0x278(%rbp), %rdi
testq %rdi, %rdi
je 0xbc83
jmp 0xbc79
jmp 0xbc80
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
testq %rdi, %rdi
je 0xbc83
callq 0x2180
jmp 0xbc83
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
callq 0x2a40
movq %rbx, %rdi
callq 0x2260
nop