// File: sisong[P]ApkDiffPatch/lzma/C/LzFind.c
// Function: GetMatchesSpec1
Z7_FORCE_INLINE
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
    size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
    UInt32 *d, UInt32 maxLen)
{
  CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
  CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
  unsigned len0 = 0, len1 = 0;

  UInt32 cmCheck;

  // if (curMatch >= pos) { *ptr0 = *ptr1 = kEmptyHashValue; return NULL; }

  cmCheck = (UInt32)(pos - _cyclicBufferSize);
  if ((UInt32)pos <= _cyclicBufferSize)
    cmCheck = 0;

  if (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);
      const UInt32 pair0 = pair[0];
      if (pb[len] == cur[len])
      {
        if (++len != lenLimit && pb[len] == cur[len])
          while (++len != lenLimit)
            if (pb[len] != cur[len])
              break;
        if (maxLen < len)
        {
          maxLen = (UInt32)len;
          *d++ = (UInt32)len;
          *d++ = delta - 1;
          if (len == lenLimit)
          {
            *ptr1 = pair0;
            *ptr0 = pair[1];
            return d;
          }
        }
      }
      if (pb[len] < cur[len])
      {
        *ptr1 = curMatch;
        // const UInt32 curMatch2 = pair[1];
        // if (curMatch2 >= curMatch) { *ptr0 = *ptr1 = kEmptyHashValue;  return NULL; }
        // curMatch = curMatch2;
        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 d;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x14(%rbp), %eax
subl 0x10(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x10(%rbp), %eax
ja 0x7010d
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jae 0x70320
jmp 0x7011b
movl -0x14(%rbp), %eax
subl -0x10(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
movl -0x50(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x70(%rbp)
movl -0x50(%rbp), %eax
cmpq -0x30(%rbp), %rax
jbe 0x7014b
movl 0x10(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x70152
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
jmp 0x70152
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
movl -0x7c(%rbp), %edx
movl %edx, %edx
addq %rdx, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0x70195
movl -0x44(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x7019b
movl -0x48(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movl -0x64(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x70288
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
cmpl -0xc(%rbp), %eax
je 0x70220
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movl -0x64(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x70220
jmp 0x701f2
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
cmpl -0xc(%rbp), %eax
je 0x7021e
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movl -0x64(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x7021c
jmp 0x7021e
jmp 0x701f2
jmp 0x70220
movl 0x28(%rbp), %eax
cmpl -0x64(%rbp), %eax
jae 0x70286
movl -0x64(%rbp), %eax
movl %eax, 0x28(%rbp)
movl -0x64(%rbp), %ecx
movq 0x20(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, 0x20(%rbp)
movl %ecx, (%rax)
movl -0x50(%rbp), %ecx
subl $0x1, %ecx
movq 0x20(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, 0x20(%rbp)
movl %ecx, (%rax)
movl -0x64(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x70284
movl -0x68(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq 0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7033c
jmp 0x70286
jmp 0x70288
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movl -0x64(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jge 0x702c9
movl -0x10(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x702e9
movl -0x10(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x702eb
movl 0x18(%rbp), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x81(%rbp)
je 0x70310
movl -0x4c(%rbp), %eax
cmpl -0x10(%rbp), %eax
setb %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x7011b
jmp 0x70320
movq -0x40(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq 0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)