// File: /workspace/github_c_makefile_star2_O2/madler[P]pigz/zopfli/src/zopfli/lz77.c
// Function: ZopfliCopyLZ77Store
void ZopfliCopyLZ77Store(
    const ZopfliLZ77Store* source, ZopfliLZ77Store* dest) {
  size_t i;
  size_t llsize = ZOPFLI_NUM_LL * CeilDiv(source->size, ZOPFLI_NUM_LL);
  size_t dsize = ZOPFLI_NUM_D * CeilDiv(source->size, ZOPFLI_NUM_D);
  ZopfliCleanLZ77Store(dest);
  ZopfliInitLZ77Store(source->data, dest);
  dest->litlens =
      (unsigned short*)malloc(sizeof(*dest->litlens) * source->size);
  dest->dists = (unsigned short*)malloc(sizeof(*dest->dists) * source->size);
  dest->pos = (size_t*)malloc(sizeof(*dest->pos) * source->size);
  dest->ll_symbol =
      (unsigned short*)malloc(sizeof(*dest->ll_symbol) * source->size);
  dest->d_symbol =
      (unsigned short*)malloc(sizeof(*dest->d_symbol) * source->size);
  dest->ll_counts = (size_t*)malloc(sizeof(*dest->ll_counts) * llsize);
  dest->d_counts = (size_t*)malloc(sizeof(*dest->d_counts) * dsize);

  /* Allocation failed. */
  if (!dest->litlens || !dest->dists) exit(-1);
  if (!dest->pos) exit(-1);
  if (!dest->ll_symbol || !dest->d_symbol) exit(-1);
  if (!dest->ll_counts || !dest->d_counts) exit(-1);

  dest->size = source->size;
  for (i = 0; i < source->size; i++) {
    dest->litlens[i] = source->litlens[i];
    dest->dists[i] = source->dists[i];
    dest->pos[i] = source->pos[i];
    dest->ll_symbol[i] = source->ll_symbol[i];
    dest->d_symbol[i] = source->d_symbol[i];
  }
  for (i = 0; i < llsize; i++) {
    dest->ll_counts[i] = source->ll_counts[i];
  }
  for (i = 0; i < dsize; i++) {
    dest->d_counts[i] = source->d_counts[i];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x10(%rdi), %rsi
leaq 0x11f(%rsi), %rax
movl $0x120, %ecx            # imm = 0x120
xorl %edx, %edx
divq %rcx
movq %rax, (%rsp)
addq $0x1f, %rsi
andq $-0x20, %rsi
movq %rsi, 0x8(%rsp)
movq %rbp, %rdi
callq 0x10a05
movq 0x18(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
andq $0x0, 0x10(%rbp)
movq %rax, 0x18(%rbp)
movups %xmm0, 0x28(%rbp)
movups %xmm0, 0x38(%rbp)
movq 0x10(%rbx), %r14
leaq (%r14,%r14), %r15
movq %r15, %rdi
callq 0x33d0
movq %rax, 0x20(%rsp)
movq %rax, (%rbp)
movq %r15, %rdi
callq 0x33d0
movq %rax, %r12
movq %rax, 0x8(%rbp)
movq %rbp, 0x10(%rsp)
movq %r14, 0x18(%rsp)
leaq (,%r14,8), %rdi
callq 0x33d0
movq %rax, %r13
movq %rax, 0x20(%rbp)
movq %r15, %rdi
callq 0x33d0
movq %rax, %r14
movq %rax, 0x28(%rbp)
movq %r15, %rdi
callq 0x33d0
movq %rax, %r15
movq %rax, 0x30(%rbp)
imulq $0x900, (%rsp), %rdi    # imm = 0x900
callq 0x33d0
movq %rax, %rbp
movq 0x10(%rsp), %rax
movq %rbp, 0x38(%rax)
movq 0x8(%rsp), %rax
leaq (,%rax,8), %rdi
callq 0x33d0
movq 0x20(%rsp), %r8
movq 0x10(%rsp), %rdx
movq %rax, 0x40(%rdx)
testq %r8, %r8
je 0x10c28
testq %r12, %r12
je 0x10c28
testq %r13, %r13
je 0x10c28
testq %r14, %r14
je 0x10c28
testq %r15, %r15
je 0x10c28
testq %rbp, %rbp
je 0x10c28
testq %rax, %rax
je 0x10c28
imulq $0x120, (%rsp), %rcx    # imm = 0x120
movq 0x18(%rsp), %rsi
movq %rsi, 0x10(%rdx)
movq 0x10(%rbx), %rdx
xorl %esi, %esi
cmpq %rdx, %rsi
jae 0x10be3
movq (%rbx), %rdi
movzwl (%rdi,%rsi,2), %edi
movw %di, (%r8,%rsi,2)
movq 0x8(%rbx), %rdi
movzwl (%rdi,%rsi,2), %edi
movw %di, (%r12,%rsi,2)
movq 0x20(%rbx), %rdi
movq (%rdi,%rsi,8), %rdi
movq %rdi, (%r13,%rsi,8)
movq 0x28(%rbx), %rdi
movzwl (%rdi,%rsi,2), %edi
movw %di, (%r14,%rsi,2)
movq 0x30(%rbx), %rdi
movzwl (%rdi,%rsi,2), %edi
movw %di, (%r15,%rsi,2)
incq %rsi
jmp 0x10b99
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x10bfc
movq 0x38(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movq %rsi, (%rbp,%rdx,8)
incq %rdx
jmp 0x10be5
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
cmpq %rcx, %rsi
je 0x10c19
movq 0x40(%rbx), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x10c03
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rdi
callq 0x3540