// File: sisong[P]ApkDiffPatch/lzma/C/Lzma2Dec.c
// Function: Lzma2Dec_DecodeToDic
SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
{
  SizeT inSize = *srcLen;
  *srcLen = 0;
  *status = LZMA_STATUS_NOT_SPECIFIED;

  while (p->state != LZMA2_STATE_ERROR)
  {
    SizeT dicPos;

    if (p->state == LZMA2_STATE_FINISHED)
    {
      *status = LZMA_STATUS_FINISHED_WITH_MARK;
      return SZ_OK;
    }
    
    dicPos = p->decoder.dicPos;
    
    if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY)
    {
      *status = LZMA_STATUS_NOT_FINISHED;
      return SZ_OK;
    }

    if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)
    {
      if (*srcLen == inSize)
      {
        *status = LZMA_STATUS_NEEDS_MORE_INPUT;
        return SZ_OK;
      }
      (*srcLen)++;
      p->state = Lzma2Dec_UpdateState(p, *src++);
      if (dicPos == dicLimit && p->state != LZMA2_STATE_FINISHED)
        break;
      continue;
    }
    
    {
      SizeT inCur = inSize - *srcLen;
      SizeT outCur = dicLimit - dicPos;
      ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY;
      
      if (outCur >= p->unpackSize)
      {
        outCur = (SizeT)p->unpackSize;
        curFinishMode = LZMA_FINISH_END;
      }

      if (LZMA2_IS_UNCOMPRESSED_STATE(p))
      {
        if (inCur == 0)
        {
          *status = LZMA_STATUS_NEEDS_MORE_INPUT;
          return SZ_OK;
        }

        if (p->state == LZMA2_STATE_DATA)
        {
          BoolInt initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC);
          LzmaDec_InitDicAndState(&p->decoder, initDic, False);
        }

        if (inCur > outCur)
          inCur = outCur;
        if (inCur == 0)
          break;

        LzmaDec_UpdateWithUncompressed(&p->decoder, src, inCur);

        src += inCur;
        *srcLen += inCur;
        p->unpackSize -= (UInt32)inCur;
        p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
      }
      else
      {
        SRes res;

        if (p->state == LZMA2_STATE_DATA)
        {
          BoolInt initDic = (p->control >= 0xE0);
          BoolInt initState = (p->control >= 0xA0);
          LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
          p->state = LZMA2_STATE_DATA_CONT;
        }
  
        if (inCur > p->packSize)
          inCur = (SizeT)p->packSize;
        
        res = LzmaDec_DecodeToDic(&p->decoder, dicPos + outCur, src, &inCur, curFinishMode, status);

        src += inCur;
        *srcLen += inCur;
        p->packSize -= (UInt32)inCur;
        outCur = p->decoder.dicPos - dicPos;
        p->unpackSize -= (UInt32)outCur;

        if (res != 0)
          break;
        
        if (*status == LZMA_STATUS_NEEDS_MORE_INPUT)
        {
          if (p->packSize == 0)
            break;
          return SZ_OK;
        }

        if (inCur == 0 && outCur == 0)
        {
          if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
              || p->unpackSize != 0
              || p->packSize != 0)
            break;
          p->state = LZMA2_STATE_CONTROL;
        }
        
        *status = LZMA_STATUS_NOT_SPECIFIED;
      }
    }
  }
  
  *status = LZMA_STATUS_NOT_SPECIFIED;
  p->state = LZMA2_STATE_ERROR;
  return SZ_ERROR_DATA;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x9, (%rax)
je 0xab56a
movq -0x10(%rbp), %rax
cmpl $0x8, (%rax)
jne 0xab23c
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xab585
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0xab26e
cmpl $0x0, -0x2c(%rbp)
jne 0xab26e
movq -0x38(%rbp), %rax
movl $0x2, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xab585
movq -0x10(%rbp), %rax
cmpl $0x6, (%rax)
je 0xab2f1
movq -0x10(%rbp), %rax
cmpl $0x7, (%rax)
je 0xab2f1
movq -0x28(%rbp), %rax
movq (%rax), %rax
cmpq -0x40(%rbp), %rax
jne 0xab2a3
movq -0x38(%rbp), %rax
movl $0x3, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xab585
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %esi
callq 0xab590
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0xab2ec
movq -0x10(%rbp), %rax
cmpl $0x8, (%rax)
je 0xab2ec
jmp 0xab56a
jmp 0xab210
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
subq (%rcx), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jb 0xab335
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x58(%rbp)
movl $0x1, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0xab417
cmpq $0x0, -0x50(%rbp)
jne 0xab368
movq -0x38(%rbp), %rax
movl $0x3, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xab585
movq -0x10(%rbp), %rax
cmpl $0x6, (%rax)
jne 0xab399
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
movl -0x60(%rbp), %esi
xorl %edx, %edx
callq 0xa5c50
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jbe 0xab3ab
movq -0x58(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xab3b7
jmp 0xab56a
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xab7d0
movq -0x50(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl $0x7, %ecx
xorl %eax, %eax
cmpl $0x0, %edx
cmovel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
jmp 0xab565
movq -0x10(%rbp), %rax
cmpl $0x6, (%rax)
jne 0xab46d
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0xe0, %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0xa0, %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
movl -0x68(%rbp), %esi
movl -0x6c(%rbp), %edx
callq 0xa5c50
movq -0x10(%rbp), %rax
movl $0x7, (%rax)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
cmpq %rcx, %rax
jbe 0xab488
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
movq -0x48(%rbp), %rsi
addq -0x58(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x5c(%rbp), %r8d
movq -0x38(%rbp), %r9
leaq -0x50(%rbp), %rcx
callq 0xa5ce0
movl %eax, -0x64(%rbp)
movq -0x50(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xc(%rax)
cmpl $0x0, -0x64(%rbp)
je 0xab506
jmp 0xab56a
movq -0x38(%rbp), %rax
cmpl $0x3, (%rax)
jne 0xab524
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xab51b
jmp 0xab56a
movl $0x0, -0x4(%rbp)
jmp 0xab585
cmpq $0x0, -0x50(%rbp)
jne 0xab55b
cmpq $0x0, -0x58(%rbp)
jne 0xab55b
movq -0x38(%rbp), %rax
cmpl $0x4, (%rax)
jne 0xab54f
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0xab54f
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0xab551
jmp 0xab56a
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
jmp 0xab210
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x9, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop