// File: 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:
subq $0x198, %rsp            # imm = 0x198
movq %rdi, 0x190(%rsp)
movq %rsi, 0x188(%rsp)
movq %rdx, 0x180(%rsp)
movq 0x190(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0x168(%rsp), %rdi
callq 0xdc410
movl $0x0, 0x164(%rsp)
movl $0x0, 0x160(%rsp)
movslq 0x160(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x188(%rsp), %rdi
callq 0xd5290
movq %rax, %rcx
movq 0x98(%rsp), %rax
cmpq %rcx, %rax
jae 0xf8ffa
xorps %xmm0, %xmm0
movaps %xmm0, 0x140(%rsp)
movq $0x0, 0x150(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0xde8e0
jmp 0xf8bd1
leaq 0x110(%rsp), %rdi
callq 0xdc610
movslq 0x160(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x188(%rsp), %rdi
callq 0xd5290
movq 0x88(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x97(%rsp)
jae 0xf8c39
movq 0x188(%rsp), %rdi
movslq 0x160(%rsp), %rsi
callq 0xd9290
movsbl (%rax), %eax
cmpl $0x2c, %eax
setne %al
movb %al, 0x97(%rsp)
movb 0x97(%rsp), %al
testb $0x1, %al
jne 0xf8c46
jmp 0xf8cb5
movq 0x188(%rsp), %rdi
movslq 0x160(%rsp), %rsi
callq 0xd9290
movsbl (%rax), %esi
leaq 0x110(%rsp), %rdi
callq 0xd46b0
jmp 0xf8c6d
movl 0x160(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x160(%rsp)
jmp 0xf8bde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0xf9083
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0xf8fe8
movq 0xa0(%rsp), %rdi
movl 0x160(%rsp), %eax
incl %eax
movl %eax, 0x160(%rsp)
callq 0xdf7e0
movq %rax, 0x80(%rsp)
jmp 0xf8cdc
movq 0x80(%rsp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
leaq 0x110(%rsp), %rsi
callq *%rax
movq %rax, 0x78(%rsp)
jmp 0xf8cfc
leaq 0x168(%rsp), %rdi
callq 0xd3a60
movq 0x78(%rsp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
jmp 0xf8f8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
movl 0x134(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xf8fe8
movq 0x138(%rsp), %rdi
callq 0xd1d20
movq %rax, 0x108(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0xe2f50
movq %rax, 0x70(%rsp)
jmp 0xf8d7e
movq 0xa0(%rsp), %rdi
movq 0x70(%rsp), %rax
movb (%rax), %al
movb %al, 0x107(%rsp)
callq 0xd6150
movq %rax, 0x68(%rsp)
jmp 0xf8da0
movq 0x68(%rsp), %rdi
movsbl 0x107(%rsp), %esi
callq 0xdd7e0
movq %rax, 0x60(%rsp)
jmp 0xf8db9
movq 0x60(%rsp), %rax
movq %rax, 0xf8(%rsp)
cmpq $0x0, 0xf8(%rsp)
jne 0xf8eca
movb $0x1, 0xd6(%rsp)
movl $0x20, %edi
callq 0xd2b40
movq %rax, 0x50(%rsp)
leaq 0xd7(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0xe0c80
movq 0x58(%rsp), %rdx
leaq 0x8eaeb(%rip), %rsi     # 0x1878f5
leaq 0xd8(%rsp), %rdi
callq 0xe00a0
jmp 0xf8e19
movq 0x50(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xd1ae0
jmp 0xf8e2d
movq 0x50(%rsp), %rdi
movb $0x0, 0xd6(%rsp)
movq 0xcf04f(%rip), %rsi     # 0x1c7e90
movq 0xced88(%rip), %rdx     # 0x1c7bd0
callq 0xe01f0
jmp 0xf90a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0xf8fdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0xf8ea2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xd4550
leaq 0xd7(%rsp), %rdi
callq 0xd8ec0
testb $0x1, 0xd6(%rsp)
jne 0xf8ebb
jmp 0xf8ec5
movq 0x50(%rsp), %rdi
callq 0xd5400
jmp 0xf8fdf
movq 0xf8(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x168(%rsp), %rdi
callq 0xd3a60
movq 0x40(%rsp), %rcx
movq %rcx, (%rax)
movq 0xf8(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x110(%rsp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0xd8920
jmp 0xf8f1c
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq 0x58(%rax), %rax
leaq 0xb0(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq *%rax
movq %rax, 0x38(%rsp)
jmp 0xf8f41
leaq 0x168(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xd3a60
movq 0x38(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0xb0(%rsp), %rdi
callq 0xd4550
movq 0x28(%rsp), %rdi
movl 0xd0(%rsp), %eax
movl %eax, 0x34(%rsp)
callq 0xd3a60
movl 0x34(%rsp), %ecx
movl %ecx, 0x10(%rax)
callq 0xdf2c0
jmp 0xf8f8c
jmp 0xf8f8e
leaq 0x168(%rsp), %rdi
callq 0xd3a60
movl 0x10(%rax), %eax
addl 0x164(%rsp), %eax
movl %eax, 0x164(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xd4550
jmp 0xf8b72
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xd4550
callq 0xdf2c0
jmp 0xf8fe6
jmp 0xf8fe8
leaq 0x110(%rsp), %rdi
callq 0xd4550
jmp 0xf9083
movq 0xa0(%rsp), %rdi
callq 0xd6150
movq %rax, 0x20(%rsp)
jmp 0xf900e
movq 0x20(%rsp), %rdi
leaq 0x168(%rsp), %rsi
xorl %edx, %edx
callq 0xdbc00
movq %rax, 0x18(%rsp)
jmp 0xf9029
movq 0x18(%rsp), %rax
movq %rax, 0xa8(%rsp)
movl 0x164(%rsp), %ecx
movq 0x180(%rsp), %rax
movl %ecx, (%rax)
movq 0xa8(%rsp), %rdi
callq 0xd20e0
movq %rax, 0x10(%rsp)
jmp 0xf905b
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x168(%rsp), %rdi
callq 0xdc1e0
movq 0x8(%rsp), %rax
addq $0x198, %rsp            # imm = 0x198
retq
leaq 0x168(%rsp), %rdi
callq 0xdc1e0
movq 0x138(%rsp), %rdi
callq 0xe0be0
movq %rax, %rdi
callq 0xe7140
nopw %cs:(%rax,%rax)