// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rcx
leaq -0xa(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xb21b
movq 0x6df8(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x3efb(%rip), %rsi      # 0xf105
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movzwl -0xa(%rbp), %eax
cmpl $0x33cc, %eax           # imm = 0x33CC
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0xc93e(%rip)      # 0x17b70
movq -0x8(%rbp), %rcx
leaq -0xa(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xb271
movq 0x6da2(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x3ecf(%rip), %rsi      # 0xf12f
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
cmpl $0x0, 0xc8f8(%rip)      # 0x17b70
je 0xb283
leaq -0xa(%rbp), %rdi
callq 0xb5a0
movzwl -0xa(%rbp), %eax
movl %eax, 0xc8db(%rip)      # 0x17b68
cmpl $0x100, 0xc8d1(%rip)    # imm = 0x100
jl 0xb2a3
movl $0xffffffff, 0xc8c5(%rip) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rcx
leaq -0xa(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xb2e2
movq 0x6d31(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x3e8c(%rip), %rsi      # 0xf15d
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
cmpl $0x0, 0xc887(%rip)      # 0x17b70
je 0xb2f4
leaq -0xa(%rbp), %rdi
callq 0xb5a0
movzwl -0xa(%rbp), %eax
movl %eax, 0xc86e(%rip)      # 0x17b6c
cmpl $0x100, 0xc864(%rip)    # imm = 0x100
jl 0xb314
movl $0xffffffff, 0xc858(%rip) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rcx
leaq -0x10(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xb353
movq 0x6cc0(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x3e4d(%rip), %rsi      # 0xf18f
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
cmpl $0x0, 0xc816(%rip)      # 0x17b70
je 0xb365
leaq -0x10(%rbp), %rdi
callq 0xb5e0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
leaq 0x3e4d(%rip), %rsi      # 0xf1c2
callq 0x22c0
movq %rax, 0xc7f7(%rip)      # 0x17b78
cmpq $0x0, 0xc7ef(%rip)      # 0x17b78
jne 0xb395
movl $0x1, %edi
callq 0x1260
cmpl $0x0, -0x10(%rbp)
jle 0xb3de
movq 0xc7d6(%rip), %rdi      # 0x17b78
movslq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rcx
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xb3dc
movq 0x6c37(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x3e10(%rip), %rsi      # 0xf1db
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
jmp 0xb3de
movq 0xc793(%rip), %rax      # 0x17b78
movslq -0x10(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl 0xc77d(%rip), %edi      # 0x17b70
callq 0xaf70
movq $0x0, 0xc735(%rip) # 0x17b38
movq $0x0, 0xc74a(%rip) # 0x17b58
movq $0x0, 0xc727(%rip) # 0x17b40
movq $0x0, 0xc724(%rip) # 0x17b48
movq $0x0, 0xc721(%rip) # 0x17b50
movq $0x0, 0xc726(%rip) # 0x17b60
movq -0x8(%rbp), %rdi
callq 0xb640
movq %rax, 0xc6ee(%rip)      # 0x17b38
cmpq $0x0, 0xc6e6(%rip)      # 0x17b38
jne 0xb459
jmp 0xb50b
cmpl $0x0, 0xc708(%rip)      # 0x17b68
jl 0xb483
movq -0x8(%rbp), %rdi
callq 0xb640
movq %rax, 0xc6e6(%rip)      # 0x17b58
cmpq $0x0, 0xc6de(%rip)      # 0x17b58
jne 0xb481
jmp 0xb50b
jmp 0xb483
movq -0x8(%rbp), %rdi
callq 0xb640
movq %rax, 0xc6ad(%rip)      # 0x17b40
cmpq $0x0, 0xc6a5(%rip)      # 0x17b40
jne 0xb49f
jmp 0xb50b
movq -0x8(%rbp), %rdi
callq 0xb640
movq %rax, 0xc699(%rip)      # 0x17b48
cmpq $0x0, 0xc691(%rip)      # 0x17b48
jne 0xb4bb
jmp 0xb50b
movq -0x8(%rbp), %rdi
callq 0xb640
movq %rax, 0xc685(%rip)      # 0x17b50
cmpq $0x0, 0xc67d(%rip)      # 0x17b50
jne 0xb4d7
jmp 0xb50b
cmpl $0x0, 0xc68e(%rip)      # 0x17b6c
jl 0xb4fe
movq -0x8(%rbp), %rdi
callq 0xb640
movq %rax, 0xc670(%rip)      # 0x17b60
cmpq $0x0, 0xc668(%rip)      # 0x17b60
jne 0xb4fc
jmp 0xb50b
jmp 0xb4fe
leaq 0xc633(%rip), %rax      # 0x17b38
addq $0x10, %rsp
popq %rbp
retq
cmpq $0x0, 0xc625(%rip)      # 0x17b38
je 0xb521
movq 0xc61c(%rip), %rdi      # 0x17b38
callq 0x1030
cmpq $0x0, 0xc62f(%rip)      # 0x17b58
je 0xb537
movq 0xc626(%rip), %rdi      # 0x17b58
callq 0x1030
cmpq $0x0, 0xc601(%rip)      # 0x17b40
je 0xb54d
movq 0xc5f8(%rip), %rdi      # 0x17b40
callq 0x1030
cmpq $0x0, 0xc5f3(%rip)      # 0x17b48
je 0xb563
movq 0xc5ea(%rip), %rdi      # 0x17b48
callq 0x1030
cmpq $0x0, 0xc5e5(%rip)      # 0x17b50
je 0xb579
movq 0xc5dc(%rip), %rdi      # 0x17b50
callq 0x1030
cmpq $0x0, 0xc5df(%rip)      # 0x17b60
je 0xb58f
movq 0xc5d6(%rip), %rdi      # 0x17b60
callq 0x1030
movl $0x1, %edi
callq 0x1260
nopl (%rax)