// File: sisong[P]ApkDiffPatch/lzma/C/Lzma2Enc.c
// Function: Lzma2Enc_Encode2
SRes Lzma2Enc_Encode2(CLzma2EncHandle p,
    ISeqOutStreamPtr outStream,
    Byte *outBuf, size_t *outBufSize,
    ISeqInStreamPtr inStream,
    const Byte *inData, size_t inDataSize,
    ICompressProgressPtr progress)
{
  // GET_CLzma2Enc_p

  if (inStream && inData)
    return SZ_ERROR_PARAM;

  if (outStream && outBuf)
    return SZ_ERROR_PARAM;

  {
    unsigned i;
    for (i = 0; i < MTCODER_THREADS_MAX; i++)
      p->coders[i].propsAreSet = False;
  }

  #ifndef Z7_ST
  
  if (p->props.numBlockThreads_Reduced > 1)
  {
    IMtCoderCallback2 vt;

    if (!p->mtCoder_WasConstructed)
    {
      p->mtCoder_WasConstructed = True;
      MtCoder_Construct(&p->mtCoder);
    }

    vt.Code = Lzma2Enc_MtCallback_Code;
    vt.Write = Lzma2Enc_MtCallback_Write;

    p->outStream = outStream;
    p->outBuf = NULL;
    p->outBuf_Rem = 0;
    if (!outStream)
    {
      p->outBuf = outBuf;
      p->outBuf_Rem = *outBufSize;
      *outBufSize = 0;
    }

    p->mtCoder.allocBig = p->allocBig;
    p->mtCoder.progress = progress;
    p->mtCoder.inStream = inStream;
    p->mtCoder.inData = inData;
    p->mtCoder.inDataSize = inDataSize;
    p->mtCoder.mtCallback = &vt;
    p->mtCoder.mtCallbackObject = p;

    p->mtCoder.blockSize = (size_t)p->props.blockSize;
    if (p->mtCoder.blockSize != p->props.blockSize)
      return SZ_ERROR_PARAM; /* SZ_ERROR_MEM */

    {
      const size_t destBlockSize = p->mtCoder.blockSize + (p->mtCoder.blockSize >> 10) + 16;
      if (destBlockSize < p->mtCoder.blockSize)
        return SZ_ERROR_PARAM;
      if (p->outBufSize != destBlockSize)
        Lzma2Enc_FreeOutBufs(p);
      p->outBufSize = destBlockSize;
    }

    p->mtCoder.numThreadsMax = (unsigned)p->props.numBlockThreads_Max;
    p->mtCoder.expectedDataSize = p->expectedDataSize;
    
    {
      const SRes res = MtCoder_Code(&p->mtCoder);
      if (!outStream)
        *outBufSize = (size_t)(p->outBuf - outBuf);
      return res;
    }
  }

  #endif


  return Lzma2Enc_EncodeMt1(p,
      &p->coders[0],
      outStream, outBuf, outBufSize,
      inStream, inData, inDataSize,
      True, /* finished */
      progress);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x65fe5
cmpq $0x0, -0x38(%rbp)
je 0x65fe5
movl $0x5, -0x4(%rbp)
jmp 0x66295
cmpq $0x0, -0x18(%rbp)
je 0x65fff
cmpq $0x0, -0x20(%rbp)
je 0x65fff
movl $0x5, -0x4(%rbp)
jmp 0x66295
movl $0x0, -0x3c(%rbp)
cmpl $0x40, -0x3c(%rbp)
jae 0x6602f
movq -0x10(%rbp), %rax
addq $0x88, %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x8(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x66006
movq -0x10(%rbp), %rax
cmpl $0x1, 0x58(%rax)
jle 0x6624c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x908(%rax)
jne 0x66068
movq -0x10(%rbp), %rax
movl $0x1, 0x908(%rax)
movq -0x10(%rbp), %rdi
addq $0x910, %rdi            # imm = 0x910
callq 0x784f0
leaq 0x241(%rip), %rax       # 0x662b0
movq %rax, -0x50(%rbp)
leaq 0x396(%rip), %rax       # 0x66410
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x688(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x690(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x698(%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x660de
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x690(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x698(%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x948(%rax)
movq 0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x940(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x928(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x930(%rax)
movq 0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x938(%rax)
movq -0x10(%rbp), %rax
leaq -0x50(%rbp), %rcx
movq %rcx, 0x950(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x958(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x910(%rax)
movq -0x10(%rbp), %rax
movq 0x910(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
je 0x66182
movl $0x5, -0x4(%rbp)
jmp 0x66295
movq -0x10(%rbp), %rax
movq 0x910(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x910(%rcx), %rcx
shrq $0xa, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x910(%rcx), %rax
jae 0x661c4
movl $0x5, -0x4(%rbp)
jmp 0x66295
movq -0x10(%rbp), %rax
movq 0x6a0(%rax), %rax
cmpq -0x58(%rbp), %rax
je 0x661de
movq -0x10(%rbp), %rdi
callq 0x65e10
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x6a0(%rax)
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x918(%rax)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x920(%rax)
movq -0x10(%rbp), %rdi
addq $0x910, %rdi            # imm = 0x910
callq 0x78720
movl %eax, -0x5c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x66244
movq -0x10(%rbp), %rax
movq 0x690(%rax), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x66295
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x88, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x38(%rbp), %r11
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x66510
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)