// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl 0x14(%rdi), %ecx
cmpq $0x3, %rcx
ja 0x30285
callq 0x2fd7d
jmp 0x30475
movq (%rdi), %rdx
movzbl (%rdx), %esi
leaq 0x1(%rdx), %rax
movq %rax, (%rsp)
movzbl 0x1(%rdx), %r9d
xorl 0x78(%rdi,%rsi,4), %r9d
movzbl 0x2(%rdx), %esi
shll $0x8, %esi
xorl %r9d, %esi
andl $0x3ff, %r9d            # imm = 0x3FF
movzwl %si, %r11d
movzbl 0x3(%rdx), %r8d
movl 0x78(%rdi,%r8,4), %r14d
shll $0x5, %r14d
xorl %esi, %r14d
andl 0x38(%rdi), %r14d
movq 0x28(%rdi), %r15
movl 0x8(%rdi), %ebp
movl %ebp, %r8d
subl (%r15,%r9,4), %r8d
movl %ebp, %r10d
subl 0x1000(%r15,%r11,4), %r10d
movl 0x41000(%r15,%r14,4), %esi
movl %ebp, (%r15,%r9,4)
movl %ebp, 0x1000(%r15,%r11,4)
movl %ebp, 0x41000(%r15,%r14,4)
movl 0x1c(%rdi), %r11d
cmpl %r11d, %ebp
cmovbl %ebp, %r11d
cmpl %r11d, %r8d
jae 0x30345
movl %r8d, %r9d
movq %rdx, %r14
subq %r9, %r14
movb (%r14), %bpl
cmpb (%rdx), %bpl
jne 0x30345
negq %r9
movl $0x2, (%rbx)
decl %r8d
movl %r8d, 0x4(%rbx)
leaq 0x8(%rbx), %r15
movb 0x2(%rdx,%r9), %r8b
cmpb 0x2(%rdx), %r8b
jne 0x30487
movq %r15, %rbx
jmp 0x30374
pushq $0x3
popq %r8
cmpl %r11d, %r10d
jae 0x303b4
movl %r10d, %r9d
movq %rdx, %r11
subq %r9, %r11
movb (%r11), %r11b
cmpb (%rdx), %r11b
jne 0x303b4
negq %r9
pushq $0x8
popq %r8
pushq $0x4
popq %r11
decl %r10d
movl %r10d, (%rbx,%r11)
addq %r8, %rbx
leaq 0x3(%rdx), %r10
leaq (%rdx,%rcx), %r8
leaq -0x3(%rcx), %r11
testq %r11, %r11
je 0x30399
movb (%r10,%r9), %bpl
cmpb (%r10), %bpl
jne 0x30396
incq %r10
decq %r11
jmp 0x30380
movq %r10, %r8
subl %edx, %r8d
movl %r8d, -0x8(%rbx)
cmpl %r8d, %ecx
jne 0x303b4
movq 0x30(%rdi), %rcx
movl 0x18(%rdi), %edx
movl %esi, (%rcx,%rdx,4)
jmp 0x30459
movq %rbx, %r15
movl 0x8(%rdi), %r9d
movl 0x18(%rdi), %r10d
movq 0x30(%rdi), %r11
movl 0x1c(%rdi), %ebp
movl 0x3c(%rdi), %r14d
movl %esi, (%r11,%r10,4)
movq %r15, %rbx
testl %esi, %esi
je 0x30459
movl %r9d, %r15d
subl %esi, %r15d
cmpl %ebp, %r15d
jae 0x30459
movl %r15d, %r12d
movq %r10, %rsi
subq %r12, %rsi
cmpl %r10d, %r15d
movl $0x0, %r13d
cmoval %ebp, %r13d
leaq (%r11,%rsi,4), %rsi
movl (%rsi,%r13,4), %esi
movl %r8d, %r13d
movb (%rdx,%r13), %al
subq %r12, %r13
cmpb (%rdx,%r13), %al
jne 0x30445
negq %r12
addq %rdx, %r12
xorl %r13d, %r13d
movb (%rdx,%r13), %al
cmpb (%r12,%r13), %al
jne 0x3042f
incq %r13
cmpq %r13, %rcx
jne 0x3041b
jmp 0x3044c
cmpl %r13d, %r8d
jae 0x30445
movl %r13d, (%rbx)
decl %r15d
movl %r15d, 0x4(%rbx)
addq $0x8, %rbx
movl %r13d, %r8d
decl %r14d
jne 0x303d1
jmp 0x30459
movl %ecx, (%rbx)
decl %r15d
movl %r15d, 0x4(%rbx)
addq $0x8, %rbx
incl 0x18(%rdi)
movq (%rsp), %rax
movq %rax, (%rdi)
movl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
cmpl 0xc(%rdi), %eax
jne 0x30475
callq 0x2fd91
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x3
popq %r8
cmpl %r11d, %r10d
jae 0x303b7
movl %r10d, %r9d
movq %rdx, %r11
subq %r9, %r11
movb (%r11), %r11b
cmpb (%rdx), %r11b
jne 0x303b7
negq %r9
pushq $0x10
popq %r8
pushq $0xc
jmp 0x30368