// File: /workspace/github_cpp_makefile_star2_O3/SilentAssassinMa[P]Sudoku-Solver/SudokuSolver.cpp
// Function: SudokuSolver::FindMaxConstrain(int*, int&, int&)
void SudokuSolver::FindMaxConstrain(int *sudoku, int &x, int &y)
{
    // This returns the empty element with maximum constrain
    int rowconstrain[10] = {0};
    int columnconstrain[10] = {0};
    int subsquareconstrain[3][3] = {0};
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (FindElement(sudoku, i, j) != 0)
            {
                rowconstrain[i]++;
                columnconstrain[j]++;
            }

            if ((i % 3) == 1 && (j % 3) == 1)
            {
                for (int m = 0; m < 3; m++)
                {
                    for (int n = 0; n < 3; n++)
                    {
                        if (FindElement(sudoku, i + m, j + n) != 0)
                            subsquareconstrain[i / 3][j / 3]++;
                    }
                }
            }
        }
    }
    int maxconstrain = -1;

    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (FindElement(sudoku, i, j) == 0)
            {
                int sumconstrain = rowconstrain[i] + columnconstrain[j] + subsquareconstrain[(i - 1) / 3][(j - 1) / 3];
                if (sumconstrain > maxconstrain)
                {
                    maxconstrain = sumconstrain;
                    x = i;
                    y = j;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorps %xmm0, %xmm0
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)
movaps %xmm0, -0x60(%rsp)
movaps %xmm0, -0x70(%rsp)
movl $0x0, -0x50(%rsp)
leaq -0x28(%rsi), %rax
movq %rax, -0x78(%rsp)
movl $0x1, %edi
movl $0xaaaaaaab, %r8d       # imm = 0xAAAAAAAB
movq %rsi, %r9
movl %edi, %eax
imulq %r8, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %r11d
movl %edi, %r10d
subl %r11d, %r10d
leaq (%rdi,%rdi,8), %r11
movq -0x78(%rsp), %rbx
leaq (%rbx,%r11,4), %r11
leaq (%rax,%rax,2), %rax
leaq (%rsp,%rax,4), %rbx
addq $-0x70, %rbx
movq %r9, %r14
movl $0x1, %r15d
cmpl $0x0, (%r11,%r15,4)
je 0x34dd
incl -0x10(%rsp,%rdi,4)
incl -0x40(%rsp,%r15,4)
cmpl $0x1, %r10d
jne 0x3537
movzbl %r15b, %eax
imull $0xab, %eax, %eax
shrl $0x9, %eax
leal (%rax,%rax,2), %eax
movl %r15d, %ebp
subb %al, %bpl
cmpb $0x1, %bpl
jne 0x3537
movl %r15d, %eax
imulq %r8, %rax
shrq $0x21, %rax
leaq (%rbx,%rax,4), %r12
movq %r14, %r13
xorl %ebp, %ebp
xorl %eax, %eax
cmpl $0x0, (%r13,%rax,4)
je 0x3521
incl (%r12)
incq %rax
cmpq $0x3, %rax
jne 0x3515
incq %rbp
addq $0x24, %r13
cmpq $0x3, %rbp
jne 0x3513
incq %r15
addq $0x4, %r14
cmpq $0xa, %r15
jne 0x34cd
incq %rdi
addq $0x24, %r9
cmpq $0xa, %rdi
jne 0x3497
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl $0x1, %eax
movl $0xaaaaaaab, %edi       # imm = 0xAAAAAAAB
leal -0x1(%rax), %r9d
imulq %rdi, %r9
shrq $0x21, %r9
leaq (%r9,%r9,2), %r9
leaq (%rsp,%r9,4), %r9
addq $-0x70, %r9
xorl %r10d, %r10d
cmpl $0x0, (%rsi,%r10,4)
jne 0x35bf
movl -0x3c(%rsp,%r10,4), %r11d
addl -0x10(%rsp,%rax,4), %r11d
movsbl %r10b, %ebx
imull $0x56, %ebx, %ebx
movzwl %bx, %ebp
shrl $0x8, %ebx
shrl $0xf, %ebp
addb %bl, %bpl
movsbq %bpl, %rbx
movl %ebx, %ebx
addl (%r9,%rbx,4), %r11d
cmpl %r8d, %r11d
jle 0x35bf
leal 0x1(%r10), %r8d
movl %eax, (%rdx)
movl %r8d, (%rcx)
movl %r11d, %r8d
incq %r10
cmpq $0x9, %r10
jne 0x3580
incq %rax
addq $0x24, %rsi
cmpq $0xa, %rax
jne 0x3565
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq