// File: smallsimple[P]CoreInterpreter-CSE5341/Tokenizer.cpp
// Function: Tokenizer::dealToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Tokenizer::dealToken(string str){
  int start = 0;
  int flag = 0; 
  Token tok;
  vector<SpecMarker> sMarker1;
  sMarker1 = this->searchSpec(str);
  for (int i = 0; i < sMarker1.size(); i++){
    // deal with string before special symbol if any
    if (start < sMarker1[i].start){
      int len = sMarker1[i].start - start;
      int ID;
      string temp = str.substr(start, len);
      if(!isLegalToken(temp)) {
	cout << "program stopped." << endl;
	exit(0);
      }
    }
    // deal with speical symbol
    tok.name = specSymbols[sMarker1[i].id];
    tok.num = sMarker1[i].id + 12;
    tokens.push_back(tok);
    // move start to end of next speical symbol
    start = sMarker1[i].start + specSymbols[sMarker1[i].id].size();
  }
  
  // if there is token after the last special symbols
  if (start < str.size()){
    string temp = str.substr(start, str.size()-start);
    if(!isLegalToken(temp)) {
      cout << "program stopped." << endl;
      exit(0);
    }
    else{
    }
    
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rsi, -0x130(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4dc0
leaq -0x58(%rbp), %rdi
callq 0x4cd0
movq -0x130(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x20d0
jmp 0x417a
movq -0x138(%rbp), %rsi
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x38e0
jmp 0x4193
leaq -0x58(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4e70
leaq -0x70(%rbp), %rdi
callq 0x4d60
leaq -0x90(%rbp), %rdi
callq 0x2110
movl $0x0, -0xa0(%rbp)
movslq -0xa0(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4ea0
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jae 0x442b
movl -0x14(%rbp), %eax
movl %eax, -0x144(%rbp)
movslq -0xa0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4ec0
movq %rax, %rcx
movl -0x144(%rbp), %eax
cmpl (%rcx), %eax
jge 0x436e
movslq -0xa0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4ec0
movq -0x130(%rbp), %rsi
movl (%rax), %eax
movl -0x14(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xa4(%rbp)
movslq -0x14(%rbp), %rdx
movslq -0xa4(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
callq 0x2200
jmp 0x4250
leaq -0xe8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x20d0
jmp 0x4265
movq -0x138(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x3cf0
movb %al, -0x145(%rbp)
jmp 0x4280
movb -0x145(%rbp), %al
xorb $-0x1, %al
movb %al, -0x146(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x2110
movb -0x146(%rbp), %al
testb $0x1, %al
jne 0x42a9
jmp 0x434f
movq 0xcd28(%rip), %rdi      # 0x10fd8
leaq 0x7e8f(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0x150(%rbp)
jmp 0x42c5
movq -0x150(%rbp), %rdi
movq 0xccf5(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x42da
xorl %edi, %edi
callq 0x2280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x458d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x2110
jmp 0x458d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x435d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x2110
jmp 0x435d
leaq -0xc8(%rbp), %rdi
callq 0x2110
jmp 0x436e
leaq -0xc8(%rbp), %rdi
callq 0x2110
jmp 0x458d
movslq -0xa0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4ec0
movslq 0x4(%rax), %rax
shlq $0x5, %rax
leaq 0xd003(%rip), %rsi      # 0x11390
addq %rax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x2040
jmp 0x439b
movslq -0xa0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4ec0
movq -0x138(%rbp), %rdi
movl 0x4(%rax), %eax
addl $0xc, %eax
movl %eax, -0x40(%rbp)
leaq -0x40(%rbp), %rsi
callq 0x4de0
jmp 0x43c6
movslq -0xa0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4ec0
movslq (%rax), %rax
movq %rax, -0x158(%rbp)
movslq -0xa0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4ec0
movslq 0x4(%rax), %rax
leaq 0xcf95(%rip), %rdi      # 0x11390
shlq $0x5, %rax
addq %rax, %rdi
callq 0x2140
movq %rax, %rcx
movq -0x158(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x14(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x41bf
movq -0x130(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0x160(%rbp)
callq 0x2140
movq %rax, %rcx
movq -0x160(%rbp), %rax
cmpq %rcx, %rax
jae 0x4572
movq -0x130(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0x168(%rbp)
callq 0x2140
movq -0x130(%rbp), %rsi
movq -0x168(%rbp), %rdx
movq %rax, %rcx
movslq -0x14(%rbp), %rax
subq %rax, %rcx
leaq -0x108(%rbp), %rdi
callq 0x2200
jmp 0x4492
leaq -0x128(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x20d0
jmp 0x44a7
movq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x3cf0
movb %al, -0x169(%rbp)
jmp 0x44c2
movb -0x169(%rbp), %al
xorb $-0x1, %al
movb %al, -0x16a(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x2110
movb -0x16a(%rbp), %al
testb $0x1, %al
jne 0x44e8
jmp 0x4554
movq 0xcae9(%rip), %rdi      # 0x10fd8
leaq 0x7c50(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0x178(%rbp)
jmp 0x4504
movq -0x178(%rbp), %rdi
movq 0xcab6(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x4519
xorl %edi, %edi
callq 0x2280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4564
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x2110
jmp 0x4564
jmp 0x4556
leaq -0x108(%rbp), %rdi
callq 0x2110
jmp 0x4572
leaq -0x108(%rbp), %rdi
callq 0x2110
jmp 0x458d
leaq -0x58(%rbp), %rdi
callq 0x4d60
leaq -0x40(%rbp), %rdi
callq 0x4e50
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x4d60
leaq -0x40(%rbp), %rdi
callq 0x4e50
movq -0x98(%rbp), %rdi
callq 0x2370
nopl (%rax,%rax)