// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x5, %eax
testb %dl, %cl
jne 0x322fa
movq %rsi, %r12
testq %rsi, %rsi
setne %cl
testq %r14, %r14
setne %dl
testb %dl, %cl
je 0x32309
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
movb $0x0, (%r15,%rax)
addq $0x18, %rax
cmpq $0x690, %rax            # imm = 0x690
jne 0x32328
cmpl $0x2, 0x58(%r15)
jl 0x3249f
cmpl $0x0, 0x908(%r15)
jne 0x3236f
movl $0x1, 0x908(%r15)
leaq 0x910(%r15), %rdi
callq 0x3b601
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r10
leaq 0x14e(%rip), %rax       # 0x324c4
movq %rax, 0x8(%rsp)
leaq 0x220(%rip), %rax       # 0x325a2
movq %rax, 0x10(%rsp)
movq %r12, 0x688(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x690(%r15)
testq %r12, %r12
jne 0x323b6
movq %r14, 0x690(%r15)
movq (%rbx), %rax
movq %rax, 0x698(%r15)
movq $0x0, (%rbx)
movq 0x50(%r15), %rcx
movq 0x80(%r15), %rax
movq %rax, 0x948(%r15)
movq %r11, 0x940(%r15)
movq %rbp, 0x928(%r15)
movq %r13, 0x930(%r15)
movq %r10, 0x938(%r15)
leaq 0x8(%rsp), %rax
movq %rax, 0x950(%r15)
movq %r15, 0x958(%r15)
movq %rcx, 0x910(%r15)
movq %rcx, %rax
shrq $0xa, %rax
leaq (%rcx,%rax), %rbp
addq $0x10, %rbp
movl $0x5, %eax
cmpq %rcx, %rbp
jb 0x322fa
leaq 0x910(%r15), %rax
movq %rax, (%rsp)
cmpq %rbp, 0x6a0(%r15)
je 0x3245b
xorl %r13d, %r13d
movq 0x3450(%r15,%r13,8), %rsi
testq %rsi, %rsi
je 0x32452
movq 0x78(%r15), %rdi
callq *0x8(%rdi)
movq $0x0, 0x3450(%r15,%r13,8)
incq %r13
cmpq $0x4c, %r13
jne 0x32432
movq %rbp, 0x6a0(%r15)
movl 0x5c(%r15), %eax
movl %eax, 0x918(%r15)
movq 0x68(%r15), %rax
movq %rax, 0x920(%r15)
movq (%rsp), %rdi
callq 0x3b76d
testq %r12, %r12
jne 0x322fa
addq $0x690, %r15            # imm = 0x690
movq (%r15), %rcx
subq %r14, %rcx
movq %rcx, (%rbx)
jmp 0x322fa
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
movq %rbp, %r9
pushq %r11
pushq $0x1
pushq %r10
pushq %r13
callq 0x3260e
addq $0x38, %rsp
jmp 0x322fe