// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
leaq -0x28(%rsi), %rcx
movl $0x1, %r8d
xorl %edi, %edi
xorps %xmm0, %xmm0
movl $0xaaaaaaab, %r13d      # imm = 0xAAAAAAAB
xorl %eax, %eax
movaps %xmm0, -0x10(%rsp)
movaps %xmm0, -0x20(%rsp)
movq %rdi, (%rsp)
movq %rdi, -0x30(%rsp)
movaps %xmm0, -0x40(%rsp)
movaps %xmm0, -0x50(%rsp)
movl %r8d, %r9d
imulq %r13, %r9
shrq $0x21, %r9
leal (%r9,%r9,2), %r10d
movl %r8d, %r9d
subl %r10d, %r9d
leaq (%r8,%r8,8), %r10
leaq (%rcx,%r10,4), %r10
leaq (%rcx,%r8,4), %r11
movq %rsi, %rbx
movl $0x1, %r14d
movslq (%r10,%r14,4), %r15
testq %r15, %r15
je 0x333c
movl -0x50(%rsp,%r15,4), %r12d
leal 0x1(%r12), %ebp
movl %ebp, -0x50(%rsp,%r15,4)
testl %r12d, %r12d
jg 0x3407
leaq (%r14,%r14,8), %r15
movslq (%r11,%r15,4), %r15
testq %r15, %r15
je 0x3361
movl -0x20(%rsp,%r15,4), %r12d
leal 0x1(%r12), %ebp
movl %ebp, -0x20(%rsp,%r15,4)
testl %r12d, %r12d
jg 0x3407
cmpl $0x1, %r9d
jne 0x33d8
movzbl %r14b, %ebp
imull $0xab, %ebp, %r15d
shrl $0x9, %r15d
leal (%r15,%r15,2), %ebp
movl %r14d, %r15d
subb %bpl, %r15b
cmpb $0x1, %r15b
jne 0x33d8
movaps %xmm0, -0x70(%rsp)
movaps %xmm0, -0x80(%rsp)
movq $0x0, -0x60(%rsp)
movq %rbx, %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq (%r15,%r13,4), %rbp
testq %rbp, %rbp
je 0x33ba
movl -0x80(%rsp,%rbp,4), %edi
leal 0x1(%rdi), %edx
movl %edx, -0x80(%rsp,%rbp,4)
testl %edi, %edi
jg 0x3407
incq %r13
cmpq $0x3, %r13
jne 0x33a2
incq %r12
addq $0x24, %r15
cmpq $0x3, %r12
jne 0x339f
xorl %edi, %edi
movl $0xaaaaaaab, %r13d      # imm = 0xAAAAAAAB
incq %r14
addq $0x4, %rbx
cmpq $0xa, %r14
jne 0x331b
cmpq $0x9, %r8
leaq 0x1(%r8), %rdx
setae %al
addq $0x24, %rsi
movq %rdx, %r8
cmpq $0xa, %rdx
jne 0x32d4
movb $0x1, %al
andb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq