// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/sleighbase.cc
// Function: SleighBase::buildXrefs()
void SleighBase::buildXrefs(void)

{
  SymbolScope *glb = symtab.getGlobalScope();
  SymbolTree::const_iterator iter;
  SleighSymbol *sym;
  int4 errors = 0;
  ostringstream s;

  for(iter=glb->begin();iter!=glb->end();++iter) {
    sym = *iter;
    if (sym->getType() == SleighSymbol::varnode_symbol) {
      pair<VarnodeData,string> ins(((VarnodeSymbol *)sym)->getFixedVarnode(),sym->getName());
      pair<map<VarnodeData,string>::iterator,bool> res = varnode_xref.insert(ins);
      if (!res.second) {
	s << "Duplicate (offset,size) pair for registers: ";
	s << sym->getName() << " and " << (*(res.first)).second << '\n';
	errors += 1;
      }
    }
    else if (sym->getType() == SleighSymbol::userop_symbol) {
      int4 index = ((UserOpSymbol *)sym)->getIndex();
      while(userop.size() <= index)
	userop.push_back("");
      userop[index] = sym->getName();
    }
    else if (sym->getType() == SleighSymbol::context_symbol) {
      ContextSymbol *csym = (ContextSymbol *)sym;
      ContextField *field = (ContextField *)csym->getPatternValue();
      int4 startbit = field->getStartBit();
      int4 endbit = field->getEndBit();
      registerContext(csym->getName(),startbit,endbit);
    }
  }
  if (errors > 0)
    throw SleighError(s.str());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, %rbx
movq 0x1b0(%rdi), %rax
movq (%rax), %r15
leaq 0x60(%rsp), %rdi
callq 0x41110
movq 0x20(%r15), %r14
addq $0x10, %r15
movq %r15, 0x50(%rsp)
cmpq %r15, %r14
je 0x59827
leaq 0x148(%rbx), %rax
movq %rax, 0x58(%rsp)
leaq 0x160(%rbx), %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0xc(%rsp)
leaq 0x10(%rsp), %rbp
leaq 0x27b8a(%rip), %r12     # 0x811f0
movq 0x20(%r14), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
cmpl $0x6, %eax
jne 0x59753
movq 0x48(%r13), %rax
movq %rax, 0x20(%rsp)
movups 0x38(%r13), %xmm0
movaps %xmm0, 0x10(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x3f8e0
movq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0x41c20
testb $0x1, %dl
jne 0x5972e
movq %rax, %r15
movl $0x2c, %edx
leaq 0x60(%rsp), %rdi
leaq 0x26ea4(%rip), %rsi     # 0x80579
callq 0x40b80
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
leaq 0x60(%rsp), %rdi
callq 0x40b80
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0x26ea8(%rip), %rsi     # 0x805a6
callq 0x40b80
movq 0x38(%r15), %rsi
movq 0x40(%r15), %rdx
movq %r13, %rdi
callq 0x40b80
movb $0xa, 0xb(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0xb(%rsp), %rsi
callq 0x40b80
incl 0xc(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5980a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x5980a
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
cmpl $0x2, %eax
jne 0x597c3
movslq 0x30(%r13), %r15
movq 0x148(%rbx), %rax
movq 0x150(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r15, %rcx
ja 0x597f4
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x3f8a0
movq 0x58(%rsp), %rdi
movq %rbp, %rsi
callq 0x3f7b0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x59766
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x59766
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
cmpl $0xf, %eax
jne 0x5980a
movq (%r13), %rax
movq %r13, %rdi
callq *0x60(%rax)
movl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
addq $0x8, %r13
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
callq *0x18(%rax)
jmp 0x5980a
addq $0x8, %r13
shlq $0x5, %r15
addq %rax, %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x3fc60
movq %r14, %rdi
callq 0x40bc0
movq %rax, %r14
cmpq 0x50(%rsp), %rax
jne 0x59666
cmpl $0x0, 0xc(%rsp)
jg 0x59857
movq 0x49552(%rip), %rsi     # 0xa2d80
leaq 0x60(%rsp), %rdi
callq 0x3fc30
leaq 0xd0(%rsp), %rdi
callq 0x3f730
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x418b0
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x49604(%rip), %rsi     # 0xa2e90
movq 0x493a5(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x598c2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x598c2
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x59918
movq %r14, %rdi
callq 0x40080
jmp 0x59918
jmp 0x59915
jmp 0x59915
jmp 0x59915
jmp 0x59915
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x59918
movq 0x38(%rsp), %rsi
jmp 0x5990b
jmp 0x59915
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x59918
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x59918
movq %rax, %rbx
movq 0x49461(%rip), %rsi     # 0xa2d80
leaq 0x60(%rsp), %rdi
callq 0x3fc30
leaq 0xd0(%rsp), %rdi
callq 0x3f730
movq %rbx, %rdi
callq 0x41f00