// File: /workspace/github_cpp_makefile_star2_O1/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 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rsi), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x154be
movq (%r13), %rdi
leaq 0x10(%r13), %rax
cmpq %rax, %rdi
je 0x301e2
movq (%rax), %rsi
incq %rsi
callq 0xf380
movl $0x20, %esi
movq %r13, %rdi
callq 0xf380
movq (%r12), %rax
movq %r12, %rdi
callq *0x48(%rax)
testl %r14d, %r14d
je 0x3023c
movl %eax, %ebp
shll $0x3, %ebp
cmpl %r15d, %ebp
seta %al
leal (%r14,%r15), %ecx
subl %ecx, %ebp
setae %cl
testb %cl, %al
jne 0x30284
leaq 0x322c5(%rip), %rsi     # 0x624e2
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x11754
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x2d276
jmp 0x30260
leaq 0x32280(%rip), %rsi     # 0x624c3
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x11754
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x2d276
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x30324
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf380
jmp 0x30324
movl %r14d, %eax
orl %r15d, %eax
testb $0x7, %al
je 0x302cc
movl $0x40, %edi
callq 0xf370
movq %rax, %r13
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x202ec
leaq 0x5ab19(%rip), %rax     # 0x8adc8
movq %rax, (%r13)
movq %r12, 0x30(%r13)
movl %r15d, 0x38(%r13)
movl %r14d, 0x3c(%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2da5a
jmp 0x30324
movq 0x38(%r12), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%r12), %r13
movb 0x120(%rbx), %r12b
movl $0x58, %edi
callq 0xf370
testb %r12b, %r12b
cmovnel %ebp, %r15d
shrl $0x3, %r14d
shrl $0x3, %r15d
addq %r15, %r13
leaq 0x20(%rsp), %rsi
movq %rax, %r15
movq %rax, %rdi
movq 0x40(%rsp), %rdx
movq %r13, %rcx
movl %r14d, %r8d
callq 0x4a540
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2da5a
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x30340
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xf380
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x58, %esi
movq %r15, %rdi
jmp 0x30388
movq %rax, %rbx
movl $0x40, %esi
movq %r13, %rdi
jmp 0x30388
jmp 0x30391
jmp 0x3036f
jmp 0x30391
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x30394
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf380
jmp 0x30394
jmp 0x30391
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x303b0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xf380
movq %rbx, %rdi
callq 0xf730