// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/png.c
// Function: png_free_data
void PNGAPI
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
   int num)
{
   png_debug(1, "in png_free_data");

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

#ifdef PNG_TEXT_SUPPORTED
   /* Free text item num or (if num == -1) all text items */
   if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
   {
      if (num != -1)
      {
         if (info_ptr->text && info_ptr->text[num].key)
         {
            png_free(png_ptr, info_ptr->text[num].key);
            info_ptr->text[num].key = NULL;
         }
      }
      else
      {
         int i;
         for (i = 0; i < info_ptr->num_text; i++)
             png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
         png_free(png_ptr, info_ptr->text);
         info_ptr->text = NULL;
         info_ptr->num_text=0;
      }
   }
#endif

#ifdef PNG_tRNS_SUPPORTED
   /* Free any tRNS entry */
   if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
   {
      png_free(png_ptr, info_ptr->trans_alpha);
      info_ptr->trans_alpha = NULL;
      info_ptr->valid &= ~PNG_INFO_tRNS;
   }
#endif

#ifdef PNG_sCAL_SUPPORTED
   /* Free any sCAL entry */
   if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
   {
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
      png_free(png_ptr, info_ptr->scal_s_width);
      png_free(png_ptr, info_ptr->scal_s_height);
      info_ptr->scal_s_width = NULL;
      info_ptr->scal_s_height = NULL;
#endif
      info_ptr->valid &= ~PNG_INFO_sCAL;
   }
#endif

#ifdef PNG_pCAL_SUPPORTED
   /* Free any pCAL entry */
   if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
   {
      png_free(png_ptr, info_ptr->pcal_purpose);
      png_free(png_ptr, info_ptr->pcal_units);
      info_ptr->pcal_purpose = NULL;
      info_ptr->pcal_units = NULL;
      if (info_ptr->pcal_params != NULL)
         {
            int i;
            for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
            {
               png_free(png_ptr, info_ptr->pcal_params[i]);
               info_ptr->pcal_params[i] = NULL;
            }
            png_free(png_ptr, info_ptr->pcal_params);
            info_ptr->pcal_params = NULL;
         }
      info_ptr->valid &= ~PNG_INFO_pCAL;
   }
#endif

#ifdef PNG_iCCP_SUPPORTED
   /* Free any iCCP entry */
   if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
   {
      png_free(png_ptr, info_ptr->iccp_name);
      png_free(png_ptr, info_ptr->iccp_profile);
      info_ptr->iccp_name = NULL;
      info_ptr->iccp_profile = NULL;
      info_ptr->valid &= ~PNG_INFO_iCCP;
   }
#endif

#ifdef PNG_sPLT_SUPPORTED
   /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
   if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
   {
      if (num != -1)
      {
         if (info_ptr->splt_palettes)
         {
            png_free(png_ptr, info_ptr->splt_palettes[num].name);
            png_free(png_ptr, info_ptr->splt_palettes[num].entries);
            info_ptr->splt_palettes[num].name = NULL;
            info_ptr->splt_palettes[num].entries = NULL;
         }
      }
      else
      {
         if (info_ptr->splt_palettes_num)
         {
            int i;
            for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
               png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);

            png_free(png_ptr, info_ptr->splt_palettes);
            info_ptr->splt_palettes = NULL;
            info_ptr->splt_palettes_num = 0;
         }
         info_ptr->valid &= ~PNG_INFO_sPLT;
      }
   }
#endif

#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
   if (png_ptr->unknown_chunk.data)
   {
      png_free(png_ptr, png_ptr->unknown_chunk.data);
      png_ptr->unknown_chunk.data = NULL;
   }

   if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
   {
      if (num != -1)
      {
          if (info_ptr->unknown_chunks)
          {
             png_free(png_ptr, info_ptr->unknown_chunks[num].data);
             info_ptr->unknown_chunks[num].data = NULL;
          }
      }
      else
      {
         int i;

         if (info_ptr->unknown_chunks_num)
         {
            for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
               png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);

            png_free(png_ptr, info_ptr->unknown_chunks);
            info_ptr->unknown_chunks = NULL;
            info_ptr->unknown_chunks_num = 0;
         }
      }
   }
#endif

#ifdef PNG_hIST_SUPPORTED
   /* Free any hIST entry */
   if ((mask & PNG_FREE_HIST)  & info_ptr->free_me)
   {
      png_free(png_ptr, info_ptr->hist);
      info_ptr->hist = NULL;
      info_ptr->valid &= ~PNG_INFO_hIST;
   }
#endif

   /* Free any PLTE entry that was internally allocated */
   if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
   {
      png_zfree(png_ptr, info_ptr->palette);
      info_ptr->palette = NULL;
      info_ptr->valid &= ~PNG_INFO_PLTE;
      info_ptr->num_palette = 0;
   }

#ifdef PNG_INFO_IMAGE_SUPPORTED
   /* Free any image bits attached to the info structure */
   if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
   {
      if (info_ptr->row_pointers)
      {
         int row;
         for (row = 0; row < (int)info_ptr->height; row++)
         {
            png_free(png_ptr, info_ptr->row_pointers[row]);
            info_ptr->row_pointers[row] = NULL;
         }
         png_free(png_ptr, info_ptr->row_pointers);
         info_ptr->row_pointers = NULL;
      }
      info_ptr->valid &= ~PNG_INFO_IDAT;
   }
