// File: sisong[P]ApkDiffPatch/lzma/C/LzmaEnc.c
// Function: LzmaEncProps_Normalize
void LzmaEncProps_Normalize(CLzmaEncProps *p)
{
  int level = p->level;
  if (level < 0) level = 5;
  p->level = level;
  
  if (p->dictSize == 0)
    p->dictSize = (unsigned)level <= 4 ?
        (UInt32)1 << (level * 2 + 16) :
        (unsigned)level <= sizeof(size_t) / 2 + 4 ?
          (UInt32)1 << (level + 20) :
          (UInt32)1 << (sizeof(size_t) / 2 + 24);

  if (p->dictSize > p->reduceSize)
  {
    UInt32 v = (UInt32)p->reduceSize;
    const UInt32 kReduceMin = ((UInt32)1 << 12);
    if (v < kReduceMin)
      v = kReduceMin;
    if (p->dictSize > v)
      p->dictSize = v;
  }

  if (p->lc < 0) p->lc = 3;
  if (p->lp < 0) p->lp = 0;
  if (p->pb < 0) p->pb = 2;

  if (p->algo < 0) p->algo = (unsigned)level < 5 ? 0 : 1;
  if (p->fb < 0) p->fb = (unsigned)level < 7 ? 32 : 64;
  if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
  if (p->numHashBytes < 0) p->numHashBytes = (p->btMode ? 4 : 5);
  if (p->mc == 0) p->mc = (16 + ((unsigned)p->fb >> 1)) >> (p->btMode ? 0 : 1);
  
  if (p->numThreads < 0)
    p->numThreads =
      #ifndef Z7_ST
      ((p->btMode && p->algo) ? 2 : 1);
      #else
      1;
      #endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0x6719e
movl $0x5, -0xc(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x67200
cmpl $0x4, -0xc(%rbp)
ja 0x671cb
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x10, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x18(%rbp)
jmp 0x671f6
movl -0xc(%rbp), %eax
cmpq $0x8, %rax
ja 0x671e6
movl -0xc(%rbp), %ecx
addl $0x14, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x1c(%rbp)
jmp 0x671f0
movl $0x10000000, %eax       # imm = 0x10000000
movl %eax, -0x1c(%rbp)
jmp 0x671f0
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jbe 0x6724b
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movl %eax, -0x10(%rbp)
movl $0x1000, -0x14(%rbp)    # imm = 0x1000
cmpl $0x1000, -0x10(%rbp)    # imm = 0x1000
jae 0x67233
movl $0x1000, -0x10(%rbp)    # imm = 0x1000
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x10(%rbp), %eax
jbe 0x67249
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x6724b
movq -0x8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jge 0x67260
movq -0x8(%rbp), %rax
movl $0x3, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jge 0x67275
movq -0x8(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jge 0x6728a
movq -0x8(%rbp), %rax
movl $0x2, 0x10(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jge 0x672ab
movl -0xc(%rbp), %edx
movl $0x1, %ecx
xorl %eax, %eax
cmpl $0x5, %edx
cmovbl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jge 0x672cf
movl -0xc(%rbp), %edx
movl $0x40, %ecx
movl $0x20, %eax
cmpl $0x7, %edx
cmovbl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jge 0x672f4
movq -0x8(%rbp), %rax
movl 0x14(%rax), %edx
movl $0x1, %ecx
xorl %eax, %eax
cmpl $0x0, %edx
cmovel %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jge 0x6731c
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %edx
movl $0x5, %ecx
movl $0x4, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x67351
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
shrl %eax
addl $0x10, %eax
movq -0x8(%rbp), %rcx
movl 0x1c(%rcx), %esi
movl $0x1, %ecx
xorl %edx, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
shrl %cl, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jge 0x67392
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x1c(%rcx)
movb %al, -0x1d(%rbp)
je 0x67378
movq -0x8(%rbp), %rax
cmpl $0x0, 0x14(%rax)
setne %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %dl
movl $0x1, %ecx
movl $0x2, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x30(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)