// File: /workspace/github_cpp_makefile_star2_O2/jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: ConsistencyChecker::setPostOrder(SubtableSymbol*)
void ConsistencyChecker::setPostOrder(SubtableSymbol *root)

{
  postorder.clear();
  sizemap.clear();

  // Establish post-order of SubtableSymbols so that we can
  // recursively fill in sizes of varnodes which are exported
  // from constructors

  vector<SubtableSymbol *> path;
  vector<int4> state;
  vector<int4> ctstate;

  sizemap[root] = -1;		// Mark root as traversed
  path.push_back(root);
  state.push_back(0);
  ctstate.push_back(0);

  while(!path.empty()) {
    SubtableSymbol *cur = path.back();
    int4 ctind = state.back();
    if (ctind >= cur->getNumConstructors()) {
      path.pop_back(); 		// Table is fully traversed
      state.pop_back();
      ctstate.pop_back();
      postorder.push_back(cur);	// Post the traversed table
    }
    else {
      Constructor *ct = cur->getConstructor(ctind);
      int4 oper = ctstate.back();
      if (oper >= ct->getNumOperands()) {
	state.back() = ctind + 1; // Constructor fully traversed
	ctstate.back() = 0;
      }
      else {
	ctstate.back() = oper + 1;
	OperandSymbol *opsym = ct->getOperand(oper);
	SubtableSymbol *subsym = dynamic_cast<SubtableSymbol *>(opsym->getDefiningSymbol());
	if (subsym != (SubtableSymbol *)0) {
	  map<SubtableSymbol *,int4>::const_iterator iter;
	  iter = sizemap.find(subsym);
	  if (iter == sizemap.end()) { // Not traversed yet
	    sizemap[subsym] = -1; // Mark table as traversed
	    path.push_back(subsym); // Recurse
	    state.push_back(0);
	    ctstate.push_back(0);
	  }
	}
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq %rsi, 0x28(%rsp)
movq 0x18(%rdi), %rax
cmpq %rax, 0x20(%rdi)
je 0x286c8
movq %rax, 0x20(%rbx)
leaq 0x30(%rbx), %r14
movq %r14, %rdi
callq 0x3010a
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x2ea26
orl $-0x1, (%rax)
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2ea76
leaq 0x8(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x50(%rsp), %rdi
callq 0x302b0
leaq 0x8(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x30(%rsp), %rdi
callq 0x302b0
leaq 0x18(%rbx), %r15
addq $0x38, %rbx
movq %rbx, 0x68(%rsp)
leaq 0x5ef99(%rip), %rbx     # 0x876e8
leaq 0x70(%rsp), %rbp
leaq 0x8(%rsp), %r12
movq 0x18(%rsp), %rdx
cmpq %rdx, 0x10(%rsp)
je 0x2887c
movq -0x8(%rdx), %rdi
movq %rdi, 0x8(%rsp)
movq 0x58(%rsp), %rax
movl -0x4(%rax), %ecx
addq $-0x4, %rax
movq 0x40(%rdi), %rsi
movq 0x48(%rdi), %rdi
subq %rsi, %rdi
shrq $0x3, %rdi
cmpl %edi, %ecx
jge 0x2884b
movq (%rsi,%rcx,8), %r8
movq 0x38(%rsp), %rdx
movslq -0x4(%rdx), %rsi
movq 0x18(%r8), %rdi
movq 0x20(%r8), %r8
subq %rdi, %r8
shrq $0x3, %r8
cmpl %r8d, %esi
jge 0x2886f
leal 0x1(%rsi), %eax
movl %eax, -0x4(%rdx)
movq (%rdi,%rsi,8), %rax
movq 0x48(%rax), %rdi
testq %rdi, %rdi
je 0x28759
leaq 0x5d294(%rip), %rsi     # 0x85a68
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0xf3f0
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x28759
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2fe52
cmpq 0x68(%rsp), %rax
jne 0x28759
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2ea26
orl $-0x1, (%rax)
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x2ea76
andl $0x0, 0x4(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x4(%rsp), %r13
movq %r13, %rsi
callq 0x302b0
andl $0x0, 0x4(%rsp)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x302b0
jmp 0x28759
addq $-0x8, %rdx
movq %rdx, 0x18(%rsp)
movq %rax, 0x58(%rsp)
addq $-0x4, 0x38(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x2ea76
jmp 0x28759
incl %ecx
movl %ecx, (%rax)
andl $0x0, -0x4(%rdx)
jmp 0x28759
leaq 0x30(%rsp), %rdi
callq 0x30138
leaq 0x50(%rsp), %rdi
callq 0x30138
leaq 0x10(%rsp), %rdi
callq 0x2fe1e
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x288b7
jmp 0x288b7
jmp 0x288b7
jmp 0x288b7
jmp 0x288b7
jmp 0x288b7
jmp 0x288b7
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x30138
leaq 0x50(%rsp), %rdi
callq 0x30138
leaq 0x10(%rsp), %rdi
callq 0x2fe1e
movq %rbx, %rdi
callq 0xf6e0