// File: /workspace/github_cpp_makefile_star2_O1/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 %ecx, %r14d
movl %edx, %ebp
movq %rdi, %r15
movl (%rsi), %r13d
movzwl (%rdi), %eax
movl %r13d, %r12d
shrl $0xb, %r12d
imull %eax, %r12d
cmpl $0x8, %edx
movq %rsi, (%rsp)
jb 0x37372
subl %r12d, %r13d
movl %r12d, %ecx
addq %rcx, 0x8(%rsi)
movl %eax, %ecx
shrl $0x5, %ecx
subl %ecx, %eax
movw %ax, (%r15)
cmpl $0xffffff, %r13d        # imm = 0xFFFFFF
ja 0x37306
shll $0x8, %r13d
movq %rsi, %rdi
callq 0x3721d
leaq 0x10(%r15), %rbx
movzwl 0x10(%r15), %eax
movl %r13d, %r12d
shrl $0xb, %r12d
imull %eax, %r12d
cmpl $0x10, %ebp
jb 0x37377
subl %r12d, %r13d
movl %r12d, %ecx
movq (%rsp), %rdi
addq %rcx, 0x8(%rdi)
movl %eax, %ecx
shrl $0x5, %ecx
subl %ecx, %eax
movw %ax, (%rbx)
cmpl $0xffffff, %r13d        # imm = 0xFFFFFF
ja 0x3734d
shll $0x8, %r13d
callq 0x3721d
movq (%rsp), %rdi
movl %r13d, (%rdi)
addq $0x200, %r15            # imm = 0x200
addl $-0x10, %ebp
movq %r15, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37192
movq %r15, %rbx
jmp 0x3737e
addl $-0x8, %ebp
movq (%rsp), %rsi
movl $0x800, %ecx            # imm = 0x800
subl %eax, %ecx
shrl $0x5, %ecx
addl %eax, %ecx
movw %cx, (%rbx)
cmpl $0xffffff, %r12d        # imm = 0xFFFFFF
ja 0x373a6
shll $0x8, %r12d
movq %rsi, %rdi
callq 0x3721d
movq (%rsp), %rsi
shll $0x4, %r14d
leaq (%rbx,%r14,2), %r14
movl %ebp, %r15d
shrl $0x2, %r15d
movzwl 0x2(%r14), %eax
movl %r12d, %r13d
shrl $0xb, %r13d
imull %eax, %r13d
movl %r15d, %ecx
negl %ecx
andl %ecx, %r12d
andl %r13d, %ecx
addq %rcx, 0x8(%rsi)
subl %ecx, %r12d
leal -0x1(%r15), %ecx
andl %ecx, %r13d
addl %r12d, %r13d
andl $0x7e1, %ecx            # imm = 0x7E1
subl %eax, %ecx
addl $0x1f, %ecx
shrl $0x5, %ecx
addl %eax, %ecx
movw %cx, 0x2(%r14)
cmpl $0xffffff, %r13d        # imm = 0xFFFFFF
ja 0x3740f
shll $0x8, %r13d
movq %rsi, %rdi
callq 0x3721d
movq (%rsp), %rsi
addl $0x2, %r15d
movl %ebp, %ebx
shrl %ebx
andl $0x1, %ebx
movzwl (%r14,%r15,2), %eax
movl %r13d, %r12d
shrl $0xb, %r12d
imull %eax, %r12d
movl %ebx, %ecx
negl %ecx
andl %ecx, %r13d
andl %r12d, %ecx
addq %rcx, 0x8(%rsi)
subl %ecx, %r13d
leal -0x1(%rbx), %ecx
andl %ecx, %r12d
addl %r13d, %r12d
andl $0x7e1, %ecx            # imm = 0x7E1
subl %eax, %ecx
addl $0x1f, %ecx
shrl $0x5, %ecx
addl %eax, %ecx
movw %cx, (%r14,%r15,2)
cmpl $0xffffff, %r12d        # imm = 0xFFFFFF
ja 0x37472
shll $0x8, %r12d
movq %rsi, %rdi
callq 0x3721d
movq (%rsp), %rsi
leal (%rbx,%r15,2), %eax
andl $0x1, %ebp
movzwl (%r14,%rax,2), %ecx
movl %r12d, %ebx
shrl $0xb, %ebx
imull %ecx, %ebx
movl %ebp, %edx
negl %edx
andl %edx, %r12d
andl %ebx, %edx
addq %rdx, 0x8(%rsi)
subl %edx, %r12d
decl %ebp
andl %ebp, %ebx
addl %r12d, %ebx
andl $0x7e1, %ebp            # imm = 0x7E1
subl %ecx, %ebp
addl $0x1f, %ebp
shrl $0x5, %ebp
addl %ecx, %ebp
movw %bp, (%r14,%rax,2)
cmpl $0xffffff, %ebx         # imm = 0xFFFFFF
ja 0x374ca
shll $0x8, %ebx
movq %rsi, %rdi
callq 0x3721d
movq (%rsp), %rsi
movl %ebx, (%rsi)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq