// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
movq %rsi, %rbx
movl 0x14(%rdi), %ecx
cmpq $0x4, %rcx
ja 0x38cfb
callq 0x383da
jmp 0x38f5c
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), %r8d
shll $0x5, %r8d
movzbl 0x4(%rdx), %r9d
movl 0x78(%rdi,%r9,4), %r11d
shll $0xa, %r11d
xorl %r8d, %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
movq %r15, (%rsp)
jae 0x38dc8
movl %r8d, %r11d
movq %rdx, %rax
subq %r11, %rax
movb (%rax), %al
cmpb (%rdx), %al
jne 0x38dc8
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 0x38f6e
movl %r8d, %r9d
movq %rax, %rbx
jmp 0x38dfd
movl $0x4, %r8d
cmpl %r10d, %r9d
jae 0x38e61
movl %r9d, %eax
movq %rdx, %r10
subq %rax, %r10
movb (%r10), %al
cmpb (%rdx), %al
jne 0x38e61
movl $0x8, %eax
movl $0x4, %r8d
leal -0x1(%r9), %r10d
movl %r10d, (%rbx,%r8)
addq %rax, %rbx
movl $0x3, -0x8(%rbx)
movl %r9d, %eax
movq %rdx, %r8
subq %rax, %r8
movb 0x3(%r8), %r9b
movl $0x4, %r8d
cmpb 0x3(%rdx), %r9b
jne 0x38e61
leaq 0x4(%rdx), %r8
negq %rax
leaq (%rdx,%rcx), %r9
leaq -0x4(%rcx), %r10
movb (%r8,%rax), %r11b
cmpb (%r8), %r11b
jne 0x38e40
incq %r8
decq %r10
jne 0x38e2c
movq %r9, %r8
subl %edx, %r8d
movl %r8d, -0x8(%rbx)
cmpl %r8d, %ecx
jne 0x38e61
movq 0x30(%rdi), %rax
movl 0x18(%rdi), %ecx
movl %esi, (%rax,%rcx,4)
incl 0x18(%rdi)
movq %r15, (%rdi)
jmp 0x38f4a
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 0x38f01
movl %r9d, %r13d
subl %esi, %r13d
cmpl %ebp, %r13d
jae 0x38f25
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 0x38f25
negq %r11
addq %rdx, %r11
xorl %r12d, %r12d
movb (%rdx,%r12), %al
movb (%r11,%r12), %r15b
cmpb %r15b, %al
jne 0x38f05
incq %r12
cmpq %r12, %rcx
jne 0x38ed8
movl %ecx, (%rbx)
decl %r13d
movl %r13d, 0x4(%rbx)
leaq 0x8(%rbx), %r11
movq %r11, 0x8(%rsp)
jmp 0x38f1b
xorl %esi, %esi
jmp 0x38f25
cmpl %r12d, %r8d
jae 0x38f1b
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 0x38f35
decl %r14d
jne 0x38e83
jmp 0x38f40
cmpl $0x2, %r12d
je 0x38f40
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 0x38f5c
callq 0x383ee
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %r8d
cmpl %r10d, %r9d
jae 0x38e64
movl %r9d, %r10d
movq %rdx, %r11
subq %r10, %r11
movb (%r11), %r10b
cmpb (%rdx), %r10b
jne 0x38e64
movl $0x10, %eax
movl $0xc, %r8d
movq (%rsp), %r15
jmp 0x38df2