// File: tomfunkhouser[P]gaps/pkgs/png/pngwrite.c
// Function: png_write_destroy
void /* PRIVATE */
png_write_destroy(png_structp png_ptr)
{
#ifdef PNG_SETJMP_SUPPORTED
   jmp_buf tmp_jmp; /* Save jump buffer */
#endif
   png_error_ptr error_fn;
   png_error_ptr warning_fn;
   png_voidp error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
   png_free_ptr free_fn;
#endif

   png_debug(1, "in png_write_destroy");

   /* Free any memory zlib uses */
   deflateEnd(&png_ptr->zstream);

   /* Free our memory.  png_free checks NULL for us. */
   png_free(png_ptr, png_ptr->zbuf);
   png_free(png_ptr, png_ptr->row_buf);
#ifdef PNG_WRITE_FILTER_SUPPORTED
   png_free(png_ptr, png_ptr->prev_row);
   png_free(png_ptr, png_ptr->sub_row);
   png_free(png_ptr, png_ptr->up_row);
   png_free(png_ptr, png_ptr->avg_row);
   png_free(png_ptr, png_ptr->paeth_row);
#endif

#ifdef PNG_TIME_RFC1123_SUPPORTED
   png_free(png_ptr, png_ptr->time_buffer);
#endif

#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
   png_free(png_ptr, png_ptr->prev_filters);
   png_free(png_ptr, png_ptr->filter_weights);
   png_free(png_ptr, png_ptr->inv_filter_weights);
   png_free(png_ptr, png_ptr->filter_costs);
   png_free(png_ptr, png_ptr->inv_filter_costs);
#endif

#ifdef PNG_SETJMP_SUPPORTED
   /* Reset structure */
   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
#endif

   error_fn = png_ptr->error_fn;
   warning_fn = png_ptr->warning_fn;
   error_ptr = png_ptr->error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
   free_fn = png_ptr->free_fn;
#endif

   png_memset(png_ptr, 0, png_sizeof(png_struct));

   png_ptr->error_fn = error_fn;
   png_ptr->warning_fn = warning_fn;
   png_ptr->error_ptr = error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
   png_ptr->free_fn = free_fn;
#endif

#ifdef PNG_SETJMP_SUPPORTED
   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
#endif
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
addq $0x128, %rdi            # imm = 0x128
callq 0x115350
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x198(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x1f0(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x1e8(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x1f8(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x200(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x208(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x210(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x3d0(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x3a8(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x3b0(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x3b8(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x3c0(%rax), %rsi
callq 0x1136d0
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x3c8(%rax), %rsi
callq 0x1136d0
leaq 0x20(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movl $0xc8, %edx
callq 0xf3d0
movq 0xf0(%rsp), %rax
movq 0xd0(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0xf0(%rsp), %rax
movq 0xd8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0xf0(%rsp), %rax
movq 0xe0(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x428(%rax), %rax
movq %rax, (%rsp)
movq 0xf0(%rsp), %rdi
xorl %esi, %esi
movl $0x498, %edx            # imm = 0x498
callq 0xf280
movq 0x18(%rsp), %rcx
movq 0xf0(%rsp), %rax
movq %rcx, 0xd0(%rax)
movq 0x10(%rsp), %rcx
movq 0xf0(%rsp), %rax
movq %rcx, 0xd8(%rax)
movq 0x8(%rsp), %rcx
movq 0xf0(%rsp), %rax
movq %rcx, 0xe0(%rax)
movq (%rsp), %rcx
movq 0xf0(%rsp), %rax
movq %rcx, 0x428(%rax)
movq 0xf0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0xc8, %edx
callq 0xf3d0
addq $0xf8, %rsp
retq
nopw (%rax,%rax)