// File: /workspace/github_c_makefile_star2_O1/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, %ebx
movl $0x1, %ebp
leal -0x1(%rbx), %eax
cmpl $0x3, %eax
ja 0x18ce
movq %rdi, %r14
leaq 0x834(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl (%r14), %r15d
movl 0x4(%r14), %r12d
decl %r12d
jmp 0x1807
movl (%r14), %r15d
movl 0x4(%r14), %r12d
decl %r15d
jmp 0x1807
movl (%r14), %r15d
movl 0x4(%r14), %r12d
incl %r15d
jmp 0x1807
movl (%r14), %r15d
movl 0x4(%r14), %r12d
incl %r12d
movq 0x27ca(%rip), %r13      # 0x3fd8
movq (%r13), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x1130
cmpl $-0x1, %eax
je 0x1830
movq (%r13), %rdi
callq 0x1120
movsbl %al, %eax
jmp 0x1835
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movzbl 0x8(%r14), %ecx
cmpl $0x4d, %ecx
je 0x1866
cmpl $0x40, %ecx
jne 0x1875
cmpl $0x23, %eax
jle 0x187c
cmpl $0x24, %eax
je 0x18a8
movl $0x2, %r15d
cmpl $0x2a, %eax
je 0x18c1
cmpl $0x4d, %eax
jne 0x18ce
movl $0x4, %r15d
jmp 0x18c1
xorl %r15d, %r15d
cmpl $0x20, %eax
je 0x18c1
cmpl $0x40, %eax
je 0x18c1
jmp 0x18ce
cmpl $0x20, %eax
je 0x18be
jmp 0x18ce
cmpl $0x20, %eax
je 0x18be
cmpl $0x23, %eax
jne 0x18ce
xorl %eax, %eax
leaq 0x2ae1(%rip), %rdi      # 0x4370
cmpl (%rax,%rdi), %r15d
jne 0x189c
cmpl 0x4(%rax,%rdi), %r12d
je 0x18b0
addq $0x14, %rax
cmpq $0x64, %rax
jne 0x188f
jmp 0x18ce
movl $0x3, %r15d
jmp 0x18c1
addq %rax, %rdi
movl %ebx, %esi
callq 0x17a8
testl %eax, %eax
jne 0x18ce
xorl %r15d, %r15d
movq %r14, %rdi
movl %ebx, %esi
callq 0x1a1a
movl %r15d, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq