// File: /workspace/github_c_makefile_star2_O3/thegenemyers[P]DASCRUBBER/QV.c
// Function: Read_Scheme
static HScheme *Read_Scheme(FILE *in)
{ HScheme *scheme;
  int     *look, *lens;
  uint32  *bits, base;
  int      i, j, powr;
  uint8    x;

  scheme = (HScheme *) Malloc(sizeof(HScheme),"Allocating Huffman scheme record");
  if (scheme == NULL)
    return (NULL);

  lens = scheme->codelens;
  bits = scheme->codebits;
  look = scheme->lookup;

  if (fread(&x,1,1,in) != 1)
    { EPRINTF(EPLACE,"Could not read scheme type byte (Read_Scheme)\n");
      free(scheme);
      return (NULL);
    }
  scheme->type = x;
  for (i = 0; i < 256; i++)
    { if (fread(&x,1,1,in) != 1)
        { EPRINTF(EPLACE,"Could not read length of %d'th code (Read_Scheme)\n",i);
          return (NULL);
        }
      lens[i] = x;
      if (x > 0)
        { if (fread(bits+i,sizeof(uint32),1,in) != 1)
            { EPRINTF(EPLACE,"Could not read bit encoding of %d'th code (Read_Scheme)\n",i);
              free(scheme);
              return (NULL);
            }
        }
      else
        bits[i] = 0;
    }

  if (Flip)
    { for (i = 0; i < 256; i++)
        Flip_Long(bits+i);
    }

  for (i = 0; i < 256; i++)
    { if (lens[i] > 0)
        { base = (bits[i] << (16-lens[i]));
          powr = (1 << (16-lens[i]));
          for (j = 0; j < powr; j++)
            look[base+j] = i;
        }
    }

  return (scheme);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x3553(%rip), %rsi      # 0xc438
movl $0x40804, %edi          # imm = 0x40804
callq 0x2af5
testq %rax, %rax
je 0x905f
movq %rax, %rbx
leaq 0x7(%rsp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x9013
movq %rbx, %rbp
addq $0x4, %rbp
leaq 0x7(%rsp), %r12
movzbl (%r12), %eax
movl %eax, (%rbx)
xorl %r15d, %r15d
movq %rbp, %r13
movl $0x1, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x901d
movzbl 0x7(%rsp), %eax
movl %eax, 0x400(%r13)
testl %eax, %eax
je 0x8f84
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
je 0x8f8c
jmp 0x903c
movl $0x0, (%r13)
incq %r15
addq $0x4, %r13
cmpq $0x100, %r15            # imm = 0x100
jne 0x8f35
cmpl $0x0, 0xca3d(%rip)      # 0x159e0
je 0x8fcf
xorl %eax, %eax
pxor %xmm0, %xmm0
movd (%rbp,%rax,4), %xmm1
punpcklbw %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3],xmm1[4],xmm0[4],xmm1[5],xmm0[5],xmm1[6],xmm0[6],xmm1[7],xmm0[7]
pshuflw $0x1b, %xmm1, %xmm1     # xmm1 = xmm1[3,2,1,0,4,5,6,7]
packuswb %xmm1, %xmm1
movd %xmm1, (%rbp,%rax,4)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x8fab
xorl %eax, %eax
movl 0x404(%rbx,%rax,4), %esi
testl %esi, %esi
jle 0x9006
movl (%rbp,%rax,4), %edx
movl $0x10, %ecx
subl %esi, %ecx
shll %cl, %edx
movl $0x1, %esi
movl %edx, %edi
movl %esi, %r8d
shrl %cl, %r8d
movl %eax, 0x804(%rbx,%rdi,4)
incl %edx
incl %esi
testl %r8d, %r8d
je 0x8fee
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x8fd1
jmp 0x9061
movq %rbx, %rdi
callq 0x212e
jmp 0x905f
movq 0x6fd4(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x345a(%rip), %rsi      # 0xc488
xorl %ebx, %ebx
movl %r15d, %edx
xorl %eax, %eax
callq 0x11a0
jmp 0x9061
movq 0x6fb5(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x346e(%rip), %rsi      # 0xc4bb
movl %r15d, %edx
xorl %eax, %eax
callq 0x11a0
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq