// File: /workspace/github_cpp_makefile_star2_O2/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), %eax
movl $0x9, %ecx
cmpq $0x5, %rax
ja 0x4d548
leaq 0xfeee(%rip), %rdx      # 0x5d32c
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movb $0x0, 0x6(%rdi)
movb %sil, 0x4(%rdi)
testb %sil, %sil
je 0x4d517
js 0x4d51e
cmpb $0x1, %sil
jne 0x4d537
movb $-0x40, 0x5(%rdi)
jmp 0x4d543
movzbl %sil, %eax
orl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
movb 0x4(%rdi), %al
andb $0x40, %al
xorl %ecx, %ecx
cmpb $0x1, %al
adcl $0x5, %ecx
jmp 0x4d548
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), %ecx
addl $0x3, %ecx
jmp 0x4d548
movzbl %sil, %eax
shll $0x8, %eax
movl %eax, 0x8(%rdi)
movl $0x4, %ecx
jmp 0x4d548
movzbl %sil, %eax
shll $0x8, %eax
orl %eax, 0xc(%rdi)
movl $0x2, %ecx
jmp 0x4d548
cmpb $-0x20, %sil
ja 0x4d548
pushq %rbx
movzbl %sil, %edx
movb $0x9, %sil
movl %edx, %eax
divb %sil
movl %eax, %esi
movzbl %ah, %ebx
movb $0x2d, %r8b
movl %edx, %eax
divb %r8b
movb %al, 0x12(%rdi)
movzbl %sil, %eax
movb $0x5, %dl
divb %dl
movzbl %ah, %eax
leal (%rax,%rbx), %edx
cmpb $0x4, %dl
ja 0x4d514
movb %bl, 0x10(%rdi)
movb %al, 0x11(%rdi)
movl $0x6, %ecx
popq %rbx
jmp 0x4d548
movl $0x8, %ecx
jmp 0x4d548
cmpb %sil, 0x5(%rdi)
ja 0x4d548
movzbl %sil, %eax
movb $0x0, 0x5(%rdi)
andl $0x1f, %eax
shll $0x10, %eax
movl %eax, 0xc(%rdi)
jmp 0x4d543
cmpb $0x2, %sil
ja 0x4d548
cmpb $-0x20, 0x5(%rdi)
je 0x4d548
movl $0x1, %ecx
movl %ecx, %eax
retq