// File: tomfunkhouser[P]gaps/pkgs/png/pngread.c
// Function: png_read_end
void PNGAPI
png_read_end(png_structp png_ptr, png_infop info_ptr)
{
   png_debug(1, "in png_read_end");
 
   if (png_ptr == NULL)
      return;
   png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */

   do
   {
      PNG_IHDR;
      PNG_IDAT;
      PNG_IEND;
      PNG_PLTE;
#ifdef PNG_READ_bKGD_SUPPORTED
      PNG_bKGD;
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
      PNG_cHRM;
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
      PNG_gAMA;
#endif
#ifdef PNG_READ_hIST_SUPPORTED
      PNG_hIST;
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
      PNG_iCCP;
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
      PNG_iTXt;
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
      PNG_oFFs;
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
      PNG_pCAL;
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
      PNG_pHYs;
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
      PNG_sBIT;
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
      PNG_sCAL;
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
      PNG_sPLT;
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
      PNG_sRGB;
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
      PNG_tEXt;
#endif
#ifdef PNG_READ_tIME_SUPPORTED
      PNG_tIME;
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
      PNG_tRNS;
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
      PNG_zTXt;
#endif
      png_uint_32 length = png_read_chunk_header(png_ptr);
      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;

      if (!png_memcmp(chunk_name, png_IHDR, 4))
         png_handle_IHDR(png_ptr, info_ptr, length);
      else if (!png_memcmp(chunk_name, png_IEND, 4))
         png_handle_IEND(png_ptr, info_ptr, length);
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
      else if (png_handle_as_unknown(png_ptr, chunk_name))
      {
         if (!png_memcmp(chunk_name, png_IDAT, 4))
         {
            if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
               png_benign_error(png_ptr, "Too many IDATs found");
         }
         png_handle_unknown(png_ptr, info_ptr, length);
         if (!png_memcmp(chunk_name, png_PLTE, 4))
            png_ptr->mode |= PNG_HAVE_PLTE;
      }
#endif
      else if (!png_memcmp(chunk_name, png_IDAT, 4))
      {
         /* Zero length IDATs are legal after the last IDAT has been
          * read, but not after other chunks have been read.
          */
         if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
            png_benign_error(png_ptr, "Too many IDATs found");
         png_crc_finish(png_ptr, length);
      }
      else if (!png_memcmp(chunk_name, png_PLTE, 4))
         png_handle_PLTE(png_ptr, info_ptr, length);
#ifdef PNG_READ_bKGD_SUPPORTED
      else if (!png_memcmp(chunk_name, png_bKGD, 4))
         png_handle_bKGD(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
      else if (!png_memcmp(chunk_name, png_cHRM, 4))
         png_handle_cHRM(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
      else if (!png_memcmp(chunk_name, png_gAMA, 4))
         png_handle_gAMA(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_hIST_SUPPORTED
      else if (!png_memcmp(chunk_name, png_hIST, 4))
         png_handle_hIST(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
      else if (!png_memcmp(chunk_name, png_oFFs, 4))
         png_handle_oFFs(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
      else if (!png_memcmp(chunk_name, png_pCAL, 4))
         png_handle_pCAL(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
      else if (!png_memcmp(chunk_name, png_sCAL, 4))
         png_handle_sCAL(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
      else if (!png_memcmp(chunk_name, png_pHYs, 4))
         png_handle_pHYs(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
      else if (!png_memcmp(chunk_name, png_sBIT, 4))
         png_handle_sBIT(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
      else if (!png_memcmp(chunk_name, png_sRGB, 4))
         png_handle_sRGB(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
      else if (!png_memcmp(chunk_name, png_iCCP, 4))
         png_handle_iCCP(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
      else if (!png_memcmp(chunk_name, png_sPLT, 4))
         png_handle_sPLT(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
      else if (!png_memcmp(chunk_name, png_tEXt, 4))
         png_handle_tEXt(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tIME_SUPPORTED
      else if (!png_memcmp(chunk_name, png_tIME, 4))
         png_handle_tIME(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
      else if (!png_memcmp(chunk_name, png_tRNS, 4))
         png_handle_tRNS(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
      else if (!png_memcmp(chunk_name, png_zTXt, 4))
         png_handle_zTXt(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
      else if (!png_memcmp(chunk_name, png_iTXt, 4))
         png_handle_iTXt(png_ptr, info_ptr, length);
#endif
      else
         png_handle_unknown(png_ptr, info_ptr, length);
   } while (!(png_ptr->mode & PNG_HAVE_IEND));
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0x1023c4
jmp 0x102b30
movq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x122b90
movl 0x3ce53(%rip), %eax     # 0x13f22c
movl %eax, 0x73(%rsp)
movb 0x3ce4d(%rip), %al      # 0x13f230
movb %al, 0x77(%rsp)
movl 0x36dfd(%rip), %eax     # 0x1391ea
movl %eax, 0x6e(%rsp)
movb 0x36df7(%rip), %al      # 0x1391ee
movb %al, 0x72(%rsp)
movl 0x36db2(%rip), %eax     # 0x1391b3
movl %eax, 0x69(%rsp)
movb 0x36dac(%rip), %al      # 0x1391b7
movb %al, 0x6d(%rsp)
movl 0x3ce43(%rip), %eax     # 0x13f258
movl %eax, 0x64(%rsp)
movb 0x3ce3d(%rip), %al      # 0x13f25c
movb %al, 0x68(%rsp)
movl 0x3d4f3(%rip), %eax     # 0x13f91c
movl %eax, 0x5f(%rsp)
movb 0x3d4ed(%rip), %al      # 0x13f920
movb %al, 0x63(%rsp)
movl 0x3d0ae(%rip), %eax     # 0x13f4eb
movl %eax, 0x5a(%rsp)
movb 0x3d0a8(%rip), %al      # 0x13f4ef
movb %al, 0x5e(%rsp)
movl 0x3cf08(%rip), %eax     # 0x13f359
movl %eax, 0x55(%rsp)
movb 0x3cf02(%rip), %al      # 0x13f35d
movb %al, 0x59(%rsp)
movl 0x3d553(%rip), %eax     # 0x13f9b8
movl %eax, 0x50(%rsp)
movb 0x3d54d(%rip), %al      # 0x13f9bc
movb %al, 0x54(%rsp)
movl 0x3d1d7(%rip), %eax     # 0x13f650
movl %eax, 0x4b(%rsp)
movb 0x3d1d1(%rip), %al      # 0x13f654
movb %al, 0x4f(%rsp)
movl 0x3d9fc(%rip), %eax     # 0x13fe89
movl %eax, 0x46(%rsp)
movb 0x3d9f6(%rip), %al      # 0x13fe8d
movb %al, 0x4a(%rsp)
movl 0x3d5c3(%rip), %eax     # 0x13fa64
movl %eax, 0x41(%rsp)
movb 0x3d5bd(%rip), %al      # 0x13fa68
movb %al, 0x45(%rsp)
movl 0x3d611(%rip), %eax     # 0x13fac6
movl %eax, 0x3c(%rsp)
movb 0x3d60b(%rip), %al      # 0x13faca
movb %al, 0x40(%rsp)
movl 0x3d539(%rip), %eax     # 0x13fa02
movl %eax, 0x37(%rsp)
movb 0x3d533(%rip), %al      # 0x13fa06
movb %al, 0x3b(%rsp)
movl 0x3cf63(%rip), %eax     # 0x13f440
movl %eax, 0x32(%rsp)
movb 0x3cf5d(%rip), %al      # 0x13f444
movb %al, 0x36(%rsp)
movl 0x3d6b6(%rip), %eax     # 0x13fba7
movl %eax, 0x2d(%rsp)
movb 0x3d6b0(%rip), %al      # 0x13fbab
movb %al, 0x31(%rsp)
movl 0x3d292(%rip), %eax     # 0x13f797
movl %eax, 0x28(%rsp)
movb 0x3d28c(%rip), %al      # 0x13f79b
movb %al, 0x2c(%rsp)
movl 0x3d08c(%rip), %eax     # 0x13f5a5
movl %eax, 0x23(%rsp)
movb 0x3d086(%rip), %al      # 0x13f5a9
movb %al, 0x27(%rsp)
movl 0x3d7c6(%rip), %eax     # 0x13fcf3
movl %eax, 0x1e(%rsp)
movb 0x3d7c0(%rip), %al      # 0x13fcf7
movb %al, 0x22(%rsp)
movl 0x36c77(%rip), %eax     # 0x1391b8
movl %eax, 0x19(%rsp)
movb 0x36c71(%rip), %al      # 0x1391bc
movb %al, 0x1d(%rsp)
movl 0x3d33c(%rip), %eax     # 0x13f891
movl %eax, 0x14(%rsp)
movb 0x3d336(%rip), %al      # 0x13f895
movb %al, 0x18(%rsp)
movl 0x3d836(%rip), %eax     # 0x13fd9f
movl %eax, 0xf(%rsp)
movb 0x3d830(%rip), %al      # 0x13fda3
movb %al, 0x13(%rsp)
movq 0x80(%rsp), %rdi
callq 0x122970
movl %eax, 0x8(%rsp)
movq 0x80(%rsp), %rax
addq $0x244, %rax            # imm = 0x244
movq %rax, (%rsp)
movq (%rsp), %rax
leaq 0x73(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1025cf
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1232e0
jmp 0x102b0d
movq (%rsp), %rax
leaq 0x69(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102604
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x123870
jmp 0x102b0b
movq 0x80(%rsp), %rdi
movq (%rsp), %rsi
callq 0xfc3e0
cmpl $0x0, %eax
je 0x1026b9
movq (%rsp), %rax
leaq 0x6e(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10266d
cmpl $0x0, 0x8(%rsp)
ja 0x102657
movq 0x80(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x10266b
movq 0x80(%rsp), %rdi
leaq 0x36c31(%rip), %rsi     # 0x139297
callq 0x113860
jmp 0x10266d
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1275d0
movq (%rsp), %rax
leaq 0x64(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1026b4
movq 0x80(%rsp), %rax
movl 0x11c(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x11c(%rax)
jmp 0x102b09
movq (%rsp), %rax
leaq 0x6e(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10271c
cmpl $0x0, 0x8(%rsp)
ja 0x1026f2
movq 0x80(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x102706
movq 0x80(%rsp), %rdi
leaq 0x36b96(%rip), %rsi     # 0x139297
callq 0x113860
movq 0x80(%rsp), %rdi
movl 0x8(%rsp), %esi
callq 0x122b90
jmp 0x102b07
movq (%rsp), %rax
leaq 0x64(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102751
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x123560
jmp 0x102b05
movq (%rsp), %rax
leaq 0x5f(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102786
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x125540
jmp 0x102b03
movq (%rsp), %rax
leaq 0x5a(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1027bb
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x123d90
jmp 0x102b01
movq (%rsp), %rax
leaq 0x55(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1027f0
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x123910
jmp 0x102aff
movq (%rsp), %rax
leaq 0x50(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102825
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1258a0
jmp 0x102afd
movq (%rsp), %rax
leaq 0x41(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10285a
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x125c50
jmp 0x102afb
movq (%rsp), %rax
leaq 0x3c(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10288f
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x125e70
jmp 0x102af9
movq (%rsp), %rax
leaq 0x2d(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1028c4
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x126470
jmp 0x102af7
movq (%rsp), %rax
leaq 0x37(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1028f9
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x125ad0
jmp 0x102af5
movq (%rsp), %rax
leaq 0x32(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10292e
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x123b50
jmp 0x102af3
movq (%rsp), %rax
leaq 0x23(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102963
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1243c0
jmp 0x102af1
movq (%rsp), %rax
leaq 0x4b(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102998
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x124710
jmp 0x102aef
movq (%rsp), %rax
leaq 0x28(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1029cd
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x124bf0
jmp 0x102aed
movq (%rsp), %rax
leaq 0x1e(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102a02
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x126960
jmp 0x102aeb
movq (%rsp), %rax
leaq 0x19(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102a37
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x126810
jmp 0x102ae9
movq (%rsp), %rax
leaq 0x14(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102a69
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x125140
jmp 0x102ae7
movq (%rsp), %rax
leaq 0xf(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102a9b
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x126c90
jmp 0x102ae5
movq (%rsp), %rax
leaq 0x46(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x102acd
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x127070
jmp 0x102ae3
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1275d0
jmp 0x102ae5
jmp 0x102ae7
jmp 0x102ae9
jmp 0x102aeb
jmp 0x102aed
jmp 0x102aef
jmp 0x102af1
jmp 0x102af3
jmp 0x102af5
jmp 0x102af7
jmp 0x102af9
jmp 0x102afb
jmp 0x102afd
jmp 0x102aff
jmp 0x102b01
jmp 0x102b03
jmp 0x102b05
jmp 0x102b07
jmp 0x102b09
jmp 0x102b0b
jmp 0x102b0d
jmp 0x102b0f
movq 0x80(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1023d3
addq $0x88, %rsp
retq
nopl (%rax,%rax)