// File: /workspace/github_cpp_makefile_star2_O2/Teris45[P]Maze-Game/Moving.cpp
// Function: MyMoving::checkMove(Poter&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, int)
bool MyMoving::checkMove(Poter& poter, vector<vector<int>> &maze, int i) {

    int py = poter.getPoint().getY();
    int px = poter.getPoint().getX();
    if(i==KEY_UP){
        int maze_el = maze[py-1][px];
        if(maze_el == DIADROMOS || maze_el == GEM || maze_el == PERGAMINI) {
            mvaddch(py,px,' ');
            mvaddch(py-1,px,'P');
            return true;

        }
        else if(maze_el == TRAALINAKOS || maze_el == GOBLINAKOS){
            mvaddch(py,px,' ');
            return true;
        }
    }
    else if(i == KEY_DOWN){
        int maze_el = maze[py+1][px];
        if(maze_el == DIADROMOS || maze_el == GEM || maze_el == PERGAMINI) {
            mvaddch(py,px,' ');
            mvaddch(py+1,px,'P');
            return true;

        }
        else if(maze_el == TRAALINAKOS || maze_el == GOBLINAKOS){
            mvaddch(py,px,' ');
            return true;

        }
    }
    else if(i==KEY_RIGHT){
        int maze_el = maze[py][px+1];
        if(maze_el == DIADROMOS || maze_el == GEM || maze_el == PERGAMINI) {
            mvaddch(py,px,' ');
            mvaddch(py,px+1,'P');
            return true;

        }
        else if(maze_el == TRAALINAKOS || maze_el == GOBLINAKOS){
            mvaddch(py,px,' ');
            return true;
        }
    }
    else if(i==KEY_LEFT){
        int maze_el = maze[py][px-1];
        if(maze_el == DIADROMOS || maze_el == GEM || maze_el == PERGAMINI) {
            mvaddch(py,px,' ');
            mvaddch(py,px-1,'P');
            return true;
        }
        else if(maze_el == TRAALINAKOS || maze_el == GOBLINAKOS){
            mvaddch(py,px,' ');
            return true;
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %r14
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4612
movq %rbx, %rdi
callq 0x4552
movl %eax, %ebx
leaq -0x38(%rbp), %rdi
callq 0x4668
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x4612
movq %r13, %rdi
callq 0x453e
movl %eax, %r14d
leaq -0x38(%rbp), %rdi
callq 0x4668
addl $0xfffffefe, %r12d      # imm = 0xFFFFFEFE
cmpl $0x3, %r12d
ja 0x4f3b
leaq 0x1353(%rip), %rax      # 0x6148
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl %ebx, %r12d
incl %r12d
jmp 0x4ea6
movslq %ebx, %rax
movq (%r15), %rcx
imulq $0x18, %rax, %rax
movslq %r14d, %rdx
movq (%rcx,%rax), %rax
movl -0x4(%rax,%rdx,4), %eax
cmpl $0x7, %eax
ja 0x4f16
movl $0xc4, %ecx
btl %eax, %ecx
jae 0x4f16
movl %r14d, %r15d
decl %r15d
jmp 0x4e6f
movslq %ebx, %rax
movq (%r15), %rcx
imulq $0x18, %rax, %rax
movslq %r14d, %rdx
movq (%rcx,%rax), %rax
movl 0x4(%rax,%rdx,4), %eax
cmpl $0x7, %eax
ja 0x4f16
movl $0xc4, %ecx
btl %eax, %ecx
jae 0x4f16
movl %r14d, %r15d
incl %r15d
movq 0x515a(%rip), %r12      # 0x9fd0
movq (%r12), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x2220
cmpl $-0x1, %eax
je 0x4e95
movq (%r12), %rdi
pushq $0x20
popq %rsi
callq 0x20a0
movq (%r12), %rdi
movl %ebx, %esi
movl %r15d, %edx
jmp 0x4ef6
movl %ebx, %r12d
decl %r12d
movslq %r12d, %rax
movq (%r15), %rcx
imulq $0x18, %rax, %rax
movslq %r14d, %rdx
movq (%rcx,%rax), %rax
movl (%rax,%rdx,4), %eax
cmpl $0x7, %eax
ja 0x4f16
movl $0xc4, %ecx
btl %eax, %ecx
jae 0x4f16
movq 0x5100(%rip), %r15      # 0x9fd0
movq (%r15), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x2220
cmpl $-0x1, %eax
je 0x4eed
movq (%r15), %rdi
pushq $0x20
popq %rsi
callq 0x20a0
movq (%r15), %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x2220
cmpl $-0x1, %eax
je 0x4f12
pushq $0x50
popq %rsi
movq 0x50c6(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x20a0
movb $0x1, %al
jmp 0x4f3d
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x4f3b
movq 0x50ab(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x2220
cmpl $-0x1, %eax
je 0x4f12
pushq $0x20
jmp 0x4f02
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4f4e
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x4668
movq %rbx, %rdi
callq 0x23b0