// File: /workspace/github_cpp_makefile_star2_O2/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, 0x40(%rsp)
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq 0x48(%rsi), %r15
subq 0x40(%rsi), %r15
shrq $0x5, %r15
leaq 0x4(%rsp), %rax
andl $0x0, (%rax)
xorl %r14d, %r14d
testl %r15d, %r15d
cmovlel %r14d, %r15d
pushq $0x18
popq %r12
leaq 0xd0(%rsp), %r13
movq %rsi, 0x10(%rsp)
movq %r15, 0x18(%rsp)
cmpq %r15, %r14
je 0x58d80
movq %r14, 0x48(%rsp)
shlq $0x5, %r14
movq 0x40(%rbx), %rsi
addq %r14, %rsi
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
callq 0x50630
movq %rbp, %rdi
xorl %esi, %esi
pushq $0x5
popq %rdx
leaq 0x2dcfd(%rip), %rcx     # 0x867fc
callq 0x503d0
testl %eax, %eax
je 0x58b61
leaq 0x70(%rsp), %rdi
leaq 0x2dcf2(%rip), %rsi     # 0x86806
callq 0x520f0
testb %al, %al
je 0x58d69
addq 0x58(%rbx), %r14
movq %r13, %rdi
movq %r14, %rsi
pushq $0x8
popq %rdx
callq 0x51500
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0xe8(%rsp,%rax)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x51830
movq %r13, %rdi
callq 0x4e070
jmp 0x58d69
movq 0x70(%rsp), %rax
movsbq 0x5(%rax), %r15
addq $-0x31, %r15
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rax
subq %rbx, %rax
cqto
idivq %r12
cmpq %r15, %rax
ja 0x58ba9
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
andq $0x0, 0xe0(%rsp)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x4d0e0
jmp 0x58b6f
movq %r12, %r13
movq 0x10(%rsp), %rax
addq 0x58(%rax), %r14
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x50630
imulq $0x18, %r15, %rax
addq %rax, %rbx
movq %r12, %rdi
pushq $0x3a
popq %r15
movl %r15d, %esi
xorl %edx, %edx
callq 0x50260
cmpq $-0x1, %rax
movq %r12, %r14
je 0x58d2c
movq %rax, %rbp
movl %r15d, %esi
leaq 0x1(%rax), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x50260
cmpq $-0x1, %rax
je 0x58dc4
movq %r14, %rsi
movq %rax, %r14
movq %r13, %r12
leaq 0x90(%rsp), %r13
movq %r13, %rdi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x4f700
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movq %r13, %rsi
callq 0x519f0
movq %rax, (%rbx)
leaq 0x258(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x4f700
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
pushq $0x8
popq %rdx
callq 0x51500
movq 0x18(%rsp), %r15
movq %rbp, %rdi
callq 0x4e020
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0xe8(%rsp,%rax)
leaq 0x8(%rbx), %rsi
movq %r13, %rdi
callq 0x4e460
incq %r14
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
movq %r14, %rdx
pushq $-0x1
popq %rcx
callq 0x4f700
leaq 0x90(%rsp), %rbp
leaq 0x258(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
pushq $0x8
popq %rdx
callq 0x51500
movq %r13, %rdi
callq 0x4e020
movq 0x258(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0x270(%rsp,%rax)
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x51830
movq %r14, %rdi
leaq 0x50(%rsp), %r14
callq 0x4e070
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
callq 0x4e070
movq %rbp, %rdi
callq 0x4e020
movq 0x10(%rsp), %rbx
jmp 0x58d61
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x38(%rax)
movq %r13, %r12
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rbx)
movups (%rax), %xmm0
movups %xmm0, (%rbx)
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
leaq 0xd0(%rsp), %r13
movq %r14, %rdi
callq 0x4e020
leaq 0x70(%rsp), %rdi
callq 0x4e020
movq 0x48(%rsp), %r14
incq %r14
jmp 0x58aca
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x4(%rsp), %edx
leaq 0x20(%rsp), %rsi
callq 0x50400
movl 0x28(%rax), %ecx
movq 0x40(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x20(%rax), %rbx
leaq 0x20(%rsp), %rdi
callq 0x4f8c0
movq %rbx, %rax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x4e180
movq %rax, %r14
leaq 0x2da75(%rip), %rsi     # 0x8684b
leaq 0xd0(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0x515e0
movb $0x1, %bpl
leaq 0xd0(%rsp), %rsi
movq %r14, %rdi
callq 0x4ddf0
xorl %ebp, %ebp
movq 0x56099(%rip), %rsi     # 0xaeea0
movq 0x55e2a(%rip), %rdx     # 0xaec38
movq %r14, %rdi
callq 0x51630
jmp 0x58ec4
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x4e020
testb %bpl, %bpl
jne 0x58e35
jmp 0x58ea2
movq %rax, %rbx
movq %r14, %rdi
callq 0x4ea60
jmp 0x58ea2
jmp 0x58e5c
jmp 0x58e85
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
callq 0x4e020
jmp 0x58e95
jmp 0x58e57
movq %rax, %rbx
jmp 0x58e95
movq %rax, %rbx
jmp 0x58ea2
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
callq 0x4e070
jmp 0x58e88
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x4e020
jmp 0x58e88
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x4e070
leaq 0x90(%rsp), %rdi
callq 0x4e020
leaq 0x50(%rsp), %rdi
callq 0x4e020
jmp 0x58ece
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x4e070
jmp 0x58ece
jmp 0x58ecb
jmp 0x58ecb
movq %rax, %rbx
jmp 0x58ed8
jmp 0x58ecb
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4e020
leaq 0x20(%rsp), %rdi
callq 0x4f8c0
movq %rbx, %rdi
callq 0x518c0