// File: jstaursky[P]hutch/src/Sleigh/sleighbase.cc
// Function: SleighBase::getRegisterName[abi:cxx11](AddrSpace*, unsigned long, int) const
string SleighBase::getRegisterName(AddrSpace *base,uintb off,int4 size) const

{
  VarnodeData sym;
  sym.space = base;
  sym.offset = off;
  sym.size = size;
  map<VarnodeData,string>::const_iterator iter = varnode_xref.upper_bound(sym); // First point greater than offset
  if (iter == varnode_xref.begin()) return "";
  iter--;
  const VarnodeData &point((*iter).first);
  if (point.space != base) return "";
  uintb offbase = point.offset;
  if (point.offset+point.size >= off+size)
    return (*iter).second;
  
  while(iter != varnode_xref.begin()) {
    --iter;
    const VarnodeData &point((*iter).first);
    if ((point.space != base)||(point.offset != offbase)) return "";
    if (point.offset+point.size >= off+size)
      return (*iter).second;
  }
  return "";
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movl %r8d, 0xb4(%rsp)
movq 0xc8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0xb4(%rsp), %eax
movl %eax, 0xa8(%rsp)
addq $0x160, %rdi            # imm = 0x160
leaq 0x98(%rsp), %rsi
callq 0xdbfc0
movq 0x30(%rsp), %rdi
movq %rax, 0x90(%rsp)
addq $0x160, %rdi            # imm = 0x160
callq 0xd9e50
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xd36a0
testb $0x1, %al
jne 0x1217d7
jmp 0x121833
leaq 0x87(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xe0c80
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rdx
leaq 0x67896(%rip), %rsi     # 0x189090
callq 0xe00a0
jmp 0x121801
leaq 0x87(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x87(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a8b
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
callq 0xd2c10
movq %rax, 0x68(%rsp)
leaq 0x90(%rsp), %rdi
callq 0xce1d0
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rax
cmpq 0xc0(%rsp), %rax
je 0x1218be
leaq 0x5f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xe0c80
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rdx
leaq 0x67805(%rip), %rsi     # 0x189090
callq 0xe00a0
jmp 0x121892
leaq 0x5f(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x5f(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a8b
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x60(%rsp), %rcx
movl 0x10(%rcx), %ecx
addq %rcx, %rax
movq 0xb8(%rsp), %rcx
movslq 0xb4(%rsp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jb 0x12191b
leaq 0x90(%rsp), %rdi
callq 0xce1d0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
addq $0x18, %rsi
callq 0xd2230
jmp 0x121a7e
jmp 0x12191d
movq 0x30(%rsp), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0xd9e50
movq %rax, 0x48(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xcf1e0
testb $0x1, %al
jne 0x12194e
jmp 0x121a33
leaq 0x90(%rsp), %rdi
callq 0xdf090
leaq 0x90(%rsp), %rdi
callq 0xce1d0
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
cmpq 0xc0(%rsp), %rax
jne 0x12198f
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x50(%rsp), %rax
je 0x1219e2
leaq 0x3f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xe0c80
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x676e1(%rip), %rsi     # 0x189090
callq 0xe00a0
jmp 0x1219b6
leaq 0x3f(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x3f(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a8b
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rsp), %rcx
movl 0x10(%rcx), %ecx
addq %rcx, %rax
movq 0xb8(%rsp), %rcx
movslq 0xb4(%rsp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jb 0x121a2e
leaq 0x90(%rsp), %rdi
callq 0xce1d0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
addq $0x18, %rsi
callq 0xd2230
jmp 0x121a7e
jmp 0x12191d
leaq 0x3e(%rsp), %rdi
movq %rdi, (%rsp)
callq 0xe0c80
movq 0x20(%rsp), %rdi
movq (%rsp), %rdx
leaq 0x6763f(%rip), %rsi     # 0x189090
callq 0xe00a0
jmp 0x121a58
leaq 0x3e(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x3e(%rsp), %rdi
callq 0xd8ec0
jmp 0x121a8b
movq 0x28(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0xe0be0
nopw %cs:(%rax,%rax)