// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/QV.c
// Function: Decode
static int Decode(HScheme *scheme, FILE *in, char *read, int rlen)
{ int    *look, *lens;
  int     signal, ilen;
  uint64  icode;
  uint32 *ipart;
  uint16 *xpart;
  uint8  *cpart;
  int     j, n, c;

  if (LittleEndian)
    { ipart = ((uint32 *) (&icode));
      xpart = ((uint16 *) (&icode)) + 2;
      cpart = ((uint8  *) (&icode)) + 5;
    }
  else
    { ipart = ((uint32 *) (&icode)) + 1;
      xpart = ((uint16 *) (&icode)) + 1;
      cpart = ((uint8  *) (&icode)) + 2;
    }

  if (scheme->type == 2)
    signal  = 255;
  else
    signal  = 256;
  lens = scheme->codelens;
  look = scheme->lookup;

#define GET								\
  if (n > ilen)								\
    { icode <<= ilen;							\
      if (fread(ipart,sizeof(uint32),1,in) != 1)			\
        { EPRINTF(EPLACE,"Could not read more bits (Decode)\n");	\
          return (1);							\
        }								\
      ilen    = n-ilen;							\
      icode <<= ilen;							\
      ilen    = 32-ilen;						\
    }									\
  else									\
    { icode <<= n;							\
      ilen   -= n;							\
    }

#define GETFLIP								\
  if (n > ilen)								\
    { icode <<= ilen;							\
      if (fread(ipart,sizeof(uint32),1,in) != 1)			\
        { EPRINTF(EPLACE,"Could not read more bits (Decode)\n");	\
          return (1);							\
        }								\
      Flip_Long(ipart);							\
      ilen    = n-ilen;							\
      icode <<= ilen;							\
      ilen    = 32-ilen;						\
    }									\
  else									\
    { icode <<= n;							\
      ilen   -= n;							\
    }

  n     = 16;
  ilen  = 0;
  icode = 0;
  if (Flip)
    for (j = 0; j < rlen; j++)
      { GETFLIP
        c = look[*xpart];
        n = lens[c];
        if (c == signal)
          { GETFLIP
            c = *cpart;
            n = 8;
          }
        read[j] = (char) c;
      }
  else
    for (j = 0; j < rlen; j++)
      { GET
        c = look[*xpart];
        n = lens[c];
        if (c == signal)
          { GET
            c = *cpart;
            n = 8;
          }
        read[j] = (char) c;
      }

  return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpl $0x0, 0xb3d6(%rip)      # 0x17b84
je 0xc7d2
leaq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
leaq -0x48(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x60(%rbp)
jmp 0xc7f6
leaq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x58(%rbp)
leaq -0x48(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xc808
movl $0xff, -0x3c(%rbp)
jmp 0xc80f
movl $0x100, -0x3c(%rbp)     # imm = 0x100
movq -0x10(%rbp), %rax
addq $0x404, %rax            # imm = 0x404
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x804, %rax            # imm = 0x804
movq %rax, -0x30(%rbp)
movl $0x10, -0x68(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
cmpl $0x0, 0xb338(%rip)      # 0x17b80
je 0xca0e
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xca09
movl -0x68(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0xc8ed
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xc8be
movq 0x5757(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x2a51(%rip), %rsi      # 0xf2fc
movb $0x0, %al
callq 0x1180
movl $0x1, -0x4(%rbp)
jmp 0xcbb5
movq -0x50(%rbp), %rdi
callq 0xb5e0
movl -0x68(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl $0x20, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xc908
movl -0x68(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl -0x68(%rbp), %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rcx), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x6c(%rbp)
movq -0x38(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0xc9eb
movl -0x68(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0xc9bf
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xc990
movq 0x5685(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x297f(%rip), %rsi      # 0xf2fc
movb $0x0, %al
callq 0x1180
movl $0x1, -0x4(%rbp)
jmp 0xcbb5
movq -0x50(%rbp), %rdi
callq 0xb5e0
movl -0x68(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl $0x20, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xc9da
movl -0x68(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl -0x68(%rbp), %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x6c(%rbp)
movl $0x8, -0x68(%rbp)
movl -0x6c(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xc855
jmp 0xcbae
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xcbac
movl -0x68(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0xcaa0
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xca7a
movq 0x559b(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x2895(%rip), %rsi      # 0xf2fc
movb $0x0, %al
callq 0x1180
movl $0x1, -0x4(%rbp)
jmp 0xcbb5
movl -0x68(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl $0x20, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xcabb
movl -0x68(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl -0x68(%rbp), %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rcx), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x6c(%rbp)
movq -0x38(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0xcb8e
movl -0x68(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0xcb62
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0xcb3c
movq 0x54d6(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x27d0(%rip), %rsi      # 0xf2fc
movb $0x0, %al
callq 0x1180
movl $0x1, -0x4(%rbp)
jmp 0xcbb5
movl -0x68(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl $0x20, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xcb7d
movl -0x68(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movl -0x68(%rbp), %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x6c(%rbp)
movl $0x8, -0x68(%rbp)
movl -0x6c(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xca15
jmp 0xcbae
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop