// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq 0x51b1(%rip), %rbx      # 0xafd0
leaq 0x14ff(%rip), %rsi      # 0x7325
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2150
leaq -0xb8(%rbp), %r13
movq %r13, -0x10(%r13)
xorl %eax, %eax
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq -0x58(%rbp), %r15
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb %al, (%r15)
movq 0x5182(%rip), %rdi      # 0xafe0
leaq -0xc8(%rbp), %rsi
callq 0x2160
movq -0xc8(%rbp), %rax
cmpb $0x3a, (%rax)
jne 0x5eba
movsbl 0x1(%rax), %edi
callq 0x2210
addl $-0x4c, %eax
cmpl $0x9, %eax
ja 0x60e9
leaq 0x1212(%rip), %rcx      # 0x70a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movq %rax, %rdi
movl $0x1, %esi
callq 0x57ec
jmp 0x605e
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x50f8(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20b0
leaq 0x1452(%rip), %rsi      # 0x733e
movl $0x18, %edx
movq %rax, %rdi
callq 0x2150
movq 0x50e0(%rip), %rdi      # 0xafe0
leaq -0x68(%rbp), %rsi
callq 0x2160
movq -0xc0(%rbp), %r14
cmpq $0x2, %r14
jne 0x6044
cmpq $0x2, -0x60(%rbp)
jne 0x6044
movq -0xc8(%rbp), %r12
movsbl (%r12), %edi
callq 0x2210
addl $-0x41, %eax
cmpl $0x7, %eax
ja 0x6044
movb 0x1(%r12), %al
addb $-0x31, %al
cmpb $0x7, %al
ja 0x6044
movq -0x68(%rbp), %rbx
movsbl (%rbx), %edi
callq 0x2210
addl $-0x41, %eax
cmpl $0x7, %eax
ja 0x6044
movb 0x1(%rbx), %al
addb $-0x31, %al
cmpb $0x7, %al
ja 0x6044
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movl $0x20, %edi
callq 0x2120
movq %rax, -0x38(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
addq %r12, %r14
leaq -0xa8(%rbp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x68a8
leaq -0x48(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x292a
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x68a8
movb $0x1, %r12b
leaq -0x40(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq -0x38(%rbp), %r14
callq 0x292a
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r14, %rdi
callq 0x4058
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x57fc
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x602a
callq 0x2100
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x605e
callq 0x2100
jmp 0x605e
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movq %rax, %rdi
movl $0x5, %esi
callq 0x57ec
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x606c
callq 0x2100
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0x607d
callq 0x2100
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movq %rax, %rdi
movl $0x2, %esi
callq 0x57ec
jmp 0x605e
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movq %rax, %rdi
movl $0x3, %esi
callq 0x57ec
jmp 0x605e
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movq %rax, %rdi
movl $0x4, %esi
callq 0x57ec
jmp 0x605e
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
movq %rax, %rdi
movl $0x5, %esi
callq 0x57ec
jmp 0x605e
movq %rax, -0x30(%rbp)
movb $0x1, %r12b
jmp 0x614d
jmp 0x6167
movq %rax, -0x30(%rbp)
movb $0x1, %r12b
jmp 0x6135
movq %rax, -0x30(%rbp)
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x6135
callq 0x2100
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x614d
callq 0x2100
testb %r12b, %r12b
je 0x616b
movq -0x38(%rbp), %rdi
callq 0x2100
jmp 0x616b
jmp 0x6167
jmp 0x6167
jmp 0x6167
jmp 0x6167
jmp 0x6167
movq %rax, -0x30(%rbp)
movq %rbx, %rdi
callq 0x2100
jmp 0x6179
movq %rax, -0x30(%rbp)
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x6187
callq 0x2100
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0x6198
callq 0x2100
movq -0x30(%rbp), %rdi
callq 0x21d0
nop