// File: /workspace/github_cpp_makefile_star2_O3/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 0x15420
movq (%r13), %rdi
leaq 0x10(%r13), %rax
cmpq %rax, %rdi
je 0x2ff24
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 0x2ff7e
movl %eax, %ebp
shll $0x3, %ebp
cmpl %r15d, %ebp
seta %al
leal (%r14,%r15), %ecx
subl %ecx, %ebp
setae %cl
testb %cl, %al
jne 0x2ffc6
leaq 0x325d3(%rip), %rsi     # 0x62532
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x1170e
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x2d000
jmp 0x2ffa2
leaq 0x3258e(%rip), %rsi     # 0x62513
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x1170e
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x2d000
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x30066
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf380
jmp 0x30066
movl %r14d, %eax
orl %r15d, %eax
testb $0x7, %al
je 0x3000e
movl $0x40, %edi
callq 0xf370
movq %rax, %r13
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x20362
leaq 0x5ae2f(%rip), %rax     # 0x8ae20
movq %rax, (%r13)
movq %r12, 0x30(%r13)
movl %r15d, 0x38(%r13)
movl %r14d, 0x3c(%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2d7f2
jmp 0x30066
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 0x4a14c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2d7f2
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x30082
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 0x300ca
movq %rax, %rbx
movl $0x40, %esi
movq %r13, %rdi
jmp 0x300ca
jmp 0x300d3
jmp 0x300b1
jmp 0x300d3
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x300d6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf380
jmp 0x300d6
jmp 0x300d3
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x300f2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xf380
movq %rbx, %rdi
callq 0xf730