// File: /workspace/github_c_makefile_star2_O1/imaya[P]zopfli-for-emscripten/cache.c
// Function: ZopfliCacheToSublen
void ZopfliCacheToSublen(const ZopfliLongestMatchCache* lmc,
                         size_t pos, size_t length,
                         unsigned short* sublen) {
  size_t i, j;
  unsigned maxlength = ZopfliMaxCachedSublen(lmc, pos, length);
  unsigned prevlength = 0;
  unsigned char* cache;
#if ZOPFLI_CACHE_LENGTH == 0
  return;
#endif
  if (length < 3) return;
  cache = &lmc->sublen[ZOPFLI_CACHE_LENGTH * pos * 3];
  for (j = 0; j < ZOPFLI_CACHE_LENGTH; j++) {
    unsigned length = cache[j * 3] + 3;
    unsigned dist = cache[j * 3 + 1] + 256 * cache[j * 3 + 2];
    for (i = prevlength; i <= length; i++) {
      sublen[i] = dist;
    }
    if (length == maxlength) break;
    prevlength = length + 1;
  }
}

// Assembly:
pushq %rbp
pushq %rbx
movq 0x10(%rdi), %rax
leaq (%rsi,%rsi,2), %rsi
leaq (%rax,%rsi,8), %rax
cmpb $0x0, 0x1(%rax)
jne 0x2147
cmpb $0x0, 0x2(%rax)
je 0x244e
movzbl 0x15(%rax), %esi
addl $0x3, %esi
cmpq $0x3, %rdx
jb 0x244b
addq $0xe, %rcx
xorl %edx, %edx
movdqa 0x808a(%rip), %xmm0     # 0xa1f0
movdqa 0x8092(%rip), %xmm1     # 0xa200
movdqa 0x809a(%rip), %xmm2     # 0xa210
movdqa 0x80a2(%rip), %xmm3     # 0xa220
movdqa 0x80aa(%rip), %xmm4     # 0xa230
pcmpeqd %xmm5, %xmm5
xorl %r10d, %r10d
leaq (%rdx,%rdx,2), %r9
movzbl (%rax,%r9), %edi
leal 0x3(%rdi), %r8d
cmpl %r8d, %r10d
ja 0x2433
movzwl 0x1(%rax,%r9), %r9d
movl %r10d, %r11d
movl %edi, %ebx
subq %r11, %rbx
leaq 0xb(%rbx), %r10
andq $-0x8, %r10
addq $0x3, %rbx
movq %rbx, %xmm6
pshufd $0x44, %xmm6, %xmm6     # xmm6 = xmm6[0,1,0,1]
leaq (%rcx,%r11,2), %r11
pxor %xmm4, %xmm6
xorl %ebx, %ebx
movq %rbx, %xmm7
pshufd $0x44, %xmm7, %xmm7     # xmm7 = xmm7[0,1,0,1]
movdqa %xmm7, %xmm8
por %xmm3, %xmm8
pxor %xmm4, %xmm8
movdqa %xmm8, %xmm10
pcmpgtd %xmm6, %xmm10
pshufd $0xa0, %xmm10, %xmm9    # xmm9 = xmm10[0,0,2,2]
pshuflw $0xe8, %xmm9, %xmm11    # xmm11 = xmm9[0,2,2,3,4,5,6,7]
pcmpeqd %xmm6, %xmm8
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pshuflw $0xe8, %xmm8, %xmm12    # xmm12 = xmm8[0,2,2,3,4,5,6,7]
pand %xmm11, %xmm12
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
pshuflw $0xe8, %xmm10, %xmm11   # xmm11 = xmm10[0,2,2,3,4,5,6,7]
por %xmm12, %xmm11
pxor %xmm5, %xmm11
packssdw %xmm11, %xmm11
movd %xmm11, %ebp
testb $0x1, %bpl
je 0x2242
movw %r9w, -0xe(%r11,%rbx,2)
pand %xmm9, %xmm8
por %xmm10, %xmm8
packssdw %xmm8, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm8
movd %xmm8, %ebp
shrl $0x10, %ebp
testb $0x1, %bpl
je 0x226f
movw %r9w, -0xc(%r11,%rbx,2)
movdqa %xmm7, %xmm9
por %xmm2, %xmm9
pxor %xmm4, %xmm9
movdqa %xmm9, %xmm10
pcmpgtd %xmm6, %xmm10
pshufd $0xa0, %xmm10, %xmm8    # xmm8 = xmm10[0,0,2,2]
pcmpeqd %xmm6, %xmm9
pshufd $0xf5, %xmm9, %xmm9     # xmm9 = xmm9[1,1,3,3]
movdqa %xmm9, %xmm11
pand %xmm8, %xmm11
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
por %xmm10, %xmm11
packssdw %xmm11, %xmm11
pxor %xmm5, %xmm11
packssdw %xmm11, %xmm11
pextrw $0x2, %xmm11, %ebp
testb $0x1, %bpl
je 0x22cf
movw %r9w, -0xa(%r11,%rbx,2)
pshufhw $0x84, %xmm8, %xmm8     # xmm8 = xmm8[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm9, %xmm9     # xmm9 = xmm9[0,1,2,3,4,5,4,6]
pand %xmm8, %xmm9
pshufhw $0x84, %xmm10, %xmm8    # xmm8 = xmm10[0,1,2,3,4,5,4,6]
por %xmm9, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm8
pextrw $0x3, %xmm8, %ebp
testb $0x1, %bpl
je 0x2307
movw %r9w, -0x8(%r11,%rbx,2)
movdqa %xmm7, %xmm8
por %xmm1, %xmm8
pxor %xmm4, %xmm8
movdqa %xmm8, %xmm10
pcmpgtd %xmm6, %xmm10
pshufd $0xa0, %xmm10, %xmm9    # xmm9 = xmm10[0,0,2,2]
pshuflw $0xe8, %xmm9, %xmm11    # xmm11 = xmm9[0,2,2,3,4,5,6,7]
pcmpeqd %xmm6, %xmm8
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pshuflw $0xe8, %xmm8, %xmm12    # xmm12 = xmm8[0,2,2,3,4,5,6,7]
pand %xmm11, %xmm12
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
pshuflw $0xe8, %xmm10, %xmm11   # xmm11 = xmm10[0,2,2,3,4,5,6,7]
por %xmm12, %xmm11
pxor %xmm5, %xmm11
packssdw %xmm11, %xmm11
pextrw $0x4, %xmm11, %ebp
testb $0x1, %bpl
je 0x236f
movw %r9w, -0x6(%r11,%rbx,2)
pand %xmm9, %xmm8
por %xmm10, %xmm8
packssdw %xmm8, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm8
pextrw $0x5, %xmm8, %ebp
testb $0x1, %bpl
je 0x239a
movw %r9w, -0x4(%r11,%rbx,2)
por %xmm0, %xmm7
pxor %xmm4, %xmm7
movdqa %xmm7, %xmm9
pcmpgtd %xmm6, %xmm9
pshufd $0xa0, %xmm9, %xmm8     # xmm8 = xmm9[0,0,2,2]
pcmpeqd %xmm6, %xmm7
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
movdqa %xmm7, %xmm10
pand %xmm8, %xmm10
pshufd $0xf5, %xmm9, %xmm9     # xmm9 = xmm9[1,1,3,3]
por %xmm9, %xmm10
packssdw %xmm10, %xmm10
pxor %xmm5, %xmm10
packssdw %xmm10, %xmm10
pextrw $0x6, %xmm10, %ebp
testb $0x1, %bpl
je 0x23f1
movw %r9w, -0x2(%r11,%rbx,2)
pshufhw $0x84, %xmm8, %xmm8     # xmm8 = xmm8[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm7, %xmm7     # xmm7 = xmm7[0,1,2,3,4,5,4,6]
pand %xmm8, %xmm7
pshufhw $0x84, %xmm9, %xmm8     # xmm8 = xmm9[0,1,2,3,4,5,4,6]
por %xmm7, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm7
pextrw $0x7, %xmm7, %ebp
testb $0x1, %bpl
je 0x2426
movw %r9w, (%r11,%rbx,2)
addq $0x8, %rbx
cmpq %rbx, %r10
jne 0x21d1
cmpl %esi, %r8d
je 0x244b
addl $0x4, %edi
incq %rdx
movl %edi, %r10d
cmpq $0x8, %rdx
jne 0x218d
popq %rbx
popq %rbp
retq
xorl %esi, %esi
jmp 0x214e
nopl (%rax)