// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/lz77.c
// Function: TryGetFromLongestMatchCache
static int TryGetFromLongestMatchCache(ZopfliBlockState* s,
    size_t pos, size_t* limit,
    unsigned short* sublen, unsigned short* distance, unsigned short* length) {
  /* The LMC cache starts at the beginning of the block rather than the
     beginning of the whole array. */
  size_t lmcpos = pos - s->blockstart;

  /* Length > 0 and dist 0 is invalid combination, which indicates on purpose
     that this cache value is not filled in yet. */
  unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
      s->lmc->dist[lmcpos] != 0);
  unsigned char limit_ok_for_cache = cache_available &&
      (*limit == ZOPFLI_MAX_MATCH || s->lmc->length[lmcpos] <= *limit ||
      (sublen && ZopfliMaxCachedSublen(s->lmc,
          lmcpos, s->lmc->length[lmcpos]) >= *limit));

  if (s->lmc && limit_ok_for_cache && cache_available) {
    if (!sublen || s->lmc->length[lmcpos]
        <= ZopfliMaxCachedSublen(s->lmc, lmcpos, s->lmc->length[lmcpos])) {
      *length = s->lmc->length[lmcpos];
      if (*length > *limit) *length = *limit;
      if (sublen) {
        ZopfliCacheToSublen(s->lmc, lmcpos, *length, sublen);
        *distance = sublen[*length];
        if (*limit == ZOPFLI_MAX_MATCH && *length >= ZOPFLI_MIN_MATCH) {
          assert(sublen[*length] == s->lmc->dist[lmcpos]);
        }
      } else {
        *distance = s->lmc->dist[lmcpos];
      }
      return 1;
    }
    /* Can't use much of the cache, since the "sublens" need to be calculated,
       but at  least we already know when to stop. */
    *limit = s->lmc->length[lmcpos];
  }

  return 0;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %r9, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq 0x10(%rcx), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x8(%rcx)
movb %al, 0x15(%rsp)
je 0x846f
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, 0x14(%rsp)
je 0x8467
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
setne %al
movb %al, 0x14(%rsp)
movb 0x14(%rsp), %al
movb %al, 0x15(%rsp)
movb 0x15(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, 0x17(%rsp)
movzbl 0x17(%rsp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x13(%rsp)
je 0x8524
movq 0x38(%rsp), %rcx
movb $0x1, %al
cmpq $0x102, (%rcx)          # imm = 0x102
movb %al, 0x12(%rsp)
je 0x851c
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
movq 0x38(%rsp), %rdx
movb $0x1, %al
cmpq (%rdx), %rcx
movb %al, 0x12(%rsp)
jbe 0x851c
xorl %eax, %eax
cmpq $0x0, 0x30(%rsp)
movb %al, 0x11(%rsp)
je 0x8514
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rsp), %rsi
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %edx
callq 0x25f0
movl %eax, %eax
movq 0x38(%rsp), %rcx
cmpq (%rcx), %rax
setae %al
movb %al, 0x11(%rsp)
movb 0x11(%rsp), %al
movb %al, 0x12(%rsp)
movb 0x12(%rsp), %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, 0x16(%rsp)
movq 0x48(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x86f1
movzbl 0x16(%rsp), %eax
cmpl $0x0, %eax
je 0x86f1
movzbl 0x17(%rsp), %eax
cmpl $0x0, %eax
je 0x86f1
cmpq $0x0, 0x30(%rsp)
je 0x85b6
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, 0xc(%rsp)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rsp), %rsi
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %edx
callq 0x25f0
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
ja 0x86d2
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movw (%rax,%rcx,2), %cx
movq 0x20(%rsp), %rax
movw %cx, (%rax)
movq 0x20(%rsp), %rax
movzwl (%rax), %eax
movq 0x38(%rsp), %rcx
cmpq (%rcx), %rax
jbe 0x85f8
movq 0x38(%rsp), %rax
movq (%rax), %rax
movw %ax, %cx
movq 0x20(%rsp), %rax
movw %cx, (%rax)
cmpq $0x0, 0x30(%rsp)
je 0x86aa
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
movzwl (%rax), %eax
movl %eax, %edx
movq 0x30(%rsp), %rcx
callq 0x2660
movq 0x30(%rsp), %rax
movq 0x20(%rsp), %rcx
movzwl (%rcx), %ecx
movw (%rax,%rcx,2), %cx
movq 0x28(%rsp), %rax
movw %cx, (%rax)
movq 0x38(%rsp), %rax
cmpq $0x102, (%rax)          # imm = 0x102
jne 0x86a8
movq 0x20(%rsp), %rax
movzwl (%rax), %eax
cmpl $0x3, %eax
jl 0x86a8
movq 0x30(%rsp), %rax
movq 0x20(%rsp), %rcx
movzwl (%rcx), %ecx
movzwl (%rax,%rcx,2), %eax
movq 0x48(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq 0x18(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jne 0x8687
jmp 0x86a6
leaq 0x5504(%rip), %rdi      # 0xdb92
leaq 0x5292(%rip), %rsi      # 0xd927
movl $0xb1, %edx
leaq 0x5519(%rip), %rcx      # 0xdbba
callq 0x10b0
jmp 0x86a8
jmp 0x86c8
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x18(%rsp), %rcx
movw (%rax,%rcx,2), %cx
movq 0x28(%rsp), %rax
movw %cx, (%rax)
movl $0x1, 0x54(%rsp)
jmp 0x86f9
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)