// File: smallsimple[P]CoreInterpreter-CSE5341/Prog.cpp
// Function: Prog::ParseProg()
void Prog::ParseProg(){
  Tokenizer *tokensProg; // declare a singleton Tokenizer class
  tokensProg = Tokenizer::getInstance();// get instance of the Tokenizer class  
  if (tokensProg->getToken().compare("program") != 0){
    cout << "Syntax error: the first token is not \"program\"!"<< endl;
    cout << "program stoppted." << endl;
    exit(0);
  }
  tokensProg->skipToken();
  ds = new DeclSeq();
  ds->ParseDeclSeq();
  if (tokensProg->getToken().compare("begin") != 0){
    cout << "Syntax error: \"begin\" is not in the right place!" << endl;
    cout << "program stopped." << endl;
    exit(0);
  }
  tokensProg->skipToken();
  ss = new StmtSeq(infile);
  ss->ParseStmtSeq();
  //tokensProg->skipToken();
  if (tokensProg->getToken().compare("end") != 0){
    cout << "Syntax error: \"end\" is not in the right place!" << endl;
    cout << "program stopped." << endl;
    exit(0);
  }
  else{
    tokensProg->skipToken();
    return;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x48d0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x4940
leaq -0x30(%rbp), %rdi
leaq 0x552f(%rip), %rsi      # 0xc09a
callq 0x2090
movl %eax, -0x84(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2110
movl -0x84(%rbp), %eax
cmpl $0x0, %eax
je 0x6bd5
movq 0xa447(%rip), %rdi      # 0x10fd8
leaq 0x577e(%rip), %rsi      # 0xc316
callq 0x21d0
movq %rax, %rdi
movq 0xa421(%rip), %rsi      # 0x10fc8
callq 0x2210
movq 0xa425(%rip), %rdi      # 0x10fd8
leaq 0x578c(%rip), %rsi      # 0xc346
callq 0x21d0
movq %rax, %rdi
movq 0xa3ff(%rip), %rsi      # 0x10fc8
callq 0x2210
xorl %edi, %edi
callq 0x2280
movq -0x10(%rbp), %rdi
callq 0x49c0
movl $0x10, %edi
callq 0x21e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x98(%rbp)
callq 0x6dd0
jmp 0x6bfc
movq -0x90(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq (%rax), %rdi
callq 0x6e80
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4940
leaq -0x60(%rbp), %rdi
leaq 0x5475(%rip), %rsi      # 0xc0a2
callq 0x2090
movl %eax, -0x9c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x2110
movl -0x9c(%rbp), %eax
cmpl $0x0, %eax
je 0x6cb9
movq 0xa385(%rip), %rdi      # 0x10fd8
leaq 0x56fe(%rip), %rsi      # 0xc358
callq 0x21d0
movq %rax, %rdi
movq 0xa35f(%rip), %rsi      # 0x10fc8
callq 0x2210
movq 0xa363(%rip), %rdi      # 0x10fd8
leaq 0x54ca(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, %rdi
movq 0xa33d(%rip), %rsi      # 0x10fc8
callq 0x2210
xorl %edi, %edi
callq 0x2280
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x10, %esi
callq 0x21f0
jmp 0x6db9
movq -0x10(%rbp), %rdi
callq 0x49c0
movl $0x18, %edi
callq 0x21e0
movq %rax, %rdi
movq -0x90(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0xa8(%rbp)
movq 0x10(%rax), %rsi
callq 0x72b0
jmp 0x6ceb
movq -0x90(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rax), %rdi
callq 0x7370
movq -0x10(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x4940
leaq -0x80(%rbp), %rdi
leaq 0x538a(%rip), %rsi      # 0xc0a8
callq 0x2090
movl %eax, -0xac(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2110
movl -0xac(%rbp), %eax
cmpl $0x0, %eax
je 0x6da7
movq 0xa294(%rip), %rdi      # 0x10fd8
leaq 0x563e(%rip), %rsi      # 0xc389
callq 0x21d0
movq %rax, %rdi
movq 0xa26e(%rip), %rsi      # 0x10fc8
callq 0x2210
movq 0xa272(%rip), %rdi      # 0x10fd8
leaq 0x53d9(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, %rdi
movq 0xa24c(%rip), %rsi      # 0x10fc8
callq 0x2210
xorl %edi, %edi
callq 0x2280
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x21f0
jmp 0x6db9
movq -0x10(%rbp), %rdi
callq 0x49c0
addq $0xb0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)
nopl (%rax)