// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: SleighCompile::createMacroUse(MacroSymbol*, std::vector<ExprTree*, std::allocator<ExprTree*>>*)
vector<OpTpl *> *SleighCompile::createMacroUse(MacroSymbol *sym,vector<ExprTree *> *param)

{ // Create macro build directive, given symbol and parameters
  if (sym->getNumOperands() != param->size()) {
    string errmsg = "Invocation of macro \"" + sym->getName();
    if (param->size() > sym->getNumOperands())
      errmsg += "\" passes too many parameters";
    else
      errmsg += "\" passes too few parameters";
    reportError(errmsg,true);
    return new vector<OpTpl *>;
  }
  compareMacroParams(sym,*param);
  OpTpl *op = new OpTpl(MACROBUILD);
  VarnodeTpl *idvn = new VarnodeTpl(ConstTpl(getConstantSpace()),
				      ConstTpl(ConstTpl::real,sym->getIndex()),
				      ConstTpl(ConstTpl::real,4));
  op->addInput(idvn);
  return ExprTree::appendParams(op,param);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x6c5c0
cltq
movq %rax, -0xc8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3f860
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
je 0x66393
movq -0x18(%rbp), %rdi
callq 0x401a0
movq %rax, %rdx
leaq 0x73577(%rip), %rsi     # 0xd983a
leaq -0x40(%rbp), %rdi
callq 0x147f0
movq -0x20(%rbp), %rdi
callq 0x3f860
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x6c5c0
movl %eax, -0xd4(%rbp)
jmp 0x662ed
movq -0xe0(%rbp), %rax
movl -0xd4(%rbp), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jbe 0x66330
leaq 0x73547(%rip), %rsi     # 0xd9850
leaq -0x40(%rbp), %rdi
callq 0x11410
jmp 0x66314
jmp 0x66344
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11300
jmp 0x664e2
leaq 0x73536(%rip), %rsi     # 0xd986d
leaq -0x40(%rbp), %rdi
callq 0x11410
jmp 0x66342
jmp 0x66344
movq -0xd0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0x603b0
jmp 0x6635b
movl $0x18, %edi
callq 0x11440
movq %rax, -0xe8(%rbp)
jmp 0x6636e
movq -0xe8(%rbp), %rdi
callq 0x3f710
movq -0xe8(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11300
jmp 0x664d5
movq -0xd0(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x66140
movl $0x28, %edi
callq 0x11440
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movl $0x40, %esi
callq 0x3fbb0
jmp 0x663ca
movq -0xf0(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x68, %edi
callq 0x11440
movq -0xd0(%rbp), %rdi
movq %rax, -0x100(%rbp)
callq 0x48150
movq %rax, -0xf8(%rbp)
jmp 0x663fb
movq -0xf8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x49f90
jmp 0x6640d
movq -0x18(%rbp), %rdi
callq 0x6c5e0
movl %eax, -0x104(%rbp)
jmp 0x6641e
movl -0x104(%rbp), %eax
movslq %eax, %rdx
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
callq 0x49ef0
jmp 0x66437
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x49ef0
jmp 0x6644c
movq -0x100(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x4bac0
jmp 0x6646c
movq -0x100(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x3fa10
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x3ba90
movq %rax, -0x8(%rbp)
jmp 0x664d5
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x28, %esi
callq 0x11450
jmp 0x664e2
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x68, %esi
callq 0x11450
jmp 0x664e2
movq -0x8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x118b0
nopl (%rax,%rax)