// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: ConsistencyChecker::checkVarnodeTruncation(Constructor*, int, OpTpl*, VarnodeTpl*, bool)
bool ConsistencyChecker::checkVarnodeTruncation(Constructor *ct,int4 slot,
						OpTpl *op,VarnodeTpl *vn,bool isbigendian)
{
  const ConstTpl &off( vn->getOffset() );
  if (off.getType() != ConstTpl::handle) return true;
  if (off.getSelect() != ConstTpl::v_offset_plus) return true;
  ConstTpl::const_type sztype = vn->getSize().getType();
  if ((sztype != ConstTpl::real)&&(sztype != ConstTpl::handle)) {
    printOpError(op,ct,slot,slot,"Bad truncation expression");
    return false;
  }
  int4 sz = recoverSize(off,ct); // Recover the size of the original operand
  if (sz <= 0) {
    printOpError(op,ct,slot,slot,"Could not recover size");
    return false;
  }
  bool res = vn->adjustTruncation(sz,isbigendian);
  if (!res) {
    printOpError(op,ct,slot,slot,"Truncation operator out of bounds");
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movb %r9b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3fca0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x3fc10
cmpl $0x1, %eax
je 0x5e135
movb $0x1, -0x1(%rbp)
jmp 0x5e43b
movq -0x40(%rbp), %rdi
callq 0x4e250
cmpl $0x3, %eax
je 0x5e14c
movb $0x1, -0x1(%rbp)
jmp 0x5e43b
movq -0x30(%rbp), %rdi
callq 0x3fbf0
movq %rax, %rdi
callq 0x3fc10
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x5e23b
cmpl $0x1, -0x44(%rbp)
je 0x5e23b
movq -0x28(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x118c0
movq -0xe0(%rbp), %rdx
leaq 0x7af88(%rip), %rsi     # 0xd913f
leaq -0x68(%rbp), %rdi
callq 0x14430
jmp 0x5e1c2
movl -0xe8(%rbp), %r8d
movl -0xe4(%rbp), %ecx
movq -0xf0(%rbp), %rdx
movq -0xf8(%rbp), %rsi
movq -0xd8(%rbp), %rdi
leaq -0x68(%rbp), %r9
callq 0x5dcc0
jmp 0x5e1ef
leaq -0x68(%rbp), %rdi
callq 0x11300
leaq -0x69(%rbp), %rdi
callq 0x114d0
movb $0x0, -0x1(%rbp)
jmp 0x5e43b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5e22d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x11300
leaq -0x69(%rbp), %rdi
callq 0x114d0
jmp 0x5e449
movq -0xd8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x5ac50
movl %eax, -0x80(%rbp)
cmpl $0x0, -0x80(%rbp)
jg 0x5e338
movq -0x28(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x108(%rbp)
movl %eax, -0x104(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x118c0
movq -0x100(%rbp), %rdx
leaq 0x7aeb7(%rip), %rsi     # 0xd9159
leaq -0xa0(%rbp), %rdi
callq 0x14430
jmp 0x5e2b0
movl -0x108(%rbp), %r8d
movl -0x104(%rbp), %ecx
movq -0x110(%rbp), %rdx
movq -0x118(%rbp), %rsi
movq -0xd8(%rbp), %rdi
leaq -0xa0(%rbp), %r9
callq 0x5dcc0
jmp 0x5e2e0
leaq -0xa0(%rbp), %rdi
callq 0x11300
leaq -0xa1(%rbp), %rdi
callq 0x114d0
movb $0x0, -0x1(%rbp)
jmp 0x5e43b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5e327
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x11300
leaq -0xa1(%rbp), %rdi
callq 0x114d0
jmp 0x5e449
movq -0x30(%rbp), %rdi
movl -0x80(%rbp), %esi
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x4bd90
andb $0x1, %al
movb %al, -0xa2(%rbp)
testb $0x1, -0xa2(%rbp)
jne 0x5e437
movq -0x28(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x128(%rbp)
movl %eax, -0x124(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x118c0
movq -0x120(%rbp), %rdx
leaq 0x7adc9(%rip), %rsi     # 0xd9170
leaq -0xc8(%rbp), %rdi
callq 0x14430
jmp 0x5e3b5
movl -0x128(%rbp), %r8d
movl -0x124(%rbp), %ecx
movq -0x130(%rbp), %rdx
movq -0x138(%rbp), %rsi
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %r9
callq 0x5dcc0
jmp 0x5e3e5
leaq -0xc8(%rbp), %rdi
callq 0x11300
leaq -0xc9(%rbp), %rdi
callq 0x114d0
movb $0x0, -0x1(%rbp)
jmp 0x5e43b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5e429
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x11300
leaq -0xc9(%rbp), %rdi
callq 0x114d0
jmp 0x5e449
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x118b0
nopw %cs:(%rax,%rax)