// File: IncredibleHannes[P]QMUL-ChessGame/src/View/View.cpp
// Function: View::getUserAction() const
UserAction* View::getUserAction() const {
  std::cout << "Please select a figure: ";
  std::string origin, target;
  std::cin >> origin;
  if(origin[0] == ':') {
    switch (toupper(origin[1])) {
      case 'S':
        return new UserAction(UserAction::Save);
      case 'L':
        return new UserAction(UserAction::Load);
      case 'Q':
        return new UserAction(UserAction::Quit);
      case 'U':
        return new UserAction(UserAction::Undo);
      default:
        return new UserAction(UserAction::Invalid);
    }
  }
  std::cout << std::endl << "Please select a target: ";
  std::cin >> target;
  if(origin.length() == 2 && target.length() == 2
     && toupper(origin[0]) - 'A' >= 0 &&  toupper(origin[0]) - 'A' < 8
     && origin[1] - '0' > 0 &&  origin[1] - '0' <= 8
     && toupper(target[0]) - 'A' >= 0 &&  toupper(target[0]) - 'A' < 8
     && target[1] - '0' > 0 &&  target[1] - '0' <= 8) {
    return new UserAction(new Move(Position(origin), Position(target)));
  }
  return new UserAction(UserAction::Invalid);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq 0x6eca(%rip), %rdi      # 0x11fd0
leaq 0x125c(%rip), %rsi      # 0xc369
callq 0x2150
leaq -0x30(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x21e0
leaq -0x50(%rbp), %rdi
callq 0x21e0
movq -0xc0(%rbp), %rsi
movq 0x6ea7(%rip), %rdi      # 0x11fe0
callq 0x21c0
jmp 0xb140
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x2290
movq %rax, -0xc8(%rbp)
jmp 0xb156
movq -0xc8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0xb38e
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x2290
movq %rax, -0xd0(%rbp)
jmp 0xb180
movq -0xd0(%rbp), %rax
movsbl (%rax), %edi
callq 0x2280
addl $-0x4c, %eax
movl %eax, %ecx
movq %rcx, -0xd8(%rbp)
subl $0x9, %eax
ja 0xb334
movq -0xd8(%rbp), %rax
leaq 0xf36(%rip), %rcx       # 0xc0e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xb74c
movl $0x10, %edi
callq 0x2160
movq %rax, -0xe0(%rbp)
jmp 0xb1df
movq -0xe0(%rbp), %rdi
movl $0x2, %esi
callq 0xaa70
jmp 0xb1f2
movq -0xe0(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x2140
jmp 0xb74c
movl $0x10, %edi
callq 0x2160
movq %rax, -0xe8(%rbp)
jmp 0xb239
movq -0xe8(%rbp), %rdi
movl $0x1, %esi
callq 0xaa70
jmp 0xb24c
movq -0xe8(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x2140
jmp 0xb74c
movl $0x10, %edi
callq 0x2160
movq %rax, -0xf0(%rbp)
jmp 0xb293
movq -0xf0(%rbp), %rdi
movl $0x3, %esi
callq 0xaa70
jmp 0xb2a6
movq -0xf0(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x2140
jmp 0xb74c
movl $0x10, %edi
callq 0x2160
movq %rax, -0xf8(%rbp)
jmp 0xb2ed
movq -0xf8(%rbp), %rdi
movl $0x4, %esi
callq 0xaa70
jmp 0xb300
movq -0xf8(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x2140
jmp 0xb74c
movl $0x10, %edi
callq 0x2160
movq %rax, -0x100(%rbp)
jmp 0xb347
movq -0x100(%rbp), %rdi
movl $0x5, %esi
callq 0xaa70
jmp 0xb35a
movq -0x100(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x2140
jmp 0xb74c
movq 0x6c3b(%rip), %rdi      # 0x11fd0
movq 0x6c24(%rip), %rsi      # 0x11fc0
callq 0x2180
movq %rax, -0x108(%rbp)
jmp 0xb3aa
movq -0x108(%rbp), %rdi
leaq 0xfca(%rip), %rsi       # 0xc382
callq 0x2150
jmp 0xb3bf
movq 0x6c1a(%rip), %rdi      # 0x11fe0
leaq -0x50(%rbp), %rsi
callq 0x21c0
jmp 0xb3d1
leaq -0x30(%rbp), %rdi
callq 0x2210
cmpq $0x2, %rax
jne 0xb6d9
leaq -0x50(%rbp), %rdi
callq 0x2210
cmpq $0x2, %rax
jne 0xb6d9
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x2290
movq %rax, -0x110(%rbp)
jmp 0xb40d
movq -0x110(%rbp), %rax
movsbl (%rax), %edi
callq 0x2280
subl $0x41, %eax
cmpl $0x0, %eax
jl 0xb6d9
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x2290
movq %rax, -0x118(%rbp)
jmp 0xb43e
movq -0x118(%rbp), %rax
movsbl (%rax), %edi
callq 0x2280
subl $0x41, %eax
cmpl $0x8, %eax
jge 0xb6d9
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x2290
movq %rax, -0x120(%rbp)
jmp 0xb470
movq -0x120(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0x0, %eax
jle 0xb6d9
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x2290
movq %rax, -0x128(%rbp)
jmp 0xb49d
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0x8, %eax
jg 0xb6d9
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x2290
movq %rax, -0x130(%rbp)
jmp 0xb4c9
movq -0x130(%rbp), %rax
movsbl (%rax), %edi
callq 0x2280
subl $0x41, %eax
cmpl $0x0, %eax
jl 0xb6d9
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x2290
movq %rax, -0x138(%rbp)
jmp 0xb4fa
movq -0x138(%rbp), %rax
movsbl (%rax), %edi
callq 0x2280
subl $0x41, %eax
cmpl $0x8, %eax
jge 0xb6d9
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x2290
movq %rax, -0x140(%rbp)
jmp 0xb52c
movq -0x140(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0x0, %eax
jle 0xb6d9
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x2290
movq %rax, -0x148(%rbp)
jmp 0xb559
movq -0x148(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0x8, %eax
jg 0xb6d9
movl $0x10, %edi
callq 0x2160
movq %rax, -0x150(%rbp)
jmp 0xb582
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x2160
movq %rax, -0x158(%rbp)
jmp 0xb59c
movb $0x1, -0xb1(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x20b0
jmp 0xb5b5
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x2e70
jmp 0xb5c7
leaq -0xb0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x20b0
jmp 0xb5d9
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2e70
jmp 0xb5ee
movq -0x158(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0x68b0
jmp 0xb607
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdi
movb $0x0, -0xb1(%rbp)
callq 0xaa90
jmp 0xb623
movq -0x150(%rbp), %rax
movb $0x0, -0xb2(%rbp)
movq %rax, -0x8(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x20f0
leaq -0x88(%rbp), %rdi
callq 0x20f0
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xb6c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xb6a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xb69b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x20f0
leaq -0x88(%rbp), %rdi
callq 0x20f0
testb $0x1, -0xb1(%rbp)
jne 0xb6b2
jmp 0xb6be
movq -0x158(%rbp), %rdi
callq 0x2140
jmp 0xb6c0
testb $0x1, -0xb2(%rbp)
jne 0xb6cb
jmp 0xb6d7
movq -0x150(%rbp), %rdi
callq 0x2140
jmp 0xb74c
movl $0x10, %edi
callq 0x2160
movq %rax, -0x160(%rbp)
jmp 0xb6ec
movq -0x160(%rbp), %rdi
movl $0x5, %esi
callq 0xaa70
jmp 0xb6ff
movq -0x160(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0xb72d
movq -0x160(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x2140
jmp 0xb74c
leaq -0x50(%rbp), %rdi
callq 0x20f0
leaq -0x30(%rbp), %rdi
callq 0x20f0
movq -0x8(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x20f0
leaq -0x30(%rbp), %rdi
callq 0x20f0
movq -0x58(%rbp), %rdi
callq 0x2260
nopw (%rax,%rax)