// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x90, %rsp
movq 0x53e9(%rip), %rdi      # 0xafd0
leaq 0x1707(%rip), %rsi      # 0x72f5
callq 0x2100
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movq 0x53c6(%rip), %rdi      # 0xafe0
leaq -0x50(%rbp), %rsi
callq 0x2150
movq -0x50(%rbp), %rax
cmpb $0x3a, (%rax)
jne 0x5c6c
movsbl 0x1(%rax), %edi
callq 0x21f0
addl $-0x4c, %eax
cmpl $0x9, %eax
ja 0x5e0b
leaq 0x142c(%rip), %rcx      # 0x7074
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x5874
jmp 0x5d9e
movq 0x535d(%rip), %rdi      # 0xafd0
callq 0x20b0
leaq 0x168f(%rip), %rsi      # 0x730e
movq %rax, %rdi
callq 0x2100
movq 0x5352(%rip), %rdi      # 0xafe0
leaq -0x70(%rbp), %rsi
callq 0x2150
cmpq $0x2, -0x48(%rbp)
jne 0x5d88
cmpq $0x2, -0x68(%rbp)
jne 0x5d88
movq -0x50(%rbp), %rbx
movsbl (%rbx), %edi
callq 0x21f0
addl $-0x41, %eax
cmpl $0x7, %eax
ja 0x5d88
movb 0x1(%rbx), %al
addb $-0x31, %al
cmpb $0x7, %al
ja 0x5d88
movq -0x70(%rbp), %rbx
movsbl (%rbx), %edi
callq 0x21f0
addl $-0x41, %eax
cmpl $0x7, %eax
ja 0x5d88
movb 0x1(%rbx), %al
addb $-0x31, %al
cmpb $0x7, %al
ja 0x5d88
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x20
popq %rdi
callq 0x2110
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2170
leaq -0x30(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x287a
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2170
movb $0x1, %r12b
leaq -0x28(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x287a
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq %r14, %rdi
callq 0x3ffc
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5882
leaq -0x90(%rbp), %rdi
callq 0x20a0
leaq -0xb0(%rbp), %rdi
callq 0x20a0
jmp 0x5d9e
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x5
popq %rsi
movq %rax, %rdi
callq 0x5874
leaq -0x70(%rbp), %rdi
callq 0x20a0
leaq -0x50(%rbp), %rdi
callq 0x20a0
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x2
popq %rsi
movq %rax, %rdi
callq 0x5874
jmp 0x5d9e
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x3
popq %rsi
movq %rax, %rdi
callq 0x5874
jmp 0x5d9e
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x4
popq %rsi
movq %rax, %rdi
callq 0x5874
jmp 0x5d9e
pushq $0x10
popq %rdi
callq 0x2110
movq %rax, %rbx
pushq $0x5
popq %rsi
movq %rax, %rdi
callq 0x5874
jmp 0x5d9e
movq %rax, %r15
jmp 0x5e55
jmp 0x5e69
movq %rax, %r15
movb $0x1, %r12b
jmp 0x5e44
movq %rax, %r15
leaq -0x90(%rbp), %rdi
callq 0x20a0
leaq -0xb0(%rbp), %rdi
callq 0x20a0
testb %r12b, %r12b
je 0x5e6c
movq %r14, %rdi
callq 0x20f0
jmp 0x5e6c
jmp 0x5e69
jmp 0x5e69
jmp 0x5e69
jmp 0x5e69
jmp 0x5e69
movq %rax, %r15
movq %rbx, %rdi
callq 0x20f0
jmp 0x5e79
movq %rax, %r15
leaq -0x70(%rbp), %rdi
callq 0x20a0
leaq -0x50(%rbp), %rdi
callq 0x20a0
movq %r15, %rdi
callq 0x21d0
nop