// File: /workspace/github_cpp_makefile_star2_O3/IncredibleHannes[P]QMUL-ChessGame/src/Model/Chessman/Pawn.cpp
// Function: Pawn::getPossibleMoves[abi:cxx11](Board const&) const
std::list<Move> Pawn::getPossibleMoves(const Board &board) const {
  std::list<Move> moves;
  if (!isCaptured()) {
    int x = this->position.getX();
    int y = this->position.getY();
    if (this->colour == Chessman::Colour::White) {
      if (board.getChessman(Position(x + 1, y)) == nullptr)
      { moves.push_back(Move(Position(x, y), Position(x + 1, y))); }
      //can move 2 fields!
      if (x == 1) {
        if (board.getChessman(Position(x + 1, y)) == nullptr &&
            board.getChessman(Position(x + 2, y)) == nullptr) {
          moves.push_back(Move(Position(x, y), Position(x + 2, y)));
        }
      }
      if(0 <= y - 1 && board.getChessman(Position(x + 1, y - 1)) != nullptr) {
        moves.push_back(Move(Position(x, y), Position(x + 1, y - 1)));
      }
      if(y + 1 < 8 && board.getChessman(Position(x + 1, y + 1)) != nullptr) {
        moves.push_back(Move(Position(x, y), Position(x + 1, y + 1)));
      }
    } else {
      if (board.getChessman(Position(x - 1, y)) == nullptr) {
        moves.push_back(Move(Position(x, y), Position(x - 1, y)));
      }
      //can move 2 fields!
      if (x == 6) {
        if (board.getChessman(Position(x - 1, y)) == nullptr &&
            board.getChessman(Position(x - 2, y)) == nullptr)
        { moves.push_back(Move(Position(x, y), Position(x - 2, y))); }
      }
      if(0 <= y - 1 && board.getChessman(Position(x - 1, y - 1)) != nullptr) {
        moves.push_back(Move(Position(x, y), Position(x - 1, y - 1)));
      }
      if(y + 1 < 8 && board.getChessman(Position(x - 1, y + 1)) != nullptr) {
        moves.push_back(Move(Position(x, y), Position(x - 1, y + 1)));
      }
    }
  }
  return moves;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rsi, %rdi
callq 0x37c2
testb %al, %al
jne 0x35a7
leaq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x2962
movq %rax, -0x38(%rbp)
movq %r14, %rdi
callq 0x296a
movl %eax, %r14d
movl %eax, %edx
cmpb $0x1, 0x8(%r15)
movl %r14d, -0x2c(%rbp)
jne 0x336c
movq -0x38(%rbp), %rax
leal 0x1(%rax), %r15d
leaq -0x128(%rbp), %rdi
movl %r15d, %esi
callq 0x292a
movq -0x128(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
jne 0x31a9
leaq -0x120(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0x118(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e84
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x40c0
cmpl $0x1, -0x38(%rbp)
jne 0x3255
leaq -0x110(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0x110(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
jne 0x3255
leaq -0x108(%rbp), %rdi
movl $0x3, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0x108(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
jne 0x3255
leaq -0x100(%rbp), %rdi
movl $0x1, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0xf8(%rbp), %rdi
movl $0x3, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x3600
leaq -0x58(%rbp), %rdi
callq 0x40c0
testl %r14d, %r14d
jle 0x32f2
leal -0x1(%r14), %r13d
leaq -0xf0(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x292a
movq -0xf0(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
je 0x32e8
leaq -0xe8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0xe0(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x292a
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e84
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x40c0
cmpl $0x6, %r14d
ja 0x35a7
incl %r14d
leaq -0xd8(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x292a
movq -0xd8(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
je 0x35a7
leaq -0xd0(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0xc8(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x292a
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e84
jmp 0x358f
movq -0x38(%rbp), %rax
leal -0x1(%rax), %r15d
leaq -0xc0(%rbp), %rdi
movl %r15d, %esi
callq 0x292a
movq -0xc0(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
jne 0x33f7
leaq -0xb8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0xb0(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e84
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x40c0
cmpl $0x6, -0x38(%rbp)
jne 0x34a3
leaq -0xa8(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0xa8(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
jne 0x34a3
leaq -0xa0(%rbp), %rdi
movl $0x4, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0xa0(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
jne 0x34a3
leaq -0x98(%rbp), %rdi
movl $0x6, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0x90(%rbp), %rdi
movl $0x4, %esi
movl -0x2c(%rbp), %edx
callq 0x292a
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x3600
leaq -0x58(%rbp), %rdi
callq 0x40c0
testl %r14d, %r14d
jle 0x3530
leal -0x1(%r14), %r13d
leaq -0x88(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x292a
movq -0x88(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
je 0x352a
leaq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0x78(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x292a
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e84
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x40c0
cmpl $0x6, %r14d
ja 0x35a7
incl %r14d
leaq -0x70(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x292a
movq -0x70(%rbp), %rsi
movq %r12, %rdi
callq 0x4c22
testq %rax, %rax
je 0x35a7
leaq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x292a
leaq -0x60(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x292a
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4040
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e84
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x40c0
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x35ce
jmp 0x35ce
jmp 0x35ec
jmp 0x35ec
jmp 0x35ce
jmp 0x35ce
jmp 0x35ce
jmp 0x35ce
jmp 0x35ce
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x40c0
jmp 0x35ef
jmp 0x35ec
jmp 0x35ec
jmp 0x35ec
jmp 0x35ec
jmp 0x35ec
jmp 0x35ec
jmp 0x35ec
jmp 0x35ec
movq %rax, %r14
movq %rbx, %rdi
callq 0x2b06
movq %r14, %rdi
callq 0x21d0
nop