// File: jstaursky[P]hutch/src/Sleigh/pcodecompile.cc
// Function: PcodeCompile::addressOf(VarnodeTpl*, unsigned int)
VarnodeTpl *PcodeCompile::addressOf(VarnodeTpl *var,uint4 size)

{				// Produce constant varnode that is the offset
				// portion of varnode -var-
  if (size==0) {		// If no size specified
    if (var->getSpace().getType() == ConstTpl::spaceid) {
      AddrSpace *spc = var->getSpace().getSpace();	// Look to the particular space
      size = spc->getAddrSize(); // to see if it has a standard address size
    }
  }
  VarnodeTpl *res;
  if ((var->getOffset().getType() == ConstTpl::real)&&(var->getSpace().getType() == ConstTpl::spaceid)) {
    AddrSpace *spc = var->getSpace().getSpace();
    uintb off = AddrSpace::byteToAddress(var->getOffset().getReal(),spc->getWordSize());
    res = new VarnodeTpl(ConstTpl(constantspace),
			  ConstTpl(ConstTpl::real,off),
			  ConstTpl(ConstTpl::real,size));
  }
  else
    res = new VarnodeTpl(ConstTpl(constantspace),var->getOffset(),ConstTpl(ConstTpl::real,size));
  delete var;
  return res;
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movl %edx, 0x104(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x104(%rsp)
jne 0x110f22
movq 0x108(%rsp), %rdi
callq 0xe3000
movq %rax, %rdi
callq 0xde5d0
cmpl $0x6, %eax
jne 0x110f20
movq 0x108(%rsp), %rdi
callq 0xe3000
movq %rax, %rdi
callq 0xd2a20
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0xd7510
movl %eax, 0x104(%rsp)
jmp 0x110f22
movq 0x108(%rsp), %rdi
callq 0xdbaf0
movq %rax, %rdi
callq 0xde5d0
cmpl $0x0, %eax
jne 0x11106b
movq 0x108(%rsp), %rdi
callq 0xe3000
movq %rax, %rdi
callq 0xde5d0
cmpl $0x6, %eax
jne 0x11106b
movq 0x108(%rsp), %rdi
callq 0xe3000
movq %rax, %rdi
callq 0xd2a20
movq %rax, 0xe8(%rsp)
movq 0x108(%rsp), %rdi
callq 0xdbaf0
movq %rax, %rdi
callq 0xdd890
movq %rax, 0x18(%rsp)
movq 0xe8(%rsp), %rdi
callq 0xde1c0
movq 0x18(%rsp), %rdi
movl %eax, %esi
callq 0xd29c0
movq %rax, 0xe0(%rsp)
movl $0x68, %edi
callq 0xd8380
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rsi
leaq 0xc0(%rsp), %rdi
callq 0xd69a0
jmp 0x110fe0
movq 0xe0(%rsp), %rdx
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
callq 0xd9880
jmp 0x110ff9
movl 0x104(%rsp), %eax
movl %eax, %edx
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0xd9880
jmp 0x111010
movq 0x20(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
leaq 0x70(%rsp), %rcx
callq 0xdf370
jmp 0x111031
movq 0x20(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x11110c
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
movl $0x68, %esi
callq 0xd8620
jmp 0x11113c
movl $0x68, %edi
callq 0xd8380
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x10(%rsp)
movq 0x10(%rax), %rsi
leaq 0x50(%rsp), %rdi
callq 0xd69a0
jmp 0x111092
movq 0x108(%rsp), %rdi
callq 0xdbaf0
movq %rax, 0x8(%rsp)
jmp 0x1110a6
movl 0x104(%rsp), %eax
movl %eax, %edx
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0xd9880
jmp 0x1110bd
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rcx
callq 0xdf370
jmp 0x1110d8
movq 0x10(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x11110c
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
movl $0x68, %esi
callq 0xd8620
jmp 0x11113c
movq 0x108(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x11112c
movq (%rsp), %rdi
movl $0x68, %esi
callq 0xd8620
movq 0xf0(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xb8(%rsp), %rdi
callq 0xe0be0
nopl (%rax)