// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl %ecx, %ebp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x8970e
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movl 0x118(%rsi), %esi
addl %ebp, %esi
shlq $0x5, %rsi
callq 0x92d72
testq %rax, %rax
je 0x8971d
movq 0x110(%rbx), %rsi
movl 0x118(%rbx), %edx
shlq $0x5, %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0xe370
movq 0x110(%rbx), %rsi
movq %r14, 0x20(%rsp)
movq %r14, %rdi
callq 0x92d32
movq $0x0, 0x110(%rbx)
movl %ebp, 0xc(%rsp)
testl %ebp, %ebp
jle 0x896ed
movl 0xc(%rsp), %ebp
addq $0x18, %r15
movq 0x10(%rsp), %r13
movq %rbx, 0x18(%rsp)
movq 0x20(%rsp), %r14
movl 0x118(%rbx), %ebx
shlq $0x5, %rbx
movq -0x18(%r15), %rdi
callq 0xe1e0
movq %rax, %r12
incl %r12d
movq %r14, %rdi
movq %r12, %rsi
callq 0x92d72
movq %rax, (%r13,%rbx)
testq %rax, %rax
je 0x896a1
movq -0x18(%r15), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0xe370
movslq (%r15), %rax
addq %rax, %rax
leaq (%rax,%rax,4), %rsi
movq %r14, %rdi
callq 0x92d72
movq %rax, 0x10(%r13,%rbx)
testq %rax, %rax
je 0x896b2
movq -0x8(%r15), %rsi
movslq (%r15), %rcx
addq %rcx, %rcx
leaq (%rcx,%rcx,4), %rdx
movq %rax, %rdi
callq 0xe370
movl (%r15), %eax
movl %eax, 0x18(%r13,%rbx)
movb -0x10(%r15), %al
movb %al, 0x8(%r13,%rbx)
jmp 0x896d7
movq %r14, %rdi
leaq 0x23065(%rip), %rsi     # 0xac710
callq 0x92e6e
jmp 0x896d7
movq %r14, %rdi
leaq 0x23054(%rip), %rsi     # 0xac710
callq 0x92e6e
movq (%r13,%rbx), %rsi
movq %r14, %rdi
callq 0x92d32
movq $0x0, (%r13,%rbx)
addq $0x20, %r15
addq $0x20, %r13
decq %rbp
movq 0x18(%rsp), %rbx
jne 0x8961f
movq 0x10(%rsp), %rax
movq %rax, 0x110(%rbx)
movl 0xc(%rsp), %eax
addl %eax, 0x118(%rbx)
orb $0x20, 0x9(%rbx)
orb $0x20, 0xe4(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22fd0(%rip), %rsi     # 0xac6f4
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92e6e