// File: sisong[P]ApkDiffPatch/lzma/C/LzFind.c
// Function: Hc4_MatchFinder_GetMatches
static UInt32* Hc4_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
  CMatchFinder *p = (CMatchFinder *)_p;
  UInt32 mmm;
  UInt32 h2, h3, d2, d3, pos;
  unsigned maxLen;
  UInt32 *hash;
  GET_MATCHES_HEADER(4)

  HASH4_CALC

  hash = p->hash;
  pos = p->pos;
  
  d2 = pos - hash                  [h2];
  d3 = pos - (hash + kFix3HashSize)[h3];
  curMatch = (hash + kFix4HashSize)[hv];

  hash                  [h2] = pos;
  (hash + kFix3HashSize)[h3] = pos;
  (hash + kFix4HashSize)[hv] = pos;

  SET_mmm

  maxLen = 3;

  for (;;)
  {
    if (d2 < mmm && *(cur - d2) == *cur)
    {
      distances[0] = 2;
      distances[1] = d2 - 1;
      distances += 2;
      if (*(cur - d2 + 2) == cur[2])
      {
        // distances[-2] = 3;
      }
      else if (d3 < mmm && *(cur - d3) == *cur)
      {
        d2 = d3;
        distances[1] = d3 - 1;
        distances += 2;
      }
      else
        break;
    }
    else if (d3 < mmm && *(cur - d3) == *cur)
    {
      d2 = d3;
      distances[1] = d3 - 1;
      distances += 2;
    }
    else
      break;

    UPDATE_maxLen
    distances[-2] = (UInt32)maxLen;
    if (maxLen == lenLimit)
    {
      p->son[p->cyclicBufferPos] = curMatch;
      MOVE_POS_RET
    }
    break;
  }
  
  GET_MATCHES_FOOTER_HC(maxLen)
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, -0x88(%rbp)
movq %rsi, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0xd8(%rbp)
cmpl $0x4, -0xd8(%rbp)
jae 0x7131d
movq -0x98(%rbp), %rdi
callq 0x707d0
movq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x719fc
movq -0x98(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x98(%rbp), %rax
movq -0xd0(%rbp), %rcx
movzbl (%rcx), %ecx
movl 0x78(%rax,%rcx,4), %eax
movq -0xd0(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
xorl %ecx, %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0xa0(%rbp)
movq -0xd0(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
xorl -0xdc(%rbp), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0xa4(%rbp)
movl -0xdc(%rbp), %eax
movq -0x98(%rbp), %rcx
movq -0xd0(%rbp), %rdx
movzbl 0x3(%rdx), %edx
movl 0x78(%rcx,%rdx,4), %ecx
shll $0x5, %ecx
xorl %ecx, %eax
movq -0x98(%rbp), %rcx
andl 0x38(%rcx), %eax
movl %eax, -0xc4(%rbp)
movq -0x98(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
movq -0xc0(%rbp), %rcx
movl -0xa0(%rbp), %edx
subl (%rcx,%rdx,4), %eax
movl %eax, -0xa8(%rbp)
movl -0xb0(%rbp), %eax
movq -0xc0(%rbp), %rcx
movl -0xa4(%rbp), %edx
subl 0x1000(%rcx,%rdx,4), %eax
movl %eax, -0xac(%rbp)
movq -0xc0(%rbp), %rax
movl -0xc4(%rbp), %ecx
movl 0x41000(%rax,%rcx,4), %eax
movl %eax, -0xd4(%rbp)
movl -0xb0(%rbp), %edx
movq -0xc0(%rbp), %rax
movl -0xa0(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0xb0(%rbp), %edx
movq -0xc0(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %edx, 0x1000(%rax,%rcx,4)
movl -0xb0(%rbp), %edx
movq -0xc0(%rbp), %rax
movl -0xc4(%rbp), %ecx
movl %edx, 0x41000(%rax,%rcx,4)
movq -0x98(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x9c(%rbp)
movl -0xb0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x714af
movl -0xb0(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl $0x3, -0xb4(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x715c1
movq -0xd0(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0xd0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x715c1
movq -0x90(%rbp), %rax
movl $0x2, (%rax)
movl -0xa8(%rbp), %ecx
subl $0x1, %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x90(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x90(%rbp)
movq -0xd0(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl 0x2(%rax,%rcx), %eax
movq -0xd0(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x71551
jmp 0x715bf
movl -0xac(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x715b8
movq -0xd0(%rbp), %rax
movl -0xac(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0xd0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x715b8
movl -0xac(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xac(%rbp), %ecx
subl $0x1, %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x90(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x90(%rbp)
jmp 0x715bd
jmp 0x71784
jmp 0x715bf
jmp 0x7162f
movl -0xac(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jae 0x71628
movq -0xd0(%rbp), %rax
movl -0xac(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0xd0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x71628
movl -0xac(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xac(%rbp), %ecx
subl $0x1, %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x90(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x90(%rbp)
jmp 0x7162d
jmp 0x71784
jmp 0x7162f
movl -0xa8(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0xd0(%rbp), %rax
movl -0xb4(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movq -0xd0(%rbp), %rax
movl -0xd8(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rax
cmpq -0xf8(%rbp), %rax
je 0x716b9
movq -0xf0(%rbp), %rax
movq -0xe8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0xf0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x716a3
jmp 0x716b9
jmp 0x716a5
movq -0xf0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
jmp 0x71671
movq -0xf0(%rbp), %rax
movq -0xd0(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, -0x8(%rax)
movl -0xb4(%rbp), %eax
cmpl -0xd8(%rbp), %eax
jne 0x71782
movl -0xd4(%rbp), %edx
movq -0x98(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x98(%rbp), %rcx
movl 0x18(%rcx), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x98(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x98(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %eax
movq -0x98(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x71772
movq -0x98(%rbp), %rdi
callq 0x70830
movq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x719fc
jmp 0x71784
movl -0xd8(%rbp), %eax
movl %eax, %ebx
movl -0xd4(%rbp), %r11d
movq -0x98(%rbp), %rax
movl 0x8(%rax), %r10d
movq -0x98(%rbp), %rax
movq (%rax), %r9
movq -0x98(%rbp), %rax
movq 0x30(%rax), %r8
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %edi
movq -0x98(%rbp), %rax
movl 0x1c(%rax), %esi
movq -0x98(%rbp), %rax
movl 0x3c(%rax), %edx
movq -0x90(%rbp), %rcx
movl -0xb4(%rbp), %eax
movq %rbx, -0x18(%rbp)
movl %r11d, -0x1c(%rbp)
movl %r10d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
movl %esi, -0x3c(%rbp)
movl %edx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x1c(%rbp)
jne 0x7182a
jmp 0x7197c
movl -0x20(%rbp), %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jb 0x71840
jmp 0x7197c
movq -0x30(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x38(%rbp), %rax
movl -0x5c(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x108(%rbp)
movl -0x5c(%rbp), %eax
cmpq -0x38(%rbp), %rax
jbe 0x71870
movl -0x3c(%rbp), %eax
movl %eax, -0x114(%rbp)
jmp 0x7187a
xorl %eax, %eax
movl %eax, -0x114(%rbp)
jmp 0x7187a
movq -0x110(%rbp), %rax
movq -0x108(%rbp), %rcx
movl -0x114(%rbp), %edx
movl %edx, %edx
addq %rdx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movl -0x4c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x28(%rbp), %rcx
movl -0x4c(%rbp), %edx
addq -0x68(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x7196a
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movzbl (%rax), %eax
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x7192a
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
cmpq -0x58(%rbp), %rax
jne 0x71928
movq -0x58(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movl -0x5c(%rbp), %ecx
subl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x71984
jmp 0x718d1
movq -0x70(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x74(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jae 0x71968
movl -0x74(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x74(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movl -0x5c(%rbp), %ecx
subl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
jmp 0x7196a
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jne 0x7181f
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x98(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x98(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x100(%rbp)
movl -0x100(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x100(%rbp), %eax
movq -0x98(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x719f1
movq -0x98(%rbp), %rdi
callq 0x70830
movq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %rbp
retq
nopw (%rax,%rax)