// File: /workspace/github_cpp_makefile_star2_O3/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 0x582a
movq %rbx, %rdi
callq 0x5766
movl %eax, %ebx
leaq -0x38(%rbp), %rdi
callq 0x587c
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x582a
movq %r13, %rdi
callq 0x5752
movl %eax, %r14d
leaq -0x38(%rbp), %rdi
callq 0x587c
addl $0xfffffefe, %r12d      # imm = 0xFFFFFEFE
cmpl $0x3, %r12d
ja 0x61cb
leaq 0x10f3(%rip), %rax      # 0x7174
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl %ebx, %r12d
incl %r12d
jmp 0x6134
movslq %ebx, %rax
movq (%r15), %rcx
leaq (%rax,%rax,2), %rax
movslq %r14d, %rdx
movq (%rcx,%rax,8), %rax
movl -0x4(%rax,%rdx,4), %eax
cmpl $0x7, %eax
ja 0x61a8
movl $0xc4, %ecx
btl %eax, %ecx
jae 0x61a8
movl %r14d, %r15d
decl %r15d
jmp 0x60fb
movslq %ebx, %rax
movq (%r15), %rcx
leaq (%rax,%rax,2), %rax
movslq %r14d, %rdx
movq (%rcx,%rax,8), %rax
movl 0x4(%rax,%rdx,4), %eax
cmpl $0x7, %eax
ja 0x61a8
movl $0xc4, %ecx
btl %eax, %ecx
jae 0x61a8
movl %r14d, %r15d
incl %r15d
movq 0x3ece(%rip), %r12      # 0x9fd0
movq (%r12), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x3240
cmpl $-0x1, %eax
je 0x6123
movq (%r12), %rdi
movl $0x20, %esi
callq 0x3090
movq (%r12), %rdi
movl %ebx, %esi
movl %r15d, %edx
jmp 0x6186
movl %ebx, %r12d
decl %r12d
movslq %r12d, %rax
movq (%r15), %rcx
leaq (%rax,%rax,2), %rax
movslq %r14d, %rdx
movq (%rcx,%rax,8), %rax
movl (%rax,%rdx,4), %eax
cmpl $0x7, %eax
ja 0x61a8
movl $0xc4, %ecx
btl %eax, %ecx
jae 0x61a8
movq 0x3e72(%rip), %r15      # 0x9fd0
movq (%r15), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x3240
cmpl $-0x1, %eax
je 0x617d
movq (%r15), %rdi
movl $0x20, %esi
callq 0x3090
movq (%r15), %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x3240
movl $0x50, %esi
cmpl $-0x1, %eax
je 0x61a4
movq 0x3e34(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x3090
movb $0x1, %al
jmp 0x61cd
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x61cb
movq 0x3e19(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x3240
movl $0x20, %esi
jmp 0x6190
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x61de
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x587c
movq %rbx, %rdi
callq 0x33e0
nop