// File: /workspace/github_cpp_makefile_star2_O3/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 0x2c166
movq %rax, 0x20(%rbx)
leaq 0x30(%rbx), %r14
movq %r14, %rdi
callq 0x353a4
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 0x3423a
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2c1c4
movq 0x70(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x2c1d3
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x353d2
movl $0x0, 0x28(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x2c1f8
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x2c207
leaq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3550e
movl $0x0, 0x28(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x2c22c
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x2c23b
leaq 0x30(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3550e
movq 0x18(%rsp), %rax
cmpq %rax, 0x10(%rsp)
je 0x2c418
leaq 0x18(%rbx), %r15
leaq 0x38(%rbx), %r12
leaq 0x605ce(%rip), %r13     # 0x8c828
leaq 0x28(%rsp), %rbp
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 0x2c349
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 0x2c374
leal 0x1(%rsi), %ecx
movl %ecx, -0x4(%rax)
movq (%rdi,%rsi,8), %rax
movq 0x48(%rax), %rdi
testq %rdi, %rdi
je 0x2c408
leaq 0x5e8d9(%rip), %rsi     # 0x8aba8
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xf410
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x2c408
movq 0x40(%rbx), %rcx
testq %rcx, %rcx
je 0x2c31a
movq %r12, %rdx
xorl %esi, %esi
cmpq %rax, 0x20(%rcx)
setb %sil
cmovaeq %rcx, %rdx
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x2c2f3
cmpq %r12, %rdx
je 0x2c31a
cmpq 0x20(%rdx), %rax
jae 0x2c408
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x3423a
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2c391
movq 0x68(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x2c3a0
addq $-0x8, %rax
movq %rax, 0x18(%rsp)
addq $-0x4, 0x38(%rsp)
movq %rcx, 0x58(%rsp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x2c384
movq %rdi, (%rsi)
addq $0x8, 0x20(%rbx)
jmp 0x2c408
incl %edx
movl %edx, (%rcx)
movl $0x0, -0x4(%rax)
jmp 0x2c408
movq %r15, %rdi
movq %rbp, %rdx
callq 0x353d2
jmp 0x2c408
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x353d2
movl $0x0, 0xc(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x2c3c5
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x2c3d4
leaq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x3550e
movl $0x0, 0xc(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x2c3f9
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x2c408
leaq 0x30(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x3550e
movq 0x18(%rsp), %rax
cmpq %rax, 0x10(%rsp)
jne 0x2c25f
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2c42f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2c446
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2c45d
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 0x2c478
jmp 0x2c478
jmp 0x2c478
jmp 0x2c478
jmp 0x2c478
jmp 0x2c478
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2c492
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2c4a9
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2c4c0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xf380
movq %rbx, %rdi
callq 0xf730