// File: /workspace/github_c_makefile_star2_O1/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 0x38b4(%rip), %rsi      # 0xc3c8
movl $0x40804, %edi          # imm = 0x40804
callq 0x2b85
testq %rax, %rax
je 0x8c87
movq %rax, %rbx
leaq 0x7(%rsp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x8c3b
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 0x8c45
movzbl 0x7(%rsp), %eax
movl %eax, 0x400(%r13)
testl %eax, %eax
je 0x8bb3
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
je 0x8bbb
jmp 0x8c64
movl $0x0, (%r13)
incq %r15
addq $0x4, %r13
cmpq $0x100, %r15            # imm = 0x100
jne 0x8b64
cmpl $0x0, 0xce0e(%rip)      # 0x159e0
je 0x8bf7
xorl %eax, %eax
movb 0x4(%rbx,%rax,4), %cl
movb 0x7(%rbx,%rax,4), %dl
movb %dl, 0x4(%rbx,%rax,4)
movb %cl, 0x7(%rbx,%rax,4)
rolw $0x8, 0x5(%rbx,%rax,4)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x8bd6
xorl %eax, %eax
movl 0x404(%rbx,%rax,4), %esi
testl %esi, %esi
jle 0x8c2e
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 0x8c16
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x8bf9
jmp 0x8c89
movq %rbx, %rdi
callq 0x21a6
jmp 0x8c87
movq 0x73ac(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x37c2(%rip), %rsi      # 0xc418
xorl %ebx, %ebx
movl %r15d, %edx
xorl %eax, %eax
callq 0x11a0
jmp 0x8c89
movq 0x738d(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x37d6(%rip), %rsi      # 0xc44b
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