// File: /workspace/github_cpp_makefile_star2_O2/jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: SleighCompile::defineBitrange(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, VarnodeSymbol*, unsigned int, unsigned int)
void SleighCompile::defineBitrange(string *name,VarnodeSymbol *sym,uint4 bitoffset,uint4 numb)

{ // Define a new symbol as a subrange of bits within another symbol
  // If the ends of the range fall on byte boundaries, we
  // simply define a normal VarnodeSymbol, otherwise we create
  // a special symbol which is a place holder for the bitrange operator
  string namecopy = *name;
  delete name;
  uint4 size = 8*sym->getSize(); // Number of bits
  if (numb == 0) {
    reportError("Size of bitrange is zero for: "+namecopy,true);
    return;
  }
  if ((bitoffset >= size)||((bitoffset+numb)>size)) {
    reportError("Bad bitrange for: "+namecopy,true);
    return;
  }
  if ((bitoffset%8 == 0)&&(numb%8 == 0)) {
    // This can be reduced to an ordinary varnode definition
    AddrSpace *newspace = sym->getFixedVarnode().space;
    uintb newoffset = sym->getFixedVarnode().offset;
    int4 newsize = numb/8;
    if (isBigEndian())
      newoffset += (size-bitoffset-numb)/8;
    else
      newoffset += bitoffset/8;
    addSymbol( new VarnodeSymbol(namecopy,newspace,newoffset,newsize) );
  }
  else				// Otherwise define the special symbol
    addSymbol( new BitrangeSymbol(namecopy,sym,bitoffset,numb) );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %r14d
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x28(%rsp), %rdi
callq 0xf540
movq %r13, %rdi
callq 0xf1a0
pushq $0x20
popq %rsi
movq %r13, %rdi
callq 0xf380
movq (%r12), %rax
movq %r12, %rdi
callq *0x48(%rax)
testl %r14d, %r14d
je 0x2b6d5
movl %eax, %ebp
shll $0x3, %ebp
cmpl %r15d, %ebp
seta %al
leal (%r14,%r15), %ecx
subl %ecx, %ebp
setae %cl
testb %cl, %al
jne 0x2b70a
leaq 0x2be4e(%rip), %rsi     # 0x57502
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x10cd1
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x292f0
jmp 0x2b6fb
leaq 0x2be07(%rip), %rsi     # 0x574e3
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x10cd1
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x292f0
leaq 0x8(%rsp), %rdi
callq 0xf1a0
jmp 0x2b796
movl %r14d, %eax
orl %r15d, %eax
testb $0x7, %al
je 0x2b742
pushq $0x40
popq %rdi
callq 0xf370
movq %rax, %r13
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
movq %r12, %rdx
movl %r15d, %ecx
movl %r14d, %r8d
callq 0x2ed2c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x29992
jmp 0x2b796
movq 0x38(%r12), %rax
movq %rax, (%rsp)
movq 0x40(%r12), %r13
movb 0x120(%rbx), %r12b
pushq $0x58
popq %rdi
callq 0xf370
testb %r12b, %r12b
cmovnel %ebp, %r15d
shrl $0x3, %r14d
shrl $0x3, %r15d
addq %r15, %r13
leaq 0x28(%rsp), %rsi
movq %rax, %r15
movq %rax, %rdi
movq (%rsp), %rdx
movq %r13, %rcx
movl %r14d, %r8d
callq 0x422cc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x29992
leaq 0x28(%rsp), %rdi
callq 0xf1a0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x58
popq %rsi
movq %r15, %rdi
jmp 0x2b7c3
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r13, %rdi
callq 0xf380
jmp 0x2b7e4
jmp 0x2b7e1
jmp 0x2b7d0
jmp 0x2b7e1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xf1a0
jmp 0x2b7e4
jmp 0x2b7e1
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xf1a0
movq %rbx, %rdi
callq 0xf6e0