// File: /workspace/github_cpp_makefile_star2_O2/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), %r14
leaq 0x60(%rsp), %rdi
callq 0x504a0
movq 0x20(%r14), %r13
addq $0x10, %r14
movq %r14, 0x18(%rsp)
leaq 0x148(%rbx), %r12
leaq 0x160(%rbx), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
leaq 0x20(%rsp), %r14
cmpq 0x18(%rsp), %r13
je 0x65666
movq 0x20(%r13), %r15
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
cmpl $0x6, %eax
jne 0x655bf
leaq 0x8(%r15), %rbp
movq 0x48(%r15), %rax
movq %rax, 0x30(%rsp)
movups 0x38(%r15), %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0x50630
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x51490
testb $0x1, %dl
jne 0x655b0
movq %rax, %r15
leaq 0x60(%rsp), %rdi
leaq 0x21fe8(%rip), %rsi     # 0x87559
callq 0x4f5b0
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x4f1b0
movq %rax, %rdi
leaq 0x21ff9(%rip), %rsi     # 0x87586
callq 0x4f5b0
addq $0x38, %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x4f1b0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x4fc10
incl 0xc(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x4e020
jmp 0x65656
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
cmpl $0x2, %eax
jne 0x65614
movslq 0x30(%r15), %rbp
movq 0x148(%rbx), %rdi
movq 0x150(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
ja 0x65643
movq %r14, %rdi
leaq 0x22bcb(%rip), %rsi     # 0x881c0
leaq 0xb(%rsp), %rdx
callq 0x515e0
movq %r12, %rdi
movq %r14, %rsi
callq 0x4dc80
movq %r14, %rdi
callq 0x4e020
jmp 0x655d1
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
cmpl $0xf, %eax
jne 0x65656
movq (%r15), %rax
movq %r15, %rdi
callq *0x60(%rax)
movl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
addq $0x8, %r15
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x18(%rax)
jmp 0x65656
addq $0x8, %r15
shlq $0x5, %rbp
addq %rbp, %rdi
movq %r15, %rsi
callq 0x4e400
movq %r13, %rdi
callq 0x4fb80
movq %rax, %r13
jmp 0x6550b
cmpl $0x0, 0xc(%rsp)
jg 0x65689
leaq 0x60(%rsp), %rdi
callq 0x4d7c0
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x4e180
movq %rax, %r14
leaq 0x68(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x50fb0
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x4ddf0
xorl %ebp, %ebp
movq 0x497cc(%rip), %rsi     # 0xaee88
movq 0x49575(%rip), %rdx     # 0xaec38
movq %r14, %rdi
callq 0x51630
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4e020
testb %bpl, %bpl
jne 0x656e2
jmp 0x65712
movq %rax, %rbx
movq %r14, %rdi
callq 0x4ea60
jmp 0x65712
jmp 0x65700
jmp 0x65700
jmp 0x65700
jmp 0x65700
jmp 0x65700
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x6570d
movq %rax, %rbx
jmp 0x65712
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4e020
leaq 0x60(%rsp), %rdi
callq 0x4d7c0
movq %rbx, %rdi
callq 0x518c0