// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/png/pngset.c
// Function: png_set_sPLT
void PNGAPI
png_set_sPLT(png_structp png_ptr,
             png_infop info_ptr, png_sPLT_tp entries, int nentries)
/*
 *  entries        - array of png_sPLT_t structures
 *                   to be added to the list of palettes
 *                   in the info structure.
 *  nentries       - number of palette structures to be
 *                   added.
 */
{
   png_sPLT_tp np;
   int i;

   if (png_ptr == NULL || info_ptr == NULL)
      return;

   np = (png_sPLT_tp)png_malloc_warn(png_ptr,
       (info_ptr->splt_palettes_num + nentries) *
        (png_size_t)png_sizeof(png_sPLT_t));
   if (np == NULL)
   {
      png_warning(png_ptr, "No memory for sPLT palettes");
      return;
   }

   png_memcpy(np, info_ptr->splt_palettes,
       info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
   png_free(png_ptr, info_ptr->splt_palettes);
   info_ptr->splt_palettes=NULL;

   for (i = 0; i < nentries; i++)
   {
      png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
      png_sPLT_tp from = entries + i;
      png_uint_32 length;

      length = png_strlen(from->name) + 1;
      to->name = (png_charp)png_malloc_warn(png_ptr, (png_size_t)length);
      if (to->name == NULL)
      {
         png_warning(png_ptr,
           "Out of memory while processing sPLT chunk");
         continue;
      }
      png_memcpy(to->name, from->name, length);
      to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
          (png_size_t)(from->nentries * png_sizeof(png_sPLT_entry)));
      if (to->entries == NULL)
      {
         png_warning(png_ptr,
           "Out of memory while processing sPLT chunk");
         png_free(png_ptr, to->name);
         to->name = NULL;
         continue;
      }
      png_memcpy(to->entries, from->entries,
          from->nentries * png_sizeof(png_sPLT_entry));
      to->nentries = from->nentries;
      to->depth = from->depth;
   }

   info_ptr->splt_palettes = np;
   info_ptr->splt_palettes_num += nentries;
   info_ptr->valid |= PNG_INFO_sPLT;
   info_ptr->free_me |= PNG_FREE_SPLT;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x7bc62
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r12
movl 0x118(%rsi), %esi
addl %r14d, %esi
shlq $0x5, %rsi
callq 0x84960
testq %rax, %rax
je 0x7bc71
movq %rax, %r13
movq 0x110(%rbx), %rsi
movl 0x118(%rbx), %edx
shlq $0x5, %rdx
movq %rax, %rdi
callq 0xe380
movq 0x110(%rbx), %rsi
movq %r12, %rdi
callq 0x84923
andq $0x0, 0x110(%rbx)
xorl %ebp, %ebp
testl %r14d, %r14d
movl %r14d, 0x4(%rsp)
cmovgl %r14d, %ebp
addq $0x18, %r15
movq %r13, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
subq $0x1, %rbp
jb 0x7bc41
movl 0x118(%rbx), %ebx
shlq $0x5, %rbx
movq -0x18(%r15), %rdi
callq 0xe1e0
movq %r12, %r14
movq %rax, %r12
incl %r12d
movq %r14, %rdi
movq %r12, %rsi
callq 0x84960
movq %rax, (%r13,%rbx)
testq %rax, %rax
je 0x7bbf9
movq -0x18(%r15), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0xe380
movslq (%r15), %rax
imulq $0xa, %rax, %rsi
movq %r14, %rdi
callq 0x84960
movq %rax, 0x10(%r13,%rbx)
testq %rax, %rax
movq %r14, %r12
je 0x7bc0d
movq -0x8(%r15), %rsi
movslq (%r15), %rcx
imulq $0xa, %rcx, %rdx
movq %rax, %rdi
callq 0xe380
movl (%r15), %eax
movl %eax, 0x18(%r13,%rbx)
movb -0x10(%r15), %al
movb %al, 0x8(%r13,%rbx)
jmp 0x7bc2f
movq %r14, %rdi
leaq 0x2182d(%rip), %rsi     # 0x9d430
callq 0x84a53
movq %r14, %r12
jmp 0x7bc2f
movq %r12, %rdi
leaq 0x21819(%rip), %rsi     # 0x9d430
callq 0x84a53
movq (%r13,%rbx), %rsi
movq %r12, %rdi
callq 0x84923
andq $0x0, (%r13,%rbx)
addq $0x20, %r15
addq $0x20, %r13
movq 0x10(%rsp), %rbx
jmp 0x7bb6d
movq 0x8(%rsp), %rax
movq %rax, 0x110(%rbx)
movl 0x4(%rsp), %eax
addl %eax, 0x118(%rbx)
orb $0x20, 0x9(%rbx)
orb $0x20, 0xe4(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2179c(%rip), %rsi     # 0x9d414
movq %r12, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84a53