// File: /workspace/github_cpp_makefile_star2_O2/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, %r14d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testl %r14d, %r14d
sete %al
orb %cl, %al
jne 0x7bdeb
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
movslq %r14d, %r13
movq 0xf0(%rsi), %rsi
addq %r13, %rsi
shlq $0x5, %rsi
callq 0x84960
testq %rax, %rax
je 0x7bdfa
movq %r13, 0x10(%rsp)
movq 0xe8(%rbx), %rsi
movq 0xf0(%rbx), %rdx
shlq $0x5, %rdx
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
callq 0xe380
movq 0xe8(%rbx), %rsi
movq %r15, %rdi
callq 0x84923
movq 0x8(%rsp), %rcx
andq $0x0, 0xe8(%rbx)
xorl %ebp, %ebp
testl %r14d, %r14d
cmovlel %ebp, %r14d
shlq $0x5, %r14
addq $0x10, %r12
cmpq %rbp, %r14
je 0x7bdd1
movq 0xf0(%rbx), %r13
shlq $0x5, %r13
addq %rcx, %r13
movb -0xc(%r12,%rbp), %al
movb %al, 0x4(%rbp,%r13)
movl -0x10(%r12,%rbp), %eax
movl %eax, (%rbp,%r13)
movb $0x0, 0x4(%rbp,%r13)
movq (%r12,%rbp), %rsi
movq %rsi, 0x10(%rbp,%r13)
movb 0x11c(%r15), %al
movb %al, 0x18(%rbp,%r13)
testq %rsi, %rsi
je 0x7bda6
movq %r15, %rdi
callq 0x84960
movq %rax, 0x8(%rbp,%r13)
testq %rax, %rax
je 0x7bdae
movq -0x8(%r12,%rbp), %rsi
movq (%r12,%rbp), %rdx
movq %rax, %rdi
callq 0xe380
jmp 0x7bdc3
andq $0x0, 0x8(%rbp,%r13)
jmp 0x7bdc8
movq %r15, %rdi
leaq 0x216a2(%rip), %rsi     # 0x9d45a
callq 0x84a53
andq $0x0, 0x10(%r13,%rbp)
movq 0x8(%rsp), %rcx
addq $0x20, %rbp
jmp 0x7bd36
movq %rcx, 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 0x21659(%rip), %rsi     # 0x9d45a
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84a53