// File: tomfunkhouser[P]gaps/pkgs/png/pngread.c
// Function: png_destroy_read_struct
void PNGAPI
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
   png_infopp end_info_ptr_ptr)
{
   png_structp png_ptr = NULL;
   png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
   png_free_ptr free_fn = NULL;
   png_voidp mem_ptr = NULL;
#endif

   png_debug(1, "in png_destroy_read_struct");
 
   if (png_ptr_ptr != NULL)
      png_ptr = *png_ptr_ptr;
   if (png_ptr == NULL)
      return;

#ifdef PNG_USER_MEM_SUPPORTED
   free_fn = png_ptr->free_fn;
   mem_ptr = png_ptr->mem_ptr;
#endif

   if (info_ptr_ptr != NULL)
      info_ptr = *info_ptr_ptr;

   if (end_info_ptr_ptr != NULL)
      end_info_ptr = *end_info_ptr_ptr;

   png_read_destroy(png_ptr, info_ptr, end_info_ptr);

   if (info_ptr != NULL)
   {
#ifdef PNG_TEXT_SUPPORTED
      png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);
#endif

#ifdef PNG_USER_MEM_SUPPORTED
      png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
          (png_voidp)mem_ptr);
#else
      png_destroy_struct((png_voidp)info_ptr);
#endif
      *info_ptr_ptr = NULL;
   }

   if (end_info_ptr != NULL)
   {
#ifdef PNG_READ_TEXT_SUPPORTED
      png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);
#endif
#ifdef PNG_USER_MEM_SUPPORTED
      png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn,
         (png_voidp)mem_ptr);
#else
      png_destroy_struct((png_voidp)end_info_ptr);
#endif
      *end_info_ptr_ptr = NULL;
   }

   if (png_ptr != NULL)
   {
#ifdef PNG_USER_MEM_SUPPORTED
      png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
          (png_voidp)mem_ptr);
#else
      png_destroy_struct((png_voidp)png_ptr);
#endif
      *png_ptr_ptr = NULL;
   }
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0x102b95
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x102ba2
jmp 0x102cac
movq 0x28(%rsp), %rax
movq 0x428(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movq 0x418(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x102bd9
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x102bee
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x102cc0
cmpq $0x0, 0x20(%rsp)
je 0x102c43
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x4000, %edx           # imm = 0x4000
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xfba80
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x1134e0
movq 0x38(%rsp), %rax
movq $0x0, (%rax)
cmpq $0x0, 0x18(%rsp)
je 0x102c84
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x4000, %edx           # imm = 0x4000
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xfba80
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x1134e0
movq 0x30(%rsp), %rax
movq $0x0, (%rax)
cmpq $0x0, 0x28(%rsp)
je 0x102cac
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x1134e0
movq 0x40(%rsp), %rax
movq $0x0, (%rax)
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)