// File: /workspace/github_c_makefile_star2_O1/thegenemyers[P]DASCRUBBER/QV.c
// Function: Read_QVcoding
QVcoding *Read_QVcoding(FILE *input)
{ static QVcoding coding;

  // Read endian key, run chars, and short name common to all headers

  { uint16 half;
    int    len;

    if (fread(&half,sizeof(uint16),1,input) != 1)
      { EPRINTF(EPLACE,"Could not read flip byte (Read_QVcoding)\n");
        EXIT(NULL);
      }
    coding.flip = (half != 0x33cc);

    if (fread(&half,sizeof(uint16),1,input) != 1)
      { EPRINTF(EPLACE,"Could not read deletion char (Read_QVcoding)\n");
        EXIT(NULL);
      }
    if (coding.flip)
      Flip_Short(&half);
    coding.delChar = half;
    if (coding.delChar >= 256)
      coding.delChar = -1;

    if (fread(&half,sizeof(uint16),1,input) != 1)
      { EPRINTF(EPLACE,"Could not read substitution char (Read_QVcoding)\n");
        EXIT(NULL);
      }
    if (coding.flip)
      Flip_Short(&half);
    coding.subChar = half;
    if (coding.subChar >= 256)
      coding.subChar = -1;

    //  Read the short name common to all headers

    if (fread(&len,sizeof(int),1,input) != 1)
      { EPRINTF(EPLACE,"Could not read header name length (Read_QVcoding)\n");
        EXIT(NULL);
      }
    if (coding.flip)
      Flip_Long(&len);
    coding.prefix = (char *) Malloc(len+1,"Allocating header prefix");
    if (coding.prefix == NULL)
      EXIT(NULL);
    if (len > 0)
      { if (fread(coding.prefix,len,1,input) != 1)
          { EPRINTF(EPLACE,"Could not read header name (Read_QVcoding)\n");
            EXIT(NULL);
          }
      }
    coding.prefix[len] = '\0';
  }

  //  Setup endian handling

  Set_Endian(coding.flip);

  //  Read the Huffman schemes used to compress the data

  coding.delScheme  = NULL;
  coding.dRunScheme = NULL;
  coding.insScheme  = NULL;
  coding.mrgScheme  = NULL;
  coding.subScheme  = NULL;
  coding.sRunScheme = NULL;

  coding.delScheme = Read_Scheme(input);
  if (coding.delScheme == NULL)
    goto error;
  if (coding.delChar >= 0)
    { coding.dRunScheme = Read_Scheme(input);
      if (coding.dRunScheme == NULL)
        goto error;
    }
  coding.insScheme = Read_Scheme(input);
  if (coding.insScheme == NULL)
    goto error;
  coding.mrgScheme = Read_Scheme(input);
  if (coding.mrgScheme == NULL)
    goto error;
  coding.subScheme = Read_Scheme(input);
  if (coding.subScheme == NULL)
    goto error;
  if (coding.subChar >= 0)
    { coding.sRunScheme = Read_Scheme(input);
      if (coding.sRunScheme == NULL)
        goto error;
    }

  return (&coding);

error:
  if (coding.delScheme != NULL)
    free(coding.delScheme);
  if (coding.dRunScheme != NULL)
    free(coding.dRunScheme);
  if (coding.insScheme != NULL)
    free(coding.insScheme);
  if (coding.mrgScheme != NULL)
    free(coding.mrgScheme);
  if (coding.subScheme != NULL)
    free(coding.subScheme);
  if (coding.sRunScheme != NULL)
    free(coding.sRunScheme);
  EXIT(NULL);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x2(%rsp), %rdi
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x8ae6
xorl %eax, %eax
leaq 0x2(%rsp), %rdi
cmpw $0x33cc, (%rdi)         # imm = 0x33CC
setne %al
movl %eax, 0xd13e(%rip)      # 0x159d0
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x8aeb
cmpl $0x0, 0xd11b(%rip)      # 0x159d0
je 0x88bd
rolw $0x8, 0x2(%rsp)
leaq 0x2(%rsp), %rdi
movzwl (%rdi), %eax
cmpl $0x100, %eax            # imm = 0x100
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovbl %eax, %ecx
movl %ecx, 0xd0f0(%rip)      # 0x159c8
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x8af0
cmpl $0x0, 0xd0d5(%rip)      # 0x159d0
je 0x8903
rolw $0x8, 0x2(%rsp)
movzwl 0x2(%rsp), %eax
cmpl $0x100, %eax            # imm = 0x100
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovbl %eax, %ecx
movl %ecx, 0xd0b1(%rip)      # 0x159cc
leaq 0x4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x8af5
cmpl $0x0, 0xd08d(%rip)      # 0x159d0
je 0x895b
movb 0x4(%rsp), %al
movb 0x7(%rsp), %cl
movb %cl, 0x4(%rsp)
movb %al, 0x7(%rsp)
rolw $0x8, 0x5(%rsp)
movslq 0x4(%rsp), %r14
leaq 0x1(%r14), %rdi
leaq 0x39df(%rip), %rsi      # 0xc34a
callq 0x2b85
movq %rax, 0xd061(%rip)      # 0x159d8
testq %rax, %rax
je 0x8adc
testl %r14d, %r14d
jle 0x89a2
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x8afa
movq 0xd02f(%rip), %rax      # 0x159d8
movb $0x0, (%rax,%r14)
movl 0xd01c(%rip), %eax      # 0x159d0
movl %eax, 0xd026(%rip)      # 0x159e0
movb $0x1, 0xd023(%rip)      # 0x159e4
xorps %xmm0, %xmm0
movups %xmm0, 0xcfcd(%rip)     # 0x15998
movups %xmm0, 0xcfd6(%rip)     # 0x159a8
movups %xmm0, 0xcfdf(%rip)     # 0x159b8
movq %rbx, %rdi
callq 0x8aff
movq %rax, 0xcfb0(%rip)      # 0x15998
testq %rax, %rax
je 0x8a76
cmpl $0x0, 0xcfd0(%rip)      # 0x159c8
js 0x8a0e
movq %rbx, %rdi
callq 0x8aff
movq %rax, 0xcfaf(%rip)      # 0x159b8
testq %rax, %rax
je 0x8a76
movq %rbx, %rdi
callq 0x8aff
movq %rax, 0xcf83(%rip)      # 0x159a0
testq %rax, %rax
je 0x8a76
movq %rbx, %rdi
callq 0x8aff
movq %rax, 0xcf77(%rip)      # 0x159a8
testq %rax, %rax
je 0x8a76
movq %rbx, %rdi
callq 0x8aff
movq %rax, 0xcf6b(%rip)      # 0x159b0
testq %rax, %rax
je 0x8a76
cmpl $0x0, 0xcf7b(%rip)      # 0x159cc
js 0x8a67
movq %rbx, %rdi
callq 0x8aff
movq %rax, 0xcf5e(%rip)      # 0x159c0
testq %rax, %rax
je 0x8a76
leaq 0xcf2a(%rip), %rax      # 0x15998
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0xcf1b(%rip), %rdi      # 0x15998
testq %rdi, %rdi
je 0x8a87
callq 0x1030
movq 0xcf2a(%rip), %rdi      # 0x159b8
testq %rdi, %rdi
je 0x8a98
callq 0x1030
movq 0xcf01(%rip), %rdi      # 0x159a0
testq %rdi, %rdi
je 0x8aa9
callq 0x1030
movq 0xcef8(%rip), %rdi      # 0x159a8
testq %rdi, %rdi
je 0x8aba
callq 0x1030
movq 0xceef(%rip), %rdi      # 0x159b0
testq %rdi, %rdi
je 0x8acb
callq 0x1030
movq 0xceee(%rip), %rdi      # 0x159c0
testq %rdi, %rdi
je 0x8adc
callq 0x1030
movl $0x1, %edi
callq 0x1270
callq 0x20ed
callq 0x2112
callq 0x2137
callq 0x215c
callq 0x2181