// File: sisong[P]ApkDiffPatch/lzma/C/LzmaEnc.c
// Function: WriteEndMarker
static void WriteEndMarker(CLzmaEnc *p, unsigned posState)
{
  UInt32 range;
  range = p->rc.range;
  {
    UInt32 ttt, newBound;
    CLzmaProb *prob = &p->isMatch[p->state][posState];
    RC_BIT_PRE(&p->rc, prob)
    RC_BIT_1(&p->rc, prob)
    prob = &p->isRep[p->state];
    RC_BIT_PRE(&p->rc, prob)
    RC_BIT_0(&p->rc, prob)
  }
  p->state = kMatchNextStates[p->state];
  
  p->rc.range = range;
  LenEnc_Encode(&p->lenProbs, &p->rc, 0, posState);
  range = p->rc.range;

  {
    // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[0], (1 << kNumPosSlotBits) - 1);
    CLzmaProb *probs = p->posSlotEncoder[0];
    unsigned m = 1;
    do
    {
      UInt32 ttt, newBound;
      RC_BIT_PRE(p, probs + m)
      RC_BIT_1(&p->rc, probs + m)
      m = (m << 1) + 1;
    }
    while (m < (1 << kNumPosSlotBits));
  }
  {
    // RangeEnc_EncodeDirectBits(&p->rc, ((UInt32)1 << (30 - kNumAlignBits)) - 1, 30 - kNumAlignBits);    UInt32 range = p->range;
    unsigned numBits = 30 - kNumAlignBits;
    do
    {
      range >>= 1;
      p->rc.low += range;
      RC_NORM(&p->rc)
    }
    while (--numBits);
  }
   
  {
    // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
    CLzmaProb *probs = p->posAlignEncoder;
    unsigned m = 1;
    do
    {
      UInt32 ttt, newBound;
      RC_BIT_PRE(p, probs + m)
      RC_BIT_1(&p->rc, probs + m)
      m = (m << 1) + 1;
    }
    while (m < kAlignTableSize);
  }
  p->rc.range = range;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x2280, %rax           # imm = 0x2280
movq -0x8(%rbp), %rcx
movl 0x44(%rcx), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl -0xc(%rbp), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
shrl $0xb, %eax
imull -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x18(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
movl -0x14(%rbp), %eax
movl -0x14(%rbp), %ecx
shrl $0x5, %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
cmpl $0x1000000, -0x10(%rbp) # imm = 0x1000000
jae 0x6e345
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x6db00
movq -0x8(%rbp), %rax
addq $0x2220, %rax           # imm = 0x2220
movq -0x8(%rbp), %rcx
movl 0x44(%rcx), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
shrl $0xb, %eax
imull -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %eax
movl $0x800, %ecx            # imm = 0x800
subl -0x14(%rbp), %ecx
shrl $0x5, %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
cmpl $0x1000000, -0x10(%rbp) # imm = 0x1000000
jae 0x6e3b6
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x6db00
movq -0x8(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, %ecx
leaq 0x44c8e(%rip), %rax     # 0xb3054
movzbl (%rax,%rcx), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x44(%rax)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x70(%rax)
movq -0x8(%rbp), %rdi
addq $0x2880, %rdi           # imm = 0x2880
movq -0x8(%rbp), %rsi
addq $0x70, %rsi
movl -0xc(%rbp), %ecx
xorl %edx, %edx
callq 0x6dd90
movq -0x8(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x2580, %rax           # imm = 0x2580
movq %rax, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x30(%rbp)
movl -0x10(%rbp), %eax
shrl $0xb, %eax
imull -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x34(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
movl -0x30(%rbp), %eax
movl -0x30(%rbp), %ecx
shrl $0x5, %ecx
subl %ecx, %eax
movw %ax, %dx
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
cmpl $0x1000000, -0x10(%rbp) # imm = 0x1000000
jae 0x6e486
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x6db00
movl -0x2c(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x40, -0x2c(%rbp)
jb 0x6e417
movl $0x1a, -0x38(%rbp)
movl -0x10(%rbp), %eax
shrl %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
cmpl $0x1000000, -0x10(%rbp) # imm = 0x1000000
jae 0x6e4d6
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x6db00
jmp 0x6e4d8
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jne 0x6e49e
movq -0x8(%rbp), %rax
addq $0x2200, %rax           # imm = 0x2200
movq %rax, -0x40(%rbp)
movl $0x1, -0x44(%rbp)
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x48(%rbp)
movl -0x10(%rbp), %eax
shrl $0xb, %eax
imull -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
movl -0x48(%rbp), %eax
movl -0x48(%rbp), %ecx
shrl $0x5, %ecx
subl %ecx, %eax
movw %ax, %dx
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
cmpl $0x1000000, -0x10(%rbp) # imm = 0x1000000
jae 0x6e56a
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x6db00
movl -0x44(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
cmpl $0x10, -0x44(%rbp)
jb 0x6e4fb
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x70(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)