// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/png/pngset.c
// Function: png_set_text_2
int /* PRIVATE */
png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
               int num_text)
{
   int i;

   png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
      png_ptr->chunk_name[0] == '\0') ?
      "text" : (png_const_charp)png_ptr->chunk_name));

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

   /* Make sure we have enough space in the "text" array in info_struct
    * to hold all of the incoming text_ptr objects.
    */
   if (info_ptr->num_text + num_text > info_ptr->max_text)
   {
      if (info_ptr->text != NULL)
      {
         png_textp old_text;
         int old_max;

         old_max = info_ptr->max_text;
         info_ptr->max_text = info_ptr->num_text + num_text + 8;
         old_text = info_ptr->text;
         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
            (png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
         if (info_ptr->text == NULL)
         {
            png_free(png_ptr, old_text);
            return(1);
         }
         png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
            png_sizeof(png_text)));
         png_free(png_ptr, old_text);
      }
      else
      {
         info_ptr->max_text = num_text + 8;
         info_ptr->num_text = 0;
         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
            (png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
         if (info_ptr->text == NULL)
            return(1);
         info_ptr->free_me |= PNG_FREE_TEXT;
      }
      png_debug1(3, "allocated %d entries for info_ptr->text",
         info_ptr->max_text);
   }
   for (i = 0; i < num_text; i++)
   {
      png_size_t text_length, key_len;
      png_size_t lang_len, lang_key_len;
      png_textp textp = &(info_ptr->text[info_ptr->num_text]);

      if (text_ptr[i].key == NULL)
          continue;

      key_len = png_strlen(text_ptr[i].key);

      if (text_ptr[i].compression <= 0)
      {
         lang_len = 0;
         lang_key_len = 0;
      }

      else
#ifdef PNG_iTXt_SUPPORTED
      {
         /* Set iTXt data */

         if (text_ptr[i].lang != NULL)
            lang_len = png_strlen(text_ptr[i].lang);
         else
            lang_len = 0;
         if (text_ptr[i].lang_key != NULL)
            lang_key_len = png_strlen(text_ptr[i].lang_key);
         else
            lang_key_len = 0;
      }
#else /* PNG_iTXt_SUPPORTED */
      {
         png_warning(png_ptr, "iTXt chunk not supported");
         continue;
      }
#endif

      if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
      {
         text_length = 0;
#ifdef PNG_iTXt_SUPPORTED
         if (text_ptr[i].compression > 0)
            textp->compression = PNG_ITXT_COMPRESSION_NONE;
         else
#endif
            textp->compression = PNG_TEXT_COMPRESSION_NONE;
      }

      else
      {
         text_length = png_strlen(text_ptr[i].text);
         textp->compression = text_ptr[i].compression;
      }

      textp->key = (png_charp)png_malloc_warn(png_ptr,
         (png_size_t)
         (key_len + text_length + lang_len + lang_key_len + 4));
      if (textp->key == NULL)
         return(1);
      png_debug2(2, "Allocated %lu bytes at %x in png_set_text",
                 (unsigned long)(png_uint_32)
                 (key_len + lang_len + lang_key_len + text_length + 4),
                 (int)textp->key);

      png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
      *(textp->key + key_len) = '\0';
#ifdef PNG_iTXt_SUPPORTED
      if (text_ptr[i].compression > 0)
      {
         textp->lang = textp->key + key_len + 1;
         png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
         *(textp->lang + lang_len) = '\0';
         textp->lang_key = textp->lang + lang_len + 1;
         png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
         *(textp->lang_key + lang_key_len) = '\0';
         textp->text = textp->lang_key + lang_key_len + 1;
      }
      else
#endif
      {
#ifdef PNG_iTXt_SUPPORTED
         textp->lang=NULL;
         textp->lang_key=NULL;
#endif
         textp->text = textp->key + key_len + 1;
      }
      if (text_length)
         png_memcpy(textp->text, text_ptr[i].text,
            (png_size_t)(text_length));
      *(textp->text + text_length) = '\0';

#ifdef PNG_iTXt_SUPPORTED
      if (textp->compression > 0)
      {
         textp->text_length = 0;
         textp->itxt_length = text_length;
      }
      else
#endif

      {
         textp->text_length = text_length;
#ifdef PNG_iTXt_SUPPORTED
         textp->itxt_length = 0;
#endif
      }
      info_ptr->num_text++;
      png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
   }
   return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebx
