// File: /workspace/github_cpp_makefile_star2_O2/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 0x719f
movl %edx, %r14d
testl %edx, %edx
js 0x719f
movl %esi, %r15d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
cmpl %esi, 0xc(%rdi)
jl 0x719f
cmpl %r14d, 0x10(%rdi)
jle 0x719f
movl %ecx, %ebx
testl %ecx, %ecx
js 0x71be
movl %r15d, %esi
movl %r14d, %edx
callq 0x3baa
testl %eax, %eax
jne 0x7111
movq %rbx, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movb $0x1, 0x9(%rdi)
leaq -0xa8(%rbp), %rsi
movw $0x100, 0x8(%rsi)       # imm = 0x100
leaq 0x7fd2(%rip), %rax      # 0xed40
addq $0x10, %rax
movq %rax, -0x48(%rbp)
movq %rax, (%rsi)
movw $0x1, 0x48(%rsi)
callq 0x28f4
leaq -0xa8(%rbp), %rdi
pushq $0x1
popq %rcx
movl %r15d, %esi
movl %r14d, %edx
callq 0x2d42
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r13
movq 0x20(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x30(%rax), %r12
movl 0x28(%rax), %ebx
leaq 0x38(%rax), %rsi
leaq -0x160(%rbp), %rdi
movq %rsi, -0x38(%rbp)
callq 0x7e6c
leaq -0x288(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movq %r13, %rdx
movq %r12, %rcx
movq -0x40(%rbp), %r8
movl %ebx, %r9d
leaq -0x160(%rbp), %rax
pushq %rax
pushq -0x50(%rbp)
callq 0x64ec
popq %rax
popq %rcx
leaq -0x158(%rbp), %rdi
callq 0x4b4a
movl -0x288(%rbp), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
leaq -0xa8(%rbp), %rdi
callq 0x3280
testb %al, %al
je 0x6ee6
leaq -0x220(%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 0x28f4
leaq -0x220(%rbp), %rdi
pushq $0x2
popq %rcx
movl %r15d, %esi
movl %r14d, %edx
callq 0x2d42
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %rbx
movq 0x30(%rax), %r12
movl 0x28(%rax), %r15d
leaq -0x2d8(%rbp), %r13
movq %r13, %rdi
movq -0x38(%rbp), %rsi
callq 0x7e6c
leaq -0x110(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
movl %r15d, %r9d
pushq %r13
pushq $0x64
callq 0x64ec
popq %rax
popq %rcx
leaq -0x2d0(%rbp), %rdi
callq 0x4b4a
leaq -0x110(%rbp), %rdi
movl (%rdi), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
callq 0x65ba
testb %al, %al
je 0x6fec
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x28f4
jmp 0x70e1
leaq -0x288(%rbp), %rdi
callq 0x65ba
testb %al, %al
je 0x6f11
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
pushq $0x2
popq %rcx
movl %r15d, %esi
movl %r14d, %edx
callq *(%rax)
jmp 0x70f9
leaq -0x1b8(%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 0x28f4
leaq -0x1b8(%rbp), %rdi
pushq $0x2
popq %rcx
movl %r15d, %esi
movl %r14d, %edx
callq 0x2d42
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r12
movq 0x20(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x30(%rax), %rbx
movl 0x28(%rax), %r13d
leaq -0x138(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x7e6c
leaq -0x110(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
movq -0x40(%rbp), %r8
movl %r13d, %r9d
leaq -0x138(%rbp), %rax
pushq %rax
pushq -0x50(%rbp)
callq 0x64ec
popq %rax
popq %rcx
leaq -0x130(%rbp), %rdi
callq 0x4b4a
movl -0x110(%rbp), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
cmpb $0x0, -0xac(%rbp)
jne 0x6fcc
cmpb $0x1, -0x224(%rbp)
jne 0x7016
movq -0x30(%rbp), %rax
movb $0x1, 0x64(%rax)
leaq -0xd0(%rbp), %rdi
callq 0x4b4a
leaq -0x1b8(%rbp), %rdi
jmp 0x70f4
leaq -0x220(%rbp), %rdi
callq 0x3280
testb %al, %al
jne 0x7009
cmpb $0x1, -0xac(%rbp)
jne 0x70d5
movq -0x30(%rbp), %rax
movb $0x1, 0x64(%rax)
jmp 0x70e1
leaq -0x1b8(%rbp), %rdi
callq 0x3280
testb %al, %al
je 0x7123
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %rbx
movq 0x30(%rax), %r12
movl 0x28(%rax), %r15d
leaq -0x2b0(%rbp), %r13
movq %r13, %rdi
movq -0x38(%rbp), %rsi
callq 0x7e6c
leaq -0x220(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
movl %r15d, %r9d
pushq %r13
pushq $0x64
callq 0x64ec
popq %rax
popq %rcx
leaq -0x288(%rbp), %rbx
leaq -0x220(%rbp), %rsi
movq %rbx, %rdi
callq 0x7e84
leaq -0x1e0(%rbp), %rdi
callq 0x4b4a
leaq -0x2a8(%rbp), %rdi
callq 0x4b4a
movl (%rbx), %eax
movq -0x30(%rbp), %rcx
addl %eax, (%rcx)
movq %rbx, %rdi
callq 0x65ba
testb %al, %al
je 0x716d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x28f4
jmp 0x6fd4
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x0, 0x9(%rax)
leaq -0xd0(%rbp), %rdi
callq 0x4b4a
leaq -0x220(%rbp), %rdi
callq 0x2750
leaq -0x248(%rbp), %rdi
callq 0x4b4a
leaq -0xa8(%rbp), %rdi
callq 0x2750
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x110(%rbp), %rdi
callq 0x65ba
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rdi
testb %al, %al
je 0x714e
movq (%rdi), %rax
pushq $0x1
popq %rcx
movl %r15d, %esi
movl %r14d, %edx
callq *(%rax)
jmp 0x6fd4
movb $0x0, 0x9(%rdi)
leaq -0xa8(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
movq %rcx, %rdi
callq 0x7822
jmp 0x6fd4
leaq -0xa8(%rbp), %rdi
callq 0x3280
testb %al, %al
jne 0x6fcc
cmpb $0x1, -0x224(%rbp)
je 0x6fcc
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x0, 0x9(%rax)
jmp 0x6fd4
leaq 0x3262(%rip), %rdi      # 0xa408
leaq 0x32a1(%rip), %rsi      # 0xa44e
leaq 0x32b0(%rip), %rcx      # 0xa464
movl $0xc8, %edx
callq 0x2120
leaq 0x32ca(%rip), %rdi      # 0xa48f
leaq 0x3282(%rip), %rsi      # 0xa44e
leaq 0x3291(%rip), %rcx      # 0xa464
movl $0xc9, %edx
callq 0x2120
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x4b4a
jmp 0x71f3
jmp 0x71f0
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x7206
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x4b4a
jmp 0x7220
jmp 0x721d
movq %rax, %rbx
leaq -0x2d0(%rbp), %rdi
jmp 0x7233
jmp 0x723a
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
jmp 0x7244
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x4b4a
jmp 0x723d
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x2750
jmp 0x725c
movq %rax, %rbx
leaq -0x158(%rbp), %rdi
jmp 0x7263
jmp 0x726a
movq %rax, %rbx
leaq -0x248(%rbp), %rdi
callq 0x4b4a
jmp 0x726d
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x2750
movq %rbx, %rdi
callq 0x2250
nop