// File: tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_unknown
void /* PRIVATE */
png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   png_uint_32 skip = 0;

   png_debug(1, "in png_handle_unknown");

#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 unknown chunk");
         png_crc_finish(png_ptr, length);
         return;
      }
   }
#endif

   if (png_ptr->mode & PNG_HAVE_IDAT)
   {
      PNG_IDAT;
      if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))  /* Not an IDAT */
         png_ptr->mode |= PNG_AFTER_IDAT;
   }

   if (!(png_ptr->chunk_name[0] & 0x20))
   {
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
      if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
           PNG_HANDLE_CHUNK_ALWAYS
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
           && png_ptr->read_user_chunk_fn == NULL
#endif
        )
#endif
          png_chunk_error(png_ptr, "unknown critical chunk");
   }

#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
   if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
       || (png_ptr->read_user_chunk_fn != NULL)
#endif
        )
   {
#ifdef PNG_MAX_MALLOC_64K
       if (length > (png_uint_32)65535L)
       {
           png_warning(png_ptr, "unknown chunk too large to fit in memory");
           skip = length - (png_uint_32)65535L;
           length = (png_uint_32)65535L;
       }
#endif
       png_memcpy((png_charp)png_ptr->unknown_chunk.name,
                  (png_charp)png_ptr->chunk_name,
                  png_sizeof(png_ptr->unknown_chunk.name));
       png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]
           = '\0';
       png_ptr->unknown_chunk.size = (png_size_t)length;
       if (length == 0)
         png_ptr->unknown_chunk.data = NULL;
       else
       {
         png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
       }
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
       if (png_ptr->read_user_chunk_fn != NULL)
       {
          /* Callback to user unknown chunk handler */
          int ret;
          ret = (*(png_ptr->read_user_chunk_fn))
            (png_ptr, &png_ptr->unknown_chunk);
          if (ret < 0)
             png_chunk_error(png_ptr, "error in user chunk");
          if (ret == 0)
          {
             if (!(png_ptr->chunk_name[0] & 0x20))
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
                if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
                     PNG_HANDLE_CHUNK_ALWAYS)
#endif
                   png_chunk_error(png_ptr, "unknown critical chunk");
             png_set_unknown_chunks(png_ptr, info_ptr,
               &png_ptr->unknown_chunk, 1);
          }
       }
       else
#endif
       png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
       png_free(png_ptr, png_ptr->unknown_chunk.data);
       png_ptr->unknown_chunk.data = NULL;
   }
   else
#endif
      skip = length;

   png_crc_finish(png_ptr, skip);

#ifndef PNG_READ_USER_CHUNKS_SUPPORTED
   info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
#endif
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movl %edx, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movq 0x20(%rsp), %rax
cmpl $0x0, 0x45c(%rax)
je 0x127658
movq 0x20(%rsp), %rax
cmpl $0x1, 0x45c(%rax)
jne 0x127619
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x122b90
jmp 0x1278dc
movq 0x20(%rsp), %rcx
movl 0x45c(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x45c(%rcx)
cmpl $0x1, %eax
jne 0x127656
movq 0x20(%rsp), %rdi
leaq 0x188ea(%rip), %rsi     # 0x13ff28
callq 0x113940
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x122b90
jmp 0x1278dc
jmp 0x127658
movq 0x20(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1276b6
movl 0x11b79(%rip), %eax     # 0x1391ea
movl %eax, 0xb(%rsp)
movb 0x11b73(%rip), %al      # 0x1391ee
movb %al, 0xf(%rsp)
movq 0x20(%rsp), %rax
addq $0x244, %rax            # imm = 0x244
leaq 0xb(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x1276b4
movq 0x20(%rsp), %rax
movl 0x11c(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x11c(%rax)
jmp 0x1276b6
movq 0x20(%rsp), %rax
movzbl 0x244(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x127707
movq 0x20(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq $0x244, %rsi            # imm = 0x244
callq 0xfc3e0
cmpl $0x3, %eax
je 0x127705
movq 0x20(%rsp), %rax
cmpq $0x0, 0x3e8(%rax)
jne 0x127705
movq 0x20(%rsp), %rdi
leaq 0x18852(%rip), %rsi     # 0x13ff52
callq 0x113a60
jmp 0x127707
movq 0x20(%rsp), %rax
movl 0x120(%rax), %eax
andq $0x8000, %rax           # imm = 0x8000
cmpq $0x0, %rax
jne 0x127731
movq 0x20(%rsp), %rax
cmpq $0x0, 0x3e8(%rax)
je 0x1278c6
movq 0x20(%rsp), %rax
movq 0x20(%rsp), %rcx
movl 0x244(%rcx), %edx
movl %edx, 0x460(%rax)
movb 0x248(%rcx), %cl
movb %cl, 0x464(%rax)
movq 0x20(%rsp), %rax
movb $0x0, 0x464(%rax)
movl 0x14(%rsp), %eax
movl %eax, %ecx
movq 0x20(%rsp), %rax
movq %rcx, 0x470(%rax)
cmpl $0x0, 0x14(%rsp)
jne 0x12778a
movq 0x20(%rsp), %rax
movq $0x0, 0x468(%rax)
jmp 0x1277c5
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %eax
movl %eax, %esi
callq 0x1135b0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x468(%rax)
movq 0x20(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x468(%rax), %rsi
movl 0x14(%rsp), %eax
movl %eax, %edx
callq 0x122b40
movq 0x20(%rsp), %rax
cmpq $0x0, 0x3e8(%rax)
je 0x12787e
movq 0x20(%rsp), %rax
movq 0x3e8(%rax), %rax
movq 0x20(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq *%rax
movl %eax, 0x4(%rsp)
cmpl $0x0, 0x4(%rsp)
jge 0x127813
movq 0x20(%rsp), %rdi
leaq 0x1875b(%rip), %rsi     # 0x13ff69
callq 0x113a60
cmpl $0x0, 0x4(%rsp)
jne 0x12787c
movq 0x20(%rsp), %rax
movzbl 0x244(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x12785c
movq 0x20(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq $0x244, %rsi            # imm = 0x244
callq 0xfc3e0
cmpl $0x3, %eax
je 0x12785a
movq 0x20(%rsp), %rdi
leaq 0x186fd(%rip), %rsi     # 0x13ff52
callq 0x113a60
jmp 0x12785c
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq $0x460, %rdx            # imm = 0x460
movl $0x1, %ecx
callq 0xfe930
jmp 0x12789e
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq $0x460, %rdx            # imm = 0x460
movl $0x1, %ecx
callq 0xfe930
movq 0x20(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x468(%rax), %rsi
callq 0x1136d0
movq 0x20(%rsp), %rax
movq $0x0, 0x468(%rax)
jmp 0x1278ce
movl 0x14(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x122b90
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)