// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
movq %rsi, %rbx
movl 0x14(%rdi), %ecx
cmpq $0x3, %rcx
ja 0x38967
callq 0x383da
jmp 0x38b96
movq (%rdi), %rdx
movzbl (%rdx), %esi
leaq 0x1(%rdx), %r15
movzbl 0x1(%rdx), %eax
xorl 0x78(%rdi,%rsi,4), %eax
movzbl 0x2(%rdx), %esi
shll $0x8, %esi
xorl %eax, %esi
andl $0x3ff, %eax            # imm = 0x3FF
movzwl %si, %r10d
movzbl 0x3(%rdx), %r8d
movl 0x78(%rdi,%r8,4), %r11d
shll $0x5, %r11d
xorl %esi, %r11d
andl 0x38(%rdi), %r11d
movq 0x28(%rdi), %r14
movl 0x8(%rdi), %ebp
movl %ebp, %r8d
subl (%r14,%rax,4), %r8d
movl %ebp, %r9d
subl 0x1000(%r14,%r10,4), %r9d
movl 0x41000(%r14,%r11,4), %esi
movl %ebp, (%r14,%rax,4)
movl %ebp, 0x1000(%r14,%r10,4)
movl %ebp, 0x41000(%r14,%r11,4)
movl 0x1c(%rdi), %r10d
cmpl %r10d, %ebp
cmovbl %ebp, %r10d
cmpl %r10d, %r8d
jae 0x38a1f
movl %r8d, %r11d
movq %rdx, %rax
subq %r11, %rax
movb (%rax), %al
cmpb (%rdx), %al
jne 0x38a1f
negq %r11
movl $0x2, (%rbx)
leal -0x1(%r8), %eax
movl %eax, 0x4(%rbx)
leaq 0x8(%rbx), %rax
movb 0x2(%rdx,%r11), %r11b
cmpb 0x2(%rdx), %r11b
jne 0x38ba8
movl %r8d, %r9d
movq %rax, %rbx
jmp 0x38a50
movl $0x3, %r8d
cmpl %r10d, %r9d
jae 0x38a97
movl %r9d, %eax
movq %rdx, %r10
subq %rax, %r10
movb (%r10), %al
cmpb (%rdx), %al
jne 0x38a97
movl $0x8, %eax
movl $0x4, %r8d
leal -0x1(%r9), %r10d
movl %r10d, (%rbx,%r8)
addq %rax, %rbx
leaq 0x3(%rdx), %r8
movl %r9d, %eax
negq %rax
leaq (%rdx,%rcx), %r9
leaq -0x3(%rcx), %r10
movb (%r8,%rax), %r11b
cmpb (%r8), %r11b
jne 0x38a76
incq %r8
decq %r10
jne 0x38a62
movq %r9, %r8
subl %edx, %r8d
movl %r8d, -0x8(%rbx)
cmpl %r8d, %ecx
jne 0x38a97
movq 0x30(%rdi), %rax
movl 0x18(%rdi), %ecx
movl %esi, (%rax,%rcx,4)
incl 0x18(%rdi)
movq %r15, (%rdi)
jmp 0x38b84
movq %r15, (%rsp)
movq %rbx, %rax
movl 0x8(%rdi), %r9d
movl 0x18(%rdi), %r10d
movq 0x30(%rdi), %r11
movl 0x1c(%rdi), %ebp
movl 0x3c(%rdi), %r14d
movq %r11, 0x10(%rsp)
movl %esi, (%r11,%r10,4)
movq %rax, %rbx
movl $0x2, %r12d
testl %esi, %esi
je 0x38b3b
movl %r9d, %r13d
subl %esi, %r13d
cmpl %ebp, %r13d
jae 0x38b5f
movl %r13d, %r11d
movq %r10, %rax
subq %r11, %rax
xorl %r12d, %r12d
cmpl %r10d, %r13d
movl $0x0, %esi
cmoval %ebp, %esi
movq 0x10(%rsp), %r15
leaq (%r15,%rax,4), %rax
movl (%rax,%rsi,4), %esi
movl %r8d, %eax
movb (%rdx,%rax), %r15b
subq %r11, %rax
cmpb (%rdx,%rax), %r15b
jne 0x38b5f
negq %r11
addq %rdx, %r11
xorl %r12d, %r12d
movb (%rdx,%r12), %al
movb (%r11,%r12), %r15b
cmpb %r15b, %al
jne 0x38b3f
incq %r12
cmpq %r12, %rcx
jne 0x38b12
movl %ecx, (%rbx)
decl %r13d
movl %r13d, 0x4(%rbx)
leaq 0x8(%rbx), %r11
movq %r11, 0x8(%rsp)
jmp 0x38b55
xorl %esi, %esi
jmp 0x38b5f
cmpl %r12d, %r8d
jae 0x38b55
movl %r12d, (%rbx)
decl %r13d
movl %r13d, 0x4(%rbx)
addq $0x8, %rbx
movl %r12d, %r8d
xorl %r12d, %r12d
cmpb %r15b, %al
sete %r12b
testl %r12d, %r12d
jne 0x38b6f
decl %r14d
jne 0x38abd
jmp 0x38b7a
cmpl $0x2, %r12d
je 0x38b7a
movq 0x8(%rsp), %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 0x38b96
callq 0x383ee
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, (%rsp)
movl $0x3, %r8d
cmpl %r10d, %r9d
jae 0x38a9e
movl %r9d, %r10d
movq %rdx, %r11
subq %r10, %r11
movb (%r11), %r10b
cmpb (%rdx), %r10b
jne 0x38a9e
movl $0x10, %eax
movl $0xc, %r8d
movq (%rsp), %r15
jmp 0x38a45