// File: smallsimple[P]CoreInterpreter-CSE5341/Loop.cpp
// Function: Loop::ParseLoop()
void Loop::ParseLoop(){
  Tokenizer *tokensLoop;
  tokensLoop = Tokenizer::getInstance();
  string tokenTemp = tokensLoop->getToken();
  if (tokenTemp.compare("while") == 0){
    tokensLoop->skipToken();
    cond = new Cond();
    cond->ParseCond();
    tokenTemp = tokensLoop->getToken();
    if (tokenTemp.compare("loop") == 0){
      tokensLoop->skipToken();
      stmtSeq = new StmtSeq(infile);
      stmtSeq->ParseStmtSeq();
      tokenTemp = tokensLoop->getToken();
      if (tokenTemp.compare("end") == 0){
	tokensLoop->skipToken();
	tokenTemp = tokensLoop->getToken();
	if (tokenTemp.compare(";") == 0){
	  tokensLoop->skipToken();
	  return;
	}
	else{
	  cout << "Syntax Error: ParseLoop: \";\" not found!" << endl;
	  cout << "program stopped." << endl;
	  exit(0);
	}
      }
      else {
	cout << "Syntax Error: ParseLoop: \"end\" not found!" << endl;
	cout << "program stopped." << endl;
	exit(0);
      }
    }
    else {
      cout << "Syntax Error: ParseLoop: \"loop\" not found!" << endl;
      cout << "program stopped." << endl;
      exit(0);
    }
    
  }
  
  else {
    cout << "Syntax Error: while not found!" << endl;
    cout << "program stopped.";
    exit(0);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
callq 0x48d0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x4940
leaq -0x30(%rbp), %rdi
leaq 0x2ccd(%rip), %rsi      # 0xc0b8
callq 0x2090
cmpl $0x0, %eax
jne 0x970b
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x9404
movl $0x20, %edi
callq 0x21e0
movq %rax, -0xb0(%rbp)
jmp 0x9417
movq -0xb0(%rbp), %rdi
callq 0xa460
jmp 0x9425
movq -0xa8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, (%rax)
movq (%rax), %rdi
callq 0xa750
jmp 0x9440
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4940
jmp 0x944f
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2290
leaq -0x60(%rbp), %rdi
callq 0x2110
leaq -0x30(%rbp), %rdi
leaq 0x32b0(%rip), %rsi      # 0xc720
callq 0x2090
cmpl $0x0, %eax
jne 0x96a2
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x9489
movl $0x18, %edi
callq 0x21e0
movq %rax, -0xb8(%rbp)
jmp 0x949c
movq -0xb8(%rbp), %rdi
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x72b0
jmp 0x94b5
movq -0xa8(%rbp), %rax
movq -0xb8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rax), %rdi
callq 0x7370
jmp 0x94d2
movq -0x10(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x4940
jmp 0x94e1
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2290
leaq -0x80(%rbp), %rdi
callq 0x2110
leaq -0x30(%rbp), %rdi
leaq 0x2ba6(%rip), %rsi      # 0xc0a8
callq 0x2090
cmpl $0x0, %eax
jne 0x9639
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x951b
movq -0x10(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x4940
jmp 0x952d
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2290
leaq -0xa0(%rbp), %rdi
callq 0x2110
leaq -0x30(%rbp), %rdi
leaq 0x31d4(%rip), %rsi      # 0xc728
callq 0x2090
cmpl $0x0, %eax
jne 0x95d0
movq -0x10(%rbp), %rdi
callq 0x49c0
jmp 0x9569
leaq -0x30(%rbp), %rdi
callq 0x2110
addq $0xf0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x9758
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x21f0
jmp 0x9758
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x21f0
jmp 0x9758
movq 0x7a01(%rip), %rdi      # 0x10fd8
leaq 0x314c(%rip), %rsi      # 0xc72a
callq 0x21d0
movq %rax, -0xc0(%rbp)
jmp 0x95ec
movq -0xc0(%rbp), %rdi
movq 0x79ce(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x9601
movq 0x79d0(%rip), %rdi      # 0x10fd8
leaq 0x2b37(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0xc8(%rbp)
jmp 0x961d
movq -0xc8(%rbp), %rdi
movq 0x799d(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x9632
xorl %edi, %edi
callq 0x2280
movq 0x7998(%rip), %rdi      # 0x10fd8
leaq 0x310b(%rip), %rsi      # 0xc752
callq 0x21d0
movq %rax, -0xd0(%rbp)
jmp 0x9655
movq -0xd0(%rbp), %rdi
movq 0x7965(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x966a
movq 0x7967(%rip), %rdi      # 0x10fd8
leaq 0x2ace(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0xd8(%rbp)
jmp 0x9686
movq -0xd8(%rbp), %rdi
movq 0x7934(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x969b
xorl %edi, %edi
callq 0x2280
movq 0x792f(%rip), %rdi      # 0x10fd8
leaq 0x30cc(%rip), %rsi      # 0xc77c
callq 0x21d0
movq %rax, -0xe0(%rbp)
jmp 0x96be
movq -0xe0(%rbp), %rdi
movq 0x78fc(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x96d3
movq 0x78fe(%rip), %rdi      # 0x10fd8
leaq 0x2a65(%rip), %rsi      # 0xc146
callq 0x21d0
movq %rax, -0xe8(%rbp)
jmp 0x96ef
movq -0xe8(%rbp), %rdi
movq 0x78cb(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x9704
xorl %edi, %edi
callq 0x2280
movq 0x78c6(%rip), %rdi      # 0x10fd8
leaq 0x308e(%rip), %rsi      # 0xc7a7
callq 0x21d0
movq %rax, -0xf0(%rbp)
jmp 0x9727
movq -0xf0(%rbp), %rdi
movq 0x7893(%rip), %rsi      # 0x10fc8
callq 0x2210
jmp 0x973c
movq 0x7895(%rip), %rdi      # 0x10fd8
leaq 0x29fc(%rip), %rsi      # 0xc146
callq 0x21d0
jmp 0x9751
xorl %edi, %edi
callq 0x2280
leaq -0x30(%rbp), %rdi
callq 0x2110
movq -0x38(%rbp), %rdi
callq 0x2370
nopw (%rax,%rax)