// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/mastermind/mastermind.c
// Function: main
int main(void)
{
  int user_done, user_quit;

  memset(guess, 0, sizeof(guess_t) * GUESS_SLOTS);
  display_init();
  hidden_code_randomize();

  for (current_guess = GUESS_SLOTS - 1;
       current_guess >= 0;
       current_guess--) {

    /* Wait for user to make a valid guess. */
    current_slot = user_done = user_quit = 0;
    while ((! user_done) && (! user_quit)) {
      display_update(NULL);

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

      case KEY_RIGHT:
        current_slot++;
        if (current_slot >= CODE_SLOTS)
          current_slot = CODE_SLOTS - 1;
        break;

      case KEY_UP:
        guess[current_guess].code[current_slot]++;
        if (guess[current_guess].code[current_slot] > CODE_FOXTROT)
          guess[current_guess].code[current_slot] = CODE_ALPHA;
        break;

      case KEY_DOWN:
        guess[current_guess].code[current_slot]--;
        if (guess[current_guess].code[current_slot] == CODE_NONE ||
            guess[current_guess].code[current_slot] > CODE_FOXTROT)
          guess[current_guess].code[current_slot] = CODE_FOXTROT;
        break;

      case KEY_ENTER:
      case '\n':
      case ' ':
        if (guess_is_completed())
          user_done = 1;
        break;

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

      default:
        break;
      }
    }

    if (user_quit)
      break;

    evaluate_and_give_hints();

    if (guess_is_correct())
      break;
  }

  if (guess_is_correct()) {
    display_update("Congratulations!");
  } else {
    if (user_quit) {
      display_update("Aborted.");
    } else {
      display_update("Too late!");
    }
  }

  if (! user_quit)
    getch(); /* Press any key... */

  endwin();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
leaq 0x2e6a(%rip), %rdi      # 0x40d0
xorl %esi, %esi
movl $0x140, %edx            # imm = 0x140
callq 0x10b0
callq 0x1570
callq 0x1600
movl $0x9, 0x2f8a(%rip)      # 0x4210
cmpl $0x0, 0x2f83(%rip)      # 0x4210
jl 0x1512
movl $0x0, -0xc(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, 0x2f69(%rip)      # 0x4214
xorl %eax, %eax
cmpl $0x0, -0x8(%rbp)
movb %al, -0xd(%rbp)
jne 0x12c2
cmpl $0x0, -0xc(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0xd(%rbp)
movb -0xd(%rbp), %al
testb $0x1, %al
jne 0x12ce
jmp 0x14e3
xorl %eax, %eax
movl %eax, %edi
callq 0x1660
movq 0x2d02(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x1070
movl %eax, %ecx
movl %ecx, -0x14(%rbp)
subl $0xa, %eax
je 0x14c0
jmp 0x12f6
movl -0x14(%rbp), %eax
subl $0x1b, %eax
je 0x14d3
jmp 0x1304
movl -0x14(%rbp), %eax
subl $0x20, %eax
je 0x14c0
jmp 0x1312
movl -0x14(%rbp), %eax
subl $0x51, %eax
je 0x14d3
jmp 0x1320
movl -0x14(%rbp), %eax
subl $0x71, %eax
je 0x14d3
jmp 0x132e
movl -0x14(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x1432
jmp 0x133e
movl -0x14(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x13c3
jmp 0x134a
movl -0x14(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0x1375
jmp 0x1356
movl -0x14(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0x139c
jmp 0x1362
movl -0x14(%rbp), %eax
subl $0x157, %eax            # imm = 0x157
je 0x14c0
jmp 0x14dc
movl 0x2e99(%rip), %eax      # 0x4214
addl $-0x1, %eax
movl %eax, 0x2e90(%rip)      # 0x4214
cmpl $0x0, 0x2e89(%rip)      # 0x4214
jge 0x1397
movl $0x0, 0x2e7d(%rip)      # 0x4214
jmp 0x14de
movl 0x2e72(%rip), %eax      # 0x4214
addl $0x1, %eax
movl %eax, 0x2e69(%rip)      # 0x4214
cmpl $0x4, 0x2e62(%rip)      # 0x4214
jl 0x13be
movl $0x3, 0x2e56(%rip)      # 0x4214
jmp 0x14de
movslq 0x2e46(%rip), %rcx      # 0x4210
leaq 0x2cff(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2e35(%rip), %rcx      # 0x4214
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movslq 0x2e21(%rip), %rcx      # 0x4210
leaq 0x2cda(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2e10(%rip), %rcx      # 0x4214
cmpl $0x6, (%rax,%rcx,4)
jbe 0x142d
movslq 0x2dff(%rip), %rcx      # 0x4210
leaq 0x2cb8(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2dee(%rip), %rcx      # 0x4214
movl $0x1, (%rax,%rcx,4)
jmp 0x14de
movslq 0x2dd7(%rip), %rcx      # 0x4210
leaq 0x2c90(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2dc6(%rip), %rcx      # 0x4214
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movslq 0x2db2(%rip), %rcx      # 0x4210
leaq 0x2c6b(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2da1(%rip), %rcx      # 0x4214
cmpl $0x0, (%rax,%rcx,4)
je 0x149b
movslq 0x2d90(%rip), %rcx      # 0x4210
leaq 0x2c49(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2d7f(%rip), %rcx      # 0x4214
cmpl $0x6, (%rax,%rcx,4)
jbe 0x14be
movslq 0x2d6e(%rip), %rcx      # 0x4210
leaq 0x2c27(%rip), %rax      # 0x40d0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x2d5d(%rip), %rcx      # 0x4214
movl $0x6, (%rax,%rcx,4)
jmp 0x14de
callq 0x1cf0
cmpl $0x0, %eax
je 0x14d1
movl $0x1, -0x8(%rbp)
jmp 0x14de
movl $0x1, -0xc(%rbp)
jmp 0x14de
jmp 0x14de
jmp 0x12ab
cmpl $0x0, -0xc(%rbp)
je 0x14eb
jmp 0x1512
callq 0x1b40
callq 0x1d50
cmpl $0x0, %eax
je 0x14fc
jmp 0x1512
jmp 0x14fe
movl 0x2d0c(%rip), %eax      # 0x4210
addl $-0x1, %eax
movl %eax, 0x2d03(%rip)      # 0x4210
jmp 0x1286
callq 0x1d50
cmpl $0x0, %eax
je 0x152a
leaq 0xae1(%rip), %rdi       # 0x2004
callq 0x1660
jmp 0x154c
cmpl $0x0, -0xc(%rbp)
je 0x153e
leaq 0xade(%rip), %rdi       # 0x2015
callq 0x1660
jmp 0x154a
leaq 0xad9(%rip), %rdi       # 0x201e
callq 0x1660
jmp 0x154c
cmpl $0x0, -0xc(%rbp)
jne 0x1561
movq 0x2a87(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x1070
callq 0x1130
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nop