// File: 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
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x228(%rbp)
movq %rdi, %rax
movq %rax, -0x220(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x218(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x3220
movq -0x218(%rbp), %rdi
callq 0x57d0
movb %al, -0x209(%rbp)
jmp 0x4b60
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x53dd
jmp 0x4b70
movq -0x218(%rbp), %rdi
addq $0x10, %rdi
callq 0x2ee0
movl %eax, -0x22c(%rbp)
jmp 0x4b88
movq -0x218(%rbp), %rdi
movl -0x22c(%rbp), %eax
movl %eax, -0x30(%rbp)
addq $0x10, %rdi
callq 0x2ef0
movl %eax, -0x230(%rbp)
jmp 0x4ba9
movq -0x218(%rbp), %rax
movl -0x230(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movb 0x8(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x4fc7
movq -0x18(%rbp), %rax
movq %rax, -0x238(%rbp)
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
leaq -0x3c(%rbp), %rdi
callq 0x2e50
jmp 0x4be8
movq -0x238(%rbp), %rdi
movq -0x3c(%rbp), %rsi
callq 0x7de0
movq %rax, -0x240(%rbp)
jmp 0x4c01
movq -0x240(%rbp), %rax
cmpq $0x0, %rax
jne 0x4c8d
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0x68(%rbp), %rdi
callq 0x2e50
jmp 0x4c1f
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
leaq -0x70(%rbp), %rdi
callq 0x2e50
jmp 0x4c32
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x68b0
jmp 0x4c45
movq -0x228(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3ca0
jmp 0x4c57
leaq -0x60(%rbp), %rdi
callq 0x69d0
jmp 0x4c8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x5403
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x69d0
jmp 0x5403
cmpl $0x1, -0x30(%rbp)
jne 0x4dc7
movq -0x18(%rbp), %rax
movq %rax, -0x248(%rbp)
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
leaq -0x78(%rbp), %rdi
callq 0x2e50
jmp 0x4cb5
movq -0x248(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x7de0
movq %rax, -0x250(%rbp)
jmp 0x4cce
movq -0x250(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x251(%rbp)
jne 0x4d2f
movq -0x18(%rbp), %rax
movq %rax, -0x260(%rbp)
movl -0x30(%rbp), %esi
addl $0x2, %esi
movl -0x34(%rbp), %edx
leaq -0x80(%rbp), %rdi
callq 0x2e50
jmp 0x4d02
movq -0x260(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x7de0
movq %rax, -0x268(%rbp)
jmp 0x4d1b
movq -0x268(%rbp), %rax
cmpq $0x0, %rax
sete %al
movb %al, -0x251(%rbp)
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x4d3e
jmp 0x4dc5
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0xa8(%rbp), %rdi
callq 0x2e50
jmp 0x4d52
movl -0x30(%rbp), %esi
addl $0x2, %esi
movl -0x34(%rbp), %edx
leaq -0xb0(%rbp), %rdi
callq 0x2e50
jmp 0x4d69
movq -0xa8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x68b0
jmp 0x4d85
movq -0x228(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3ca0
jmp 0x4d9a
leaq -0xa0(%rbp), %rdi
callq 0x69d0
jmp 0x4dc5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x69d0
jmp 0x5403
jmp 0x4dc7
movl -0x34(%rbp), %edx
subl $0x1, %edx
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %edx, %ecx
movb %al, -0x269(%rbp)
jg 0x4e2e
movq -0x18(%rbp), %rax
movq %rax, -0x278(%rbp)
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
decl %edx
leaq -0xb8(%rbp), %rdi
callq 0x2e50
jmp 0x4dfe
movq -0x278(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x7de0
movq %rax, -0x280(%rbp)
jmp 0x4e1a
movq -0x280(%rbp), %rax
cmpq $0x0, %rax
setne %al
movb %al, -0x269(%rbp)
movb -0x269(%rbp), %al
testb $0x1, %al
jne 0x4e3d
jmp 0x4ec5
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0xe0(%rbp), %rdi
callq 0x2e50
jmp 0x4e51
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
decl %edx
leaq -0xe8(%rbp), %rdi
callq 0x2e50
jmp 0x4e69
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x68b0
jmp 0x4e85
movq -0x228(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x3ca0
jmp 0x4e9a
leaq -0xd8(%rbp), %rdi
callq 0x69d0
jmp 0x4ec5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x69d0
jmp 0x5403
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
xorl %eax, %eax
cmpl $0x8, %ecx
movb %al, -0x281(%rbp)
jge 0x4f2b
movq -0x18(%rbp), %rax
movq %rax, -0x290(%rbp)
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
incl %edx
leaq -0xf0(%rbp), %rdi
callq 0x2e50
jmp 0x4efb
movq -0x290(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x7de0
movq %rax, -0x298(%rbp)
jmp 0x4f17
movq -0x298(%rbp), %rax
cmpq $0x0, %rax
setne %al
movb %al, -0x281(%rbp)
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x4f3a
jmp 0x4fc2
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0x118(%rbp), %rdi
callq 0x2e50
jmp 0x4f4e
movl -0x30(%rbp), %esi
incl %esi
movl -0x34(%rbp), %edx
incl %edx
leaq -0x120(%rbp), %rdi
callq 0x2e50
jmp 0x4f66
movq -0x118(%rbp), %rsi
movq -0x120(%rbp), %rdx
leaq -0x110(%rbp), %rdi
callq 0x68b0
jmp 0x4f82
movq -0x228(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x3ca0
jmp 0x4f97
leaq -0x110(%rbp), %rdi
callq 0x69d0
jmp 0x4fc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x69d0
jmp 0x5403
jmp 0x53db
movq -0x18(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
leaq -0x128(%rbp), %rdi
callq 0x2e50
jmp 0x4fe8
movq -0x2a0(%rbp), %rdi
movq -0x128(%rbp), %rsi
callq 0x7de0
movq %rax, -0x2a8(%rbp)
jmp 0x5004
movq -0x2a8(%rbp), %rax
cmpq $0x0, %rax
jne 0x509b
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0x150(%rbp), %rdi
callq 0x2e50
jmp 0x5029
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
leaq -0x158(%rbp), %rdi
callq 0x2e50
jmp 0x503f
movq -0x150(%rbp), %rsi
movq -0x158(%rbp), %rdx
leaq -0x148(%rbp), %rdi
callq 0x68b0
jmp 0x505b
movq -0x228(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x3ca0
jmp 0x5070
leaq -0x148(%rbp), %rdi
callq 0x69d0
jmp 0x509b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x69d0
jmp 0x5403
cmpl $0x6, -0x30(%rbp)
jne 0x51e1
movq -0x18(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
leaq -0x160(%rbp), %rdi
callq 0x2e50
jmp 0x50c6
movq -0x2b0(%rbp), %rdi
movq -0x160(%rbp), %rsi
callq 0x7de0
movq %rax, -0x2b8(%rbp)
jmp 0x50e2
movq -0x2b8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x2b9(%rbp)
jne 0x5149
movq -0x18(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movl -0x30(%rbp), %esi
addl $-0x2, %esi
movl -0x34(%rbp), %edx
leaq -0x168(%rbp), %rdi
callq 0x2e50
jmp 0x5119
movq -0x2c8(%rbp), %rdi
movq -0x168(%rbp), %rsi
callq 0x7de0
movq %rax, -0x2d0(%rbp)
jmp 0x5135
movq -0x2d0(%rbp), %rax
cmpq $0x0, %rax
sete %al
movb %al, -0x2b9(%rbp)
movb -0x2b9(%rbp), %al
testb $0x1, %al
jne 0x5158
jmp 0x51df
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0x190(%rbp), %rdi
callq 0x2e50
jmp 0x516c
movl -0x30(%rbp), %esi
addl $-0x2, %esi
movl -0x34(%rbp), %edx
leaq -0x198(%rbp), %rdi
callq 0x2e50
jmp 0x5183
movq -0x190(%rbp), %rsi
movq -0x198(%rbp), %rdx
leaq -0x188(%rbp), %rdi
callq 0x68b0
jmp 0x519f
movq -0x228(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x3ca0
jmp 0x51b4
leaq -0x188(%rbp), %rdi
callq 0x69d0
jmp 0x51df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x69d0
jmp 0x5403
jmp 0x51e1
movl -0x34(%rbp), %edx
subl $0x1, %edx
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %edx, %ecx
movb %al, -0x2d1(%rbp)
jg 0x5248
movq -0x18(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
decl %edx
leaq -0x1a0(%rbp), %rdi
callq 0x2e50
jmp 0x5218
movq -0x2e0(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0x7de0
movq %rax, -0x2e8(%rbp)
jmp 0x5234
movq -0x2e8(%rbp), %rax
cmpq $0x0, %rax
setne %al
movb %al, -0x2d1(%rbp)
movb -0x2d1(%rbp), %al
testb $0x1, %al
jne 0x5257
jmp 0x52df
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0x1c8(%rbp), %rdi
callq 0x2e50
jmp 0x526b
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
decl %edx
leaq -0x1d0(%rbp), %rdi
callq 0x2e50
jmp 0x5283
movq -0x1c8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
leaq -0x1c0(%rbp), %rdi
callq 0x68b0
jmp 0x529f
movq -0x228(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3ca0
jmp 0x52b4
leaq -0x1c0(%rbp), %rdi
callq 0x69d0
jmp 0x52df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x69d0
jmp 0x5403
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
xorl %eax, %eax
cmpl $0x8, %ecx
movb %al, -0x2e9(%rbp)
jge 0x5345
movq -0x18(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
incl %edx
leaq -0x1d8(%rbp), %rdi
callq 0x2e50
jmp 0x5315
movq -0x2f8(%rbp), %rdi
movq -0x1d8(%rbp), %rsi
callq 0x7de0
movq %rax, -0x300(%rbp)
jmp 0x5331
movq -0x300(%rbp), %rax
cmpq $0x0, %rax
setne %al
movb %al, -0x2e9(%rbp)
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x5354
jmp 0x53d9
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
leaq -0x200(%rbp), %rdi
callq 0x2e50
jmp 0x5368
movl -0x30(%rbp), %esi
decl %esi
movl -0x34(%rbp), %edx
incl %edx
leaq -0x208(%rbp), %rdi
callq 0x2e50
jmp 0x5380
movq -0x200(%rbp), %rsi
movq -0x208(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0x68b0
jmp 0x539c
movq -0x228(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x3ca0
jmp 0x53b1
leaq -0x1f8(%rbp), %rdi
callq 0x69d0
jmp 0x53d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x69d0
jmp 0x5403
jmp 0x53db
jmp 0x53dd
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x53f3
movq -0x228(%rbp), %rdi
callq 0x3240
movq -0x220(%rbp), %rax
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq -0x228(%rbp), %rdi
callq 0x3240
movq -0x28(%rbp), %rdi
callq 0x2260
nopl (%rax,%rax)