// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: SleighCompile::attachVarnodes(std::vector<SleighSymbol*, std::allocator<SleighSymbol*>>*, std::vector<SleighSymbol*, std::allocator<SleighSymbol*>>*)
void SleighCompile::attachVarnodes(vector<SleighSymbol *> *symlist,vector<SleighSymbol *> *varlist)

{
  SleighSymbol *dupsym = dedupSymbolList(symlist);
  if (dupsym != (SleighSymbol *)0)
    reportWarning("\"attach variables\" list contains duplicate entries: "+dupsym->getName(),true);
  for(int4 i=0;i<symlist->size();++i) {
    ValueSymbol *sym = (ValueSymbol *)(*symlist)[i];
    if (sym == (ValueSymbol *)0) continue;
    PatternValue *patval = sym->getPatternValue();
    if (patval->maxValue() + 1 != varlist->size()) {
      reportError("Attach varnode " + sym->getName() + " is wrong size for list", true);
    }
    int4 sz = 0;      
    for(int4 j=0;j<varlist->size();++j) {
      VarnodeSymbol *vsym = (VarnodeSymbol *)(*varlist)[j];
      if (vsym != (VarnodeSymbol *)0) {
	if (sz == 0)
	  sz = vsym->getFixedVarnode().size;
	else if (sz != vsym->getFixedVarnode().size) {
	  reportError("Attach statement contains varnodes of different sizes",true);
	  break;
	}
      }
    }
    symtab.replaceSymbol(sym,new VarnodeListSymbol(sym->getName(),patval,*varlist));
  }
  delete varlist;
  delete symlist;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
movq -0x10(%rbp), %rsi
callq 0x64970
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x650a8
movq -0x20(%rbp), %rdi
callq 0x401a0
movq %rax, %rdx
leaq 0x7474a(%rip), %rsi     # 0xd97a3
leaq -0x40(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x147f0
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movl $0x1, %edx
callq 0x62430
jmp 0x65083
leaq -0x40(%rbp), %rdi
callq 0x11300
jmp 0x650a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11300
jmp 0x65448
movl $0x0, -0x50(%rbp)
movslq -0x50(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6c010
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x653e3
movq -0x10(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x6c030
movq (%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x650f6
jmp 0x653b6
movq -0x58(%rbp), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x6c010
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
je 0x651d6
movq -0x58(%rbp), %rdi
callq 0x401a0
movq %rax, %rdx
leaq 0x74690(%rip), %rsi     # 0xd97d8
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x147f0
movq -0x100(%rbp), %rsi
leaq 0x745e4(%rip), %rdx     # 0xd974d
leaq -0x80(%rbp), %rdi
callq 0x6b540
jmp 0x65174
movq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x1, %edx
callq 0x603b0
jmp 0x6518b
leaq -0x80(%rbp), %rdi
callq 0x11300
leaq -0xa0(%rbp), %rdi
callq 0x11300
jmp 0x651d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x651c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x11300
leaq -0xa0(%rbp), %rdi
callq 0x11300
jmp 0x65448
movl $0x0, -0xa4(%rbp)
movl $0x0, -0xa8(%rbp)
movslq -0xa8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rdi
callq 0x6c010
movq %rax, %rcx
movq -0x108(%rbp), %rax
cmpq %rcx, %rax
jae 0x6533d
movq -0x18(%rbp), %rdi
movslq -0xa8(%rbp), %rsi
callq 0x6c030
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x65327
cmpl $0x0, -0xa4(%rbp)
jne 0x6525f
movq -0xb0(%rbp), %rdi
callq 0x57780
movl 0x10(%rax), %eax
movl %eax, -0xa4(%rbp)
jmp 0x65325
movl -0xa4(%rbp), %eax
movl %eax, -0x10c(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x57780
movq %rax, %rcx
movl -0x10c(%rbp), %eax
cmpl 0x10(%rcx), %eax
je 0x65323
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x118c0
movq -0x118(%rbp), %rdx
leaq 0x7453e(%rip), %rsi     # 0xd97e8
leaq -0xd0(%rbp), %rdi
callq 0x14430
jmp 0x652b8
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x1, %edx
callq 0x603b0
jmp 0x652d2
leaq -0xd0(%rbp), %rdi
callq 0x11300
leaq -0xd1(%rbp), %rdi
callq 0x114d0
jmp 0x6533d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x65312
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x11300
leaq -0xd1(%rbp), %rdi
callq 0x114d0
jmp 0x65448
jmp 0x65325
jmp 0x65327
jmp 0x65329
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x651ea
movq -0xe0(%rbp), %rax
addq $0x198, %rax            # imm = 0x198
movq %rax, -0x138(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x130(%rbp)
movl $0x58, %edi
callq 0x11440
movq %rax, -0x128(%rbp)
movq -0x58(%rbp), %rdi
callq 0x401a0
movq %rax, -0x120(%rbp)
jmp 0x6537f
movq -0x120(%rbp), %rsi
movq -0x128(%rbp), %rdi
movq -0x60(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0xa76b0
jmp 0x6539c
movq -0x128(%rbp), %rdx
movq -0x130(%rbp), %rsi
movq -0x138(%rbp), %rdi
callq 0xa2f40
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x650af
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x58, %esi
callq 0x11450
jmp 0x65448
movq -0x18(%rbp), %rax
movq %rax, -0x140(%rbp)
cmpq $0x0, %rax
je 0x65411
movq -0x140(%rbp), %rdi
callq 0x6c170
movq -0x140(%rbp), %rdi
movl $0x18, %esi
callq 0x11450
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
cmpq $0x0, %rax
je 0x6543f
movq -0x148(%rbp), %rdi
callq 0x6c170
movq -0x148(%rbp), %rdi
movl $0x18, %esi
callq 0x11450
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x118b0
nopw %cs:(%rax,%rax)