// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x2e6f(%rip), %rbx      # 0x40d0
movl $0x140, %edx            # imm = 0x140
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10b0
callq 0x1090
callq 0x1030
testb %al, %al
je 0x12e9
callq 0x10c0
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1100
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1100
movl $0x3, %edi
movl $0x3, %esi
xorl %edx, %edx
callq 0x1100
movl $0x4, %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x1100
movl $0x5, %edi
movl $0x5, %esi
xorl %edx, %edx
callq 0x1100
movl $0x6, %edi
movl $0x6, %esi
xorl %edx, %edx
callq 0x1100
callq 0x1080
movq 0x2ceb(%rip), %r14      # 0x3fe0
movq (%r14), %rdi
movl $0x1, %esi
callq 0x10d0
xorl %r12d, %r12d
xorl %edi, %edi
callq 0x10e0
movl %eax, %edi
callq 0x1060
movabsq $0x2aaaaaaaaaaaaaab, %r13 # imm = 0x2AAAAAAAAAAAAAAB
leaq 0x2efc(%rip), %r15      # 0x4220
callq 0x10f0
movq %rax, %rcx
imulq %r13
movq %rdx, %rax
shrq $0x3f, %rax
addl %edx, %eax
addl %eax, %eax
leal (%rax,%rax,2), %eax
subl %eax, %ecx
incl %ecx
movl %ecx, (%r12,%r15)
addq $0x4, %r12
cmpq $0x10, %r12
jne 0x1324
movl $0x9, 0x2eb7(%rip)      # 0x4210
movabsq $0x4332322132212110, %r12 # imm = 0x4332322132212110
leaq 0xce6(%rip), %r13       # 0x2050
movl $0x1, %ebp
movl $0x0, 0x2e9b(%rip)      # 0x4214
xorl %edi, %edi
callq 0x1814
movq (%r14), %rdi
callq 0x1070
cmpl $0x70, %eax
jle 0x13d0
leal -0x102(%rax), %ecx
cmpl $0x3, %ecx
ja 0x13fb
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movslq 0x2e67(%rip), %rax      # 0x4210
shlq $0x5, %rax
addq %rbx, %rax
movslq 0x2e5d(%rip), %rcx      # 0x4214
movl (%rax,%rcx,4), %edx
leal -0x1(%rdx), %esi
addl $-0x8, %edx
cmpl $-0x6, %edx
movl $0x6, %edx
cmovbl %edx, %esi
movl %esi, (%rax,%rcx,4)
jmp 0x1379
cmpl $0x1f, %eax
jg 0x1427
cmpl $0xa, %eax
movdqa 0xc4f(%rip), %xmm9      # 0x2030
pcmpeqd %xmm10, %xmm10
movdqa 0xc51(%rip), %xmm11     # 0x2040
je 0x1447
cmpl $0x1b, %eax
jne 0x1379
jmp 0x1807
cmpl $0x157, %eax            # imm = 0x157
movdqa 0xc27(%rip), %xmm9      # 0x2030
pcmpeqd %xmm10, %xmm10
movdqa 0xc29(%rip), %xmm11     # 0x2040
je 0x1447
cmpl $0x71, %eax
jne 0x1379
jmp 0x1807
cmpl $0x20, %eax
movdqa 0xbfd(%rip), %xmm9      # 0x2030
pcmpeqd %xmm10, %xmm10
movdqa 0xbff(%rip), %xmm11     # 0x2040
jne 0x14cb
movslq 0x2dc2(%rip), %rax      # 0x4210
shlq $0x5, %rax
addq %rbx, %rax
xorl %ecx, %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x1379
incq %rcx
cmpq $0x4, %rcx
jne 0x1457
jmp 0x14d9
movl 0x2da2(%rip), %eax      # 0x4214
cmpl $0x2, %eax
cmovll %ebp, %eax
decl %eax
movl %eax, 0x2d94(%rip)      # 0x4214
jmp 0x1379
movl 0x2d89(%rip), %eax      # 0x4214
cmpl $0x2, %eax
movl $0x2, %ecx
cmovgel %ecx, %eax
incl %eax
movl %eax, 0x2d76(%rip)      # 0x4214
jmp 0x1379
movslq 0x2d66(%rip), %rax      # 0x4210
shlq $0x5, %rax
addq %rbx, %rax
movslq 0x2d5c(%rip), %rcx      # 0x4214
movl (%rax,%rcx,4), %edx
incl %edx
cmpl $0x7, %edx
cmovael %ebp, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1379
cmpl $0x51, %eax
jne 0x1379
jmp 0x1807
movslq 0x2d30(%rip), %rax      # 0x4210
movq %rax, %rdx
shlq $0x5, %rdx
movdqa (%rdx,%rbx), %xmm0
pcmpeqd 0x2d2c(%rip), %xmm0     # 0x4220
leaq (%rbx,%rdx), %rsi
movmskps %xmm0, %edi
psrld $0x1f, %xmm0
movdqa %xmm0, 0x10(%rsp)
movl %edi, %ecx
shll $0x2, %ecx
movq %r12, %r8
shrq %cl, %r8
movdqa %xmm0, (%rsp)
andl $0x7, %r8d
xorl %r9d, %r9d
xorl %ecx, %ecx
movdqa 0xae9(%rip), %xmm7      # 0x2010
movdqa 0xaf0(%rip), %xmm8      # 0x2020
cmpl $0x0, 0x10(%rsp,%r9,4)
jne 0x1562
xorl %r10d, %r10d
cmpl $0x0, (%rsp,%r10)
jne 0x154c
movl (%rsi,%r9,4), %r11d
cmpl (%r10,%r15), %r11d
je 0x1558
addq $0x4, %r10
cmpq $0x10, %r10
jne 0x153b
jmp 0x1562
movl $0x1, (%rsp,%r10)
incl %ecx
incq %r9
cmpq $0x4, %r9
jne 0x1530
testb %dil, %dil
je 0x1671
movzbl %r8b, %esi
movl %esi, %edi
addl $0x3, %edi
andl $0xc, %edi
leaq -0x1(%rsi), %r8
movq %r8, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rdx,%rbx), %r8
addq $0x1c, %r8
xorl %r9d, %r9d
movdqa %xmm8, %xmm1
movdqa %xmm7, %xmm2
movdqa %xmm0, %xmm3
pxor %xmm9, %xmm3
movdqa %xmm1, %xmm4
pxor %xmm9, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %r10d
notl %r10d
testb $0x1, %r10b
je 0x15e9
movl $0x1, -0xc(%r8,%r9,4)
pxor %xmm10, %xmm4
pextrw $0x4, %xmm4, %r10d
testb $0x1, %r10b
je 0x1603
movl $0x1, -0x8(%r8,%r9,4)
movdqa %xmm2, %xmm4
pxor %xmm9, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pand %xmm5, %xmm4
pshufd $0xf5, %xmm5, %xmm3     # xmm3 = xmm5[1,1,3,3]
por %xmm4, %xmm3
pxor %xmm10, %xmm3
pextrw $0x0, %xmm3, %r10d
testb $0x1, %r10b
je 0x1644
movl $0x1, -0x4(%r8,%r9,4)
pextrw $0x4, %xmm3, %r10d
testb $0x1, %r10b
je 0x1658
movl $0x1, (%r8,%r9,4)
addq $0x4, %r9
paddq %xmm11, %xmm1
paddq %xmm11, %xmm2
cmpq %r9, %rdi
jne 0x15a2
jmp 0x1673
xorl %esi, %esi
testl %ecx, %ecx
jle 0x1767
movl %ecx, %edi
addl $0x3, %ecx
andl $-0x4, %ecx
decq %rdi
movq %rdi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rdx,%rsi,4), %rsi
addq %rbx, %rsi
addq $0x1c, %rsi
pxor %xmm9, %xmm0
xorl %edi, %edi
movq %rdi, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por %xmm8, %xmm2
pxor %xmm9, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm0, %xmm3
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %r8d
notl %r8d
testb $0x1, %r8b
je 0x16ee
movl $0x2, -0xc(%rsi,%rdi,4)
pxor %xmm10, %xmm2
pextrw $0x4, %xmm2, %r8d
testb $0x1, %r8b
je 0x1707
movl $0x2, -0x8(%rsi,%rdi,4)
por %xmm7, %xmm1
pxor %xmm9, %xmm1
movdqa %xmm1, %xmm2
pcmpgtd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm3     # xmm3 = xmm1[1,1,3,3]
pand %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm1     # xmm1 = xmm2[1,1,3,3]
por %xmm3, %xmm1
pxor %xmm10, %xmm1
pextrw $0x0, %xmm1, %r8d
testb $0x1, %r8b
je 0x1747
movl $0x2, -0x4(%rsi,%rdi,4)
pextrw $0x4, %xmm1, %r8d
testb $0x1, %r8b
je 0x175a
movl $0x2, (%rsi,%rdi,4)
addq $0x4, %rdi
cmpq %rdi, %rcx
jne 0x16a2
leaq (%rdx,%rbx), %rcx
addq $0x10, %rcx
xorl %edx, %edx
cmpl $0x1, (%rcx,%rdx,4)
jne 0x1782
incq %rdx
cmpq $0x4, %rdx
jne 0x1771
jmp 0x1798
leal -0x1(%rax), %ecx
movl %ecx, 0x2a85(%rip)      # 0x4210
testl %eax, %eax
jg 0x136f
movb $0x1, %bpl
jmp 0x180f
movb $0x1, %bpl
shlq $0x5, %rax
addq %rbx, %rax
addq $0x10, %rax
xorl %ecx, %ecx
cmpl $0x1, (%rax,%rcx,4)
jne 0x17ca
incq %rcx
cmpq $0x4, %rcx
jne 0x17a8
leaq 0x8ca(%rip), %rdi       # 0x2088
callq 0x1814
testb %bpl, %bpl
jne 0x17db
jmp 0x17f1
testb %bpl, %bpl
je 0x17e5
leaq 0x8cc(%rip), %rdi       # 0x20a2
callq 0x1814
movq (%r14), %rdi
callq 0x1070
jmp 0x17f1
leaq 0x8ad(%rip), %rdi       # 0x2099
callq 0x1814
callq 0x1130
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x2a03(%rip), %ecx      # 0x4210
xorl %ebp, %ebp
movslq %ecx, %rax
jmp 0x179b