// File: /workspace/github_cpp_makefile_star2_O1/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, 0x70(%rsp)
movq 0x18(%rdi), %rax
cmpq %rax, 0x20(%rdi)
je 0x2c32c
movq %rax, 0x20(%rbx)
leaq 0x30(%rbx), %r14
movq %r14, %rdi
callq 0x35764
xorl %eax, %eax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x3461e
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2c38a
movq 0x70(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x2c399
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x35792
movl $0x0, 0x28(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x2c3be
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x2c3cd
leaq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x358ce
movl $0x0, 0x28(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x2c3f2
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x2c401
leaq 0x30(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x358ce
movq 0x18(%rsp), %rax
cmpq %rax, 0x10(%rsp)
je 0x2c5e9
leaq 0x18(%rbx), %r15
leaq 0x38(%rbx), %rbp
leaq 0x60408(%rip), %r13     # 0x8c828
leaq 0x28(%rsp), %r12
movq -0x8(%rax), %rdi
movq %rdi, 0x28(%rsp)
movq 0x58(%rsp), %rcx
movl -0x4(%rcx), %edx
addq $-0x4, %rcx
movq 0x40(%rdi), %rsi
movq 0x48(%rdi), %r8
subq %rsi, %r8
shrq $0x3, %r8
cmpl %r8d, %edx
jge 0x2c495
movq (%rsi,%rdx,8), %r8
movq 0x38(%rsp), %rax
movslq -0x4(%rax), %rsi
movq 0x18(%r8), %rdi
movq 0x20(%r8), %r8
subq %rdi, %r8
shrq $0x3, %r8
cmpl %r8d, %esi
jge 0x2c4c0
leal 0x1(%rsi), %ecx
movl %ecx, -0x4(%rax)
movq (%rdi,%rsi,8), %rax
movq 0x48(%rax), %rdi
testq %rdi, %rdi
je 0x2c4e0
leaq 0x5e6c7(%rip), %rsi     # 0x8ab50
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xf410
jmp 0x2c4e2
addq $-0x8, %rax
movq %rax, 0x18(%rsp)
addq $-0x4, 0x38(%rsp)
movq %rcx, 0x58(%rsp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x2c4d0
movq %rdi, (%rsi)
addq $0x8, 0x20(%rbx)
jmp 0x2c5d9
incl %edx
movl %edx, (%rcx)
movl $0x0, -0x4(%rax)
jmp 0x2c5d9
movq %r15, %rdi
movq %r12, %rdx
callq 0x35792
jmp 0x2c5d9
xorl %eax, %eax
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x2c5d9
movq 0x40(%rbx), %rdx
movq %rbp, %rcx
testq %rdx, %rdx
je 0x2c517
movq %rbp, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x2c4ff
movq %rbp, %rdx
cmpq %rbp, %rcx
je 0x2c52a
cmpq 0x20(%rcx), %rax
cmovbq %rbp, %rcx
movq %rcx, %rdx
cmpq %rbp, %rdx
jne 0x2c5d9
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x3461e
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2c562
movq 0x68(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x2c571
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x35792
movl $0x0, 0xc(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x2c596
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x2c5a5
leaq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x358ce
movl $0x0, 0xc(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x2c5ca
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x2c5d9
leaq 0x30(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x358ce
movq 0x18(%rsp), %rax
cmpq %rax, 0x10(%rsp)
jne 0x2c425
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2c600
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2c617
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2c62e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c649
jmp 0x2c649
jmp 0x2c649
jmp 0x2c649
jmp 0x2c649
jmp 0x2c649
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2c663
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2c67a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2c691
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq %rbx, %rdi
callq 0xf730
nop