// File: jstaursky[P]hutch/src/Sleigh/pcodecompile.cc
// Function: PcodeCompile::createLoad(StarQuality*, ExprTree*)
ExprTree *PcodeCompile::createLoad(StarQuality *qual,ExprTree *ptr)

{				// Create new load expression, free ptr expression
  VarnodeTpl *outvn = buildTemporary();
  OpTpl *op = new OpTpl(CPUI_LOAD);
  // The first varnode input to the load is a constant reference to the AddrSpace being loaded
  // from.  Internally, we really store the pointer to the AddrSpace as the reference, but this
  // isn't platform independent. So officially, we assume that the constant reference will be the
  // AddrSpace index.  We can safely assume this always has size 4.
  VarnodeTpl *spcvn = new VarnodeTpl(ConstTpl(constantspace),
				     qual->id,
				     ConstTpl(ConstTpl::real,8));
  op->addInput(spcvn);
  op->addInput(ptr->outvn);
  op->setOutput(outvn);
  ptr->ops->push_back(op);
  if (qual->size > 0)
    force_size(outvn,ConstTpl(ConstTpl::real,qual->size),*ptr->ops);
  ptr->outvn = new VarnodeTpl(*outvn);
  delete qual;
  return ptr;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xd5da0
movq %rax, 0xb8(%rsp)
movl $0x28, %edi
callq 0xd8380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x30(%rsp)
movl $0x2, %esi
callq 0xcf490
jmp 0x10f15a
movq 0x30(%rsp), %rax
movq %rax, 0xb0(%rsp)
movl $0x68, %edi
callq 0xd8380
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rsi
leaq 0x78(%rsp), %rdi
callq 0xd69a0
jmp 0x10f18e
movq 0xc8(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0xd9880
jmp 0x10f1ae
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x58(%rsp), %rcx
callq 0xdf370
jmp 0x10f1c9
movq 0x20(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xb0(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0xe1280
movq 0xb0(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xe1280
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0xddc10
movq 0xc0(%rsp), %rax
movq (%rax), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xdc8a0
movq 0xc8(%rsp), %rax
cmpl $0x0, 0x20(%rax)
jbe 0x10f2d5
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xc8(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, %edx
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0xd9880
movq 0x10(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq (%rax), %rdx
leaq 0x38(%rsp), %rsi
callq 0xcf5c0
jmp 0x10f2d5
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x28, %esi
callq 0xd8620
jmp 0x10f35d
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x68, %esi
callq 0xd8620
jmp 0x10f35d
movl $0x68, %edi
callq 0xd8380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rsi
callq 0xdfaf0
jmp 0x10f2f9
movq 0x8(%rsp), %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xc8(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x10f32a
movq (%rsp), %rdi
movl $0x28, %esi
callq 0xd8620
movq 0xc0(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x68, %esi
callq 0xd8620
movq 0xa8(%rsp), %rdi
callq 0xe0be0
nopw (%rax,%rax)