// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/space.cc
// Function: JoinSpace::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int&) const
uintb JoinSpace::read(const string &s,int4 &size) const

{
  vector<VarnodeData> pieces;
  int4 szsum = 0;
  int4 i=0;
  while(i < s.size()) {
    pieces.push_back(VarnodeData()); // Prepare to read next VarnodeData
    string token;
    while((i<s.size())&&(s[i]!=',')) {
      token += s[i];
      i += 1;
    }
    i += 1;			// Skip the comma
    try {
      pieces.back() = getTrans()->getRegister(token);
    }
    catch(LowlevelError &err) {	// Name doesn't exist
      char shortcut = token[0];
      AddrSpace *spc = getManager()->getSpaceByShortcut(shortcut);
      if (spc == (AddrSpace *)0)
	throw LowlevelError("Could not parse join string");

      int4 subsize;
      pieces.back().space = spc;
      pieces.back().offset = spc->read(token.substr(1),subsize);
      pieces.back().size = subsize;
    }
    szsum += pieces.back().size;
  }
  JoinRecord *rec = getManager()->findAddJoin(pieces,0);
  size = szsum;
  return rec->getUnified().offset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x60(%rsp)
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x8(%rsi)
je 0x4b61d
movq %rsi, %r15
xorl %ebx, %ebx
leaq 0x20(%rsp), %r13
xorl %r12d, %r12d
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x4b4d4
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x4b4df
movq %rsp, %rdi
movq %r13, %rdx
callq 0x41460
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movslq %r12d, %rbp
cmpq %rbp, 0x8(%r15)
jbe 0x4b521
movq (%r15), %rax
movb (%rax,%rbp), %al
cmpb $0x2c, %al
je 0x4b51e
movsbl %al, %esi
movq %r13, %rdi
callq 0x40480
incq %rbp
cmpq %rbp, 0x8(%r15)
ja 0x4b500
movl %ebp, %r12d
movq 0x18(%r14), %rdi
movq (%rdi), %rax
movq %r13, %rsi
callq *0x38(%rax)
movq 0x8(%rsp), %rcx
movq 0x10(%rax), %rdx
movq %rdx, -0x8(%rcx)
movups (%rax), %xmm0
movups %xmm0, -0x18(%rcx)
movq 0x8(%rsp), %rax
addl -0x8(%rax), %ebx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4b566
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x40870
incl %r12d
movslq %r12d, %rax
cmpq %rax, 0x8(%r15)
ja 0x4b4a4
jmp 0x4b61f
movq %rax, %rbp
cmpl $0x1, %edx
jne 0x4b72d
movq %rbp, %rdi
callq 0x3f910
movq 0x20(%rsp), %rax
movsbl (%rax), %esi
movq 0x10(%r14), %rdi
callq 0x415e0
movq %rax, %rbp
testq %rax, %rax
je 0x4b660
movq 0x8(%rsp), %rax
movq %rbp, -0x18(%rax)
movl $0x1, %edx
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
movq $-0x1, %rcx
callq 0x408c0
movq (%rbp), %rax
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
leaq 0x1c(%rsp), %rdx
callq *0x58(%rax)
movq 0x8(%rsp), %rcx
movq %rax, -0x10(%rcx)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4b607
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x40870
movl 0x1c(%rsp), %eax
movq 0x8(%rsp), %rcx
movl %eax, -0x8(%rcx)
callq 0x41a90
jmp 0x4b542
xorl %ebx, %ebx
movq 0x10(%r14), %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0x410a0
movq 0x60(%rsp), %rcx
movl %ebx, (%rcx)
movq 0x20(%rax), %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4b64e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x40870
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
movq %rax, (%rdi)
leaq 0x341f4(%rip), %rsi     # 0x7f875
leaq 0x34208(%rip), %rdx     # 0x7f890
callq 0x3f8a0
movb $0x1, %r14b
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x3f890
xorl %r14d, %r14d
movq 0x57801(%rip), %rsi     # 0xa2ea8
movq 0x5758a(%rip), %rdx     # 0xa2c38
movq %rbx, %rdi
callq 0x41d60
movq %rax, %rbp
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4b6dd
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b6dd
movq %rax, %rbp
movb $0x1, %r14b
testb %r14b, %r14b
je 0x4b714
movq %rbx, %rdi
callq 0x40080
jmp 0x4b714
jmp 0x4b72a
movq %rax, %rbp
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4b714
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4b714
jmp 0x4b711
movq %rax, %rbp
callq 0x41a90
jmp 0x4b72d
movq %rax, %rdi
callq 0x477f0
jmp 0x4b725
movq %rax, %rbp
jmp 0x4b749
movq %rax, %rbp
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4b749
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x40870
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4b75f
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x40870
movq %rbp, %rdi
callq 0x41f00
nop