// File: smallsimple[P]CoreInterpreter-CSE5341/Assign.cpp
// Function: Assign::ParseAssign()
void Assign::ParseAssign(){
  Tokenizer *tokensAssign;
  tokensAssign = Tokenizer::getInstance();
  int tokenType;
  tokenType = tokensAssign->getTokenType();
  if (tokenType != tokensAssign->idNum){
    cout << "Error: Assign: not legal identifier" << endl;
    cout << "program stopped." << endl;
    exit(0);
  }
  id = Id::ParseId();
  string tokenTemp;
  tokenTemp = tokensAssign->getToken();
  if (tokenTemp.compare("=") != 0){
    cout << "Error: Assign: \"=\" not found after identifier." << endl;
    cout << "program stopped." << endl;
    exit(0);
  }
  else {
    tokensAssign->skipToken();
  }
  
  expr = new Expr();
  expr->ParseExpr();
  tokenTemp = tokensAssign->getToken();
  if (tokenTemp.compare(";") != 0){
    cout << "Error; Assign: \";\" not found or not in the right place!" << endl;
    cout << "program stopped." << endl;
    exit(0);
  }
  tokensAssign->skipToken();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x48d0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4ba0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x3e03(%rip), %rcx      # 0xc30c
cmpl (%rcx), %eax
je 0x8558
movq 0x8ac4(%rip), %rdi      # 0x10fd8
leaq 0x406f(%rip), %rsi      # 0xc58a
callq 0x21d0
movq %rax, %rdi
movq 0x8a9e(%rip), %rsi      # 0x10fc8
callq 0x2210
movq 0x8aa2(%rip), %rdi      # 0x10fd8
leaq 0x3c09(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, %rdi
movq 0x8a7c(%rip), %rsi      # 0x10fc8
callq 0x2210
xorl %edi, %edi
callq 0x2280
callq 0x7820
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x22d0
movq -0x10(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4940
jmp 0x8582
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2290
leaq -0x58(%rbp), %rdi
callq 0x2110
leaq -0x38(%rbp), %rdi
leaq 0x3b39(%rip), %rsi      # 0xc0dc
callq 0x2090
cmpl $0x0, %eax
je 0x8627
movq 0x8a24(%rip), %rdi      # 0x10fd8
leaq 0x3ff3(%rip), %rsi      # 0xc5ae
callq 0x21d0
movq %rax, -0x98(%rbp)
jmp 0x85c9
movq -0x98(%rbp), %rdi
movq 0x89f1(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x85de
movq 0x89f3(%rip), %rdi      # 0x10fd8
leaq 0x3b5a(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0xa0(%rbp)
jmp 0x85fa
movq -0xa0(%rbp), %rdi
movq 0x89c0(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x860f
xorl %edi, %edi
callq 0x2280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x875e
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x8632
jmp 0x8634
movl $0x18, %edi
callq 0x21e0
movq %rax, -0xa8(%rbp)
jmp 0x8647
movq -0xa8(%rbp), %rdi
callq 0x8770
jmp 0x8655
movq -0x90(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rax), %rdi
callq 0x8970
jmp 0x8672
movq -0x10(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x4940
jmp 0x8684
leaq -0x38(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x2290
leaq -0x88(%rbp), %rdi
callq 0x2110
leaq -0x38(%rbp), %rdi
leaq 0x407d(%rip), %rsi      # 0xc728
callq 0x2090
cmpl $0x0, %eax
je 0x8741
movq 0x8918(%rip), %rdi      # 0x10fd8
leaq 0x3f16(%rip), %rsi      # 0xc5dd
callq 0x21d0
movq %rax, -0xb0(%rbp)
jmp 0x86d5
movq -0xb0(%rbp), %rdi
movq 0x88e5(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x86ea
movq 0x88e7(%rip), %rdi      # 0x10fd8
leaq 0x3a4e(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0xb8(%rbp)
jmp 0x8706
movq -0xb8(%rbp), %rdi
movq 0x88b4(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x871b
xorl %edi, %edi
callq 0x2280
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x18, %esi
callq 0x21f0
jmp 0x875e
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x874c
leaq -0x38(%rbp), %rdi
callq 0x2110
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x2110
movq -0x60(%rbp), %rdi
callq 0x2370