// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/cavescroll/cavescroll.c
// Function: main
int main(void)
{
  int c;
  action_t action;

  data_initialize();
  screen_initialize();

  screen_update();

  while (1) {

    action = ACTION_NONE;
    while ((c = getch()) != ERR) {
      switch (c) {
      case KEY_RESIZE:
        return 0; /* Not allowed! */

      case KEY_UP:
        action = ACTION_MOVE_UP;
        break;

      case KEY_DOWN:
        action = ACTION_MOVE_DOWN;
        break;

      case ' ':
        action = ACTION_SHOOT;
        break;

      case 'q':
      case 'Q':
      case '\e':
        exit(0);

      default:
        break;
      }
    }

    switch (action) {
    case ACTION_MOVE_UP:
      player_y--;
      break;

    case ACTION_MOVE_DOWN:
      player_y++;
      break;

    case ACTION_SHOOT:
      if (ammo > 0) {
        object_spawn(GRAPHICS_SHOT);
        ammo--;
      }
      break;

    default:
      break;
    }

    generate_cave();
    objects_move();

    /* Check for player death collisions, one step ahead. */
    c = mvinch(player_y, player_x + 1);
    if (c == GRAPHICS_CAVE || c == GRAPHICS_ENEMY) {
      flash();
      exit(0);
    }

    /* Redraw screen. */
    screen_update();
    usleep(100000);

    objects_cleanup();
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
callq 0x1440
callq 0x14d0
callq 0x15c0
movl $0x0, -0xc(%rbp)
movq 0x3d24(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
callq 0x1060
movl %eax, -0x8(%rbp)
cmpl $-0x1, %eax
je 0x1350
movl -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
subl $0x1b, %eax
je 0x1342
jmp 0x12dd
movl -0x10(%rbp), %eax
subl $0x20, %eax
je 0x1339
jmp 0x12e7
movl -0x10(%rbp), %eax
subl $0x51, %eax
je 0x1342
jmp 0x12f1
movl -0x10(%rbp), %eax
subl $0x71, %eax
je 0x1342
jmp 0x12fb
movl -0x10(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x1330
jmp 0x1307
movl -0x10(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x1327
jmp 0x1313
movl -0x10(%rbp), %eax
subl $0x19a, %eax            # imm = 0x19A
jne 0x1349
jmp 0x131f
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
movl $0x1, -0xc(%rbp)
jmp 0x134b
movl $0x2, -0xc(%rbp)
jmp 0x134b
movl $0x3, -0xc(%rbp)
jmp 0x134b
xorl %edi, %edi
callq 0x1160
jmp 0x134b
jmp 0x12b5
movl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
subl $0x1, %eax
je 0x1371
jmp 0x135d
movl -0x14(%rbp), %eax
subl $0x2, %eax
je 0x1382
jmp 0x1367
movl -0x14(%rbp), %eax
subl $0x3, %eax
je 0x1393
jmp 0x13b7
movl 0x3d79(%rip), %eax      # 0x50f0
addl $-0x1, %eax
movl %eax, 0x3d70(%rip)      # 0x50f0
jmp 0x13b9
movl 0x3d68(%rip), %eax      # 0x50f0
addl $0x1, %eax
movl %eax, 0x3d5f(%rip)      # 0x50f0
jmp 0x13b9
cmpl $0x0, 0x3d5a(%rip)      # 0x50f4
jle 0x13b5
movl $0x2d, %edi
callq 0x1730
movl 0x3d48(%rip), %eax      # 0x50f4
addl $-0x1, %eax
movl %eax, 0x3d3f(%rip)      # 0x50f4
jmp 0x13b9
jmp 0x13b9
callq 0x1840
callq 0x1a70
movq 0x3c16(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movl 0x3d1d(%rip), %esi      # 0x50f0
movl 0x3d1f(%rip), %edx      # 0x50f8
addl $0x1, %edx
callq 0x1130
cmpl $-0x1, %eax
jne 0x13f0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x18(%rbp)
jmp 0x1402
movq 0x3be9(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
callq 0x1110
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x8(%rbp)
cmpl $0x23, -0x8(%rbp)
je 0x1414
cmpl $0x40, -0x8(%rbp)
jne 0x1420
callq 0x10c0
xorl %edi, %edi
callq 0x1160
callq 0x15c0
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1180
callq 0x1c50
jmp 0x12ae
nopl (%rax)