// File: /workspace/github_c_makefile_star2_O3/kobolt[P]curses-collection/cgame/cgame.c
// Function: move_object_check
static move_t move_object_check(object_t *object, direction_t direction)
{
  int i, hit_y, hit_x;
  char hit_object;

  switch (direction) {
  case DIRECTION_LEFT:
    hit_y = object->y;
    hit_x = object->x - 1;
    break;
  case DIRECTION_RIGHT:
    hit_y = object->y;
    hit_x = object->x + 1;
    break;
  case DIRECTION_UP:
    hit_y = object->y - 1;
    hit_x = object->x;
    break;
  case DIRECTION_DOWN:
    hit_y = object->y + 1;
    hit_x = object->x;
    break;
  case DIRECTION_NONE:
  default:
    return MOVE_BLOCKED;
  }
  hit_object = mvinch(hit_y, hit_x) & A_CHARTEXT;

  if (object->symbol == '@') { /* Player. */
    switch (hit_object) {
    case '*':
      move_object_actual(object, direction);
      return MOVE_ON_MINE;
    case '$':
      move_object_actual(object, direction);
      return MOVE_ON_MONEY;
    case 'M':
      move_object_actual(object, direction);
      return MOVE_ON_ENEMY;
    case '#':
      for (i = 0; i < AMOUNT_OF_CRATES; i++) {
        if (hit_y == crates[i].y && hit_x == crates[i].x) {
          if (move_object_check(&crates[i], direction) == MOVE_OK) {
            move_object_actual(object, direction);
            return MOVE_OK;
          } else {
            return MOVE_BLOCKED;
          }
        }
      }
      return MOVE_BLOCKED;
    case ' ':
      move_object_actual(object, direction);
      return MOVE_OK;
    default:
      return MOVE_BLOCKED;
    }

  } else if (object->symbol == 'M') { /* Enemy. */
    if (hit_object == ' ' || hit_object == '@') {
      move_object_actual(object, direction);
      return MOVE_OK;
    } else {
      return MOVE_BLOCKED;
    }

  } else { /* Crates, etc. */
    if (hit_object == ' ') {
      move_object_actual(object, direction);
      return MOVE_OK;
    } else {
      return MOVE_BLOCKED;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r14d
movl $0x1, %eax
leal -0x1(%r14), %r13d
cmpl $0x3, %r13d
ja 0x19a7
movq %rdi, %rbx
leaq 0x838(%rip), %rax       # 0x2004
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl (%rbx), %r15d
movl 0x4(%rbx), %r12d
decl %r12d
jmp 0x1803
movl (%rbx), %r15d
movl 0x4(%rbx), %r12d
decl %r15d
jmp 0x1803
movl (%rbx), %r15d
movl 0x4(%rbx), %r12d
incl %r15d
jmp 0x1803
movl (%rbx), %r15d
movl 0x4(%rbx), %r12d
incl %r12d
movq 0x27ce(%rip), %rbp      # 0x3fd8
movq (%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x1130
cmpl $-0x1, %eax
je 0x182c
movq (%rbp), %rdi
callq 0x1120
movsbl %al, %edx
jmp 0x1831
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movzbl 0x8(%rbx), %ecx
cmpl $0x4d, %ecx
je 0x188c
cmpl $0x40, %ecx
jne 0x18b6
cmpl $0x23, %edx
jle 0x18db
cmpl $0x24, %edx
je 0x190f
cmpl $0x2a, %edx
je 0x192f
cmpl $0x4d, %edx
movl $0x1, %eax
jne 0x19a7
movl $0x4, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x7cb(%rip), %rcx       # 0x2044
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl $0x1, %esi
jmp 0x1966
cmpl $0x40, %edx
movl $0x1, %eax
je 0x189f
cmpl $0x20, %edx
jne 0x19a7
xorl %eax, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x767(%rip), %rcx       # 0x2014
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
cmpl $0x20, %edx
movl $0x1, %eax
jne 0x19a7
xorl %eax, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x7a2(%rip), %rcx       # 0x2074
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
cmpl $0x20, %edx
je 0x1949
cmpl $0x23, %edx
jne 0x1905
xorl %eax, %eax
leaq 0x2a82(%rip), %rdi      # 0x4370
cmpl (%rax,%rdi), %r15d
jne 0x18fb
cmpl 0x4(%rax,%rdi), %r12d
je 0x196b
addq $0x14, %rax
cmpq $0x64, %rax
jne 0x18ee
movl $0x1, %eax
jmp 0x19a7
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x739(%rip), %rcx       # 0x2054
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
addq $0x4, %rbx
movl $0x3, %eax
jmp 0x19a5
movl $0x2, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x724(%rip), %rcx       # 0x2064
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %eax, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x6cd(%rip), %rcx       # 0x2024
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
addq $0x4, %rbx
jmp 0x19a5
movl %r14d, %eax
jmp 0x19a5
addq %rax, %rdi
movl %r14d, %esi
callq 0x17a1
testl %eax, %eax
movl $0x1, %eax
jne 0x19a7
xorl %eax, %eax
cmpl $0x3, %r13d
ja 0x19a7
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x6a1(%rip), %rcx       # 0x2034
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
addq $0x4, %rbx
movl $0x1, %esi
addl %esi, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x4, %rbx
movl $0x3, %eax
jmp 0x19a0