// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %rdi, %r14
movl 0x14(%rdi), %edi
cmpq $0x3, %rdi
ja 0x396e9
movq %r14, %rdi
callq 0x383da
jmp 0x39a19
movq (%r14), %r10
movzbl (%r10), %eax
movzbl 0x1(%r10), %ecx
xorl 0x78(%r14,%rax,4), %ecx
movzbl 0x2(%r10), %eax
shll $0x8, %eax
xorl %ecx, %eax
andl $0x3ff, %ecx            # imm = 0x3FF
movzwl %ax, %r8d
movzbl 0x3(%r10), %edx
movl 0x78(%r14,%rdx,4), %r9d
shll $0x5, %r9d
xorl %eax, %r9d
andl 0x38(%r14), %r9d
movq 0x28(%r14), %r11
movl 0x8(%r14), %ebx
movl %ebx, %eax
subl (%r11,%rcx,4), %eax
movl %ebx, %edx
subl 0x1000(%r11,%r8,4), %edx
movl 0x41000(%r11,%r9,4), %esi
movl %ebx, (%r11,%rcx,4)
movl %ebx, 0x1000(%r11,%r8,4)
movl %ebx, 0x41000(%r11,%r9,4)
movl 0x1c(%r14), %ecx
cmpl %ecx, %ebx
cmovbl %ebx, %ecx
cmpl %ecx, %eax
jae 0x397a1
movl %eax, %r8d
movq %r10, %r9
subq %r8, %r9
movb (%r9), %r9b
cmpb (%r10), %r9b
jne 0x397a1
negq %r8
movl $0x2, (%r15)
leal -0x1(%rax), %r9d
movl %r9d, 0x4(%r15)
leaq 0x8(%r15), %r9
movb 0x2(%r10,%r8), %r8b
cmpb 0x2(%r10), %r8b
jne 0x39a2b
movl %eax, %edx
movq %r9, %r15
jmp 0x397d7
movl $0x3, %eax
cmpl %ecx, %edx
jae 0x39850
movl %edx, %ecx
movq %r10, %r8
subq %rcx, %r8
movb (%r8), %cl
cmpb (%r10), %cl
jne 0x39850
movl $0x8, %eax
movl $0x4, %ecx
leal -0x1(%rdx), %r8d
movl %r8d, (%r15,%rcx)
addq %rax, %r15
leaq 0x3(%r10), %rax
movl %edx, %ecx
negq %rcx
leaq (%r10,%rdi), %rdx
movq %rdi, %r8
addq $-0x3, %r8
movb (%rax,%rcx), %r9b
cmpb (%rax), %r9b
jne 0x397ff
incq %rax
decq %r8
jne 0x397eb
movq %rdx, %rax
subl %r10d, %eax
movl %eax, -0x8(%r15)
cmpl %eax, %edi
jne 0x39850
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 0x39a19
movq %r14, %rdi
jmp 0x39a14
movq %r15, %r9
leaq 0x1(%r10), %rcx
movq %rcx, 0x30(%rsp)
movl 0x8(%r14), %r8d
movl 0x18(%r14), %edx
movq 0x30(%r14), %r11
movl 0x1c(%r14), %ebx
leaq (%r11,%rdx,8), %rcx
movq %rcx, 0x10(%rsp)
movq %rdx, 0x40(%rsp)
movq %r11, 0x28(%rsp)
leaq (%r11,%rdx,8), %rdx
addq $0x4, %rdx
xorl %ecx, %ecx
movl %r8d, 0x24(%rsp)
movl %ebx, 0x20(%rsp)
subl %ebx, %r8d
cmovbl %ecx, %r8d
movl %r8d, 0x1c(%rsp)
cmpl %esi, %r8d
movq %r14, 0x38(%rsp)
jae 0x399e6
movl 0x3c(%r14), %r8d
movl $0x0, 0x8(%rsp)
xorl %r11d, %r11d
movq %r9, %r14
movl 0x24(%rsp), %ecx
movl %ecx, %r13d
subl %esi, %r13d
movq 0x40(%rsp), %r9
movq %r9, %rcx
subq %r13, %rcx
cmpl %r9d, %r13d
movl $0x0, %r12d
cmoval 0x20(%rsp), %r12d
addq %rcx, %r12
movq %r10, %rcx
subq %r13, %rcx
movl 0x8(%rsp), %r9d
cmpl %r11d, %r9d
movl %r11d, 0xc(%rsp)
cmovbl %r9d, %r11d
movq 0x28(%rsp), %r9
leaq (%r9,%r12,8), %r9
movb (%rcx,%r11), %bl
cmpb (%r10,%r11), %bl
jne 0x3999d
leal 0x1(%r11), %ebx
cmpl %edi, %ebx
je 0x3995e
movl %ebx, %ebp
movl %esi, 0x18(%rsp)
movq %rdi, %rsi
movq %r15, %rdi
movb (%rcx,%rbp), %r15b
cmpb (%r10,%rbp), %r15b
movq %rdi, %r15
movq %rsi, %rdi
movl 0x18(%rsp), %esi
jne 0x3995e
addl $0x2, %r11d
cmpl %r11d, %edi
je 0x3995c
movl %r11d, %ebx
movb (%rcx,%rbx), %bpl
incl %r11d
cmpb (%r10,%rbx), %bpl
je 0x3993f
decl %r11d
movl %r11d, %ebx
jmp 0x3995e
movl %edi, %ebx
cmpl %ebx, %eax
jae 0x3999a
movq 0x28(%rsp), %rax
movl (%rax,%r12,8), %eax
movl %ebx, (%r14)
decl %r13d
movl %r13d, 0x4(%r14)
addq $0x8, %r14
cmpl %edi, %ebx
jne 0x39998
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl 0x4(%r9), %eax
movl %eax, (%rdx)
xorl %ecx, %ecx
movl %ebx, %eax
movq %r14, %r15
movl 0xc(%rsp), %r11d
jmp 0x399d1
movl %ebx, %eax
movl %ebx, %r11d
movl %r11d, %ebx
movb (%rcx,%rbx), %cl
cmpb (%r10,%rbx), %cl
jae 0x399bb
movq 0x10(%rsp), %rcx
movl %esi, (%rcx)
addq $0x4, %r9
movq %r9, 0x10(%rsp)
jmp 0x399cc
movl %esi, (%rdx)
movq %r9, %rdx
movl %r11d, 0x8(%rsp)
movl 0xc(%rsp), %ecx
movl %ecx, %r11d
movl (%r9), %esi
movb $0x1, %cl
testb %cl, %cl
je 0x399f7
decl %r8d
je 0x399e9
cmpl %esi, 0x1c(%rsp)
jb 0x398be
jmp 0x399e9
movq %r9, %r14
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl %eax, (%rdx)
movq %r14, %r15
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 0x39a19
callq 0x383ee
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, %eax
cmpl %ecx, %edx
jae 0x39853
movl %edx, %ecx
movq %r10, %r8
subq %rcx, %r8
movb (%r8), %cl
cmpb (%r10), %cl
jne 0x39853
movl $0x10, %eax
movl $0xc, %ecx
jmp 0x397cc