// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/lz77.c
// Function: StoreInLongestMatchCache
static void StoreInLongestMatchCache(ZopfliBlockState* s,
    size_t pos, size_t limit,
    const 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);

  if (s->lmc && limit == ZOPFLI_MAX_MATCH && sublen && !cache_available) {
    assert(s->lmc->length[lmcpos] == 1 && s->lmc->dist[lmcpos] == 0);
    s->lmc->dist[lmcpos] = length < ZOPFLI_MIN_MATCH ? 0 : distance;
    s->lmc->length[lmcpos] = length < ZOPFLI_MIN_MATCH ? 0 : length;
    assert(!(s->lmc->length[lmcpos] == 1 && s->lmc->dist[lmcpos] == 0));
    ZopfliSublenToCache(sublen, lmcpos, length, s->lmc);
  }
}

// Assembly:
subq $0x68, %rsp
movl %r8d, 0x14(%rsp)
movq %rcx, %rax
movl 0x14(%rsp), %ecx
movq %rax, 0x18(%rsp)
movq %rdx, %rax
movq 0x18(%rsp), %rdx
movq %rax, 0x20(%rsp)
movq %rsi, %rax
movq 0x20(%rsp), %rsi
movq %rax, 0x28(%rsp)
movq %rdi, %r8
movq 0x28(%rsp), %rdi
movw %r9w, %ax
movq %r8, 0x60(%rsp)
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movw %cx, 0x46(%rsp)
movw %ax, 0x44(%rsp)
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
subq 0x10(%rcx), %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x8(%rcx)
movb %al, 0x36(%rsp)
je 0x8a26
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movzwl (%rax,%rcx,2), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, 0x13(%rsp)
je 0x8a1e
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
setne %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
movb %al, 0x36(%rsp)
movb 0x36(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, 0x37(%rsp)
movq 0x60(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x8ba3
cmpq $0x102, 0x50(%rsp)      # imm = 0x102
jne 0x8ba3
cmpq $0x0, 0x48(%rsp)
je 0x8ba3
cmpb $0x0, 0x37(%rsp)
jne 0x8ba3
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x1, %eax
jne 0x8aa0
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jne 0x8aa0
jmp 0x8abf
leaq 0x518f(%rip), %rdi      # 0xdc36
leaq 0x4e79(%rip), %rsi      # 0xd927
movl $0xd2, %edx
leaq 0x51b5(%rip), %rcx      # 0xdc6f
callq 0x10b0
movzwl 0x44(%rsp), %eax
cmpl $0x3, %eax
jge 0x8ad1
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x8ada
movzwl 0x46(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movw %ax, %dx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movzwl 0x44(%rsp), %eax
cmpl $0x3, %eax
jge 0x8b09
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x8b12
movzwl 0x44(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movw %ax, %dx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x1, %eax
jne 0x8b63
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
je 0x8b65
jmp 0x8b84
leaq 0x517d(%rip), %rdi      # 0xdce9
leaq 0x4db4(%rip), %rsi      # 0xd927
movl $0xd5, %edx
leaq 0x50f0(%rip), %rcx      # 0xdc6f
callq 0x10b0
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rsi
movzwl 0x44(%rsp), %eax
movl %eax, %edx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rcx
callq 0x23f0
addq $0x68, %rsp
retq
nopl (%rax,%rax)