// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/lzma/C/Lzma2Dec.c
// Function: Lzma2Dec_UpdateState
static unsigned Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
{
  switch (p->state)
  {
    case LZMA2_STATE_CONTROL:
      p->isExtraMode = False;
      p->control = b;
      PRF(printf("\n %8X", (unsigned)p->decoder.dicPos));
      PRF(printf(" %02X", (unsigned)b));
      if (b == 0)
        return LZMA2_STATE_FINISHED;
      if (LZMA2_IS_UNCOMPRESSED_STATE(p))
      {
        if (b == LZMA2_CONTROL_COPY_RESET_DIC)
          p->needInitLevel = 0xC0;
        else if (b > 2 || p->needInitLevel == 0xE0)
          return LZMA2_STATE_ERROR;
      }
      else
      {
        if (b < p->needInitLevel)
          return LZMA2_STATE_ERROR;
        p->needInitLevel = 0;
        p->unpackSize = (UInt32)(b & 0x1F) << 16;
      }
      return LZMA2_STATE_UNPACK0;
    
    case LZMA2_STATE_UNPACK0:
      p->unpackSize |= (UInt32)b << 8;
      return LZMA2_STATE_UNPACK1;
    
    case LZMA2_STATE_UNPACK1:
      p->unpackSize |= (UInt32)b;
      p->unpackSize++;
      PRF(printf(" %7u", (unsigned)p->unpackSize));
      return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
    
    case LZMA2_STATE_PACK0:
      p->packSize = (UInt32)b << 8;
      return LZMA2_STATE_PACK1;

    case LZMA2_STATE_PACK1:
      p->packSize |= (UInt32)b;
      p->packSize++;
      // if (p->packSize < 5) return LZMA2_STATE_ERROR;
      PRF(printf(" %5u", (unsigned)p->packSize));
      return (p->control & 0x40) ? LZMA2_STATE_PROP : LZMA2_STATE_DATA;

    case LZMA2_STATE_PROP:
    {
      unsigned lc, lp;
      if (b >= (9 * 5 * 5))
        return LZMA2_STATE_ERROR;
      lc = b % 9;
      b /= 9;
      p->decoder.prop.pb = (Byte)(b / 5);
      lp = b % 5;
      if (lc + lp > LZMA2_LCLP_MAX)
        return LZMA2_STATE_ERROR;
      p->decoder.prop.lc = (Byte)lc;
      p->decoder.prop.lp = (Byte)lp;
      return LZMA2_STATE_DATA;
    }
    
    default:
      return LZMA2_STATE_ERROR;
  }
}

// Assembly:
movl (%rdi), %ecx
movl $0x9, %eax
cmpq $0x5, %rcx
ja 0x57f5a
leaq 0x103cd(%rip), %rdx     # 0x6821c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movb $0x0, 0x6(%rdi)
movb %sil, 0x4(%rdi)
testb %sil, %sil
je 0x57f2f
js 0x57f35
cmpb $0x1, %sil
jne 0x57f4e
movb $-0x40, 0x5(%rdi)
jmp 0x57f5b
movzbl %sil, %eax
orl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
movb 0x4(%rdi), %cl
andb $0x40, %cl
xorl %eax, %eax
cmpb $0x1, %cl
adcl $0x5, %eax
retq
movzbl %sil, %eax
orl 0xc(%rdi), %eax
incl %eax
movl %eax, 0xc(%rdi)
xorl %eax, %eax
cmpb $0x0, 0x4(%rdi)
setns %al
leal (%rax,%rax,2), %eax
addl $0x3, %eax
retq
movzbl %sil, %eax
shll $0x8, %eax
movl %eax, 0x8(%rdi)
movl $0x4, %eax
retq
movzbl %sil, %eax
shll $0x8, %eax
orl %eax, 0xc(%rdi)
movl $0x2, %eax
retq
cmpb $-0x20, %sil
ja 0x57f5a
pushq %rbx
movzbl %sil, %r8d
imull $0x39, %r8d, %ecx
shrl $0x9, %ecx
leal (%rcx,%rcx,8), %r9d
movl %esi, %edx
subb %r9b, %dl
imull $0x6d, %r8d, %r8d
shrl $0x8, %r8d
subb %r8b, %sil
shrb %sil
addb %r8b, %sil
shrb $0x5, %sil
movb %sil, 0x12(%rdi)
imull $0x34, %ecx, %ebx
movzbl %bh, %esi
leal (%rsi,%rsi,4), %esi
subb %sil, %cl
leal (%rcx,%rdx), %esi
cmpb $0x4, %sil
popq %rbx
ja 0x57f5a
movb %dl, 0x10(%rdi)
movb %cl, 0x11(%rdi)
movl $0x6, %eax
retq
movl $0x8, %eax
retq
cmpb %sil, 0x5(%rdi)
ja 0x57f5a
movzbl %sil, %eax
movb $0x0, 0x5(%rdi)
andl $0x1f, %eax
shll $0x10, %eax
movl %eax, 0xc(%rdi)
jmp 0x57f5b
cmpb $0x2, %sil
ja 0x57f5a
cmpb $-0x20, 0x5(%rdi)
jne 0x57f5b
retq
movl $0x1, %eax
retq