// File: 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
movq %rsp, %rbp
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, -0x98(%rbp)
movq %rsi, -0xa0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0xe8(%rbp)
cmpl $0x4, -0xe8(%rbp)
jae 0x73440
movq -0xa8(%rbp), %rdi
callq 0x707d0
movq -0xa0(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x73cbf
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0xa8(%rbp), %rax
movq -0xe0(%rbp), %rcx
movzbl (%rcx), %ecx
movl 0x78(%rax,%rcx,4), %eax
movq -0xe0(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
xorl %ecx, %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0xb0(%rbp)
movq -0xe0(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
xorl -0xec(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0xb4(%rbp)
movl -0xec(%rbp), %eax
movq -0xa8(%rbp), %rcx
movq -0xe0(%rbp), %rdx
movzbl 0x3(%rdx), %edx
movl 0x78(%rcx,%rdx,4), %ecx
shll $0x5, %ecx
xorl %ecx, %eax
movq -0xa8(%rbp), %rcx
andl 0x38(%rcx), %eax
movl %eax, -0xd4(%rbp)
movq -0xa8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
movq -0xd0(%rbp), %rcx
movl -0xb0(%rbp), %edx
subl (%rcx,%rdx,4), %eax
movl %eax, -0xb8(%rbp)
movl -0xc0(%rbp), %eax
movq -0xd0(%rbp), %rcx
movl -0xb4(%rbp), %edx
subl 0x1000(%rcx,%rdx,4), %eax
movl %eax, -0xbc(%rbp)
movq -0xd0(%rbp), %rax
movl -0xd4(%rbp), %ecx
movl 0x41000(%rax,%rcx,4), %eax
movl %eax, -0xe4(%rbp)
movl -0xc0(%rbp), %edx
movq -0xd0(%rbp), %rax
movl -0xb0(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0xc0(%rbp), %edx
movq -0xd0(%rbp), %rax
movl -0xb4(%rbp), %ecx
movl %edx, 0x1000(%rax,%rcx,4)
movl -0xc0(%rbp), %edx
movq -0xd0(%rbp), %rax
movl -0xd4(%rbp), %ecx
movl %edx, 0x41000(%rax,%rcx,4)
movq -0xa8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xac(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x735d2
movl -0xc0(%rbp), %eax
movl %eax, -0xac(%rbp)
movl $0x3, -0xc4(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x736e4
movq -0xe0(%rbp), %rax
movl -0xb8(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0xe0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x736e4
movq -0xa0(%rbp), %rax
movl $0x2, (%rax)
movl -0xb8(%rbp), %ecx
subl $0x1, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xa0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xa0(%rbp)
movq -0xe0(%rbp), %rax
movl -0xb8(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl 0x2(%rax,%rcx), %eax
movq -0xe0(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x73674
jmp 0x736e2
movl -0xbc(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x736db
movq -0xe0(%rbp), %rax
movl -0xbc(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0xe0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x736db
movl -0xbc(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xa0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xa0(%rbp)
jmp 0x736e0
jmp 0x738e6
jmp 0x736e2
jmp 0x73752
movl -0xbc(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x7374b
movq -0xe0(%rbp), %rax
movl -0xbc(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0xe0(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x7374b
movl -0xbc(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xa0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xa0(%rbp)
jmp 0x73750
jmp 0x738e6
jmp 0x73752
movl -0xb8(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0xe0(%rbp), %rax
movl -0xc4(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x100(%rbp)
movq -0xe0(%rbp), %rax
movl -0xe8(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rax
cmpq -0x108(%rbp), %rax
je 0x737dc
movq -0x100(%rbp), %rax
movq -0xf8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x100(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x737c6
jmp 0x737dc
jmp 0x737c8
movq -0x100(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x100(%rbp)
jmp 0x73794
movq -0x100(%rbp), %rax
movq -0xe0(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, -0x8(%rax)
movl -0xc4(%rbp), %eax
cmpl -0xe8(%rbp), %eax
jne 0x738e4
movl -0xe8(%rbp), %edi
movl -0xe4(%rbp), %esi
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %edx
movq -0xa8(%rbp), %rax
movq (%rax), %rcx
movq -0xa8(%rbp), %rax
movq 0x30(%rax), %r8
movq -0xa8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %r9d
movq -0xa8(%rbp), %rax
movl 0x1c(%rax), %r10d
movq -0xa8(%rbp), %rax
movl 0x3c(%rax), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x70db0
movq -0xa8(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0xa8(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x10c(%rbp), %eax
movq -0xa8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x738d1
movq -0xa8(%rbp), %rdi
callq 0x70830
movq -0xa0(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x73cbf
jmp 0x738e6
movl -0xe8(%rbp), %ebx
movl -0xe4(%rbp), %r11d
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %r10d
movq -0xa8(%rbp), %rax
movq (%rax), %r9
movq -0xa8(%rbp), %rax
movq 0x30(%rax), %r8
movq -0xa8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %edi
movq -0xa8(%rbp), %rax
movl 0x1c(%rax), %esi
movq -0xa8(%rbp), %rax
movl 0x3c(%rax), %edx
movq -0xa0(%rbp), %rcx
movl -0xc4(%rbp), %eax
movl %ebx, -0x14(%rbp)
movl %r11d, -0x18(%rbp)
movl %r10d, -0x1c(%rbp)
movq %r9, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
movl %esi, -0x3c(%rbp)
movl %edx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x1c(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
ja 0x739ba
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x73c28
jmp 0x739c8
movl -0x1c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x38(%rbp), %rax
movl -0x70(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x118(%rbp)
movl -0x70(%rbp), %eax
cmpq -0x38(%rbp), %rax
jbe 0x73a01
movl -0x3c(%rbp), %eax
movl %eax, -0x124(%rbp)
jmp 0x73a0b
xorl %eax, %eax
movl %eax, -0x124(%rbp)
jmp 0x73a0b
movq -0x120(%rbp), %rax
movq -0x118(%rbp), %rcx
movl -0x124(%rbp), %edx
movl %edx, %edx
addq %rdx, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movl -0x70(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x68(%rbp), %eax
jae 0x73a5a
movl -0x64(%rbp), %eax
movl %eax, -0x128(%rbp)
jmp 0x73a63
movl -0x68(%rbp), %eax
movl %eax, -0x128(%rbp)
movl -0x128(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movl -0x84(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x28(%rbp), %rcx
movl -0x84(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x73b86
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
cmpl -0x14(%rbp), %eax
je 0x73b0f
movq -0x80(%rbp), %rax
movl -0x84(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x28(%rbp), %rcx
movl -0x84(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x73b0f
jmp 0x73ad5
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
cmpl -0x14(%rbp), %eax
je 0x73b0d
movq -0x80(%rbp), %rax
movl -0x84(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x28(%rbp), %rcx
movl -0x84(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x73b0b
jmp 0x73b0d
jmp 0x73ad5
jmp 0x73b0f
movl -0x4c(%rbp), %eax
cmpl -0x84(%rbp), %eax
jae 0x73b84
movl -0x84(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x84(%rbp), %ecx
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x48(%rbp)
movl %ecx, (%rax)
movl -0x70(%rbp), %ecx
subl $0x1, %ecx
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x48(%rbp)
movl %ecx, (%rax)
movl -0x84(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x73b82
movl -0x88(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, (%rax)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x73c44
jmp 0x73b84
jmp 0x73b86
movq -0x80(%rbp), %rax
movl -0x84(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x28(%rbp), %rcx
movl -0x84(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jge 0x73bd0
movl -0x18(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, (%rax)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x78(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x60(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x73bf3
movl -0x18(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x40(%rbp), %ecx
addl $-0x1, %ecx
movl %ecx, -0x40(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x129(%rbp)
je 0x73c18
movl -0x6c(%rbp), %eax
cmpl -0x18(%rbp), %eax
setb %al
movb %al, -0x129(%rbp)
movb -0x129(%rbp), %al
testb $0x1, %al
jne 0x739c8
jmp 0x73c28
movq -0x60(%rbp), %rax
movl $0x0, (%rax)
movq -0x58(%rbp), %rax
movl $0x0, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa8(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0xa8(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
movl -0x110(%rbp), %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x110(%rbp), %eax
movq -0xa8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x73cb1
movq -0xa8(%rbp), %rdi
callq 0x70830
movq -0xa0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %rbp
retq