// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rbx
leal -0x1(%r14), %eax
cmpl $0x3, %eax
ja 0x18a6
movq %rdi, %r15
leaq 0x870(%rip), %rcx       # 0x2028
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl (%r15), %ebp
movl 0x4(%r15), %r12d
decl %r12d
jmp 0x17ed
movl (%r15), %ebp
movl 0x4(%r15), %r12d
decl %ebp
jmp 0x17ed
movl (%r15), %ebp
movl 0x4(%r15), %r12d
incl %ebp
jmp 0x17ed
movl (%r15), %ebp
movl 0x4(%r15), %r12d
incl %r12d
movq 0x27e4(%rip), %r13      # 0x3fd8
movq (%r13), %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x1130
cmpl $-0x1, %eax
je 0x1815
movq (%r13), %rdi
callq 0x1120
movsbl %al, %eax
jmp 0x1818
pushq $-0x1
popq %rax
movzbl 0x8(%r15), %ecx
cmpl $0x4d, %ecx
je 0x1861
cmpl $0x40, %ecx
jne 0x1866
cmpl $0x20, %eax
je 0x186b
cmpl $0x4d, %eax
je 0x187a
cmpl $0x24, %eax
je 0x1898
cmpl $0x2a, %eax
je 0x1889
cmpl $0x23, %eax
jne 0x18a6
xorl %eax, %eax
leaq 0x2b27(%rip), %rdi      # 0x4370
cmpq $0x64, %rax
je 0x18a6
cmpl (%rax,%rdi), %ebp
jne 0x185b
cmpl 0x4(%rax,%rdi), %r12d
je 0x18b7
addq $0x14, %rax
jmp 0x1849
cmpl $0x40, %eax
je 0x186b
cmpl $0x20, %eax
jne 0x18a6
movq %r15, %rdi
movl %r14d, %esi
callq 0x19c0
xorl %ebx, %ebx
jmp 0x18a6
movq %r15, %rdi
movl %r14d, %esi
callq 0x19c0
pushq $0x4
jmp 0x18a5
movq %r15, %rdi
movl %r14d, %esi
callq 0x19c0
pushq $0x2
jmp 0x18a5
movq %r15, %rdi
movl %r14d, %esi
callq 0x19c0
pushq $0x3
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rax, %rdi
movl %r14d, %esi
callq 0x1790
testl %eax, %eax
jne 0x18a6
jmp 0x186b