// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, 0x10(%rdi)
movq %rsi, %rdi
callq 0x37ae
testb %al, %al
jne 0x35bf
leaq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x28a6
movq %rax, -0x38(%rbp)
movq %r14, %rdi
callq 0x28ae
movl %eax, %r14d
movl %eax, %edx
cmpb $0x1, 0x8(%r15)
movl %r14d, -0x2c(%rbp)
jne 0x33bb
movq -0x38(%rbp), %rax
leal 0x1(%rax), %r15d
leaq -0x128(%rbp), %rdi
movl %r15d, %esi
callq 0x286e
movq -0x128(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
jne 0x320d
leaq -0x120(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0x118(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
cmpl $0x1, -0x38(%rbp)
jne 0x32b3
leaq -0x110(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0x110(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
jne 0x32b3
leaq -0x108(%rbp), %rdi
pushq $0x3
popq %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0x108(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
jne 0x32b3
leaq -0x100(%rbp), %rdi
pushq $0x1
popq %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0xf8(%rbp), %rdi
pushq $0x3
popq %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
testl %r14d, %r14d
jle 0x3341
leal -0x1(%r14), %r13d
leaq -0xf0(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x286e
movq -0xf0(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
je 0x3337
leaq -0xe8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0xe0(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x286e
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
cmpl $0x6, %r14d
ja 0x35bf
incl %r14d
leaq -0xd8(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x286e
movq -0xd8(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
je 0x35bf
leaq -0xd0(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0xc8(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x286e
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
jmp 0x35b6
movq -0x38(%rbp), %rax
leal -0x1(%rax), %r15d
leaq -0xc0(%rbp), %rdi
movl %r15d, %esi
callq 0x286e
movq -0xc0(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
jne 0x3437
leaq -0xb8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0xb0(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
cmpl $0x6, -0x38(%rbp)
jne 0x34dd
leaq -0xa8(%rbp), %rdi
movl %r15d, %esi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0xa8(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
jne 0x34dd
leaq -0xa0(%rbp), %rdi
pushq $0x4
popq %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0xa0(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
jne 0x34dd
leaq -0x98(%rbp), %rdi
pushq $0x6
popq %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0x90(%rbp), %rdi
pushq $0x4
popq %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
testl %r14d, %r14d
jle 0x3557
leal -0x1(%r14), %r13d
leaq -0x88(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x286e
movq -0x88(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
je 0x3551
leaq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0x78(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x286e
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
cmpl $0x6, %r14d
ja 0x35bf
incl %r14d
leaq -0x70(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x286e
movq -0x70(%rbp), %rsi
movq %r12, %rdi
callq 0x4a86
testq %rax, %rax
je 0x35bf
leaq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x286e
leaq -0x60(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x286e
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3ffc
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfa
leaq -0x58(%rbp), %rdi
callq 0x4072
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x35e6
jmp 0x35e6
jmp 0x3604
jmp 0x3604
jmp 0x35e6
jmp 0x35e6
jmp 0x35e6
jmp 0x35e6
jmp 0x35e6
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x4072
jmp 0x3607
jmp 0x3604
jmp 0x3604
jmp 0x3604
jmp 0x3604
jmp 0x3604
jmp 0x3604
jmp 0x3604
jmp 0x3604
movq %rax, %r14
movq %rbx, %rdi
callq 0x2a40
movq %r14, %rdi
callq 0x21d0
nop