// File: /workspace/github_cpp_makefile_star2_O3/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 $0x3e8, %rsp            # imm = 0x3E8
movq %rdx, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x48(%rsi), %rax
movq %rsi, 0x30(%rsp)
subq 0x40(%rsi), %rax
movq %rdi, 0x40(%rsp)
shrq $0x5, %rax
movl $0x0, 0xc(%rsp)
testl %eax, %eax
jle 0x4b0a1
movq %rbx, 0x88(%rsp)
leaq 0x58(%rsp), %r15
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ebp, %ebp
leaq 0x48(%rsp), %r14
leaq 0xe0(%rsp), %rcx
movq 0x30(%rsp), %rbx
movq %rax, 0x90(%rsp)
movq %rcx, %r12
movq 0x40(%rbx), %rax
movq %rbp, 0x98(%rsp)
shlq $0x5, %rbp
movq %r15, 0x48(%rsp)
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3f8e0
movl $0x5, %edx
movq %r14, %rdi
xorl %esi, %esi
leaq 0x34b08(%rip), %rcx     # 0x7f7fc
callq 0x41090
testl %eax, %eax
je 0x4ad75
leaq 0x48(%rsp), %rdi
leaq 0x34afd(%rip), %rsi     # 0x7f806
callq 0x3f590
testl %eax, %eax
movq %r12, %rcx
jne 0x4b058
addq 0x58(%rbx), %rbp
movq %rcx, %rdi
movq %rbp, %rsi
movl $0x8, %edx
movq %rcx, %r14
callq 0x41c90
movq 0xe0(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0xf8(%rsp,%rax)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0x41ec0
movq %r14, %rdi
movq 0x57fb5(%rip), %rsi     # 0xa2d10
callq 0x41450
leaq 0x158(%rsp), %rdi
callq 0x3f730
movq %r14, %rcx
jmp 0x4b058
movq 0x48(%rsp), %rax
movsbq 0x5(%rax), %rbx
addq $-0x31, %rbx
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %rsi
movq %rsi, %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rbx, %rax
ja 0x4adfc
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movq $0x0, 0xf0(%rsp)
cmpq 0x20(%rsp), %rsi
je 0x4ade3
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movq 0x18(%rsp), %rsi
addq $0x18, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x4adf5
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
callq 0x41470
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %r14
jmp 0x4ad8d
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rax
leaq 0x78(%rsp), %rcx
movq %rcx, 0x68(%rsp)
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r13
movq %r13, %rdi
callq 0x3f8e0
leaq (%rbx,%rbx,2), %rax
leaq (%r14,%rax,8), %rax
movq %rax, 0x38(%rsp)
movq %r13, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x40fa0
cmpq $-0x1, %rax
je 0x4b00c
movq %rax, %r14
movq %r13, %rbp
leaq 0x1(%rax), %rbx
movq %r13, %rdi
movl $0x3a, %esi
movq %rbx, %rdx
callq 0x40fa0
cmpq $-0x1, %rax
je 0x4b0eb
movq %rax, %r13
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x408d0
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
movq %r15, %rsi
callq 0x41fe0
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x268(%rsp), %r14
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x408d0
movq %r12, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x41c90
movq 0x30(%rsp), %rbx
movq 0x268(%rsp), %rdi
leaq 0x278(%rsp), %rax
cmpq %rax, %rdi
je 0x4aefb
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x40880
movq 0xe0(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0xf8(%rsp,%rax)
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %rsi
movq %r12, %rdi
callq 0x3fc90
incq %r13
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
movq %r13, %rdx
movq $-0x1, %rcx
callq 0x408d0
leaq 0x268(%rsp), %rdi
movq %r14, %rsi
movl $0x8, %edx
leaq 0x58(%rsp), %r15
callq 0x41c90
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4af81
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x40880
movq 0x268(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0x280(%rsp,%rax)
movq 0x38(%rsp), %rsi
addq $0x10, %rsi
leaq 0x268(%rsp), %r14
movq %r14, %rdi
callq 0x41ec0
movq %r14, %rdi
movq 0x57d58(%rip), %r14     # 0xa2d10
movq %r14, %rsi
callq 0x41450
leaq 0x2e0(%rsp), %rdi
callq 0x3f730
movq %r12, %rdi
movq %r14, %rsi
callq 0x41450
leaq 0x158(%rsp), %rdi
callq 0x3f730
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x4b036
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4b036
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
movq %r13, %rsi
callq *0x38(%rax)
movq 0x10(%rax), %rcx
movq 0x38(%rsp), %rdx
movq %rcx, 0x10(%rdx)
movups (%rax), %xmm0
movups %xmm0, (%rdx)
movq 0x30(%rsp), %rbx
movq %r12, %rcx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x4b058
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x40880
movq %r12, %rcx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4b072
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x40880
movq %r12, %rcx
movq 0x98(%rsp), %rbp
incq %rbp
movq 0x90(%rsp), %rax
cmpq %rax, %rbp
leaq 0x48(%rsp), %r14
jne 0x4acb7
movl 0xc(%rsp), %edx
movq 0x88(%rsp), %rbx
jmp 0x4b0a3
xorl %edx, %edx
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x10(%rsp), %rsi
callq 0x410b0
movl 0x28(%rax), %ecx
movl %ecx, (%rbx)
movq 0x20(%rax), %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4b0d6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x40880
movq %rbx, %rax
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0xf0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x34740(%rip), %rsi     # 0x7f84b
leaq 0x34762(%rip), %rdx     # 0x7f874
leaq 0xe0(%rsp), %rdi
callq 0x3f8a0
movb $0x1, %bpl
leaq 0xe0(%rsp), %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x57d6d(%rip), %rsi     # 0xa2ea8
movq 0x57af6(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x4b2bf
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r15, %rdi
je 0x4b16f
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x40880
testb %bpl, %bpl
jne 0x4b17c
jmp 0x4b297
movq %rax, %rbx
movq %r14, %rdi
callq 0x40090
jmp 0x4b297
jmp 0x4b1cb
jmp 0x4b24e
movq %rax, %rbx
movq 0x268(%rsp), %rdi
leaq 0x278(%rsp), %rax
cmpq %rax, %rdi
je 0x4b272
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4b272
jmp 0x4b1c3
movq %rax, %rbx
jmp 0x4b272
movq %rax, %rbx
jmp 0x4b297
movq %rax, %rbx
movq 0x57b33(%rip), %rsi     # 0xa2d10
leaq 0x268(%rsp), %rdi
callq 0x41450
leaq 0x2e0(%rsp), %rdi
callq 0x3f730
jmp 0x4b251
movq %rax, %rbx
movq 0x57b0d(%rip), %rsi     # 0xa2d10
leaq 0xe0(%rsp), %rdi
callq 0x41450
leaq 0x158(%rsp), %rdi
callq 0x3f730
jmp 0x4b2c9
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4b251
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4b251
jmp 0x4b2c6
movq %rax, %rbx
movq 0x57ab8(%rip), %rsi     # 0xa2d10
leaq 0xe0(%rsp), %rdi
callq 0x41450
leaq 0x158(%rsp), %rdi
callq 0x3f730
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x4b297
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x40880
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x4b2b8
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4b2b8
movq %rax, %rbx
leaq 0x58(%rsp), %r15
jmp 0x4b2c9
movq %rax, %rbx
jmp 0x4b2e0
jmp 0x4b2c6
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4b2e0
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x40880
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4b2f7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x40880
movq %rbx, %rdi
callq 0x41f10
nop