// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/targets.c
// Function: readsection
lword readsection(struct GlobalVars *gv,uint8_t rtype,uint8_t *p,
                  uint16_t bpos,uint16_t bsiz,lword mask)
/* Read data from section at 'p', using bit-offset 'bpos' and a field-size
   of 'bsiz' bits. The result is denormalized using the supplied mask.
   Complex RelocInsert scenarios are not supported, but this doesn't
   matter as those relocations have their addend information available
   anyway (ELF: .rela section) and don't need to read it from a section. */
{
  lword v = 0;
  int n;

  p += bpos >> 3;
  bpos &= 7;

  if (n = (bpos + bsiz + 7) >> 3) {
    if (gv->endianess == _LITTLE_ENDIAN_) {
      p += n;
      while (n--) {
        v <<= 8;
        v |= (lword)*(--p);
      }
      v >>= bpos;  /* normalize extracted bit-field */
    }
    else {  /* _BIG_ENDIAN_ or undefined */
      while (n--) {
        v <<= 8;
        v |= (lword)*p++;
      }
      v >>= (8 - ((bpos + bsiz) & 7)) & 7; /* normalize extracted bit-field */
    }
    v &= makemask(bsiz);

    /* mask and denormalize the read value using 'mask' */
    n = lshiftcnt(mask);
    mask >>= n;
    v &= mask;
    if (rtype==R_SD || rtype==R_SD2 || rtype==R_SD21)
      v <<= n;
    else
      v = sign_extend(v,(int)bsiz) << n;  /* sign-extend */
  }

  return v;
}

// Assembly:
subq $0x38, %rsp
movw %r8w, %ax
movq %rdi, 0x30(%rsp)
movb %sil, 0x2f(%rsp)
movq %rdx, 0x20(%rsp)
movw %cx, 0x1e(%rsp)
movw %ax, 0x1c(%rsp)
movq %r9, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movzwl 0x1e(%rsp), %ecx
sarl $0x3, %ecx
movq 0x20(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movzwl 0x1e(%rsp), %eax
andl $0x7, %eax
movw %ax, 0x1e(%rsp)
movzwl 0x1e(%rsp), %eax
movzwl 0x1c(%rsp), %ecx
addl %ecx, %eax
addl $0x7, %eax
sarl $0x3, %eax
movl %eax, 0x4(%rsp)
cmpl $0x0, %eax
je 0x110a8
movq 0x30(%rsp), %rax
movsbl 0x202(%rax), %eax
cmpl $0x0, %eax
jne 0x10f9f
movl 0x4(%rsp), %ecx
movq 0x20(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movl 0x4(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x0, %eax
je 0x10f89
movq 0x8(%rsp), %rax
shlq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, 0x20(%rsp)
movzbl -0x1(%rax), %eax
orq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x10f48
movzwl 0x1e(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, %ecx
sarq %cl, %rax
movq %rax, 0x8(%rsp)
jmp 0x11009
jmp 0x10fa1
movl 0x4(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x0, %eax
je 0x10fe1
movq 0x8(%rsp), %rax
shlq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rsp)
movzbl (%rax), %eax
orq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x10fa1
movzwl 0x1e(%rsp), %eax
movzwl 0x1c(%rsp), %ecx
addl %ecx, %eax
andl $0x7, %eax
movl $0x8, %ecx
subl %eax, %ecx
andl $0x7, %ecx
movq 0x8(%rsp), %rax
movl %ecx, %ecx
sarq %cl, %rax
movq %rax, 0x8(%rsp)
movzwl 0x1c(%rsp), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
andq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x88c0
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, %ecx
sarq %cl, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
andq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movzbl 0x2f(%rsp), %eax
cmpl $0xa, %eax
je 0x11076
movzbl 0x2f(%rsp), %eax
cmpl $0x20, %eax
je 0x11076
movzbl 0x2f(%rsp), %eax
cmpl $0x21, %eax
jne 0x1108b
movl 0x4(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, 0x8(%rsp)
jmp 0x110a6
movq 0x8(%rsp), %rdi
movzwl 0x1c(%rsp), %esi
callq 0x89f0
movl 0x4(%rsp), %ecx
shlq %cl, %rax
movq %rax, 0x8(%rsp)
jmp 0x110a8
movq 0x8(%rsp), %rax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)