// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/lzma/C/LzFind.c
// Function: Bt4_MatchFinder_GetMatches
static UInt32* Bt4_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)
    {
      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 $0x48, %rsp
movq %rsi, %r14
movq %rdi, %r15
movl 0x14(%rdi), %eax
movq %rax, 0x8(%rsp)
cmpq $0x3, %rax
ja 0x30f64
movq %r15, %rdi
callq 0x2fd7d
jmp 0x3128e
movq (%r15), %rbx
movzbl (%rbx), %ecx
movzbl 0x1(%rbx), %eax
xorl 0x78(%r15,%rcx,4), %eax
movzbl 0x2(%rbx), %ecx
shll $0x8, %ecx
xorl %eax, %ecx
andl $0x3ff, %eax            # imm = 0x3FF
movzwl %cx, %r8d
movzbl 0x3(%rbx), %edx
movl 0x78(%r15,%rdx,4), %r9d
shll $0x5, %r9d
xorl %ecx, %r9d
andl 0x38(%r15), %r9d
movq 0x28(%r15), %r10
movl 0x8(%r15), %r11d
movl %r11d, %edx
subl (%r10,%rax,4), %edx
movl %r11d, %ecx
subl 0x1000(%r10,%r8,4), %ecx
movl 0x41000(%r10,%r9,4), %esi
movl %r11d, (%r10,%rax,4)
movl %r11d, 0x1000(%r10,%r8,4)
movl %r11d, 0x41000(%r10,%r9,4)
movl 0x1c(%r15), %r8d
cmpl %r8d, %r11d
cmovbl %r11d, %r8d
cmpl %r8d, %edx
jae 0x31015
movl %edx, %eax
movq %rbx, %r9
subq %rax, %r9
movb (%r9), %r9b
cmpb (%rbx), %r9b
jne 0x31015
negq %rax
movl $0x2, (%r14)
decl %edx
movl %edx, 0x4(%r14)
leaq 0x8(%r14), %rdi
movb 0x2(%rbx,%rax), %dl
cmpb 0x2(%rbx), %dl
jne 0x312a0
movq %rdi, %r14
jmp 0x31047
pushq $0x3
popq %r11
cmpl %r8d, %ecx
jae 0x310cb
movl %ecx, %eax
movq %rbx, %rdx
subq %rax, %rdx
movb (%rdx), %dl
cmpb (%rbx), %dl
jne 0x310cb
negq %rax
pushq $0x8
popq %rdx
pushq $0x4
popq %r8
decl %ecx
movl %ecx, (%r14,%r8)
addq %rdx, %r14
leaq 0x3(%rbx), %rcx
movq 0x8(%rsp), %rdx
leaq (%rbx,%rdx), %r11
addq $-0x3, %rdx
testq %rdx, %rdx
je 0x31071
movb (%rcx,%rax), %r8b
cmpb (%rcx), %r8b
jne 0x3106e
incq %rcx
decq %rdx
jmp 0x31058
movq %rcx, %r11
subl %ebx, %r11d
movl %r11d, -0x8(%r14)
movq 0x8(%rsp), %rdi
cmpl %r11d, %edi
jne 0x310cb
movq 0x30(%r15), %r8
movl 0x8(%r15), %edx
movl 0x18(%r15), %r9d
movl 0x1c(%r15), %eax
movl 0x3c(%r15), %r10d
movq %rbx, %rcx
pushq %r10
pushq %rax
callq 0x2ffe0
popq %rax
popq %rcx
incl 0x18(%r15)
incq (%r15)
movl 0x8(%r15), %eax
incl %eax
movl %eax, 0x8(%r15)
cmpl 0xc(%r15), %eax
jne 0x3128e
movq %r15, %rdi
callq 0x2fd91
jmp 0x3128e
movq %r14, %rdi
movq %rdi, 0x10(%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x30(%rsp)
movl 0x8(%r15), %r13d
movl 0x18(%r15), %eax
movq 0x30(%r15), %rcx
movl 0x1c(%r15), %edx
leaq (%rcx,%rax,8), %r12
movq %rax, 0x40(%rsp)
movq %rcx, 0x28(%rsp)
leaq (%rcx,%rax,8), %rdi
addq $0x4, %rdi
xorl %ecx, %ecx
movl %r13d, %eax
movl %edx, 0x1c(%rsp)
subl %edx, %eax
movl $0x0, 0x4(%rsp)
cmovbl %ecx, %eax
movl %eax, 0x18(%rsp)
cmpl %esi, %eax
movq %r15, 0x38(%rsp)
jae 0x3125f
movl 0x3c(%r15), %edx
xorl %eax, %eax
movq 0x8(%rsp), %r15
movl %r13d, (%rsp)
movl %r13d, %r10d
subl %esi, %r10d
movq 0x40(%rsp), %r8
movq %r8, %rcx
subq %r10, %rcx
cmpl %r8d, %r10d
movl $0x0, %ebp
cmoval 0x1c(%rsp), %ebp
addq %rcx, %rbp
movq %rbx, %rcx
subq %r10, %rcx
movl 0x4(%rsp), %r8d
cmpl %eax, %r8d
movl %eax, %r9d
cmovbl %r8d, %r9d
movq 0x28(%rsp), %r8
leaq (%r8,%rbp,8), %r8
movb (%rcx,%r9), %r14b
cmpb (%rbx,%r9), %r14b
jne 0x31227
movq %r12, %r13
movq %rdi, 0x20(%rsp)
movq %r11, %rdi
leal 0x1(%r9), %r12d
movl %r15d, %r14d
cmpl %r15d, %r12d
je 0x311d5
movl %r12d, %r15d
movb (%rcx,%r15), %r11b
movl %r12d, %r14d
cmpb (%rbx,%r15), %r11b
movq 0x8(%rsp), %r15
jne 0x311d5
addl $0x2, %r9d
cmpl %r9d, %r15d
je 0x311d2
movl %r9d, %r11d
movb (%rcx,%r11), %r14b
incl %r9d
cmpb (%rbx,%r11), %r14b
je 0x311b5
decl %r9d
movl %r9d, %r14d
jmp 0x311d5
movl %r15d, %r14d
movq %rdi, %r11
cmpl %r14d, %r11d
movq %r13, %r12
jae 0x3121b
movq 0x28(%rsp), %rdi
movl (%rdi,%rbp,8), %r9d
movq 0x10(%rsp), %r11
movl %r14d, (%r11)
decl %r10d
movl %r10d, 0x4(%r11)
addq $0x8, %r11
movq %r11, 0x10(%rsp)
cmpl %r15d, %r14d
movq 0x20(%rsp), %rdi
movl (%rsp), %r13d
je 0x312cc
movl %r14d, %r11d
movl %r14d, %r9d
jmp 0x31227
movl %r14d, %r9d
movq 0x20(%rsp), %rdi
movl (%rsp), %r13d
movl %r9d, %r10d
movb (%rcx,%r10), %cl
cmpb (%rbx,%r10), %cl
jae 0x31244
movl %esi, (%r12)
addq $0x4, %r8
movq %r8, %r12
movl %r9d, %eax
jmp 0x3124e
movl %esi, (%rdi)
movq %r8, %rdi
movl %r9d, 0x4(%rsp)
decl %edx
je 0x3125f
movl (%r8), %esi
cmpl %esi, 0x18(%rsp)
jb 0x31138
andl $0x0, (%r12)
andl $0x0, (%rdi)
movq 0x38(%rsp), %rdi
incl 0x18(%rdi)
movq 0x30(%rsp), %rax
movq %rax, (%rdi)
movl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
cmpl 0xc(%rdi), %eax
jne 0x31289
callq 0x2fd91
movq 0x10(%rsp), %r14
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x3
popq %r11
cmpl %r8d, %ecx
jae 0x310ce
movl %ecx, %eax
movq %rbx, %rdx
subq %rax, %rdx
movb (%rdx), %dl
cmpb (%rbx), %dl
jne 0x310ce
negq %rax
pushq $0x10
popq %rdx
pushq $0xc
jmp 0x3103c
movl %r9d, (%r12)
movl 0x4(%r8), %eax
movl %eax, (%rdi)
jmp 0x31267