// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/lzma/C/LzFind.c
// Function: Hc5_MatchFinder_GetMatches
static UInt32 * Hc5_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(5)

  HASH5_CALC

  hash = p->hash;
  pos = p->pos;

  d2 = pos - hash                  [h2];
  d3 = pos - (hash + kFix3HashSize)[h3];
  // d4 = pos - (hash + kFix4HashSize)[h4];

  curMatch = (hash + kFix5HashSize)[hv];

  hash                  [h2] = pos;
  (hash + kFix3HashSize)[h3] = pos;
  // (hash + kFix4HashSize)[h4] = pos;
  (hash + kFix5HashSize)[hv] = pos;

  SET_mmm
  
  maxLen = 4;

  for (;;)
  {
    if (d2 < mmm && *(cur - d2) == *cur)
    {
      distances[0] = 2;
      distances[1] = d2 - 1;
      distances += 2;
      if (*(cur - d2 + 2) == cur[2])
      {
      }
      else if (d3 < mmm && *(cur - d3) == *cur)
      {
        distances[1] = d3 - 1;
        distances += 2;
        d2 = d3;
      }
      else
        break;
    }
    else if (d3 < mmm && *(cur - d3) == *cur)
    {
      distances[1] = d3 - 1;
      distances += 2;
      d2 = d3;
    }
    else
      break;

    distances[-2] = 3;
    if (*(cur - d2 + 3) != cur[3])
      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 $0x4, %rcx
ja 0x305cb
callq 0x2fd7d
jmp 0x30802
movq (%rdi), %rdx
movzbl (%rdx), %esi
leaq 0x1(%rdx), %rax
movq %rax, (%rsp)
movzbl 0x1(%rdx), %r8d
xorl 0x78(%rdi,%rsi,4), %r8d
movzbl 0x2(%rdx), %esi
shll $0x8, %esi
xorl %r8d, %esi
andl $0x3ff, %r8d            # imm = 0x3FF
movzwl %si, %r9d
movzbl 0x3(%rdx), %r10d
movl 0x78(%rdi,%r10,4), %r10d
shll $0x5, %r10d
movzbl 0x4(%rdx), %r11d
movl 0x78(%rdi,%r11,4), %r14d
shll $0xa, %r14d
xorl %r10d, %r14d
xorl %esi, %r14d
andl 0x38(%rdi), %r14d
movq 0x28(%rdi), %r15
movl 0x8(%rdi), %r12d
movl %r12d, %r11d
subl (%r15,%r8,4), %r11d
movl %r12d, %r10d
subl 0x1000(%r15,%r9,4), %r10d
movl 0x41000(%r15,%r14,4), %esi
movl %r12d, (%r15,%r8,4)
movl %r12d, 0x1000(%r15,%r9,4)
movl %r12d, 0x41000(%r15,%r14,4)
movl 0x1c(%rdi), %ebp
cmpl %ebp, %r12d
cmovbl %r12d, %ebp
pushq $0x4
popq %r8
cmpl %ebp, %r11d
jae 0x3069c
movl %r11d, %r9d
movq %rdx, %r14
subq %r9, %r14
movb (%r14), %r14b
cmpb (%rdx), %r14b
jne 0x3069c
negq %r9
movl $0x2, (%rbx)
decl %r11d
movl %r11d, 0x4(%rbx)
leaq 0x8(%rbx), %r11
movb 0x2(%rdx,%r9), %r14b
cmpb 0x2(%rdx), %r14b
jne 0x30703
movq %r11, %rbx
jmp 0x306cf
cmpl %ebp, %r10d
jae 0x30747
movl %r10d, %r9d
movq %rdx, %r11
subq %r9, %r11
movb (%r11), %r11b
cmpb (%rdx), %r11b
jne 0x30747
negq %r9
pushq $0x8
popq %r11
pushq $0x4
popq %r14
decl %r10d
movl %r10d, (%rbx,%r14)
addq %r11, %rbx
movl $0x3, -0x8(%rbx)
movb 0x3(%rdx,%r9), %r10b
cmpb 0x3(%rdx), %r10b
jne 0x30747
leaq 0x4(%rdx), %r10
leaq (%rdx,%rcx), %r8
leaq -0x4(%rcx), %r11
testq %r11, %r11
je 0x3072c
movb (%r10,%r9), %bpl
cmpb (%r10), %bpl
jne 0x30729
incq %r10
decq %r11
jmp 0x306ed
cmpl %ebp, %r10d
jae 0x30724
movl %r10d, %r9d
movq %rdx, %r14
subq %r9, %r14
movb (%r14), %bpl
cmpb (%rdx), %bpl
jne 0x30724
negq %r9
pushq $0x10
popq %r11
pushq $0xc
jmp 0x306c3
movq %r11, %rbx
jmp 0x30747
movq %r10, %r8
subl %edx, %r8d
movl %r8d, -0x8(%rbx)
cmpl %r8d, %ecx
jne 0x30747
movq 0x30(%rdi), %rcx
movl 0x18(%rdi), %edx
movl %esi, (%rcx,%rdx,4)
jmp 0x307e6
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)
testl %esi, %esi
je 0x307e6
movl %r9d, %r15d
subl %esi, %r15d
cmpl %ebp, %r15d
jae 0x307e6
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 0x307d2
negq %r12
addq %rdx, %r12
xorl %r13d, %r13d
movb (%rdx,%r13), %al
cmpb (%r12,%r13), %al
jne 0x307bc
incq %r13
cmpq %r13, %rcx
jne 0x307a8
jmp 0x307d9
cmpl %r13d, %r8d
jae 0x307d2
movl %r13d, (%rbx)
decl %r15d
movl %r15d, 0x4(%rbx)
addq $0x8, %rbx
movl %r13d, %r8d
decl %r14d
jne 0x3075e
jmp 0x307e6
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 0x30802
callq 0x2fd91
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq