// File: /workspace/github_cpp_makefile_star2_O1/SilentAssassinMa[P]Sudoku-Solver/SudokuSolver.cpp
// Function: SudokuSolver::CheckConsistency(int*)
bool SudokuSolver::CheckConsistency(int *sudoku)
{
    // loop over every column and row and subsquare
    for (int i = 1; i <= 9; i++)
    {
        int rowsum[10] = {0};
        int columnsum[10] = {0};
        for (int j = 1; j <= 9; j++)
        {
            if (FindElement(sudoku, i, j) != 0)
            {
                columnsum[FindElement(sudoku, i, j)]++;
                if (columnsum[FindElement(sudoku, i, j)] > 1)
                    return false;
            }
            if (FindElement(sudoku, j, i) != 0)
            {
                rowsum[FindElement(sudoku, j, i)]++;
                if (rowsum[FindElement(sudoku, j, i)] > 1)
                    return false;
            }

            if ((i % 3) == 1 && (j % 3) == 1)
            {
                int subsquaresum[10] = {0};
                for (int m = 0; m < 3; m++)
                {
                    for (int n = 0; n < 3; n++)
                    {
                        if (FindElement(sudoku, i + m, j + n) != 0)
                        {
                            subsquaresum[FindElement(sudoku, i + m, j + n)]++;
                            if (subsquaresum[FindElement(sudoku, i + m, j + n)] > 1)
                                return false;
                        }
                    }
                }
            }
        }
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq -0x28(%rsi), %rax
movq %rax, -0x78(%rsp)
movl $0x1, %edx
xorps %xmm0, %xmm0
movl $0xaaaaaaab, %r8d       # imm = 0xAAAAAAAB
movaps %xmm0, (%rsp)
movaps %xmm0, -0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, -0x20(%rsp)
movaps %xmm0, -0x30(%rsp)
movaps %xmm0, -0x40(%rsp)
movl %edx, %eax
imulq %r8, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %r9d
movl %edx, %eax
subl %r9d, %eax
leaq (%rdx,%rdx,8), %r9
movq -0x78(%rsp), %rcx
leaq (%rcx,%r9,4), %r9
leaq (%rcx,%rdx,4), %r10
movq %rsi, %r11
movl $0x1, %ebx
movslq (%r9,%rbx,4), %r14
testq %r14, %r14
je 0x3346
movl -0x40(%rsp,%r14,4), %r15d
leal 0x1(%r15), %ebp
movl %ebp, -0x40(%rsp,%r14,4)
testl %r15d, %r15d
jg 0x3408
leaq (%rbx,%rbx,8), %r14
movslq (%r10,%r14,4), %r14
testq %r14, %r14
je 0x336a
movl -0x10(%rsp,%r14,4), %r15d
leal 0x1(%r15), %ebp
movl %ebp, -0x10(%rsp,%r14,4)
testl %r15d, %r15d
jg 0x3408
cmpl $0x1, %eax
jne 0x33f3
movl %ebx, %r14d
imulq %r8, %r14
shrq $0x21, %r14
leal (%r14,%r14,2), %ebp
movl %ebx, %r14d
subl %ebp, %r14d
cmpl $0x1, %r14d
jne 0x33f3
movaps %xmm0, -0x60(%rsp)
movaps %xmm0, -0x70(%rsp)
movq $0x0, -0x50(%rsp)
movq %r11, %r14
xorl %r15d, %r15d
xorl %r13d, %r13d
xorl %r12d, %r12d
movslq (%r14,%r13,4), %rbp
testq %rbp, %rbp
je 0x33c5
movl -0x70(%rsp,%rbp,4), %edi
leal 0x1(%rdi), %ecx
movl %ecx, -0x70(%rsp,%rbp,4)
testl %edi, %edi
jg 0x33da
cmpq $0x2, %r13
leaq 0x1(%r13), %rcx
setae %r12b
movq %rcx, %r13
cmpq $0x3, %rcx
jne 0x33ad
testb $0x1, %r12b
je 0x33ed
incq %r15
addq $0x24, %r14
cmpq $0x3, %r15
jne 0x33a7
testb $0x1, %r12b
je 0x3408
incq %rbx
addq $0x4, %r11
cmpq $0xa, %rbx
jne 0x3326
movb $0x1, %al
jmp 0x340a
xorl %eax, %eax
testb %al, %al
je 0x341f
incq %rdx
addq $0x24, %rsi
cmpq $0xa, %rdx
jne 0x32db
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq