// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: ConsistencyChecker::recoverSize(ConstTpl const&, Constructor*)
int4 ConsistencyChecker::recoverSize(const ConstTpl &sizeconst,Constructor *ct)

{
  int4 size,handindex;
  OperandSymbol *opsym;
  SubtableSymbol *tabsym;
  map<SubtableSymbol *,int4>::const_iterator iter;

  switch(sizeconst.getType()) {
  case ConstTpl::real:
    size = (int4) sizeconst.getReal();
    break;
  case ConstTpl::handle:
    handindex = sizeconst.getHandleIndex();
    opsym = ct->getOperand(handindex);
    size = opsym->getSize();
    if (size == -1) {
      tabsym = dynamic_cast<SubtableSymbol *>(opsym->getDefiningSymbol());
      if (tabsym == (SubtableSymbol *)0)
	throw SleighError("Could not recover varnode template size");
      iter = sizemap.find(tabsym);
      if (iter == sizemap.end())
	throw SleighError("Subtable out of order");
      size = (*iter).second;
    }
    break;
  default:
    throw SleighError("Bad constant type as varnode template size");
  }
  return size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6a510
movq -0x10(%rbp), %rdi
callq 0x3fc10
movl %eax, %ecx
movl %ecx, -0xe0(%rbp)
testl %eax, %eax
je 0x5aca2
jmp 0x5ac92
movl -0xe0(%rbp), %eax
subl $0x1, %eax
je 0x5acb3
jmp 0x5af50
movq -0x10(%rbp), %rdi
callq 0x3fc20
movl %eax, -0x1c(%rbp)
jmp 0x5b01a
movq -0x10(%rbp), %rdi
callq 0x402b0
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x179c0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x5af4b
movq -0x28(%rbp), %rdi
callq 0x52780
movq %rax, -0xf0(%rbp)
cmpq $0x0, %rax
je 0x5ad23
movq -0xf0(%rbp), %rdi
leaq 0xd4b1e(%rip), %rsi     # 0x12f828
leaq 0xd6977(%rip), %rdx     # 0x131688
xorl %eax, %eax
movl %eax, %ecx
callq 0x11530
movq %rax, -0xf8(%rbp)
jmp 0x5ad2e
xorl %eax, %eax
movq %rax, -0xf8(%rbp)
jmp 0x5ad2e
movq -0xf8(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5adfc
movb $0x1, -0x6d(%rbp)
movl $0x20, %edi
callq 0x11250
movq %rax, -0x108(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x118c0
movq -0x100(%rbp), %rdx
leaq 0x7dcdd(%rip), %rsi     # 0xd8a54
leaq -0x58(%rbp), %rdi
callq 0x14430
jmp 0x5ad82
movq -0x108(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3faa0
jmp 0x5ad94
movq -0x108(%rbp), %rdi
movb $0x0, -0x6d(%rbp)
leaq 0xd43aa(%rip), %rsi     # 0x12f150
leaq -0x1b2dd(%rip), %rdx    # 0x3fad0
callq 0x11860
jmp 0x5b02f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5adda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x11300
leaq -0x59(%rbp), %rdi
callq 0x114d0
testb $0x1, -0x6d(%rbp)
jne 0x5adeb
jmp 0x5adf7
movq -0x108(%rbp), %rdi
callq 0x11360
jmp 0x5b026
movq -0xe8(%rbp), %rdi
addq $0x30, %rdi
leaq -0x30(%rbp), %rsi
callq 0x6a530
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6a560
movq -0xe8(%rbp), %rdi
movq -0x78(%rbp), %rax
movq %rax, -0x38(%rbp)
addq $0x30, %rdi
callq 0x6a5b0
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x6a560
leaq -0x38(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x6a580
testb $0x1, %al
jne 0x5ae6c
jmp 0x5af3c
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x11250
movq %rax, -0x118(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x118c0
movq -0x110(%rbp), %rdx
leaq 0x7dbd7(%rip), %rsi     # 0xd8a7c
leaq -0xb0(%rbp), %rdi
callq 0x14430
jmp 0x5aeb3
movq -0x118(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3faa0
jmp 0x5aec8
movq -0x118(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0xd4273(%rip), %rsi     # 0x12f150
leaq -0x1b414(%rip), %rdx    # 0x3fad0
callq 0x11860
jmp 0x5b02f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5af14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x11300
leaq -0xb1(%rbp), %rdi
callq 0x114d0
testb $0x1, -0xb2(%rbp)
jne 0x5af2b
jmp 0x5af37
movq -0x118(%rbp), %rdi
callq 0x11360
jmp 0x5b026
leaq -0x38(%rbp), %rdi
callq 0x6a5e0
movl 0x8(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x5b01a
movb $0x1, -0xda(%rbp)
movl $0x20, %edi
callq 0x11250
movq %rax, -0x128(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x118c0
movq -0x120(%rbp), %rdx
leaq 0x7db09(%rip), %rsi     # 0xd8a92
leaq -0xd8(%rbp), %rdi
callq 0x14430
jmp 0x5af97
movq -0x128(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x3faa0
jmp 0x5afac
movq -0x128(%rbp), %rdi
movb $0x0, -0xda(%rbp)
leaq 0xd418f(%rip), %rsi     # 0x12f150
leaq -0x1b4f8(%rip), %rdx    # 0x3fad0
callq 0x11860
jmp 0x5b02f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5aff5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x11300
leaq -0xd9(%rbp), %rdi
callq 0x114d0
testb $0x1, -0xda(%rbp)
jne 0x5b00c
jmp 0x5b018
movq -0x128(%rbp), %rdi
callq 0x11360
jmp 0x5b026
movl -0x1c(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x118b0
nop