// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movq %rdi, %r14
movl 0x14(%rdi), %edi
cmpq $0x4, %rdi
ja 0x39b4e
movq %r14, %rdi
callq 0x383da
jmp 0x39eb9
movq (%r14), %r10
movzbl (%r10), %ecx
movzbl 0x1(%r10), %eax
xorl 0x78(%r14,%rcx,4), %eax
movzbl 0x2(%r10), %ecx
shll $0x8, %ecx
xorl %eax, %ecx
andl $0x3ff, %eax            # imm = 0x3FF
movzwl %cx, %r8d
movzbl 0x3(%r10), %edx
movl 0x78(%r14,%rdx,4), %edx
shll $0x5, %edx
movzbl 0x4(%r10), %esi
movl 0x78(%r14,%rsi,4), %r9d
shll $0xa, %r9d
xorl %edx, %r9d
xorl %ecx, %r9d
andl 0x38(%r14), %r9d
movq 0x28(%r14), %r11
movl 0x8(%r14), %ebx
movl %ebx, %ecx
subl (%r11,%rax,4), %ecx
movl %ebx, %edx
subl 0x1000(%r11,%r8,4), %edx
movl 0x41000(%r11,%r9,4), %esi
movl %ebx, (%r11,%rax,4)
movl %ebx, 0x1000(%r11,%r8,4)
movl %ebx, 0x41000(%r11,%r9,4)
movl 0x1c(%r14), %r8d
cmpl %r8d, %ebx
cmovbl %ebx, %r8d
cmpl %r8d, %ecx
jae 0x39c1c
movl %ecx, %eax
movq %r10, %r9
subq %rax, %r9
movb (%r9), %r9b
cmpb (%r10), %r9b
jne 0x39c1c
negq %rax
movq 0x8(%rsp), %r11
movl $0x2, (%r11)
leal -0x1(%rcx), %r9d
movl %r9d, 0x4(%r11)
leaq 0x8(%r11), %r9
movb 0x2(%r10,%rax), %al
cmpb 0x2(%r10), %al
jne 0x39ecd
movl %ecx, %edx
movq %r9, %r11
jmp 0x39c58
movl $0x4, %eax
cmpl %r8d, %edx
movq 0x8(%rsp), %r11
jae 0x39cf2
movl %edx, %ecx
movq %r10, %r8
subq %rcx, %r8
movb (%r8), %cl
cmpb (%r10), %cl
jne 0x39cf2
movl $0x8, %eax
movl $0x4, %ecx
leal -0x1(%rdx), %r8d
movl %r8d, (%r11,%rcx)
addq %rax, %r11
movl $0x3, -0x8(%r11)
movl %edx, %ecx
movq %r10, %rax
subq %rcx, %rax
movb 0x3(%rax), %dl
movl $0x4, %eax
cmpb 0x3(%r10), %dl
jne 0x39cf2
leaq 0x4(%r10), %rax
negq %rcx
leaq (%r10,%rdi), %rdx
movq %rdi, %r8
addq $-0x4, %r8
movb (%rax,%rcx), %r9b
cmpb (%rax), %r9b
jne 0x39c9c
incq %rax
decq %r8
jne 0x39c88
movq %rdx, %rax
subl %r10d, %eax
movl %eax, -0x8(%r11)
cmpl %eax, %edi
jne 0x39cf2
movq %r11, 0x8(%rsp)
movq 0x30(%r14), %r8
movl 0x8(%r14), %edx
movl 0x18(%r14), %r9d
movl 0x1c(%r14), %eax
movl 0x3c(%r14), %r11d
movq %r10, %rcx
pushq %r11
pushq %rax
callq 0x386a6
addq $0x10, %rsp
incl 0x18(%r14)
incq (%r14)
movl 0x8(%r14), %eax
incl %eax
movl %eax, 0x8(%r14)
cmpl 0xc(%r14), %eax
jne 0x39eb9
movq %r14, %rdi
jmp 0x39eb4
movq %r11, %r9
movq %r9, 0x20(%rsp)
leaq 0x1(%r10), %rcx
movq %rcx, 0x40(%rsp)
movl 0x8(%r14), %edx
movl 0x18(%r14), %r8d
movq 0x30(%r14), %r9
movl 0x1c(%r14), %r11d
leaq (%r9,%r8,8), %rcx
movq %rcx, 0x10(%rsp)
movq %r8, 0x50(%rsp)
movq %r9, 0x38(%rsp)
leaq (%r9,%r8,8), %rcx
addq $0x4, %rcx
movq %rcx, 0x18(%rsp)
xorl %ecx, %ecx
movl %edx, 0x34(%rsp)
movl %r11d, 0x30(%rsp)
subl %r11d, %edx
cmovbl %ecx, %edx
movl %edx, 0x2c(%rsp)
cmpl %esi, %edx
movq %r14, 0x48(%rsp)
jae 0x39e7d
movl 0x3c(%r14), %r8d
xorl %r14d, %r14d
xorl %edx, %edx
movl 0x34(%rsp), %ecx
movl %ecx, %r13d
subl %esi, %r13d
movq 0x50(%rsp), %r9
movq %r9, %rcx
subq %r13, %rcx
cmpl %r9d, %r13d
movl $0x0, %ebx
cmoval 0x30(%rsp), %ebx
addq %rcx, %rbx
movq %r10, %rcx
subq %r13, %rcx
cmpl %edx, %r14d
movl %edx, %r11d
cmovbl %r14d, %r11d
movq 0x38(%rsp), %r9
leaq (%r9,%rbx,8), %r9
movb (%rcx,%r11), %r12b
cmpb (%r10,%r11), %r12b
jne 0x39e32
leal 0x1(%r11), %r12d
cmpl %edi, %r12d
je 0x39de4
movl %r12d, %ebp
movb (%rcx,%rbp), %r15b
cmpb (%r10,%rbp), %r15b
jne 0x39de4
addl $0x2, %r11d
movq %rdi, %r12
cmpl %r11d, %r12d
je 0x39de4
movl %r11d, %r15d
movb (%rcx,%r15), %bpl
incl %r11d
cmpb (%r10,%r15), %bpl
je 0x39dc7
decl %r11d
movl %r11d, %r12d
jmp 0x39de4
cmpl %r12d, %eax
jae 0x39e2f
movq 0x38(%rsp), %rax
movl (%rax,%rbx,8), %eax
movq 0x20(%rsp), %r11
movl %r12d, (%r11)
decl %r13d
movl %r13d, 0x4(%r11)
addq $0x8, %r11
cmpl %edi, %r12d
movq %r11, 0x20(%rsp)
jne 0x39e2c
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl 0x4(%r9), %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
xorl %ecx, %ecx
movl %r12d, %eax
movq %r11, 0x8(%rsp)
jmp 0x39e6a
movl %r12d, %eax
movl %r12d, %r11d
movl %r11d, %ebx
movb (%rcx,%rbx), %cl
cmpb (%r10,%rbx), %cl
jae 0x39e50
movq 0x10(%rsp), %rcx
movl %esi, (%rcx)
addq $0x4, %r9
movq %r9, 0x10(%rsp)
jmp 0x39e62
movq 0x18(%rsp), %rcx
movl %esi, (%rcx)
movq %r9, 0x18(%rsp)
movl %r11d, %r14d
movl %edx, %r11d
movl (%r9), %esi
movb $0x1, %cl
movl %r11d, %edx
testb %cl, %cl
je 0x39e97
decl %r8d
je 0x39e7d
cmpl %esi, 0x2c(%rsp)
jb 0x39d5e
xorl %ecx, %ecx
movq 0x10(%rsp), %rax
movl %ecx, (%rax)
movq 0x18(%rsp), %rax
movl %ecx, (%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
incl 0x18(%rdi)
movq 0x40(%rsp), %rax
movq %rax, (%rdi)
movl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
cmpl 0xc(%rdi), %eax
jne 0x39eb9
callq 0x383ee
movq 0x8(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %eax
cmpl %r8d, %edx
jae 0x39cf5
movl %edx, %ecx
movq %r10, %r8
subq %rcx, %r8
movb (%r8), %cl
cmpb (%r10), %cl
jne 0x39cf5
movl $0x10, %eax
movl $0xc, %ecx
jmp 0x39c4d