// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/lzma/C/LzmaEnc.c
// Function: LenEnc_Encode
static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posState)
{
  UInt32 range, ttt, newBound;
  CLzmaProb *probs = p->low;
  range = rc->range;
  RC_BIT_PRE(rc, probs)
  if (sym >= kLenNumLowSymbols)
  {
    RC_BIT_1(rc, probs)
    probs += kLenNumLowSymbols;
    RC_BIT_PRE(rc, probs)
    if (sym >= kLenNumLowSymbols * 2)
    {
      RC_BIT_1(rc, probs)
      rc->range = range;
      // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - kLenNumLowSymbols * 2);
      LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2);
      return;
    }
    sym -= kLenNumLowSymbols;
  }

  // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBits, sym);
  {
    unsigned m;
    unsigned bit;
    RC_BIT_0(rc, probs)
    probs += (posState << (1 + kLenNumLowBits));
    bit = (sym >> 2)    ; RC_BIT(rc, probs + 1, bit)  m = (1 << 1) + bit;
    bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit)  m = (m << 1) + bit;
    bit =  sym       & 1; RC_BIT(rc, probs + m, bit)
    rc->range = range;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movl (%rsi), %r13d
movzwl (%rdi), %eax
movl %r13d, %r12d
shrl $0xb, %r12d
imull %eax, %r12d
cmpl $0x8, %edx
jb 0x2edc0
subl %r12d, %r13d
movl %r12d, %edx
addq %rdx, 0x8(%rbx)
movl %eax, %edx
shrl $0x5, %edx
subl %edx, %eax
movw %ax, (%r15)
cmpl $0xffffff, %r13d        # imm = 0xFFFFFF
ja 0x2ed55
shll $0x8, %r13d
movq %rbx, %rdi
movq %rcx, %r14
callq 0x2ec6a
movq %r14, %rcx
leaq 0x10(%r15), %r14
movzwl 0x10(%r15), %eax
movl %r13d, %r12d
shrl $0xb, %r12d
imull %eax, %r12d
cmpl $0x10, %ebp
jb 0x2edc5
subl %r12d, %r13d
movl %r12d, %ecx
addq %rcx, 0x8(%rbx)
movl %eax, %ecx
shrl $0x5, %ecx
subl %ecx, %eax
movw %ax, (%r14)
cmpl $0xffffff, %r13d        # imm = 0xFFFFFF
ja 0x2ed98
shll $0x8, %r13d
movq %rbx, %rdi
callq 0x2ec6a
movl %r13d, (%rbx)
addq $0x200, %r15            # imm = 0x200
addl $-0x10, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2ebdf
movq %r15, %r14
jmp 0x2edc8
addl $-0x8, %ebp
movl $0x800, %edx            # imm = 0x800
subl %eax, %edx
shrl $0x5, %edx
addl %eax, %edx
movw %dx, (%r14)
cmpl $0xffffff, %r12d        # imm = 0xFFFFFF
ja 0x2edf3
shll $0x8, %r12d
movq %rbx, %rdi
movq %rcx, %r15
callq 0x2ec6a
movq %r15, %rcx
shll $0x4, %ecx
leaq (%r14,%rcx,2), %rdi
movl %ebp, %r15d
shrl $0x2, %r15d
movzwl 0x2(%rdi), %ecx
movl %r12d, %r13d
shrl $0xb, %r13d
imull %ecx, %r13d
movl %r15d, %eax
negl %eax
andl %eax, %r12d
andl %r13d, %eax
subl %eax, %r12d
addq 0x8(%rbx), %rax
movq %rax, 0x8(%rbx)
leal -0x1(%r15), %edx
andl %edx, %r13d
addl %r12d, %r13d
andl $0x7e1, %edx            # imm = 0x7E1
subl %ecx, %edx
addl $0x1f, %edx
shrl $0x5, %edx
addl %ecx, %edx
movw %dx, 0x2(%rdi)
cmpl $0xffffff, %r13d        # imm = 0xFFFFFF
ja 0x2ee63
shll $0x8, %r13d
movq %rdi, %r14
movq %rbx, %rdi
callq 0x2ec6a
movq %r14, %rdi
movq 0x8(%rbx), %rax
addl $0x2, %r15d
movl %ebp, %r14d
shrl %r14d
andl $0x1, %r14d
movzwl (%rdi,%r15,2), %edx
movl %r13d, %r12d
shrl $0xb, %r12d
imull %edx, %r12d
movl %r14d, %ecx
negl %ecx
andl %ecx, %r13d
andl %r12d, %ecx
subl %ecx, %r13d
addq %rax, %rcx
movq %rcx, 0x8(%rbx)
leal -0x1(%r14), %eax
andl %eax, %r12d
addl %r13d, %r12d
andl $0x7e1, %eax            # imm = 0x7E1
subl %edx, %eax
addl $0x1f, %eax
shrl $0x5, %eax
addl %edx, %eax
movw %ax, (%rdi,%r15,2)
cmpl $0xffffff, %r12d        # imm = 0xFFFFFF
ja 0x2eed3
shll $0x8, %r12d
movq %rdi, %r13
movq %rbx, %rdi
callq 0x2ec6a
movq %r13, %rdi
movq 0x8(%rbx), %rcx
leal (%r14,%r15,2), %eax
andl $0x1, %ebp
movzwl (%rdi,%rax,2), %edx
movl %r12d, %r14d
shrl $0xb, %r14d
imull %edx, %r14d
movl %ebp, %esi
negl %esi
andl %esi, %r12d
andl %r14d, %esi
subl %esi, %r12d
addq %rcx, %rsi
movq %rsi, 0x8(%rbx)
decl %ebp
andl %ebp, %r14d
addl %r12d, %r14d
andl $0x7e1, %ebp            # imm = 0x7E1
subl %edx, %ebp
addl $0x1f, %ebp
shrl $0x5, %ebp
addl %edx, %ebp
movw %bp, (%rdi,%rax,2)
cmpl $0xffffff, %r14d        # imm = 0xFFFFFF
ja 0x2ef2e
shll $0x8, %r14d
movq %rbx, %rdi
callq 0x2ec6a
movl %r14d, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq