// File: /workspace/github_cpp_makefile_star2_O3/jstaursky[P]hutch/src/Sleigh/slghsymbol.cc
// Function: SymbolTable::purge()
void SymbolTable::purge(void)

{				// Get rid of unsavable symbols and scopes
  SleighSymbol *sym;
  for(int4 i=0;i<symbollist.size();++i) {
    sym = symbollist[i];
    if (sym == (SleighSymbol *)0) continue;
    if (sym->scopeid != 0) { // Not in global scope
      if (sym->getType() == SleighSymbol::operand_symbol) continue;
    }
    else {
      switch(sym->getType()) {
      case SleighSymbol::space_symbol:
      case SleighSymbol::token_symbol:
      case SleighSymbol::epsilon_symbol:
      case SleighSymbol::section_symbol:
	break;
      case SleighSymbol::macro_symbol:
	{			// Delete macro's local symbols
	  MacroSymbol *macro = (MacroSymbol *)sym;
	  for(int4 i=0;i<macro->getNumOperands();++i) {
	    SleighSymbol *opersym = macro->getOperand(i);
	    table[opersym->scopeid]->removeSymbol(opersym);
	    symbollist[opersym->id] = (SleighSymbol *)0;
	    delete opersym;
	  }
	  break;
	}
      case SleighSymbol::subtable_symbol:
	{			// Delete unused subtables
	  SubtableSymbol *subsym = (SubtableSymbol *)sym;
	  if (subsym->getPattern() != (TokenPattern *)0) continue;
	  for(int4 i=0;i<subsym->getNumConstructors();++i) { // Go thru each constructor
	    Constructor *con = subsym->getConstructor(i);
	    for(int4 j=0;j<con->getNumOperands();++j) { // Go thru each operand
	      OperandSymbol *oper = con->getOperand(j);
	      table[oper->scopeid]->removeSymbol(oper);
	      symbollist[oper->id] = (SleighSymbol *)0;
	      delete oper;
	    }
	  }
	  break;		// Remove the subtable symbol itself
	}
      default:
	continue;
      }
    }
    table[sym->scopeid]->removeSymbol(sym); // Remove the symbol
    symbollist[i] = (SleighSymbol *)0;
    delete sym;
  }
  for(int4 i=1;i<table.size();++i) { // Remove any empty scopes
    if (table[i]->tree.empty()) {
      delete table[i];
      table[i] = (SymbolScope *)0;
    }
  }
  renumber();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
cmpq %rax, 0x8(%rdi)
je 0x65b04
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
movq (%rax,%rbp,8), %r13
testq %r13, %r13
je 0x65aea
movl 0x2c(%r13), %r14d
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
testl %r14d, %r14d
je 0x6590f
cmpl $0x8, %eax
jne 0x65aaa
jmp 0x65aea
leal -0xb(%rax), %ecx
cmpl $0x5, %ecx
ja 0x65a1d
leaq 0x1b5d2(%rip), %rdx     # 0x80ef4
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
movq %r13, 0x10(%rsp)
jmpq *%rax
cmpq $0x0, 0x30(%r13)
jne 0x65aea
movq 0x40(%r13), %rax
movq 0x48(%r13), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
testl %edx, %edx
jle 0x65aaa
xorl %edi, %edi
movq %rbp, 0x18(%rsp)
movq (%rax,%rdi,8), %r14
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rsi
subq %rdx, %rsi
shrq $0x3, %rsi
testl %esi, %esi
jle 0x659ff
movq %rdi, 0x20(%rsp)
movq %r15, %rbp
xorl %r15d, %r15d
movq (%rdx,%r15,8), %r12
movl 0x2c(%r12), %eax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r13
movq %r12, 0x8(%rsp)
addq $0x8, %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3f970
movq %r13, %rdi
movq %rax, %rsi
callq 0x3fb50
movl 0x28(%r12), %eax
movq (%rbx), %rcx
movq $0x0, (%rcx,%rax,8)
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
incq %r15
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rax
subq %rdx, %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r15
jl 0x65982
movq 0x10(%rsp), %r13
movq 0x40(%r13), %rax
movq 0x48(%r13), %rcx
movq %rbp, %r15
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rdi
incq %rdi
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
movslq %edx, %rdx
cmpq %rdx, %rdi
jl 0x6595c
jmp 0x65aaa
cmpl $0x2, %eax
jb 0x65aaa
jmp 0x65aea
movq 0x40(%r13), %rax
movq 0x48(%r13), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0x65aaa
xorl %r14d, %r14d
movq (%rax,%r14,8), %r12
movl 0x2c(%r12), %eax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r13
movq %r12, 0x8(%rsp)
addq $0x8, %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x3f970
movq %r13, %rdi
movq 0x10(%rsp), %r13
movq %rax, %rsi
callq 0x3fb50
movl 0x28(%r12), %eax
movq (%rbx), %rcx
movq $0x0, (%rcx,%rax,8)
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
incq %r14
movq 0x40(%r13), %rax
movq 0x48(%r13), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r14
jl 0x65a41
movl 0x2c(%r13), %eax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r12
movq %r13, 0x8(%rsp)
addq $0x8, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x3f970
movq %r12, %rdi
movq %rax, %rsi
callq 0x3fb50
movq (%rbx), %rax
movq $0x0, (%rax,%rbp,8)
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
incq %rbp
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
ja 0x658e1
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x9, %rdx
jb 0x65b65
movl $0x1, %r15d
movq (%rax,%r15,8), %r14
cmpq $0x0, 0x30(%r14)
jne 0x65b53
leaq 0x8(%r14), %rdi
callq 0x40790
movl $0x40, %esi
movq %r14, %rdi
callq 0x40880
movq 0x18(%rbx), %rax
movq $0x0, (%rax,%r15,8)
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
incq %r15
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
ja 0x65b1e
movq %rbx, %rdi
callq 0x41250
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq