// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/lzma/C/LzFind.c
// Function: Bt5_MatchFinder_GetMatches
static UInt32* Bt5_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)
    {
      SkipMatchesSpec(MF_PARAMS(p));
      MOVE_POS_RET
    }
    break;
  }
  
  GET_MATCHES_FOOTER_BT(maxLen)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movl 0x14(%rdi), %r13d
cmpq $0x4, %r13
ja 0x396f6
callq 0x38071
jmp 0x39a77
movq (%rdi), %r10
movzbl (%r10), %ecx
movzbl 0x1(%r10), %eax
xorl 0x78(%rdi,%rcx,4), %eax
movzbl 0x2(%r10), %ecx
shll $0x8, %ecx
xorl %eax, %ecx
andl $0x3ff, %eax            # imm = 0x3FF
movzwl %cx, %edx
movzbl 0x3(%r10), %esi
movl 0x78(%rdi,%rsi,4), %esi
shll $0x5, %esi
movzbl 0x4(%r10), %r8d
movl 0x78(%rdi,%r8,4), %r9d
shll $0xa, %r9d
xorl %esi, %r9d
xorl %ecx, %r9d
andl 0x38(%rdi), %r9d
movq 0x28(%rdi), %r11
movl 0x8(%rdi), %ebx
movl %ebx, %r8d
subl (%r11,%rax,4), %r8d
movl %ebx, %ecx
subl 0x1000(%r11,%rdx,4), %ecx
movl 0x41000(%r11,%r9,4), %esi
movl %ebx, (%r11,%rax,4)
movl %ebx, 0x1000(%r11,%rdx,4)
movl %ebx, 0x41000(%r11,%r9,4)
movq %rdi, 0x10(%rsp)
movl 0x1c(%rdi), %r9d
cmpl %r9d, %ebx
cmovbl %ebx, %r9d
cmpl %r9d, %r8d
jae 0x397c3
movl %r8d, %edx
movq %r10, %rax
subq %rdx, %rax
movb (%rax), %al
cmpb (%r10), %al
jne 0x397c3
negq %rdx
movl $0x2, (%r14)
decl %r8d
movl %r8d, 0x4(%r14)
leaq 0x8(%r14), %rdi
movb 0x2(%r10,%rdx), %al
cmpb 0x2(%r10), %al
jne 0x398a0
movq %rdi, %r14
movq 0x10(%rsp), %rbx
jmp 0x397fc
cmpl %r9d, %ecx
jae 0x39886
movl %ecx, %edx
movq %r10, %r8
subq %rdx, %r8
movb (%r8), %r8b
cmpb (%r10), %r8b
movq 0x10(%rsp), %rbx
jne 0x39899
negq %rdx
movl $0x8, %eax
movl $0x4, %r8d
decl %ecx
movl %ecx, (%r14,%r8)
addq %rax, %r14
movl $0x3, -0x8(%r14)
movb 0x3(%r10,%rdx), %cl
movl $0x4, %eax
cmpb 0x3(%r10), %cl
jne 0x39892
leaq 0x4(%r10), %rax
leaq (%r10,%r13), %rcx
movq %r13, %r8
addq $-0x4, %r8
movb (%rax,%rdx), %r9b
cmpb (%rax), %r9b
jne 0x39837
incq %rax
decq %r8
jne 0x39823
movq %rcx, %rax
subl %r10d, %eax
movl %eax, -0x8(%r14)
cmpl %eax, %r13d
jne 0x39892
movq 0x30(%rbx), %r8
movl 0x8(%rbx), %edx
movl 0x18(%rbx), %r9d
movl 0x1c(%rbx), %eax
movl 0x3c(%rbx), %r11d
movl %r13d, %edi
movq %r10, %rcx
pushq %r11
pushq %rax
callq 0x382f2
addq $0x10, %rsp
incl 0x18(%rbx)
incq (%rbx)
movl 0x8(%rbx), %eax
incl %eax
movl %eax, 0x8(%rbx)
cmpl 0xc(%rbx), %eax
jne 0x39a77
movq %rbx, %rdi
jmp 0x39a72
movq %r14, 0x8(%rsp)
movq 0x10(%rsp), %rbx
jmp 0x398d7
movq %r14, 0x8(%rsp)
jmp 0x398dc
movq %r14, 0x8(%rsp)
jmp 0x398d7
movq %rdi, 0x8(%rsp)
cmpl %r9d, %ecx
movq 0x10(%rsp), %rbx
jae 0x398d7
movl %ecx, %edx
movq %r10, %r8
subq %rdx, %r8
movb (%r8), %r8b
cmpb (%r10), %r8b
movl $0x4, %eax
jne 0x398dc
negq %rdx
movl $0x10, %eax
movl $0xc, %r8d
jmp 0x397f3
movl $0x4, %eax
leaq 0x1(%r10), %rcx
movq %rcx, 0x48(%rsp)
movl 0x8(%rbx), %edx
movl 0x18(%rbx), %ecx
movq 0x30(%rbx), %rdi
movl 0x1c(%rbx), %r8d
leaq (%rdi,%rcx,8), %r14
movq %rcx, 0x50(%rsp)
movq %rdi, 0x40(%rsp)
leaq (%rdi,%rcx,8), %rdi
addq $0x4, %rdi
xorl %ecx, %ecx
movl %edx, 0x34(%rsp)
movl %r8d, 0x30(%rsp)
subl %r8d, %edx
cmovbl %ecx, %edx
movl %edx, 0x2c(%rsp)
cmpl %esi, %edx
jae 0x39a49
movq %rax, 0x38(%rsp)
movl 0x3c(%rbx), %edx
xorl %r9d, %r9d
xorl %ebx, %ebx
movl 0x34(%rsp), %eax
movl %eax, %ebp
subl %esi, %ebp
movq 0x50(%rsp), %rax
movq %rax, %rcx
subq %rbp, %rcx
cmpl %eax, %ebp
movl $0x0, %r12d
cmoval 0x30(%rsp), %r12d
addq %rcx, %r12
movq %r10, %rcx
subq %rbp, %rcx
cmpl %ebx, %r9d
movl %ebx, %r11d
cmovbl %r9d, %r11d
movq 0x40(%rsp), %rax
leaq (%rax,%r12,8), %r8
movb (%rcx,%r11), %r15b
cmpb (%r10,%r11), %r15b
jne 0x39a15
movq %r14, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
leal 0x1(%r11), %r15d
movq %r13, %rax
movq %r13, %r14
cmpl %eax, %r15d
je 0x399ce
movl %r15d, %eax
movb (%rcx,%rax), %dil
movl %r15d, %r13d
cmpb (%r10,%rax), %dil
jne 0x399ce
addl $0x2, %r11d
movq %r14, %r15
cmpl %r11d, %r15d
je 0x399cb
movl %r11d, %eax
movb (%rcx,%rax), %dil
incl %r11d
cmpb (%r10,%rax), %dil
je 0x399ae
decl %r11d
movl %r11d, %r13d
jmp 0x399ce
movl %r15d, %r13d
cmpl %r13d, 0x38(%rsp)
jae 0x39a05
movq 0x40(%rsp), %rax
movl (%rax,%r12,8), %eax
movq 0x8(%rsp), %rdi
movl %r13d, (%rdi)
decl %ebp
movl %ebp, 0x4(%rdi)
addq $0x8, %rdi
movq %rdi, 0x8(%rsp)
cmpl %r14d, %r13d
je 0x39a89
movl %r13d, %eax
movq %rax, 0x38(%rsp)
movl %r13d, %r11d
movq %r14, %r13
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r14
movl %r11d, %eax
movb (%rcx,%rax), %cl
cmpb (%r10,%rax), %cl
jae 0x39a30
movl %esi, (%r14)
addq $0x4, %r8
movq %r8, %r14
movl %r11d, %ebx
jmp 0x39a38
movl %esi, (%rdi)
movq %r8, %rdi
movl %r11d, %r9d
decl %edx
je 0x39a49
movl (%r8), %esi
cmpl %esi, 0x2c(%rsp)
jb 0x39933
xorl %eax, %eax
movl %eax, (%r14)
movl %eax, (%rdi)
movq 0x10(%rsp), %rdi
incl 0x18(%rdi)
movq 0x48(%rsp), %rax
movq %rax, (%rdi)
movl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
cmpl 0xc(%rdi), %eax
movq 0x8(%rsp), %r14
jne 0x39a77
callq 0x38085
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movl 0x4(%r8), %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
jmp 0x39a50