// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl $0x40804, %edi          # imm = 0x40804
leaq 0x3be8(%rip), %rsi      # 0xf240
callq 0x22c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xb675
movq $0x0, -0x8(%rbp)
jmp 0xb8b5
movq -0x18(%rbp), %rax
addq $0x404, %rax            # imm = 0x404
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq $0x804, %rax            # imm = 0x804
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rcx
leaq -0x41(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x10a0
cmpq $0x1, %rax
je 0xb6e6
movq 0x6939(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x3b98(%rip), %rsi      # 0xf261
movb $0x0, %al
callq 0x1180
movq -0x18(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
jmp 0xb8b5
movzbl -0x41(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x38(%rbp)
cmpl $0x100, -0x38(%rbp)     # imm = 0x100
jge 0xb7d9
movq -0x10(%rbp), %rcx
leaq -0x41(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x10a0
cmpq $0x1, %rax
je 0xb747
movq 0x68d2(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x3b5d(%rip), %rsi      # 0xf290
movb $0x0, %al
callq 0x1180
movq $0x0, -0x8(%rbp)
jmp 0xb8b5
movzbl -0x41(%rbp), %edx
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movzbl -0x41(%rbp), %eax
cmpl $0x0, %eax
jle 0xb7ba
movq -0x30(%rbp), %rdi
movslq -0x38(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xb7b8
movq 0x686a(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x3b28(%rip), %rsi      # 0xf2c3
movb $0x0, %al
callq 0x1180
movq -0x18(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
jmp 0xb8b5
jmp 0xb7c9
movq -0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0xb7cb
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xb6f7
cmpl $0x0, 0xc3a0(%rip)      # 0x17b80
je 0xb813
movl $0x0, -0x38(%rbp)
cmpl $0x100, -0x38(%rbp)     # imm = 0x100
jge 0xb811
movq -0x30(%rbp), %rdi
movslq -0x38(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0xb5e0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xb7e9
jmp 0xb813
movl $0x0, -0x38(%rbp)
cmpl $0x100, -0x38(%rbp)     # imm = 0x100
jge 0xb8ad
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0xb89d
movq -0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rdx
movslq -0x38(%rbp), %rsi
movl $0x10, %ecx
subl (%rdx,%rsi,4), %ecx
shll %cl, %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rdx
movl $0x10, %ecx
subl (%rax,%rdx,4), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0xb89b
movl -0x38(%rbp), %edx
movq -0x20(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xb876
jmp 0xb89d
jmp 0xb89f
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xb81a
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop