// File: /workspace/github_cpp_makefile_star2_O3/davidjosepha[P]slitherlink/src/generator/loopgen.cpp
// Function: LoopGen::countLines(int, int) const
int LoopGen::countLines(int i, int j) const {
    bool inside = inLoop(i, j);

    int lines = ((!inBounds({ i + 1, j}) && inside) || (inBounds({ i + 1, j }) && inLoop(i + 1, j) != inside))
                + ((!inBounds({ i - 1, j}) && inside) || (inBounds({ i - 1, j }) && inLoop(i - 1, j) != inside))
                + ((!inBounds({ i, j + 1}) && inside) || (inBounds({ i, j + 1 }) && inLoop(i, j + 1) != inside))
                + ((!inBounds({ i, j - 1}) && inside) || (inBounds({ i, j - 1 }) && inLoop(i, j - 1) != inside));

    return lines;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movabsq $-0x7fffffff80000000, %r9 # imm = 0x8000000080000000
movq (%rdi), %r14
movslq %esi, %r12
movq (%r14,%r12,8), %rax
movslq %edx, %r15
movq %rax, -0x30(%rbp)
movl (%rax,%r15,4), %r8d
decl %r8d
cmpl $0x2, %r8d
setb %cl
incl %r12d
movq %r15, %rbx
shlq $0x20, %rbx
leaq (%r12,%rbx), %r10
testq %r9, %r10
sete %r10b
movl 0x10(%rdi), %r11d
cmpl %r12d, %r11d
setg %r13b
andb %r10b, %r13b
movl %ecx, %r10d
cmpb $0x1, %r13b
jne 0xe168
cmpl $0x2, %r8d
setb %al
movl 0x14(%rdi), %r13d
cmpl %edx, %r13d
setle %r9b
movb $0x1, %r10b
testb %r9b, %al
jne 0xe168
cmpl %edx, %r13d
jle 0xe165
cmpl $0x2, %r8d
setb %al
movslq %r12d, %r9
movq (%r14,%r9,8), %r9
movl (%r9,%r15,4), %r9d
decl %r9d
cmpl $0x2, %r9d
setb %r10b
xorb %al, %r10b
jmp 0xe168
xorl %r10d, %r10d
leal -0x1(%rsi), %r12d
orq %r12, %rbx
movabsq $-0x7fffffff80000000, %rax # imm = 0x8000000080000000
testq %rax, %rbx
sete %al
cmpl %esi, %r11d
setge %r9b
andb %al, %r9b
movl %ecx, %ebx
cmpb $0x1, %r9b
jne 0xe1d1
cmpl $0x2, %r8d
setb %al
movl 0x14(%rdi), %r13d
cmpl %edx, %r13d
setle %r9b
movb $0x1, %bl
testb %r9b, %al
jne 0xe1d1
cmpl %edx, %r13d
jle 0xe1cf
cmpl $0x2, %r8d
setb %al
movslq %r12d, %r9
movq (%r14,%r9,8), %r9
movl (%r9,%r15,4), %r9d
decl %r9d
cmpl $0x2, %r9d
setb %bl
xorb %al, %bl
jmp 0xe1d1
xorl %ebx, %ebx
leal 0x1(%rdx), %r12d
movq %r12, %rax
shlq $0x20, %rax
movl %esi, %r15d
orq %r15, %rax
movabsq $-0x7fffffff80000000, %r9 # imm = 0x8000000080000000
testq %r9, %rax
sete %al
cmpl %esi, %r11d
setg %r9b
andb %al, %r9b
movl %ecx, %r14d
cmpb $0x1, %r9b
jne 0xe249
cmpl $0x2, %r8d
setb %al
movl 0x14(%rdi), %r13d
cmpl %r12d, %r13d
setle %r9b
movb $0x1, %r14b
testb %r9b, %al
jne 0xe249
cmpl %r12d, %r13d
jle 0xe246
cmpl $0x2, %r8d
setb %al
movslq %r12d, %r9
movq -0x30(%rbp), %r14
movl (%r14,%r9,4), %r9d
decl %r9d
cmpl $0x2, %r9d
setb %r14b
xorb %al, %r14b
jmp 0xe249
xorl %r14d, %r14d
cmpl %esi, %r11d
setg %al
leal -0x1(%rdx), %esi
movq %rsi, %r9
shlq $0x20, %r9
orq %r15, %r9
movabsq $-0x7fffffff80000000, %r11 # imm = 0x8000000080000000
testq %r11, %r9
sete %r9b
andb %al, %r9b
cmpb $0x1, %r9b
jne 0xe2a6
cmpl $0x2, %r8d
setb %cl
movl 0x14(%rdi), %eax
cmpl %edx, %eax
setl %dl
jge 0xe28b
andb %dl, %cl
jmp 0xe2a6
cmpl $0x2, %r8d
setb %al
movslq %esi, %rcx
movq -0x30(%rbp), %rdx
movl (%rdx,%rcx,4), %ecx
decl %ecx
cmpl $0x2, %ecx
setb %cl
xorb %al, %cl
movzbl %cl, %eax
movzbl %r14b, %ecx
addl %eax, %ecx
movzbl %bl, %edx
movzbl %r10b, %eax
addl %edx, %eax
addl %ecx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop