// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_tEXt
void /* PRIVATE */
png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   png_textp text_ptr;
   png_charp key;
   png_charp text;
   png_uint_32 skip = 0;
   png_size_t slength;
   int ret;

   png_debug(1, "in png_handle_tEXt");

#ifdef PNG_USER_LIMITS_SUPPORTED
   if (png_ptr->user_chunk_cache_max != 0)
   {
      if (png_ptr->user_chunk_cache_max == 1)
      {
         png_crc_finish(png_ptr, length);
         return;
      }
      if (--png_ptr->user_chunk_cache_max == 1)
      {
         png_warning(png_ptr, "No space in chunk cache for tEXt");
         png_crc_finish(png_ptr, length);
         return;
      }
   }
#endif

   if (!(png_ptr->mode & PNG_HAVE_IHDR))
      png_error(png_ptr, "Missing IHDR before tEXt");

   if (png_ptr->mode & PNG_HAVE_IDAT)
      png_ptr->mode |= PNG_AFTER_IDAT;

#ifdef PNG_MAX_MALLOC_64K
   if (length > (png_uint_32)65535L)
   {
      png_warning(png_ptr, "tEXt chunk too large to fit in memory");
      skip = length - (png_uint_32)65535L;
      length = (png_uint_32)65535L;
   }
#endif

   png_free(png_ptr, png_ptr->chunkdata);

   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
   if (png_ptr->chunkdata == NULL)
   {
     png_warning(png_ptr, "No memory to process text chunk");
     return;
   }
   slength = (png_size_t)length;
   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);

   if (png_crc_finish(png_ptr, skip))
   {
      png_free(png_ptr, png_ptr->chunkdata);
      png_ptr->chunkdata = NULL;
      return;
   }

   key = png_ptr->chunkdata;

   key[slength] = 0x00;

   for (text = key; *text; text++)
      /* Empty loop to find end of key */ ;

   if (text != key + slength)
      text++;

   text_ptr = (png_textp)png_malloc_warn(png_ptr,
      png_sizeof(png_text));
   if (text_ptr == NULL)
   {
     png_warning(png_ptr, "Not enough memory to process text chunk");
     png_free(png_ptr, png_ptr->chunkdata);
     png_ptr->chunkdata = NULL;
     return;
   }
   text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
   text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
   text_ptr->lang = NULL;
   text_ptr->lang_key = NULL;
   text_ptr->itxt_length = 0;
#endif
   text_ptr->text = text;
   text_ptr->text_length = png_strlen(text);

   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);

   png_free(png_ptr, png_ptr->chunkdata);
   png_ptr->chunkdata = NULL;
   png_free(png_ptr, text_ptr);
   if (ret)
     png_warning(png_ptr, "Insufficient memory to process text chunk");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movl 0x45c(%rdi), %eax
testl %eax, %eax
je 0x9bcdf
cmpl $0x1, %eax
je 0x9bcc6
decl %eax
movl %eax, 0x45c(%rbx)
cmpl $0x1, %eax
jne 0x9bcdf
leaq 0x176f0(%rip), %rsi     # 0xb33ae
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movl %r15d, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x99b4f
movl 0x11c(%rbx), %eax
testb $0x1, %al
jne 0x9bcfe
leaq 0x176df(%rip), %rsi     # 0xb33cf
movq %rbx, %rdi
callq 0x920b4
movl 0x11c(%rbx), %eax
testb $0x4, %al
je 0x9bd0b
orl $0x8, %eax
movl %eax, 0x11c(%rbx)
movq 0x488(%rbx), %rsi
movq %rbx, %rdi
callq 0x92016
leal 0x1(%r15), %esi
movq %rbx, %rdi
callq 0x92056
movq %rax, 0x488(%rbx)
testq %rax, %rax
je 0x9bd7d
movl %r15d, %r15d
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x99b23
movq %rbx, %rdi
xorl %esi, %esi
callq 0x99b4f
movq 0x488(%rbx), %r12
testl %eax, %eax
je 0x9bd9a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x92016
movq $0x0, 0x488(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17664(%rip), %rsi     # 0xb33e8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9214d
movb $0x0, (%r12,%r15)
leaq -0x1(%r12), %rbp
incq %r15
decq %r15
cmpb $0x0, 0x1(%rbp)
leaq 0x1(%rbp), %rbp
jne 0x9bda7
movl $0x38, %esi
movq %rbx, %rdi
callq 0x92056
testq %rax, %rax
je 0x9be43
movq %rax, %r13
cmpq $0x1, %r15
sbbq $-0x1, %rbp
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq %r12, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
xorl %r15d, %r15d
movq %r15, 0x30(%rax)
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0xe1e0
movq %rax, 0x18(%r13)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0x8837d
movl %eax, %ebp
movq 0x488(%rbx), %rsi
movq %rbx, %rdi
callq 0x92016
movq %r15, 0x488(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x92016
testl %ebp, %ebp
je 0x9bd6e
leaq 0x175f2(%rip), %rsi     # 0xb3430
jmp 0x9bd84
leaq 0x175be(%rip), %rsi     # 0xb3408
movq %rbx, %rdi
callq 0x9214d
movq 0x488(%rbx), %rsi
movq %rbx, %rdi
jmp 0x9bd5e