// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/sudoku/sudoku.c
// Function: main
int main(int argc, char *argv[])
{
  int done;
  char *current_status;

  if (argc == 2)
    read_from_file(argv[1]);

  initscr();
  noecho();
  keypad(stdscr, TRUE);

  current_status = NULL;
  done = 0;
  while (! done) {
    display_update(current_status);

    switch (getch()) {
    case KEY_LEFT:
      current_x--;
      if (current_x < 0)
        current_x = 0;
      break;

    case KEY_RIGHT:
      current_x++;
      if (current_x >= 9)
        current_x = 8;
      break;

    case KEY_UP:
      current_y--;
      if (current_y < 0)
        current_y = 0;
      break;

    case KEY_DOWN:
      current_y++;
      if (current_y >= 9)
        current_y = 8;
      break;

    case '1':
      sudoku[current_y][current_x] = 1;
      break;

    case '2':
      sudoku[current_y][current_x] = 2;
      break;

    case '3':
      sudoku[current_y][current_x] = 3;
      break;

    case '4':
      sudoku[current_y][current_x] = 4;
      break;

    case '5':
      sudoku[current_y][current_x] = 5;
      break;

    case '6':
      sudoku[current_y][current_x] = 6;
      break;

    case '7':
      sudoku[current_y][current_x] = 7;
      break;

    case '8':
      sudoku[current_y][current_x] = 8;
      break;

    case '9':
      sudoku[current_y][current_x] = 9;
      break;

    case '0':
    case ' ':
      sudoku[current_y][current_x] = 0;
      break;

    case KEY_ENTER:
    case '\n':
      if (solve_sudoku())
        current_status = "Unable to solve, enter more numbers.";
      else
        current_status = "Solved!";
      break;

    case 'q':
    case 'Q':
    case '\e':
      done = 1;
      break;

    default:
      break;
    }
  }

  endwin();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x1279
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1650
callq 0x1070
callq 0x1060
movq 0x3d56(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x1090
movq $0x0, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x12b8
jmp 0x1642
movq -0x20(%rbp), %rdi
callq 0x17d0
movq 0x3d18(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
callq 0x1040
movl %eax, %ecx
movl %ecx, -0x24(%rbp)
subl $0xa, %eax
je 0x160e
jmp 0x12e0
movl -0x24(%rbp), %eax
subl $0x1b, %eax
je 0x1632
jmp 0x12ee
movl -0x24(%rbp), %eax
subl $0x20, %eax
je 0x15e9
jmp 0x12fc
movl -0x24(%rbp), %eax
subl $0x30, %eax
je 0x15e9
jmp 0x130a
movl -0x24(%rbp), %eax
subl $0x31, %eax
je 0x1487
jmp 0x1318
movl -0x24(%rbp), %eax
subl $0x32, %eax
je 0x14af
jmp 0x1326
movl -0x24(%rbp), %eax
subl $0x33, %eax
je 0x14d7
jmp 0x1334
movl -0x24(%rbp), %eax
subl $0x34, %eax
je 0x14ff
jmp 0x1342
movl -0x24(%rbp), %eax
subl $0x35, %eax
je 0x1527
jmp 0x1350
movl -0x24(%rbp), %eax
subl $0x36, %eax
je 0x154f
jmp 0x135e
movl -0x24(%rbp), %eax
subl $0x37, %eax
je 0x1577
jmp 0x136c
movl -0x24(%rbp), %eax
subl $0x38, %eax
je 0x159f
jmp 0x137a
movl -0x24(%rbp), %eax
subl $0x39, %eax
je 0x15c4
jmp 0x1388
movl -0x24(%rbp), %eax
subl $0x51, %eax
je 0x1632
jmp 0x1396
movl -0x24(%rbp), %eax
subl $0x71, %eax
je 0x1632
jmp 0x13a4
movl -0x24(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x1460
jmp 0x13b4
movl -0x24(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x1439
jmp 0x13c0
movl -0x24(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0x13eb
jmp 0x13cc
movl -0x24(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0x1412
jmp 0x13d8
movl -0x24(%rbp), %eax
subl $0x157, %eax            # imm = 0x157
je 0x160e
jmp 0x163b
movl 0x3cdf(%rip), %eax      # 0x50d0
addl $-0x1, %eax
movl %eax, 0x3cd6(%rip)      # 0x50d0
cmpl $0x0, 0x3ccf(%rip)      # 0x50d0
jge 0x140d
movl $0x0, 0x3cc3(%rip)      # 0x50d0
jmp 0x163d
movl 0x3cb8(%rip), %eax      # 0x50d0
addl $0x1, %eax
movl %eax, 0x3caf(%rip)      # 0x50d0
cmpl $0x9, 0x3ca8(%rip)      # 0x50d0
jl 0x1434
movl $0x8, 0x3c9c(%rip)      # 0x50d0
jmp 0x163d
movl 0x3c95(%rip), %eax      # 0x50d4
addl $-0x1, %eax
movl %eax, 0x3c8c(%rip)      # 0x50d4
cmpl $0x0, 0x3c85(%rip)      # 0x50d4
jge 0x145b
movl $0x0, 0x3c79(%rip)      # 0x50d4
jmp 0x163d
movl 0x3c6e(%rip), %eax      # 0x50d4
addl $0x1, %eax
movl %eax, 0x3c65(%rip)      # 0x50d4
cmpl $0x9, 0x3c5e(%rip)      # 0x50d4
jl 0x1482
movl $0x8, 0x3c52(%rip)      # 0x50d4
jmp 0x163d
movslq 0x3c46(%rip), %rcx      # 0x50d4
leaq 0x3c4b(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3c2d(%rip), %rcx      # 0x50d0
movl $0x1, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3c1e(%rip), %rcx      # 0x50d4
leaq 0x3c23(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3c05(%rip), %rcx      # 0x50d0
movl $0x2, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3bf6(%rip), %rcx      # 0x50d4
leaq 0x3bfb(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3bdd(%rip), %rcx      # 0x50d0
movl $0x3, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3bce(%rip), %rcx      # 0x50d4
leaq 0x3bd3(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3bb5(%rip), %rcx      # 0x50d0
movl $0x4, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3ba6(%rip), %rcx      # 0x50d4
leaq 0x3bab(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3b8d(%rip), %rcx      # 0x50d0
movl $0x5, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3b7e(%rip), %rcx      # 0x50d4
leaq 0x3b83(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3b65(%rip), %rcx      # 0x50d0
movl $0x6, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3b56(%rip), %rcx      # 0x50d4
leaq 0x3b5b(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3b3d(%rip), %rcx      # 0x50d0
movl $0x7, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3b2e(%rip), %rcx      # 0x50d4
leaq 0x3b33(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3b15(%rip), %rcx      # 0x50d0
movl $0x8, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3b09(%rip), %rcx      # 0x50d4
leaq 0x3b0e(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3af0(%rip), %rcx      # 0x50d0
movl $0x9, (%rax,%rcx,4)
jmp 0x163d
movslq 0x3ae4(%rip), %rcx      # 0x50d4
leaq 0x3ae9(%rip), %rax      # 0x50e0
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movslq 0x3acb(%rip), %rcx      # 0x50d0
movl $0x0, (%rax,%rcx,4)
jmp 0x163d
callq 0x1af0
cmpl $0x0, %eax
je 0x1625
leaq 0x1a06(%rip), %rax      # 0x3025
movq %rax, -0x20(%rbp)
jmp 0x1630
leaq 0x1a1e(%rip), %rax      # 0x304a
movq %rax, -0x20(%rbp)
jmp 0x163d
movl $0x1, -0x14(%rbp)
jmp 0x163d
jmp 0x163d
jmp 0x12a6
callq 0x1120
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nop