// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq %rax, -0x30(%rbp)
subq $0x4, %rax
ja 0x1a92
movq -0x30(%rbp), %rax
leaq 0x5f1(%rip), %rcx       # 0x2018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1a9e
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1a9e
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x1a9e
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x1a9e
jmp 0x1a92
movl $0x1, -0x4(%rbp)
jmp 0x1c85
movq 0x2533(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0x1130
cmpl $-0x1, %eax
jne 0x1ac2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x34(%rbp)
jmp 0x1ad4
movq 0x250f(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
callq 0x1120
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
andl $0xff, %eax
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x40, %eax
jne 0x1c23
movsbl -0x21(%rbp), %eax
addl $-0x20, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x2d, %eax
ja 0x1c1a
movq -0x40(%rbp), %rax
leaq 0x51b(%rip), %rcx       # 0x202c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x2, -0x4(%rbp)
jmp 0x1c85
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x3, -0x4(%rbp)
jmp 0x1c85
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x4, -0x4(%rbp)
jmp 0x1c85
movl $0x0, -0x18(%rbp)
cmpl $0x5, -0x18(%rbp)
jge 0x1bf9
movl -0x1c(%rbp), %eax
movslq -0x18(%rbp), %rdx
leaq 0x27ef(%rip), %rcx      # 0x4370
imulq $0x14, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x1be9
movl -0x20(%rbp), %eax
movslq -0x18(%rbp), %rdx
leaq 0x27d6(%rip), %rcx      # 0x4370
imulq $0x14, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jne 0x1be9
movslq -0x18(%rbp), %rax
leaq 0x27bf(%rip), %rdi      # 0x4370
imulq $0x14, %rax, %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x1a00
cmpl $0x0, %eax
jne 0x1bdd
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x0, -0x4(%rbp)
jmp 0x1c85
movl $0x1, -0x4(%rbp)
jmp 0x1c85
jmp 0x1beb
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1b69
movl $0x1, -0x4(%rbp)
jmp 0x1c85
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x0, -0x4(%rbp)
jmp 0x1c85
movl $0x1, -0x4(%rbp)
jmp 0x1c85
movq -0x10(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x4d, %eax
jne 0x1c60
movsbl -0x21(%rbp), %eax
cmpl $0x20, %eax
je 0x1c42
movsbl -0x21(%rbp), %eax
cmpl $0x40, %eax
jne 0x1c57
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x0, -0x4(%rbp)
jmp 0x1c85
movl $0x1, -0x4(%rbp)
jmp 0x1c85
movsbl -0x21(%rbp), %eax
cmpl $0x20, %eax
jne 0x1c7e
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1f50
movl $0x0, -0x4(%rbp)
jmp 0x1c85
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop