// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/space.cc
// Function: JoinSpace::restoreXmlAttributes(Element const*, unsigned int&) const
uintb JoinSpace::restoreXmlAttributes(const Element *el,uint4 &size) const

{
  vector<VarnodeData> pieces;
  int4 numAttribs = el->getNumAttributes();
  uint4 sizesum = 0;
  uint4 logicalsize = 0;
  for(int4 i=0;i<numAttribs;++i) {
    string attrName = el->getAttributeName(i);
    if (0!=attrName.compare(0,5,"piece")) {
      if (attrName == "logicalsize") {
	istringstream s3(el->getAttributeValue(i));
	s3.unsetf(ios::dec | ios::hex | ios::oct);
	s3 >> logicalsize;
      }
      continue;
    }
    int4 pos = (int4)(attrName[5] - '1');
    while(pieces.size() <= pos)
      pieces.push_back(VarnodeData());
    VarnodeData &vdat( pieces[pos] );

    string attrVal = el->getAttributeValue(i);
    string::size_type offpos = attrVal.find(':');
    if (offpos == string::npos) {
      const Translate *trans = getTrans();
      const VarnodeData &point(trans->getRegister(attrVal));
      vdat = point;
    }
    else {
      string::size_type szpos = attrVal.find(':',offpos+1);
      if (szpos==string::npos)
	throw LowlevelError("join address piece attribute is malformed");
      string spcname = attrVal.substr(0,offpos);
      vdat.space = getManager()->getSpaceByName(spcname);
      istringstream s1(attrVal.substr(offpos+1,szpos));
      s1.unsetf(ios::dec | ios::hex | ios::oct);
      s1 >> vdat.offset;
      istringstream s2(attrVal.substr(szpos+1));
      s2.unsetf(ios::dec | ios::hex | ios::oct);
      s2 >> vdat.size;
    }
    sizesum += vdat.size;
  }
  JoinRecord *rec = getManager()->findAddJoin(pieces,logicalsize);
  size = rec->getUnified().size;
  return rec->getUnified().offset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
movq %rdx, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x48(%rsi), %r12
subq 0x40(%rsi), %r12
movq %rdi, 0x28(%rsp)
shrq $0x5, %r12
movl $0x0, 0x4(%rsp)
testl %r12d, %r12d
jle 0x4b101
movq %rsi, %rbx
leaq 0x50(%rsp), %r13
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %ebp, %ebp
leaq 0x40(%rsp), %r15
leaq 0xd0(%rsp), %rcx
movq %rsi, 0x30(%rsp)
movq %r12, 0x38(%rsp)
movq %rcx, %r14
movq 0x40(%rbx), %rax
movq %rbp, 0x88(%rsp)
shlq $0x5, %rbp
movq %r13, 0x40(%rsp)
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x3f8e0
movl $0x5, %edx
movq %r15, %rdi
xorl %esi, %esi
leaq 0x34a87(%rip), %rcx     # 0x7f7fc
callq 0x41080
testl %eax, %eax
je 0x4adf6
leaq 0x40(%rsp), %rdi
leaq 0x34a7c(%rip), %rsi     # 0x7f806
callq 0x3f590
testl %eax, %eax
movq %r14, %rcx
jne 0x4b0ce
addq 0x58(%rbx), %rbp
movq %rcx, %rdi
movq %rbp, %rsi
movl $0x8, %edx
movq %rcx, %r15
callq 0x41c80
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0xe8(%rsp,%rax)
movq %r15, %rdi
leaq 0x4(%rsp), %rsi
callq 0x41eb0
movq %r15, %rdi
movq 0x57f34(%rip), %rsi     # 0xa2d10
callq 0x41440
leaq 0x148(%rsp), %rdi
callq 0x3f730
movq %r15, %rcx
jmp 0x4b0ce
movq 0x40(%rsp), %rax
movsbq 0x5(%rax), %rbx
addq $-0x31, %rbx
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rsi
movq %rsi, %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rbx, %rax
ja 0x4ae6b
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
cmpq 0x20(%rsp), %rsi
je 0x4ae5c
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x4ae04
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
callq 0x41460
jmp 0x4ae04
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rax
leaq 0x70(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0x3f8e0
leaq (%rbx,%rbx,2), %rax
leaq (%r12,%rax,8), %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x40f90
cmpq $-0x1, %rax
je 0x4b07d
movq %rax, %rbx
leaq 0x1(%rax), %r12
movq %r15, %rdi
movl $0x3a, %esi
movq %r12, %rdx
callq 0x40f90
cmpq $-0x1, %rax
je 0x4b155
movq %rax, %r13
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x408c0
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rdi
movq %rbp, %rsi
callq 0x41fd0
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x258(%rsp), %rbx
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x408c0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x41c80
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r12
movq 0x258(%rsp), %rdi
leaq 0x268(%rsp), %rax
cmpq %rax, %rdi
je 0x4af6c
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x40870
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0xe8(%rsp,%rax)
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x3fc90
incq %r13
leaq 0x90(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
movq %r13, %rdx
movq $-0x1, %rcx
callq 0x408c0
leaq 0x258(%rsp), %rdi
movq %r15, %rsi
movl $0x8, %edx
leaq 0x50(%rsp), %r13
callq 0x41c80
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x4aff2
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x40870
movq 0x258(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0x270(%rsp,%rax)
movq 0x8(%rsp), %rsi
addq $0x10, %rsi
leaq 0x258(%rsp), %r15
movq %r15, %rdi
callq 0x41eb0
movq %r15, %rdi
movq 0x57ce7(%rip), %r15     # 0xa2d10
movq %r15, %rsi
callq 0x41440
leaq 0x2d0(%rsp), %rdi
callq 0x3f730
movq %r14, %rdi
movq %r15, %rsi
callq 0x41440
leaq 0x148(%rsp), %rdi
callq 0x3f730
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x4b0ac
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b0ac
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x38(%rax)
movq 0x10(%rax), %rcx
movq 0x8(%rsp), %rdx
movq %rcx, 0x10(%rdx)
movups (%rax), %xmm0
movups %xmm0, (%rdx)
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r12
movq %r14, %rcx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4b0ce
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x40870
movq %r14, %rcx
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x4b0e8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x40870
movq %r14, %rcx
movq 0x88(%rsp), %rbp
incq %rbp
cmpq %r12, %rbp
leaq 0x40(%rsp), %r15
jne 0x4ad38
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x4(%rsp), %edx
leaq 0x10(%rsp), %rsi
callq 0x410a0
movl 0x28(%rax), %ecx
movq 0x80(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x20(%rax), %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4b140
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x40870
movq %rbx, %rax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0xe0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x346d6(%rip), %rsi     # 0x7f84b
leaq 0x346f8(%rip), %rdx     # 0x7f874
leaq 0xd0(%rsp), %rdi
callq 0x3f8a0
movb $0x1, %bpl
leaq 0xd0(%rsp), %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x57d03(%rip), %rsi     # 0xa2ea8
movq 0x57a8c(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x4b32d
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x4b1e1
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b1e1
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x4b305
movq %r14, %rdi
callq 0x40080
jmp 0x4b305
jmp 0x4b239
jmp 0x4b2bc
movq %rax, %rbx
movq 0x258(%rsp), %rdi
leaq 0x268(%rsp), %rax
cmpq %rax, %rdi
je 0x4b2e0
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b2e0
jmp 0x4b231
movq %rax, %rbx
jmp 0x4b2e0
movq %rax, %rbx
jmp 0x4b305
movq %rax, %rbx
movq 0x57ac5(%rip), %rsi     # 0xa2d10
leaq 0x258(%rsp), %rdi
callq 0x41440
leaq 0x2d0(%rsp), %rdi
callq 0x3f730
jmp 0x4b2bf
movq %rax, %rbx
movq 0x57a9f(%rip), %rsi     # 0xa2d10
leaq 0xd0(%rsp), %rdi
callq 0x41440
leaq 0x148(%rsp), %rdi
callq 0x3f730
jmp 0x4b337
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x4b2bf
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b2bf
jmp 0x4b334
movq %rax, %rbx
movq 0x57a4a(%rip), %rsi     # 0xa2d10
leaq 0xd0(%rsp), %rdi
callq 0x41440
leaq 0x148(%rsp), %rdi
callq 0x3f730
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x4b305
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x40870
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4b326
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b326
movq %rax, %rbx
leaq 0x50(%rsp), %r13
jmp 0x4b337
movq %rax, %rbx
jmp 0x4b34e
jmp 0x4b334
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x4b34e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x40870
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4b365
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x40870
movq %rbx, %rdi
callq 0x41f00
nop