// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/sudoku/sudoku.c
// Function: is_blocked_elsewhere
static int is_blocked_elsewhere(int target, int y, int x)
{
  int ny, nx, skipped = 0;

  /* If number can already be found in the same 3x3 block... */
  for (ny = (y / 3) * 3; ny < ((y / 3) + 1) * 3; ny++) {
    for (nx = (x / 3) * 3; nx < ((x / 3) + 1) * 3; nx++) {
      if (sudoku[ny][nx] == target)
        return 0; /* ...then abort. */
    }
  }

  /* For each other empty field in the block... */
  for (ny = (y / 3) * 3; ny < ((y / 3) + 1) * 3; ny++) {
    for (nx = (x / 3) * 3; nx < ((x / 3) + 1) * 3; nx++) {
      if (sudoku[ny][nx] > 0) {
        skipped++;
        continue; /* ...but only the empty ones... */
      }
      if (ny == y && nx == x) {
        skipped++;
        continue; /* ...not including itself. */
      }

      if (ny != y && is_blocked_horizontally(target, ny)) {
        continue; /* Horizontal path is blocked! */
      } else {
        if (nx != x && is_blocked_vertically(target, nx)) {
          continue; /* Vertical path is blocked! */
        } else {
          return 0; /* No paths blocked. */
        }
      }

    }
  }

  if (skipped == 9)
    return 0; /* Algorithm fails if all fields are occupied! */

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0xc(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
imull $0x3, %eax, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x20(%rbp), %eax
addl $0x1, %ecx
imull $0x3, %ecx, %ecx
cmpl %ecx, %eax
jge 0x2321
movl -0x10(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
imull $0x3, %eax, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x10(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x24(%rbp), %eax
addl $0x1, %ecx
imull $0x3, %ecx, %ecx
cmpl %ecx, %eax
jge 0x2311
movslq -0x14(%rbp), %rcx
leaq 0x2dfb(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x8(%rbp), %eax
jne 0x2304
movl $0x0, -0x4(%rbp)
jmp 0x243e
jmp 0x2306
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22ba
jmp 0x2313
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2289
movl -0xc(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
imull $0x3, %eax, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0xc(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x28(%rbp), %eax
addl $0x1, %ecx
imull $0x3, %ecx, %ecx
cmpl %ecx, %eax
jge 0x2428
movl -0x10(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
imull $0x3, %eax, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x10(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x2c(%rbp), %eax
addl $0x1, %ecx
imull $0x3, %ecx, %ecx
cmpl %ecx, %eax
jge 0x2418
movslq -0x14(%rbp), %rcx
leaq 0x2d4a(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x23b2
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x240a
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x23cd
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x23cd
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x240a
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0x23e7
movl -0x8(%rbp), %edi
movl -0x14(%rbp), %esi
callq 0x2450
cmpl $0x0, %eax
je 0x23e7
jmp 0x240a
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
je 0x2401
movl -0x8(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x24b0
cmpl $0x0, %eax
je 0x2401
jmp 0x240a
movl $0x0, -0x4(%rbp)
jmp 0x243e
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2367
jmp 0x241a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2332
cmpl $0x9, -0x1c(%rbp)
jne 0x2437
movl $0x0, -0x4(%rbp)
jmp 0x243e
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)