// File: /workspace/github_c_makefile_star2_O2/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 0x2a16(%rip), %rsi      # 0xa3c8
movl $0x40804, %edi          # imm = 0x40804
callq 0x1bad
testq %rax, %rax
je 0x7b2a
movq %rax, %rbx
leaq 0x7(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rdx, %rsi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x7aca
movq %rbx, %r12
addq $0x4, %r12
leaq 0x7(%rsp), %rax
movzbl (%rax), %eax
movl %eax, (%rbx)
xorl %r15d, %r15d
pushq $0x1
popq %r13
movq %r12, %rbp
cmpq $0x100, %r15            # imm = 0x100
je 0x7a5e
leaq 0x7(%rsp), %rdi
movq %r13, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x7ae8
movzbl 0x7(%rsp), %eax
movl %eax, 0x400(%rbp)
testl %eax, %eax
je 0x7a51
movq %rbp, %rdi
pushq $0x4
popq %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
je 0x7a55
jmp 0x7b07
andl $0x0, (%rbp)
incq %r15
addq $0x4, %rbp
jmp 0x7a00
cmpl $0x0, 0xbf7b(%rip)      # 0x139e0
je 0x7a82
xorl %r14d, %r14d
cmpq $0x400, %r14            # imm = 0x400
je 0x7a82
leaq (%r12,%r14), %rdi
callq 0x7983
addq $0x4, %r14
jmp 0x7a6a
xorl %eax, %eax
pushq $0x10
popq %rdx
cmpq $0x100, %rax            # imm = 0x100
je 0x7b2c
movl 0x404(%rbx,%rax,4), %edi
testl %edi, %edi
jle 0x7ac5
movl (%r12,%rax,4), %esi
movl %edx, %ecx
subl %edi, %ecx
shll %cl, %esi
xorl %edi, %edi
movl %edi, %r8d
shrl %cl, %r8d
testl %r8d, %r8d
jne 0x7ac5
leal (%rsi,%rdi), %r8d
movl %eax, 0x804(%rbx,%r8,4)
incl %edi
jmp 0x7aaa
incq %rax
jmp 0x7a87
movq 0x6527(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x290e(%rip), %rdi      # 0xa3e9
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1280
jmp 0x7b22
movq 0x6509(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x291f(%rip), %rsi      # 0xa418
xorl %ebx, %ebx
movl %r15d, %edx
xorl %eax, %eax
callq 0x11a0
jmp 0x7b2c
movq 0x64ea(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x2933(%rip), %rsi      # 0xa44b
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