// File: /workspace/github_cpp_makefile_star2_O3/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 0x41120
movq 0x20(%r15), %r14
addq $0x10, %r15
movq %r15, 0x50(%rsp)
cmpq %r15, %r14
je 0x59547
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 0x27e6a(%rip), %r12     # 0x811f0
movq 0x20(%r14), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
cmpl $0x6, %eax
jne 0x59473
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 0x41c30
testb $0x1, %dl
jne 0x5944e
movq %rax, %r15
movl $0x2c, %edx
leaq 0x60(%rsp), %rdi
leaq 0x27184(%rip), %rsi     # 0x80579
callq 0x40b90
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
leaq 0x60(%rsp), %rdi
callq 0x40b90
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0x27188(%rip), %rsi     # 0x805a6
callq 0x40b90
movq 0x38(%r15), %rsi
movq 0x40(%r15), %rdx
movq %r13, %rdi
callq 0x40b90
movb $0xa, 0xb(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0xb(%rsp), %rsi
callq 0x40b90
incl 0xc(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5952a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x5952a
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
cmpl $0x2, %eax
jne 0x594e3
movslq 0x30(%r13), %r15
movq 0x148(%rbx), %rax
movq 0x150(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r15, %rcx
ja 0x59514
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 0x59486
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x59486
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
cmpl $0xf, %eax
jne 0x5952a
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 0x5952a
addq $0x8, %r13
shlq $0x5, %r15
addq %rax, %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x3fc60
movq %r14, %rdi
callq 0x40bd0
movq %rax, %r14
cmpq 0x50(%rsp), %rax
jne 0x59386
cmpl $0x0, 0xc(%rsp)
jg 0x59577
movq 0x49832(%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 0x418c0
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x498e4(%rip), %rsi     # 0xa2e90
movq 0x49685(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x595da
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x40880
testb %bpl, %bpl
jne 0x595e4
jmp 0x59635
movq %rax, %rbx
movq %r14, %rdi
callq 0x40090
jmp 0x59635
jmp 0x59632
jmp 0x59632
jmp 0x59632
jmp 0x59632
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x59635
movq 0x38(%rsp), %rsi
jmp 0x59628
jmp 0x59632
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x59635
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x59635
movq %rax, %rbx
movq 0x49744(%rip), %rsi     # 0xa2d80
leaq 0x60(%rsp), %rdi
callq 0x3fc30
leaq 0xd0(%rsp), %rdi
callq 0x3f730
movq %rbx, %rdi
callq 0x41f10
nop