// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/pngset.c
// Function: png_set_unknown_chunks
void PNGAPI
png_set_unknown_chunks(png_structp png_ptr,
   png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
{
   png_unknown_chunkp np;
   int i;

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

   np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
       (png_size_t)((info_ptr->unknown_chunks_num + num_unknowns) *
       png_sizeof(png_unknown_chunk)));
   if (np == NULL)
   {
      png_warning(png_ptr,
          "Out of memory while processing unknown chunk");
      return;
   }

   png_memcpy(np, info_ptr->unknown_chunks,
       info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
   png_free(png_ptr, info_ptr->unknown_chunks);
   info_ptr->unknown_chunks = NULL;

   for (i = 0; i < num_unknowns; i++)
   {
      png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
      png_unknown_chunkp from = unknowns + i;

      png_memcpy((png_charp)to->name, (png_charp)from->name,
          png_sizeof(from->name));
      to->name[png_sizeof(to->name)-1] = '\0';
      to->size = from->size;
      /* Note our location in the read or write sequence */
      to->location = (png_byte)(png_ptr->mode & 0xff);

      if (from->size == 0)
         to->data=NULL;
      else
      {
         to->data = (png_bytep)png_malloc_warn(png_ptr,
           (png_size_t)from->size);
         if (to->data == NULL)
         {
            png_warning(png_ptr,
             "Out of memory while processing unknown chunk");
            to->size = 0;
         }
         else
            png_memcpy(to->data, from->data, from->size);
      }
   }

   info_ptr->unknown_chunks = np;
   info_ptr->unknown_chunks_num += num_unknowns;
   info_ptr->free_me |= PNG_FREE_UNKN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testl %ebp, %ebp
sete %al
orb %cl, %al
jne 0x89895
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movslq %ebp, %r12
movq 0xf0(%rsi), %rsi
addq %r12, %rsi
shlq $0x5, %rsi
callq 0x92d72
testq %rax, %rax
je 0x898a4
movq %r12, 0x10(%rsp)
movq 0xe8(%rbx), %rsi
movq 0xf0(%rbx), %rdx
shlq $0x5, %rdx
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0xe370
movq 0xe8(%rbx), %rsi
movq %r14, %rdi
callq 0x92d32
movq $0x0, 0xe8(%rbx)
testl %ebp, %ebp
jle 0x89876
movl %ebp, %ebp
addq $0x10, %r15
movq 0x8(%rsp), %r12
addq $0x10, %r12
movq 0xf0(%rbx), %r13
shlq $0x5, %r13
movb -0xc(%r15), %al
movb %al, -0xc(%r12,%r13)
movl -0x10(%r15), %eax
movl %eax, -0x10(%r12,%r13)
movb $0x0, -0xc(%r12,%r13)
movq (%r15), %rax
movq %rax, (%r12,%r13)
movb 0x11c(%r14), %al
movb %al, 0x8(%r12,%r13)
movq (%r15), %rsi
testq %rsi, %rsi
je 0x89843
movq %r14, %rdi
callq 0x92d72
movq %rax, -0x8(%r12,%r13)
testq %rax, %rax
je 0x8984e
movq -0x8(%r15), %rsi
movq (%r15), %rdx
movq %rax, %rdi
callq 0xe370
jmp 0x89865
movq $0x0, -0x8(%r12,%r13)
jmp 0x89865
movq %r14, %rdi
leaq 0x22ee2(%rip), %rsi     # 0xac73a
callq 0x92e6e
movq $0x0, (%r12,%r13)
addq $0x20, %r15
addq $0x20, %r12
decq %rbp
jne 0x897e2
movq 0x8(%rsp), %rax
movq %rax, 0xe8(%rbx)
movq 0x10(%rsp), %rax
addq %rax, 0xf0(%rbx)
orb $0x2, 0xe5(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22e8f(%rip), %rsi     # 0xac73a
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92e6e