// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
testq %r8, %r8
setne %cl
testq %r9, %r9
setne %dl
pushq $0x5
popq %rax
testb %dl, %cl
jne 0x2a5d5
movq %rsi, %r12
testq %rsi, %rsi
setne %cl
testq %r14, %r14
setne %dl
testb %dl, %cl
je 0x2a5e4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r9, %r13
movq %r8, %rbp
movq %rdi, %r15
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r10
leaq 0x88(%rdi), %rsi
movl $0x90, %eax
cmpq $0x690, %rax            # imm = 0x690
je 0x2a616
movb $0x0, (%r15,%rax)
addq $0x18, %rax
jmp 0x2a603
cmpl $0x2, 0x58(%r15)
jl 0x2a6f4
cmpl $0x0, 0x908(%r15)
jne 0x2a64c
movl $0x1, 0x908(%r15)
leaq 0x910(%r15), %rdi
callq 0x331c9
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r10
leaq 0x121(%rip), %rax       # 0x2a774
movq %rax, 0x8(%rsp)
leaq 0x1f1(%rip), %rax       # 0x2a850
movq %rax, 0x10(%rsp)
movq %r12, 0x688(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x690(%r15)
testq %r12, %r12
jne 0x2a690
movq %r14, 0x690(%r15)
movq (%rbx), %rax
movq %rax, 0x698(%r15)
andq $0x0, (%rbx)
movq 0x50(%r15), %rax
movq 0x80(%r15), %rcx
movq %rcx, 0x948(%r15)
movq %r11, 0x940(%r15)
movq %rbp, 0x928(%r15)
movq %r13, 0x930(%r15)
movq %r10, 0x938(%r15)
leaq 0x8(%rsp), %rcx
movq %rcx, 0x950(%r15)
movq %r15, 0x958(%r15)
movq %rax, 0x910(%r15)
movq %rax, %rcx
shrq $0xa, %rcx
leaq (%rax,%rcx), %rbp
addq $0x10, %rbp
cmpq %rax, %rbp
jae 0x2a719
pushq $0x5
popq %rax
jmp 0x2a5d5
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
movq %rbp, %r9
pushq %r11
pushq $0x1
pushq %r10
pushq %r13
callq 0x2a8bc
addq $0x38, %rsp
jmp 0x2a5d9
leaq 0x910(%r15), %r13
cmpq %rbp, 0x6a0(%r15)
je 0x2a731
movq %r15, %rdi
callq 0x2a4cb
movq %rbp, 0x6a0(%r15)
movl 0x5c(%r15), %eax
movl %eax, 0x918(%r15)
movq 0x68(%r15), %rax
movq %rax, 0x920(%r15)
movq %r13, %rdi
callq 0x33329
testq %r12, %r12
jne 0x2a5d5
addq $0x690, %r15            # imm = 0x690
movq (%r15), %rcx
subq %r14, %rcx
movq %rcx, (%rbx)
jmp 0x2a5d5