// File: sisong[P]ApkDiffPatch/lzma/C/LzFindMt.c
// Function: MixMatches4
static UInt32 * MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d)
{
  UInt32 h2, h3, /* h4, */ c2, c3 /* , c4 */;
  UInt32 *hash = p->hash;
  const Byte *cur = p->pointerToCurPos;
  const UInt32 m = p->lzPos;
  MT_HASH3_CALC
  // MT_HASH4_CALC
  c2 = hash[h2];
  c3 = (hash + kFix3HashSize)[h3];
  // c4 = (hash + kFix4HashSize)[h4];
  
  hash[h2] = m;
  (hash + kFix3HashSize)[h3] = m;
  // (hash + kFix4HashSize)[h4] = m;

  // #define BT5_USE_H2
  // #ifdef BT5_USE_H2
  if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0])
  {
    d[1] = m - c2 - 1;
    if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2])
    {
      // d[0] = (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) ? 4 : 3;
      // return d + 2;

      if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3])
      {
        d[0] = 4;
        return d + 2;
      }
      d[0] = 3;
      d += 2;

      #ifdef BT5_USE_H4
      if (c4 >= matchMinPos)
        if (
          cur[(ptrdiff_t)c4 - (ptrdiff_t)m]     == cur[0] &&
          cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3]
          )
      {
        *d++ = 4;
        *d++ = m - c4 - 1;
      }
      #endif
      return d;
    }
    d[0] = 2;
    d += 2;
  }
  // #endif
  
  if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0])
  {
    d[1] = m - c3 - 1;
    if (cur[(ptrdiff_t)c3 - (ptrdiff_t)m + 3] == cur[3])
    {
      d[0] = 4;
      return d + 2;
    }
    d[0] = 3;
    d += 2;
  }

  #ifdef BT5_USE_H4
  if (c4 >= matchMinPos)
    if (
      cur[(ptrdiff_t)c4 - (ptrdiff_t)m]     == cur[0] &&
      cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3]
      )
    {
      *d++ = 4;
      *d++ = m - c4 - 1;
    }
  #endif
  
  return d;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x40(%rbp), %rcx
movzbl (%rcx), %ecx
movl (%rax,%rcx,4), %eax
movq -0x40(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
xorl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0x24(%rbp)
movl -0x48(%rbp), %eax
movq -0x40(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movl -0x28(%rbp), %ecx
movl 0x1000(%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movl -0x44(%rbp), %edx
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %edx
movq -0x38(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %edx, 0x1000(%rax,%rcx,4)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jb 0x76d1a
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl -0x44(%rbp), %edx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x40(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x76d1a
movl -0x44(%rbp), %ecx
subl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl -0x44(%rbp), %edx
subq %rdx, %rcx
movzbl 0x2(%rax,%rcx), %eax
movq -0x40(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x76d04
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl -0x44(%rbp), %edx
subq %rdx, %rcx
movzbl 0x3(%rax,%rcx), %eax
movq -0x40(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
cmpl %ecx, %eax
jne 0x76ce1
movq -0x20(%rbp), %rax
movl $0x4, (%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0x76da2
movq -0x20(%rbp), %rax
movl $0x3, (%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x76da2
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x14(%rbp), %eax
jb 0x76d9a
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %ecx
movl -0x44(%rbp), %edx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x40(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x76d9a
movl -0x44(%rbp), %ecx
subl -0x30(%rbp), %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %ecx
movl -0x44(%rbp), %edx
subq %rdx, %rcx
movzbl 0x3(%rax,%rcx), %eax
movq -0x40(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
cmpl %ecx, %eax
jne 0x76d84
movq -0x20(%rbp), %rax
movl $0x4, (%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0x76da2
movq -0x20(%rbp), %rax
movl $0x3, (%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax,%rax)