// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movq %rsi, %r14
movl 0x14(%rdi), %r13d
cmpq $0x3, %r13
ja 0x39283
callq 0x38071
jmp 0x395a2
movq (%rdi), %r10
movzbl (%r10), %eax
movzbl 0x1(%r10), %edx
xorl 0x78(%rdi,%rax,4), %edx
movzbl 0x2(%r10), %eax
shll $0x8, %eax
xorl %edx, %eax
andl $0x3ff, %edx            # imm = 0x3FF
movzwl %ax, %r8d
movzbl 0x3(%r10), %ecx
movl 0x78(%rdi,%rcx,4), %r9d
shll $0x5, %r9d
xorl %eax, %r9d
andl 0x38(%rdi), %r9d
movq 0x28(%rdi), %r11
movl 0x8(%rdi), %ebx
movl %ebx, %eax
subl (%r11,%rdx,4), %eax
movl %ebx, %ecx
subl 0x1000(%r11,%r8,4), %ecx
movl 0x41000(%r11,%r9,4), %esi
movl %ebx, (%r11,%rdx,4)
movl %ebx, 0x1000(%r11,%r8,4)
movl %ebx, 0x41000(%r11,%r9,4)
movq %rdi, 0x10(%rsp)
movl 0x1c(%rdi), %r8d
cmpl %r8d, %ebx
cmovbl %ebx, %r8d
cmpl %r8d, %eax
jae 0x39341
movl %eax, %edx
movq %r10, %r9
subq %rdx, %r9
movb (%r9), %r9b
cmpb (%r10), %r9b
jne 0x39341
negq %rdx
movl $0x2, (%r14)
decl %eax
movl %eax, 0x4(%r14)
leaq 0x8(%r14), %rdi
movb 0x2(%r10,%rdx), %al
cmpb 0x2(%r10), %al
jne 0x395b4
movq %rdi, %r14
movq 0x10(%rsp), %rbx
jmp 0x3937f
movl $0x3, %eax
cmpl %r8d, %ecx
jae 0x393f1
movl %ecx, %edx
movq %r10, %r8
subq %rdx, %r8
movb (%r8), %r8b
cmpb (%r10), %r8b
movq 0x10(%rsp), %rbx
jne 0x393fd
negq %rdx
movl $0x8, %eax
movl $0x4, %r8d
decl %ecx
movl %ecx, (%r14,%r8)
addq %rax, %r14
leaq 0x3(%r10), %rax
leaq (%r10,%r13), %rcx
movq %r13, %r8
addq $-0x3, %r8
movb (%rax,%rdx), %r9b
cmpb (%rax), %r9b
jne 0x393a2
incq %rax
decq %r8
jne 0x3938e
movq %rcx, %rax
subl %r10d, %eax
movl %eax, -0x8(%r14)
cmpl %eax, %r13d
jne 0x393fd
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 0x395a2
movq %rbx, %rdi
jmp 0x3959d
movq %r14, 0x8(%rsp)
movq 0x10(%rsp), %rbx
jmp 0x39402
movq %r14, 0x8(%rsp)
leaq 0x1(%r10), %rcx
movq %rcx, 0x48(%rsp)
movl 0x8(%rbx), %edx
movl 0x18(%rbx), %edi
movq 0x30(%rbx), %r8
movl 0x1c(%rbx), %r11d
leaq (%r8,%rdi,8), %rcx
movq %rcx, 0x20(%rsp)
movq %rdi, 0x50(%rsp)
movq %r8, 0x40(%rsp)
leaq (%r8,%rdi,8), %r9
addq $0x4, %r9
xorl %ecx, %ecx
movl %edx, 0x3c(%rsp)
movl %r11d, 0x38(%rsp)
subl %r11d, %edx
cmovbl %ecx, %edx
movl %edx, 0x34(%rsp)
cmpl %esi, %edx
jae 0x3956f
movl 0x3c(%rbx), %edx
movl $0x0, 0x1c(%rsp)
xorl %ebx, %ebx
movl 0x3c(%rsp), %ecx
movl %ecx, %ebp
subl %esi, %ebp
movq 0x50(%rsp), %rdi
movq %rdi, %rcx
subq %rbp, %rcx
cmpl %edi, %ebp
movl $0x0, %r12d
cmoval 0x38(%rsp), %r12d
addq %rcx, %r12
movq %r10, %rcx
subq %rbp, %rcx
movl 0x1c(%rsp), %edi
cmpl %ebx, %edi
movl %ebx, %r11d
cmovbl %edi, %r11d
movq 0x40(%rsp), %rdi
leaq (%rdi,%r12,8), %r8
movb (%rcx,%r11), %r15b
cmpb (%r10,%r11), %r15b
jne 0x39532
movq %r9, 0x28(%rsp)
leal 0x1(%r11), %r15d
movq %r13, %rdi
movq %r13, %r9
cmpl %edi, %r15d
je 0x394f7
movl %r15d, %r14d
movb (%rcx,%r14), %dil
movl %r15d, %r13d
cmpb (%r10,%r14), %dil
jne 0x394f7
addl $0x2, %r11d
movq %r9, %r15
cmpl %r11d, %r15d
je 0x394f4
movl %r11d, %edi
movb (%rcx,%rdi), %r14b
incl %r11d
cmpb (%r10,%rdi), %r14b
je 0x394d7
decl %r11d
movl %r11d, %r13d
jmp 0x394f7
movl %r15d, %r13d
cmpl %r13d, %eax
jae 0x39527
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 %r9d, %r13d
je 0x395f3
movl %r13d, %eax
movl %r13d, %r11d
movq %r9, %r13
movq 0x28(%rsp), %r9
movl %r11d, %edi
movb (%rcx,%rdi), %cl
cmpb (%r10,%rdi), %cl
jae 0x39553
movq 0x20(%rsp), %rcx
movl %esi, (%rcx)
addq $0x4, %r8
movq %r8, 0x20(%rsp)
movl %r11d, %ebx
jmp 0x3955e
movl %esi, (%r9)
movq %r8, %r9
movl %r11d, 0x1c(%rsp)
decl %edx
je 0x3956f
movl (%r8), %esi
cmpl %esi, 0x34(%rsp)
jb 0x3945e
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
movl %eax, (%r9)
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 0x395a2
callq 0x38085
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, 0x8(%rsp)
movl $0x3, %eax
cmpl %r8d, %ecx
movq 0x10(%rsp), %rbx
jae 0x39402
movl %ecx, %edx
movq %r10, %r8
subq %rdx, %r8
movb (%r8), %r8b
cmpb (%r10), %r8b
jne 0x39402
negq %rdx
movl $0x10, %eax
movl $0xc, %r8d
jmp 0x39376
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
movl 0x4(%r8), %eax
movq 0x28(%rsp), %rcx
movl %eax, (%rcx)
jmp 0x3957b