#endif

   if (num == -1)
      info_ptr->free_me &= ~mask;
   else
      info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %r14d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x88147
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movl 0xe4(%rsi), %eax
andl %edx, %eax
btl $0xe, %eax
jae 0x87def
cmpl $-0x1, %r14d
je 0x87daf
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x87def
movslq %r14d, %rcx
imulq $0x38, %rcx, %r12
movq 0x8(%rax,%r12), %rsi
testq %rsi, %rsi
je 0x87def
movq %r15, %rdi
callq 0x92d32
movq 0x48(%rbx), %rax
movq $0x0, 0x8(%rax,%r12)
jmp 0x87def
cmpl $0x0, 0x3c(%rbx)
jle 0x87dd4
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rsi
movl $0x4000, %edx           # imm = 0x4000
movl %r12d, %ecx
callq 0x87d43
incl %r12d
cmpl 0x3c(%rbx), %r12d
jl 0x87db8
movq 0x48(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x48(%rbx)
movl $0x0, 0x3c(%rbx)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
btl $0xd, %eax
jae 0x87e15
movq 0x60(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x60(%rbx)
andb $-0x11, 0x8(%rbx)
movl 0xe4(%rbx), %eax
movl %ebp, %ecx
andl %eax, %ecx
btl $0x8, %ecx
jae 0x87e29
andb $-0x41, 0x9(%rbx)
testb %al, %bpl
jns 0x87ec4
movq 0xc0(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0xd0(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
xorl %eax, %eax
movq %rax, 0xc0(%rbx)
movq %rax, 0xd0(%rbx)
cmpq %rax, 0xd8(%rbx)
je 0x87ec0
cmpb $0x0, 0xe1(%rbx)
je 0x87ea6
xorl %r12d, %r12d
movq 0xd8(%rbx), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0xd8(%rbx), %rax
movq $0x0, (%rax,%r12,8)
incq %r12
movzbl 0xe1(%rbx), %eax
cmpq %rax, %r12
jb 0x87e75
movq 0xd8(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0xd8(%rbx)
andb $-0x5, 0x9(%rbx)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
testb $0x10, %al
je 0x87efc
movq 0xf8(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0x100(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
xorps %xmm0, %xmm0
movups %xmm0, 0xf8(%rbx)
andb $-0x11, 0x9(%rbx)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
testb $0x20, %al
je 0x87fb9
cmpl $-0x1, %r14d
je 0x87f5d
movq 0x110(%rbx), %rax
testq %rax, %rax
je 0x87fb9
movslq %r14d, %r12
shlq $0x5, %r12
movq (%rax,%r12), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0x110(%rbx), %rax
movq 0x10(%rax,%r12), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0x110(%rbx), %rax
xorl %ecx, %ecx
movq %rcx, (%rax,%r12)
movq %rcx, 0x10(%rax,%r12)
jmp 0x87fb9
cmpl $0x0, 0x118(%rbx)
je 0x87fb5
cmpl $0x0, 0x118(%rbx)
jle 0x87f91
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rsi
movl $0x20, %edx
movl %r12d, %ecx
callq 0x87d43
incl %r12d
cmpl 0x118(%rbx), %r12d
jl 0x87f72
movq 0x110(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x110(%rbx)
movl $0x0, 0x118(%rbx)
andb $-0x21, 0x9(%rbx)
movq 0x468(%r15), %rsi
testq %rsi, %rsi
je 0x87fd8
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x468(%r15)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
btl $0x9, %eax
jae 0x88070
cmpl $-0x1, %r14d
je 0x88022
movq 0xe8(%rbx), %rax
testq %rax, %rax
je 0x88070
movslq %r14d, %r12
shlq $0x5, %r12
movq 0x8(%rax,%r12), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0xe8(%rbx), %rax
movq $0x0, 0x8(%rax,%r12)
jmp 0x88070
cmpq $0x0, 0xf0(%rbx)
je 0x88070
cmpl $0x0, 0xf0(%rbx)
jle 0x88057
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rsi
movl $0x200, %edx            # imm = 0x200
movl %r12d, %ecx
callq 0x87d43
incl %r12d
cmpl 0xf0(%rbx), %r12d
jl 0x88038
movq 0xe8(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
xorps %xmm0, %xmm0
movups %xmm0, 0xe8(%rbx)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
testb $0x8, %al
je 0x8809a
movq 0x98(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x98(%rbx)
andb $-0x41, 0x8(%rbx)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
btl $0xc, %eax
jae 0x880c6
movq 0x18(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x18(%rbx)
andb $-0x9, 0x8(%rbx)
movw $0x0, 0x20(%rbx)
movl 0xe4(%rbx), %eax
andl %ebp, %eax
testb $0x40, %al
je 0x88131
cmpq $0x0, 0x140(%rbx)
je 0x8812d
cmpl $0x0, 0x4(%rbx)
jle 0x88113
xorl %r12d, %r12d
movq 0x140(%rbx), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x92d32
movq 0x140(%rbx), %rax
movq $0x0, (%rax,%r12,8)
incq %r12
movslq 0x4(%rbx), %rax
cmpq %rax, %r12
jl 0x880e5
movq 0x140(%rbx), %rsi
movq %r15, %rdi
callq 0x92d32
movq $0x0, 0x140(%rbx)
andb $0x7f, 0x9(%rbx)
movl %ebp, %eax
andl $0xffffbddf, %eax       # imm = 0xFFFFBDDF
cmpl $-0x1, %r14d
cmovel %ebp, %eax
notl %eax
andl %eax, 0xe4(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq