// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rdx, %r15
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %dl
orb %al, %dl
je 0x7b1fb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq %rdi, %rbx
movl %ecx, 0x4(%rsp)
movl %r8d, 0x8(%rsp)
movl %r9d, 0xc(%rsp)
movq 0x60(%rsp), %r12
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0x50(%rsp), %r13d
movq %r15, %rdi
callq 0xe1e0
movq %rax, %rbp
incq %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x84960
movq %rax, 0xc0(%r14)
testq %rax, %rax
je 0x7b341
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0xe380
movl 0x4(%rsp), %eax
movl %eax, 0xc8(%r14)
movl 0x8(%rsp), %eax
movl %eax, 0xcc(%r14)
movl 0xc(%rsp), %eax
movb %al, 0xe0(%r14)
movb %r13b, 0xe1(%r14)
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0xe1e0
movq %rax, %r15
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x84960
movq %rax, 0xd0(%r14)
testq %rax, %rax
je 0x7b34a
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xe380
movslq %r13d, %rax
leaq 0x8(,%rax,8), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x84960
movq %rax, 0xd8(%r14)
testq %rax, %rax
je 0x7b353
xorl %ebp, %ebp
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xe270
testl %r13d, %r13d
cmovlel %ebp, %r13d
cmpq %rbp, %r13
je 0x7b35c
movq (%r12,%rbp,8), %rdi
callq 0xe1e0
movq %rax, %r15
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x84960
movq 0xd8(%r14), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0xd8(%r14), %rax
movq (%rax,%rbp,8), %rdi
testq %rdi, %rdi
je 0x7b36e
movq (%r12,%rbp,8), %rsi
movq %r15, %rdx
callq 0xe380
incq %rbp
jmp 0x7b2f6
leaq 0x21f78(%rip), %rsi     # 0x9d2c0
jmp 0x7b375
leaq 0x21f94(%rip), %rsi     # 0x9d2e5
jmp 0x7b375
leaq 0x21fae(%rip), %rsi     # 0x9d308
jmp 0x7b375
orb $0x4, 0x9(%r14)
orb $-0x80, 0xe4(%r14)
jmp 0x7b1ec
leaq 0x21fb7(%rip), %rsi     # 0x9d32c
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84a53