// File: smallsimple[P]CoreInterpreter-CSE5341/Op.cpp
// Function: Op::ParseOp()
void Op::ParseOp(){
  Tokenizer *tokensOp;
  tokensOp = Tokenizer::getInstance();
  int tokenType = tokensOp->getTokenType();
  if (tokenType == tokensOp->intNum){
    alterId = 1;
    inte = new Inte();
    inte->ParseInte();
  }
  else if (tokenType == tokensOp->idNum){
    //cout << "token.name: "<< tokensOp->getToken() << endl;
    alterId = 2;
    id = Id::ParseId();    
  }
  else if (tokenType == 20){//20 for "("
    alterId = 3;
    tokensOp->skipToken();
    expr = new Expr();
    expr->ParseExpr();
    tokenType = tokensOp->getTokenType();
    if (tokenType == 21){//21 for ")"
      tokensOp->skipToken();
    }
    else {
      cout << "Error: ParseOp: \")\" not found or not in right place!" << endl;
      cout << "program stopped." << endl;
      exit(0);
    }
  }
  else {
    cout << "Error: ParseOp: no Op is found!" << endl;
    cout << "program stopped." << endl;
    exit(0);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
callq 0x48d0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4ba0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x33c5(%rip), %rcx      # 0xc308
cmpl (%rcx), %eax
jne 0x8fa4
movq -0x30(%rbp), %rax
movl $0x1, 0x18(%rax)
movl $0x28, %edi
callq 0x21e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x38(%rbp)
callq 0x9110
jmp 0x8f6d
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
movq (%rax), %rdi
callq 0x9180
jmp 0x90f8
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x28, %esi
callq 0x21f0
jmp 0x90fe
movl -0x14(%rbp), %eax
leaq 0x335e(%rip), %rcx      # 0xc30c
cmpl (%rcx), %eax
jne 0x8fd2
movq -0x30(%rbp), %rax
movl $0x2, 0x18(%rax)
callq 0x7820
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x90f6
cmpl $0x14, -0x14(%rbp)
jne 0x90a9
movq -0x30(%rbp), %rax
movl $0x3, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x49c0
movl $0x18, %edi
callq 0x21e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x40(%rbp)
callq 0x8770
jmp 0x900b
movq -0x30(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rax), %rdi
callq 0x8970
movq -0x10(%rbp), %rdi
callq 0x4ba0
movl %eax, -0x14(%rbp)
cmpl $0x15, -0x14(%rbp)
jne 0x905c
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x90a7
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x21f0
jmp 0x90fe
movq 0x7f75(%rip), %rdi      # 0x10fd8
leaq 0x3637(%rip), %rsi      # 0xc6a1
callq 0x21d0
movq %rax, %rdi
movq 0x7f4f(%rip), %rsi      # 0x10fc8
callq 0x2210
movq 0x7f53(%rip), %rdi      # 0x10fd8
leaq 0x30ba(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, %rdi
movq 0x7f2d(%rip), %rsi      # 0x10fc8
callq 0x2210
xorl %edi, %edi
callq 0x2280
jmp 0x90f4
movq 0x7f28(%rip), %rdi      # 0x10fd8
leaq 0x361f(%rip), %rsi      # 0xc6d6
callq 0x21d0
movq %rax, %rdi
movq 0x7f02(%rip), %rsi      # 0x10fc8
callq 0x2210
movq 0x7f06(%rip), %rdi      # 0x10fd8
leaq 0x306d(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, %rdi
movq 0x7ee0(%rip), %rsi      # 0x10fc8
callq 0x2210
xorl %edi, %edi
callq 0x2280
jmp 0x90f6
jmp 0x90f8
addq $0x40, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x2370
nopw (%rax,%rax)