// File: sisong[P]ApkDiffPatch/lzma/C/LzmaEnc.c
// Function: LzmaEnc_SetProps
Z7_NO_INLINE
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props2)
{
  // GET_CLzmaEnc_p
  CLzmaEncProps props = *props2;
  LzmaEncProps_Normalize(&props);

  if (props.lc > LZMA_LC_MAX
      || props.lp > LZMA_LP_MAX
      || props.pb > LZMA_PB_MAX)
    return SZ_ERROR_PARAM;


  if (props.dictSize > kLzmaMaxHistorySize)
    props.dictSize = kLzmaMaxHistorySize;

  #ifndef LZMA_LOG_BSR
  {
    const UInt64 dict64 = props.dictSize;
    if (dict64 > ((UInt64)1 << kDicLogSizeMaxCompress))
      return SZ_ERROR_PARAM;
  }
  #endif

  p->dictSize = props.dictSize;
  {
    unsigned fb = (unsigned)props.fb;
    if (fb < 5)
      fb = 5;
    if (fb > LZMA_MATCH_LEN_MAX)
      fb = LZMA_MATCH_LEN_MAX;
    p->numFastBytes = fb;
  }
  p->lc = (unsigned)props.lc;
  p->lp = (unsigned)props.lp;
  p->pb = (unsigned)props.pb;
  p->fastMode = (props.algo == 0);
  // p->_maxMode = True;
  MFB.btMode = (Byte)(props.btMode ? 1 : 0);
  // MFB.btMode = (Byte)(props.btMode);
  {
    unsigned numHashBytes = 4;
    if (props.btMode)
    {
           if (props.numHashBytes <  2) numHashBytes = 2;
      else if (props.numHashBytes <  4) numHashBytes = (unsigned)props.numHashBytes;
    }
    if (props.numHashBytes >= 5) numHashBytes = 5;

    MFB.numHashBytes = numHashBytes;
    // MFB.numHashBytes_Min = 2;
    MFB.numHashOutBits = (Byte)props.numHashOutBits;
  }

  MFB.cutValue = props.mc;

  p->writeEndMark = (BoolInt)props.writeEndMark;

  #ifndef Z7_ST
  /*
  if (newMultiThread != _multiThread)
  {
    ReleaseMatchFinder();
    _multiThread = newMultiThread;
  }
  */
  p->multiThread = (props.numThreads > 1);
  p->matchFinderMt.btSync.affinity =
  p->matchFinderMt.hashSync.affinity = props.affinity;
  #endif

  return SZ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x60(%rbp), %rdi
movl $0x48, %edx
callq 0x4320
leaq -0x60(%rbp), %rdi
callq 0x67180
cmpl $0x8, -0x58(%rbp)
jg 0x6782d
cmpl $0x4, -0x54(%rbp)
jg 0x6782d
cmpl $0x4, -0x50(%rbp)
jle 0x67839
movl $0x5, -0x4(%rbp)
jmp 0x679a5
cmpl $0xf0000000, -0x5c(%rbp) # imm = 0xF0000000
jbe 0x67849
movl $0xf0000000, -0x5c(%rbp) # imm = 0xF0000000
movl -0x5c(%rbp), %eax
movq %rax, -0x68(%rbp)
movabsq $0x200000000, %rax      # imm = 0x200000000
cmpq %rax, -0x68(%rbp)
jbe 0x6786c
movl $0x5, -0x4(%rbp)
jmp 0x679a5
movl -0x5c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xf4(%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x5, -0x6c(%rbp)
jae 0x6788c
movl $0x5, -0x6c(%rbp)
cmpl $0x111, -0x6c(%rbp)     # imm = 0x111
jbe 0x6789c
movl $0x111, -0x6c(%rbp)     # imm = 0x111
movl -0x6c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x48(%rax)
movl -0x58(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xbc(%rax)
movl -0x54(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc0(%rax)
movl -0x50(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc4(%rax)
cmpl $0x0, -0x4c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xcc(%rax)
movl -0x44(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x649(%rax)
movl $0x4, -0x70(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x6792b
cmpl $0x2, -0x40(%rbp)
jge 0x6791b
movl $0x2, -0x70(%rbp)
jmp 0x67929
cmpl $0x4, -0x40(%rbp)
jge 0x67927
movl -0x40(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x67929
jmp 0x6792b
cmpl $0x5, -0x40(%rbp)
jl 0x67938
movl $0x5, -0x70(%rbp)
movl -0x70(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x684(%rax)
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x699(%rax)
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x664(%rax)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xd0(%rax)
cmpl $0x1, -0x30(%rbp)
setg %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xd8(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x430(%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x168(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop