// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-assembler/src/parser.cpp
// Function: Parser::_validateInstruction(std::vector<Token, std::allocator<Token>> const&, unsigned int const&)
bool Parser::_validateInstruction(const std::vector<Token>& tokens,
                                  const unsigned& line) {
  const std::string opcode = tokens[0].getData();
  if ("NOP" == opcode || "TIMERST" == opcode) {
    if (1 < tokens.size()) {
      std::cerr << "Error: Invalid syntax for " << opcode
                << ", must be by itself on line " << line << "." << std::endl;
      return false;
    }
  } else if ("INPUT" == opcode || "LOAD" == opcode || "MOV" == opcode ||
             "ADD" == opcode || "SUB" == opcode || "MUL" == opcode ||
             "DIV" == opcode || "AND" == opcode || "OR" == opcode ||
             "XOR" == opcode || "SHL" == opcode || "SHRA" == opcode ||
             "SHRL" == opcode || "CMP" == opcode || "TST" == opcode ||
             "PIXEL" == opcode || "STOR" == opcode) {
    if (3 != tokens.size() ||
        REGISTER != tokens[1].getType() ||
        REGISTER != tokens[2].getType()) {
      std::cerr << "Error: Invalid syntax for " << opcode
                << ", expected " << opcode << " REG1 REG2 on line "
                << line << "." << std::endl;
      return false;
    }
  } else if ("PUSH" == opcode || "POP" == opcode || "COLOR" == opcode ||
             "JMP" == opcode || "TIME" == opcode || "RND" == opcode) {
    if (2 != tokens.size() ||
        REGISTER != tokens[1].getType()) {
      std::cerr << "Error: Invalid syntax for " << opcode
                << ", expected " << opcode << " REG on line "
                << line << "." << std::endl;
      return false;
    }
  } else if ("CALL" == opcode || "JMPI" == opcode || "JEQ" == opcode ||
             "JNE" == opcode || "JG" == opcode || "JGE" == opcode ||
             "JA" == opcode || "JAE" == opcode || "JL" == opcode ||
             "JLE" == opcode || "JB" == opcode || "JBE" == opcode ||
             "JO" == opcode || "JNO" == opcode || "JS" == opcode ||
             "JNS" == opcode) {
    if (2 != tokens.size() ||
        (DATA != tokens[1].getType() &&
         LABELREF != tokens[1].getType())) {
      std::cerr << "Error: Invalid syntax for " << opcode
                << ", expected " << opcode << " LABEL|DATA on line "
                << line << "." << std::endl;
      return false;
    } else if (DATA == tokens[1].getType() && 2 < tokens[1].getSize()) {
      std::cerr << "Error: Data too large, max of 16 bits on line "
                << line << "." << std::endl;
      return false;
    } else if (LABELREF == tokens[1].getType()) {
      // Save the label reference for later validation against
      // the full list of label declarations.
      _labelRefs.push_back(make_pair(tokens[1].getData(), line));
    }
  } else if ("RET" == opcode) {
    if (2 < tokens.size() ||
        (2 == tokens.size() && DATA != tokens[1].getType())) {
      std::cerr << "Error: Invalid syntax for " << opcode
                << ", expected " << opcode << " [DATA] on line "
                << line << "." << std::endl;
      return false;
    } else if (2 == tokens.size() && 1 < tokens[1].getSize()) {
      std::cerr << "Error: Data too large, max of 8 bits on line "
                << line << "." << std::endl;
      return false;
    }
  } else if ("LOADI" == opcode || "STORI" == opcode || "MOVI" == opcode) {
    if (3 != tokens.size() ||
        REGISTER != tokens[1].getType() ||
        (DATA != tokens[2].getType() &&
         LABELREF != tokens[2].getType())) {
      std::cerr << "Error: Invalid syntax for " << opcode
                << ", expected " << opcode << " REG LABEL|DATA on line "
                << line << "." << std::endl;
      return false;
    } else if (DATA == tokens[2].getType() && 2 < tokens[2].getSize()) {
      std::cerr << "Error: Data too large, max of 16 bits on line "
                << line << "." << std::endl;
      return false;
    } else if (LABELREF == tokens[2].getType()) {
      // Save the label reference for later validation against
      // the full list of label declarations.
      _labelRefs.push_back(make_pair(tokens[2].getData(), line));
    }
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rsi
addq $0x8, %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x2210
leaq 0x1d54(%rip), %rdi      # 0x7040
movq %r12, %rsi
callq 0x6397
testb %al, %al
jne 0x530d
leaq 0x1dbb(%rip), %rdi      # 0x70ba
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
je 0x5355
movq 0x8(%r15), %rax
subq (%r15), %rax
pushq $0x28
popq %rcx
cqto
idivq %rcx
movb $0x1, %bpl
cmpq $0x2, %rax
jb 0x5577
movq 0x5cc0(%rip), %rdi      # 0xaff0
leaq 0x1e79(%rip), %rsi      # 0x71b0
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1e7b(%rip), %rsi      # 0x71cb
jmp 0x554c
leaq 0x1ce8(%rip), %rdi      # 0x7044
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1cde(%rip), %rdi      # 0x7053
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1cd0(%rip), %rdi      # 0x705e
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1cc9(%rip), %rdi      # 0x7070
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1cb4(%rip), %rdi      # 0x7074
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c9f(%rip), %rdi      # 0x7078
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c8a(%rip), %rdi      # 0x707c
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c75(%rip), %rdi      # 0x7080
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c7d(%rip), %rdi      # 0x70a1
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c47(%rip), %rdi      # 0x7084
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c32(%rip), %rdi      # 0x7088
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c1d(%rip), %rdi      # 0x708c
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1c0d(%rip), %rdi      # 0x7091
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1bfd(%rip), %rdi      # 0x7096
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1bec(%rip), %rdi      # 0x709a
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1be1(%rip), %rdi      # 0x70a4
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x54ea
leaq 0x1bd2(%rip), %rdi      # 0x70aa
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
je 0x5590
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
cmpq $0x78, %rcx
jne 0x5509
cmpl $0x1, 0x28(%rax)
jne 0x5509
movb $0x1, %bpl
cmpl $0x1, 0x50(%rax)
je 0x5577
movq 0x5ae0(%rip), %rdi      # 0xaff0
leaq 0x1c99(%rip), %rsi      # 0x71b0
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1cb8(%rip), %rsi      # 0x71e8
movq %rax, %rdi
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1ca8(%rip), %rsi      # 0x71f4
movq %rax, %rdi
callq 0x2180
movl (%rbx), %esi
movq %rax, %rdi
callq 0x2100
leaq 0x1c01(%rip), %rsi      # 0x7166
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20e0
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
callq 0x20c0
movl %ebp, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ad0(%rip), %rdi      # 0x7067
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x560e
leaq 0x1ac0(%rip), %rdi      # 0x706c
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x560e
leaq 0x1add(%rip), %rdi      # 0x709e
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x560e
leaq 0x1af0(%rip), %rdi      # 0x70c6
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x560e
leaq 0x1aca(%rip), %rdi      # 0x70b5
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x560e
leaq 0x1ac2(%rip), %rdi      # 0x70c2
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
je 0x5673
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
cmpq $0x50, %rcx
jne 0x562b
movb $0x1, %bpl
cmpl $0x1, 0x28(%rax)
je 0x5577
movq 0x59be(%rip), %rdi      # 0xaff0
leaq 0x1b77(%rip), %rsi      # 0x71b0
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1b96(%rip), %rsi      # 0x71e8
movq %rax, %rdi
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1b9a(%rip), %rsi      # 0x7208
jmp 0x554c
leaq 0x19d0(%rip), %rdi      # 0x704a
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1a37(%rip), %rdi      # 0x70ca
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1a23(%rip), %rdi      # 0x70cf
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1a0e(%rip), %rdi      # 0x70d3
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x19f9(%rip), %rdi      # 0x70d7
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x19e3(%rip), %rdi      # 0x70da
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x19ce(%rip), %rdi      # 0x70de
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x19b8(%rip), %rdi      # 0x70e1
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x19a3(%rip), %rdi      # 0x70e5
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x198d(%rip), %rdi      # 0x70e8
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1978(%rip), %rdi      # 0x70ec
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1966(%rip), %rdi      # 0x70ef
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1955(%rip), %rdi      # 0x70f3
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1943(%rip), %rdi      # 0x70f6
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1932(%rip), %rdi      # 0x70fa
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x57ef
leaq 0x1920(%rip), %rdi      # 0x70fd
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
je 0x58c7
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
cmpq $0x50, %rax
jne 0x585e
movl 0x28(%rsi), %eax
cmpl $0x2, %eax
je 0x58a6
cmpl $0x4, %eax
jne 0x585e
addq $0x30, %rsi
leaq 0x28(%rsp), %rdi
callq 0x2210
addq $0x38, %r14
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x6542
movq %r14, %rdi
movq %r15, %rsi
callq 0x6560
leaq 0x48(%rsp), %rdi
callq 0x20c0
leaq 0x28(%rsp), %rdi
callq 0x20c0
movb $0x1, %bpl
jmp 0x5577
movq 0x578b(%rip), %rdi      # 0xaff0
leaq 0x1944(%rip), %rsi      # 0x71b0
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1963(%rip), %rsi      # 0x71e8
movq %rax, %rdi
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x19e7(%rip), %rsi      # 0x7288
jmp 0x554c
movb $0x1, %bpl
cmpq $0x2, 0x38(%rsi)
jbe 0x5577
leaq 0x195b(%rip), %rsi      # 0x7216
movq 0x572e(%rip), %rax      # 0xaff0
jmp 0x554c
leaq 0x1781(%rip), %rdi      # 0x704f
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
je 0x5926
movq (%r15), %rsi
movq 0x8(%r15), %rcx
subq %rsi, %rcx
pushq $0x28
popq %rdi
movq %rcx, %rax
cqto
idivq %rdi
cmpq $0x2, %rax
ja 0x5a12
movb $0x1, %bpl
cmpq $0x50, %rcx
jne 0x5577
cmpl $0x2, 0x28(%rsi)
jne 0x5a12
cmpq $0x1, 0x38(%rsi)
jbe 0x5577
leaq 0x1932(%rip), %rsi      # 0x7256
jmp 0x58bb
leaq 0x172b(%rip), %rdi      # 0x7058
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x596c
leaq 0x176d(%rip), %rdi      # 0x70af
leaq 0x8(%rsp), %rsi
callq 0x6397
testb %al, %al
jne 0x596c
leaq 0x170b(%rip), %rdi      # 0x7062
leaq 0x8(%rsp), %rsi
callq 0x6397
movb $0x1, %bpl
testb %al, %al
je 0x5577
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
cmpq $0x78, %rax
jne 0x59ca
cmpl $0x1, 0x28(%rsi)
jne 0x59ca
movl 0x50(%rsi), %eax
cmpl $0x2, %eax
je 0x5a5a
cmpl $0x4, %eax
jne 0x59ca
addq $0x58, %rsi
leaq 0x28(%rsp), %rdi
callq 0x2210
addq $0x38, %r14
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x6542
movq %r14, %rdi
movq %r15, %rsi
callq 0x6560
jmp 0x5842
movq 0x561f(%rip), %rdi      # 0xaff0
leaq 0x17d8(%rip), %rsi      # 0x71b0
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x17f7(%rip), %rsi      # 0x71e8
movq %rax, %rdi
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1877(%rip), %rsi      # 0x7284
jmp 0x554c
movq 0x55d7(%rip), %rdi      # 0xaff0
leaq 0x1790(%rip), %rsi      # 0x71b0
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x17af(%rip), %rsi      # 0x71e8
movq %rax, %rdi
callq 0x2180
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x17f0(%rip), %rsi      # 0x7245
jmp 0x554c
movb $0x1, %bpl
cmpq $0x3, 0x60(%rsi)
jb 0x5577
jmp 0x58b4
jmp 0x5a71
jmp 0x5a8c
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x20c0
leaq 0x28(%rsp), %rdi
callq 0x20c0
jmp 0x5a8f
jmp 0x5a8c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x22b0
nop