movq %rdx, 0x10(%rsp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testl %ebx, %ebx
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x7b99e
movq %rsi, %r13
movq %rdi, %r15
movslq 0x3c(%rsi), %rcx
movslq %ebx, %rax
addq %rcx, %rax
movslq 0x40(%rsi), %r14
cmpl %r14d, %eax
jle 0x7b7a5
movq 0x48(%r13), %r12
testq %r12, %r12
je 0x7b776
addq $0x8, %rax
movl %eax, 0x40(%r13)
imulq $0x38, %rax, %rsi
movq %r15, %rdi
callq 0x84960
movq %rax, 0x48(%r13)
testq %rax, %rax
je 0x7b990
imulq $0x38, %r14, %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0xe380
movq %r15, %rdi
movq %r12, %rsi
callq 0x84923
jmp 0x7b7a5
leal 0x8(%rbx), %eax
movl %eax, 0x40(%r13)
andl $0x0, 0x3c(%r13)
cltq
imulq $0x38, %rax, %rsi
movq %r15, %rdi
callq 0x84960
movq %rax, 0x48(%r13)
testq %rax, %rax
je 0x7b99b
orb $0x40, 0xe5(%r13)
movq %r15, 0x20(%rsp)
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
imulq $0x38, %rbx, %rax
movq %rax, 0x30(%rsp)
xorl %r15d, %r15d
movq 0x10(%rsp), %rbx
movq %r13, 0x18(%rsp)
cmpq %r15, 0x30(%rsp)
je 0x7b98c
movq 0x8(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x7b983
movslq 0x3c(%r13), %rax
imulq $0x38, %rax, %r14
addq 0x48(%r13), %r14
callq 0xe1e0
movq %rax, %r12
movl (%rbx,%r15), %ebp
testl %ebp, %ebp
jle 0x7b812
movq 0x28(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x7b81d
callq 0xe1e0
movq %rax, 0x8(%rsp)
jmp 0x7b826
movq $0x0, 0x8(%rsp)
jmp 0x7b83a
movq $0x0, 0x8(%rsp)
movq 0x30(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x7b83a
callq 0xe1e0
movq %rax, %rcx
jmp 0x7b83c
xorl %ecx, %ecx
movq 0x10(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x7b85b
cmpb $0x0, (%rdi)
je 0x7b85b
movq %rcx, %rbx
callq 0xe1e0
movq %rbx, %rcx
movq %rax, %rbx
jmp 0x7b86b
xorl %eax, %eax
testl %ebp, %ebp
setg %al
leal -0x1(,%rax,2), %ebp
xorl %ebx, %ebx
movl %ebp, (%r14)
movq 0x8(%rsp), %rax
addq %r12, %rax
movq %rcx, 0x28(%rsp)
addq %rcx, %rax
leaq (%rbx,%rax), %rsi
addq $0x4, %rsi
movq 0x20(%rsp), %rdi
callq 0x84960
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x7b99b
leaq 0x8(%r14), %rbp
movq 0x10(%rsp), %r13
movq 0x8(%r13,%r15), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0xe380
movq (%rbp), %rax
movb $0x0, (%rax,%r12)
cmpl $0x0, (%r13,%r15)
jle 0x7b923
movq 0x8(%r14), %rax
leaq (%rax,%r12), %rdi
incq %rdi
movq %rdi, 0x28(%r14)
movq 0x28(%r13,%r15), %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdx
callq 0xe380
movq 0x28(%r14), %rax
xorl %ecx, %ecx
movb %cl, (%rax,%r12)
movq 0x28(%r14), %rax
leaq (%rax,%r12), %rdi
incq %rdi
leaq 0x30(%r14), %rbp
movq %rdi, 0x30(%r14)
movq 0x30(%r13,%r15), %rsi
movq 0x28(%rsp), %r12
movq %r12, %rdx
callq 0xe380
movq 0x30(%r14), %rax
xorl %edx, %edx
movb %dl, (%rax,%r12)
jmp 0x7b92b
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movq 0x18(%rsp), %r13
movq (%rbp), %rax
leaq (%rax,%r12), %rdi
incq %rdi
movq %rdi, 0x10(%r14)
testq %rbx, %rbx
je 0x7b95a
movq 0x10(%rsp), %rax
movq 0x10(%rax,%r15), %rsi
movq %rbx, %rdx
callq 0xe380
movq 0x10(%r14), %rdi
movb $0x0, (%rdi,%rbx)
cmpl $0x0, (%r14)
movq %rbx, %rax
movl $0x0, %ecx
cmovgq %rcx, %rax
cmovleq %rcx, %rbx
movq %rax, 0x18(%r14)
movq %rbx, 0x20(%r14)
incl 0x3c(%r13)
movq 0x10(%rsp), %rbx
addq $0x38, %r15
jmp 0x7b7c7
xorl %eax, %eax
jmp 0x7b99e
movq %r15, %rdi
movq %r12, %rsi
callq 0x84923
pushq $0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq