// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
cmpl $0x9, -0x1c(%rbp)
jg 0x38a9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x20a0
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x20a0
movl $0x1, -0x84(%rbp)
cmpl $0x9, -0x84(%rbp)
jg 0x3899
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x84(%rbp), %edx
callq 0x40b0
cmpl $0x0, %eax
je 0x3707
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x84(%rbp), %edx
callq 0x40b0
cltq
movl -0x80(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x80(%rbp,%rax,4)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x84(%rbp), %edx
callq 0x40b0
cltq
cmpl $0x1, -0x80(%rbp,%rax,4)
jle 0x3705
movb $0x0, -0x1(%rbp)
jmp 0x38ad
jmp 0x3707
movq -0x18(%rbp), %rdi
movl -0x84(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x40b0
cmpl $0x0, %eax
je 0x3763
movq -0x18(%rbp), %rdi
movl -0x84(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x40b0
cltq
movl -0x50(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x50(%rbp,%rax,4)
movq -0x18(%rbp), %rdi
movl -0x84(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x40b0
cltq
cmpl $0x1, -0x50(%rbp,%rax,4)
jle 0x3761
movb $0x0, -0x1(%rbp)
jmp 0x38ad
jmp 0x3763
movl -0x1c(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x3883
movl -0x84(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x3883
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x20a0
movl $0x0, -0xb4(%rbp)
cmpl $0x3, -0xb4(%rbp)
jge 0x3881
movl $0x0, -0xb8(%rbp)
cmpl $0x3, -0xb8(%rbp)
jge 0x386b
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
addl -0xb4(%rbp), %esi
movl -0x84(%rbp), %edx
addl -0xb8(%rbp), %edx
callq 0x40b0
cmpl $0x0, %eax
je 0x3855
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
addl -0xb4(%rbp), %esi
movl -0x84(%rbp), %edx
addl -0xb8(%rbp), %edx
callq 0x40b0
cltq
movl -0xb0(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0xb0(%rbp,%rax,4)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
addl -0xb4(%rbp), %esi
movl -0x84(%rbp), %edx
addl -0xb8(%rbp), %edx
callq 0x40b0
cltq
cmpl $0x1, -0xb0(%rbp,%rax,4)
jle 0x3853
movb $0x0, -0x1(%rbp)
jmp 0x38ad
jmp 0x3855
jmp 0x3857
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x37c2
jmp 0x386d
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x37ab
jmp 0x3883
jmp 0x3885
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x369e
jmp 0x389b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x366a
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)