// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/lzma/C/Lzma2Dec.c
// Function: Lzma2Dec_Parse
ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
    SizeT outSize,
    const Byte *src, SizeT *srcLen,
    int checkFinishBlock)
{
  SizeT inSize = *srcLen;
  *srcLen = 0;

  while (p->state != LZMA2_STATE_ERROR)
  {
    if (p->state == LZMA2_STATE_FINISHED)
      return (ELzma2ParseStatus)LZMA_STATUS_FINISHED_WITH_MARK;

    if (outSize == 0 && !checkFinishBlock)
      return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
    
    if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)
    {
      if (*srcLen == inSize)
        return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
      (*srcLen)++;

      p->state = Lzma2Dec_UpdateState(p, *src++);

      if (p->state == LZMA2_STATE_UNPACK0)
      {
        // if (p->decoder.dicPos != 0)
        if (p->control == LZMA2_CONTROL_COPY_RESET_DIC || p->control >= 0xE0)
          return LZMA2_PARSE_STATUS_NEW_BLOCK;
        // if (outSize == 0) return LZMA_STATUS_NOT_FINISHED;
      }

      // The following code can be commented.
      // It's not big problem, if we read additional input bytes.
      // It will be stopped later in LZMA2_STATE_DATA / LZMA2_STATE_DATA_CONT state.

      if (outSize == 0 && p->state != LZMA2_STATE_FINISHED)
      {
        // checkFinishBlock is true. So we expect that block must be finished,
        // We can return LZMA_STATUS_NOT_SPECIFIED or LZMA_STATUS_NOT_FINISHED here
        // break;
        return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
      }

      if (p->state == LZMA2_STATE_DATA)
        return LZMA2_PARSE_STATUS_NEW_CHUNK;

      continue;
    }

    if (outSize == 0)
      return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;

    {
      SizeT inCur = inSize - *srcLen;

      if (LZMA2_IS_UNCOMPRESSED_STATE(p))
      {
        if (inCur == 0)
          return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
        if (inCur > p->unpackSize)
          inCur = p->unpackSize;
        if (inCur > outSize)
          inCur = outSize;
        p->decoder.dicPos += inCur;
        src += inCur;
        *srcLen += inCur;
        outSize -= inCur;
        p->unpackSize -= (UInt32)inCur;
        p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
      }
      else
      {
        p->isExtraMode = True;

        if (inCur == 0)
        {
          if (p->packSize != 0)
            return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
        }
        else if (p->state == LZMA2_STATE_DATA)
        {
          p->state = LZMA2_STATE_DATA_CONT;
          if (*src != 0)
          {
            // first byte of lzma chunk must be Zero
            *srcLen += 1;
            p->packSize--;
            break;
          }
        }
  
        if (inCur > p->packSize)
          inCur = (SizeT)p->packSize;

        src += inCur;
        *srcLen += inCur;
        p->packSize -= (UInt32)inCur;

        if (p->packSize == 0)
        {
          SizeT rem = outSize;
          if (rem > p->unpackSize)
            rem = p->unpackSize;
          p->decoder.dicPos += rem;
          p->unpackSize -= (UInt32)rem;
          outSize -= rem;
          if (p->unpackSize == 0)
            p->state = LZMA2_STATE_CONTROL;
        }
      }
    }
  }
  
  p->state = LZMA2_STATE_ERROR;
  return (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rsi, %r12
movq (%rcx), %r13
andq $0x0, (%rcx)
movq %rdi, %r14
movl (%rdi), %eax
movl %r8d, 0x4(%rsp)
testl %r8d, %r8d
setne %cl
testq %r12, %r12
setne %bl
orb %cl, %bl
movq %rdx, %rbp
cmpl $0x8, %eax
je 0x4d70b
cmpl $0x9, %eax
je 0x4d73d
testb %bl, %bl
je 0x4d707
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
je 0x4d609
movq (%r15), %rax
cmpq %r13, %rax
je 0x4d70f
incq %rax
movq %rax, (%r15)
movzbl (%rbp), %esi
movq %r14, %rdi
callq 0x4d426
movl %eax, (%r14)
cmpl $0x1, %eax
jne 0x4d5ea
movb 0x4(%r14), %cl
cmpb $0x1, %cl
sete %dl
cmpb $-0x20, %cl
setae %cl
orb %dl, %cl
jne 0x4d725
testq %r12, %r12
jne 0x4d5f8
jmp 0x4d725
testq %r12, %r12
jne 0x4d5f8
cmpl $0x8, %eax
jne 0x4d707
incq %rbp
cmpl $0x6, %eax
jne 0x4d57e
jmp 0x4d713
testq %r12, %r12
je 0x4d707
movq (%r15), %rdi
movq %r13, %rsi
subq %rdi, %rsi
cmpb $0x0, 0x4(%r14)
jns 0x4d6bd
movb $0x1, 0x6(%r14)
movq %r13, %rcx
subq %rdi, %rcx
jne 0x4d642
xorl %r8d, %r8d
cmpl $0x0, 0x8(%r14)
je 0x4d665
jmp 0x4d70f
cmpl $0x6, %eax
je 0x4d64d
movl 0x8(%r14), %r8d
jmp 0x4d662
movl $0x7, (%r14)
cmpb $0x0, (%rbp)
movl 0x8(%r14), %r8d
jne 0x4d730
pushq $0x7
popq %rax
movl %r8d, %r9d
cmpq %r9, %rsi
cmovaeq %r9, %rsi
leaq (%rsi,%rbp), %rdx
addq %rsi, %rdi
movq %rdi, (%r15)
subl %esi, %r8d
movl %r8d, 0x8(%r14)
jne 0x4d57b
movl 0xc(%r14), %esi
cmpq %rsi, %r12
movq %rsi, %rdi
cmovbq %r12, %rdi
addq %rdi, 0x38(%r14)
subq %rdi, %r12
cmpq %r9, %rcx
cmovbq %rcx, %r9
addq %r9, %rbp
xorl %ecx, %ecx
movq %rbp, %rdx
subl %edi, %esi
movl %esi, 0xc(%r14)
movl 0x4(%rsp), %r8d
jne 0x4d56d
jmp 0x4d6fa
cmpq %rdi, %r13
je 0x4d70f
movl 0xc(%r14), %eax
cmpq %rax, %rsi
movq %rax, %rcx
cmovbq %rsi, %rcx
cmpq %r12, %rcx
cmovaeq %r12, %rcx
addq %rcx, 0x38(%r14)
addq %rcx, (%r15)
addq %rcx, %rbp
subq %rcx, %r12
subl %ecx, %eax
movl %eax, 0xc(%r14)
pushq $0x7
popq %rcx
movl $0x0, %eax
cmovel %eax, %ecx
movl 0x4(%rsp), %r8d
movl %ecx, (%r14)
movl %ecx, %eax
movq %rbp, %rdx
jmp 0x4d56d
pushq $0x2
jmp 0x4d715
pushq $0x1
jmp 0x4d715
pushq $0x3
jmp 0x4d715
pushq $0x6
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %cl, %eax
leal (%rax,%rax,2), %eax
addl $0x2, %eax
jmp 0x4d716
incq %rdi
movq %rdi, (%r15)
decl %r8d
movl %r8d, 0x8(%r14)
movl $0x9, (%r14)
xorl %eax, %eax
jmp 0x4d716