// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngset.c
// Function: png_set_pCAL
void PNGAPI
png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
   png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
   png_charp units, png_charpp params)
{
   png_size_t length;
   int i;

   png_debug1(1, "in %s storage function", "pCAL");

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

   length = png_strlen(purpose) + 1;
   png_debug1(3, "allocating purpose for info (%lu bytes)",
     (unsigned long)length);
   info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
   if (info_ptr->pcal_purpose == NULL)
   {
      png_warning(png_ptr, "Insufficient memory for pCAL purpose");
      return;
   }
   png_memcpy(info_ptr->pcal_purpose, purpose, length);

   png_debug(3, "storing X0, X1, type, and nparams in info");
   info_ptr->pcal_X0 = X0;
   info_ptr->pcal_X1 = X1;
   info_ptr->pcal_type = (png_byte)type;
   info_ptr->pcal_nparams = (png_byte)nparams;

   length = png_strlen(units) + 1;
   png_debug1(3, "allocating units for info (%lu bytes)",
     (unsigned long)length);
   info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
   if (info_ptr->pcal_units == NULL)
   {
      png_warning(png_ptr, "Insufficient memory for pCAL units");
      return;
   }
   png_memcpy(info_ptr->pcal_units, units, length);

   info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
      (png_size_t)((nparams + 1) * png_sizeof(png_charp)));
   if (info_ptr->pcal_params == NULL)
   {
      png_warning(png_ptr, "Insufficient memory for pCAL params");
      return;
   }

   png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));

   for (i = 0; i < nparams; i++)
   {
      length = png_strlen(params[i]) + 1;
      png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
        (unsigned long)length);
      info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
      if (info_ptr->pcal_params[i] == NULL)
      {
         png_warning(png_ptr, "Insufficient memory for pCAL parameter");
         return;
      }
      png_memcpy(info_ptr->pcal_params[i], params[i], length);
   }

   info_ptr->valid |= PNG_INFO_pCAL;
   info_ptr->free_me |= PNG_FREE_PCAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r13d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x87ea4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movl %r8d, 0x4(%rsp)
movl %r9d, 0x8(%rsp)
movq 0x60(%rsp), %r12
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0xc(%rsp)
movq %rdx, %rdi
callq 0xe1e0
movq %rax, %rbp
incq %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x92056
movq %rax, 0xc0(%r14)
testq %rax, %rax
je 0x88000
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0xe370
movl %r13d, 0xc8(%r14)
movl 0x4(%rsp), %eax
movl %eax, 0xcc(%r14)
movl 0x8(%rsp), %eax
movb %al, 0xe0(%r14)
movl 0xc(%rsp), %ebp
movb %bpl, 0xe1(%r14)
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0xe1e0
movq %rax, %r15
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92056
movq %rax, 0xd0(%r14)
testq %rax, %rax
je 0x88009
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xe370
movslq %ebp, %rax
leaq 0x8(,%rax,8), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92056
movq %rax, 0xd8(%r14)
testq %rax, %rax
je 0x88012
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xe260
testl %ebp, %ebp
jle 0x87fee
movl %ebp, %r13d
xorl %ebp, %ebp
movq (%r12,%rbp,8), %rdi
callq 0xe1e0
movq %rax, %r15
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92056
movq 0xd8(%r14), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0xd8(%r14), %rax
movq (%rax,%rbp,8), %rdi
testq %rdi, %rdi
je 0x8801b
movq (%r12,%rbp,8), %rsi
movq %r15, %rdx
callq 0xe370
incq %rbp
cmpq %rbp, %r13
jne 0x87fa5
orb $0x4, 0x9(%r14)
orb $-0x80, 0xe4(%r14)
jmp 0x87e95
leaq 0x245d9(%rip), %rsi     # 0xac5e0
jmp 0x88022
leaq 0x245f5(%rip), %rsi     # 0xac605
jmp 0x88022
leaq 0x2460f(%rip), %rsi     # 0xac628
jmp 0x88022
leaq 0x2462a(%rip), %rsi     # 0xac64c
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9214d