// File: sisong[P]ApkDiffPatch/lzma/C/LzFind.c
// Function: SkipMatchesSpec
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
    size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
{
  CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
  CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
  unsigned len0 = 0, len1 = 0;

  UInt32 cmCheck;

  cmCheck = (UInt32)(pos - _cyclicBufferSize);
  if ((UInt32)pos <= _cyclicBufferSize)
    cmCheck = 0;

  if (// curMatch >= pos ||  // failure
      cmCheck < curMatch)
  do
  {
    const UInt32 delta = pos - curMatch;
    {
      CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
      const Byte *pb = cur - delta;
      unsigned len = (len0 < len1 ? len0 : len1);
      if (pb[len] == cur[len])
      {
        while (++len != lenLimit)
          if (pb[len] != cur[len])
            break;
        {
          if (len == lenLimit)
          {
            *ptr1 = pair[0];
            *ptr0 = pair[1];
            return;
          }
        }
      }
      if (pb[len] < cur[len])
      {
        *ptr1 = curMatch;
        curMatch = pair[1];
        ptr1 = pair + 1;
        len1 = len;
      }
      else
      {
        *ptr0 = curMatch;
        curMatch = pair[0];
        ptr0 = pair;
        len0 = len;
      }
    }
  }
  while(--cutValue && cmCheck < curMatch);
  
  *ptr0 = *ptr1 = kEmptyHashValue;
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0xc(%rbp), %eax
subl 0x10(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x10(%rbp), %eax
ja 0x70e25
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x70fb8
jmp 0x70e33
movl -0xc(%rbp), %eax
subl -0x8(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rax
movl -0x48(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movl -0x48(%rbp), %eax
cmpq -0x28(%rbp), %rax
jbe 0x70e63
movl 0x10(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x70e6a
xorl %eax, %eax
movl %eax, -0x74(%rbp)
jmp 0x70e6a
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movl -0x74(%rbp), %edx
movl %edx, %edx
addq %rdx, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x70ead
movl -0x3c(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x70eb3
movl -0x40(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x5c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x70f29
jmp 0x70ed5
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
cmpl -0x4(%rbp), %eax
je 0x70f01
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x5c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x70eff
jmp 0x70f01
jmp 0x70ed5
movl -0x5c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jne 0x70f27
movq -0x50(%rbp), %rax
movl (%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
jmp 0x70fcc
jmp 0x70f29
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x5c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jge 0x70f6a
movl -0x8(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x8(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x70f8a
movl -0x8(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x70f8c
movl 0x18(%rbp), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x79(%rbp)
je 0x70fab
movl -0x44(%rbp), %eax
cmpl -0x8(%rbp), %eax
setb %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x70e33
jmp 0x70fb8
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
popq %rbp
retq
nop