// File: jstaursky[P]hutch/src/Sleigh/pcodecompile.cc
// Function: PcodeCompile::createStore(StarQuality*, ExprTree*, ExprTree*)
vector<OpTpl *> *PcodeCompile::createStore(StarQuality *qual,
					      ExprTree *ptr,ExprTree *val)
{
  vector<OpTpl *> *res = ptr->ops;
  ptr->ops = (vector<OpTpl *> *)0;
  res->insert(res->end(),val->ops->begin(),val->ops->end());
  val->ops->clear();
  OpTpl *op = new OpTpl(CPUI_STORE);
  // The first varnode input to the store 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->addInput(val->outvn);
  res->push_back(op);
  force_size(val->outvn,ConstTpl(ConstTpl::real,qual->size),*res);
  ptr->outvn = (VarnodeTpl *)0;
  val->outvn = (VarnodeTpl *)0;
  delete ptr;
  delete val;
  delete qual;
  return res;
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq %rcx, 0xf8(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0x100(%rsp), %rax
movq $0x0, (%rax)
movq 0xf0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xdcb70
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0xd90f0
movq 0xf8(%rsp), %rax
movq (%rax), %rdi
callq 0xd1660
movq %rax, 0xd8(%rsp)
movq 0xf8(%rsp), %rax
movq (%rax), %rdi
callq 0xdcb70
movq 0x38(%rsp), %rdi
movq %rax, 0xd0(%rsp)
movq 0xe8(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
callq 0xcf9f0
movq %rax, 0xc8(%rsp)
movq 0xf8(%rsp), %rax
movq (%rax), %rdi
callq 0xd9b80
movl $0x28, %edi
callq 0xd8380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x40(%rsp)
movl $0x3, %esi
callq 0xcf490
jmp 0x10f480
movq 0x40(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl $0x68, %edi
callq 0xd8380
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rsp)
movq 0x10(%rax), %rsi
leaq 0x88(%rsp), %rdi
callq 0xd69a0
jmp 0x10f4b7
movq 0x108(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0xd9880
jmp 0x10f4d7
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x68(%rsp), %rcx
callq 0xdf370
jmp 0x10f4f5
movq 0x28(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0xe1280
movq 0xc0(%rsp), %rdi
movq 0x100(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xe1280
movq 0xc0(%rsp), %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xe1280
movq 0xf0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xdc8a0
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x108(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, %edx
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0xd9880
movq 0x10(%rsp), %rdi
movq 0xf0(%rsp), %rdx
leaq 0x48(%rsp), %rsi
callq 0xcf5c0
movq 0x100(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0xf8(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x100(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x10f5eb
movq 0x18(%rsp), %rdi
callq 0xdb660
movq 0x18(%rsp), %rdi
movl $0x10, %esi
callq 0xd8620
movq 0xf8(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x10f617
movq 0x8(%rsp), %rdi
callq 0xdb660
movq 0x8(%rsp), %rdi
movl $0x10, %esi
callq 0xd8620
movq 0x108(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x10f637
movq (%rsp), %rdi
movl $0x28, %esi
callq 0xd8620
movq 0xf0(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
retq
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
movl $0x28, %esi
callq 0xd8620
jmp 0x10f68f
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
movl $0x68, %esi
callq 0xd8620
movq 0xb8(%rsp), %rdi
callq 0xe0be0
nopl (%rax)