// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/pngwrite.c
// Function: png_create_write_struct_2
png_structp PNGAPI
png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
   png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
   png_malloc_ptr malloc_fn, png_free_ptr free_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
   volatile int png_cleanup_needed = 0;
#ifdef PNG_SETJMP_SUPPORTED
   volatile
#endif
   png_structp png_ptr;
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
   jmp_buf jmpbuf;
#endif
#endif
   int i;

   png_debug(1, "in png_create_write_struct");

#ifdef PNG_USER_MEM_SUPPORTED
   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
      (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
#else
   png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
#endif /* PNG_USER_MEM_SUPPORTED */
   if (png_ptr == NULL)
      return (NULL);

   /* Added at libpng-1.2.6 */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
   png_ptr->user_width_max = PNG_USER_WIDTH_MAX;
   png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;
#endif

#ifdef PNG_SETJMP_SUPPORTED
/* Applications that neglect to set up their own setjmp() and then
   encounter a png_error() will longjmp here.  Since the jmpbuf is
   then meaningless we abort instead of returning. */
#ifdef USE_FAR_KEYWORD
   if (setjmp(jmpbuf))
#else
   if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */
#endif
#ifdef USE_FAR_KEYWORD
   png_memcpy(png_jmpbuf(png_ptr), jmpbuf, png_sizeof(jmp_buf));
#endif
      PNG_ABORT();
#endif

#ifdef PNG_USER_MEM_SUPPORTED
   png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
#endif /* PNG_USER_MEM_SUPPORTED */
   png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);

   if (user_png_ver)
   {
      i = 0;
      do
      {
         if (user_png_ver[i] != png_libpng_ver[i])
            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
      } while (png_libpng_ver[i++]);
   }

   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
   {
     /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
      * we must recompile any applications that use any older library version.
      * For versions after libpng 1.0, we will be compatible, so we need
      * only check the first digit.
      */
     if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
         (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
         (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
     {
#ifdef PNG_STDIO_SUPPORTED
        char msg[80];
        if (user_png_ver)
        {
           png_snprintf(msg, 80,
              "Application was compiled with png.h from libpng-%.20s",
              user_png_ver);
           png_warning(png_ptr, msg);
        }
        png_snprintf(msg, 80,
           "Application  is  running with png.c from libpng-%.20s",
           png_libpng_ver);
        png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
        png_ptr->flags = 0;
#endif
        png_warning(png_ptr,
           "Incompatible libpng version in application and library");
        png_cleanup_needed = 1;
     }
   }

   /* Initialize zbuf - compression buffer */
   png_ptr->zbuf_size = PNG_ZBUF_SIZE;
   if (!png_cleanup_needed)
   {
      png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr,
         png_ptr->zbuf_size);
      if (png_ptr->zbuf == NULL)
         png_cleanup_needed = 1;
   }
   if (png_cleanup_needed)
   {
       /* Clean up PNG structure and deallocate any memory. */
       png_free(png_ptr, png_ptr->zbuf);
       png_ptr->zbuf = 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
       return (NULL);
   }

   png_set_write_fn(png_ptr, NULL, NULL, NULL);

#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
   png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
      1, NULL, NULL);
#endif

   return (png_ptr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r14
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r15
movl $0x0, 0xc(%rsp)
movl $0x1, %edi
movq %r9, %rsi
movq %r8, %rdx
callq 0x92bd2
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
je 0x8ca94
movq (%rsp), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
movl %ecx, 0x454(%rax)
movq (%rsp), %rax
movl %ecx, 0x458(%rax)
movq (%rsp), %rdi
movq 0x586b6(%rip), %rsi     # 0xe4f78
movl $0xc8, %edx
callq 0x92fde
movq %rax, %rdi
callq 0xe680
testl %eax, %eax
jne 0x8cad4
movq 0xa0(%rsp), %rcx
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x92da5
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x93000
testq %r15, %r15
je 0x8c940
xorl %ebp, %ebp
movl %ebp, %r14d
movb (%r15,%r14), %r12b
movl %ebp, %edi
callq 0x88288
cmpb (%rax,%r14), %r12b
je 0x8c92b
movq (%rsp), %rax
orb $0x2, 0x122(%rax)
movl %ebp, %edi
callq 0x88288
leaq 0x1(%r14), %rcx
cmpb $0x0, (%rax,%r14)
movq %rcx, %r14
jne 0x8c90f
movq (%rsp), %rax
testb $0x2, 0x122(%rax)
je 0x8ca0b
testq %r15, %r15
je 0x8c9c0
movb (%r15), %bpl
xorl %eax, %eax
movl %eax, %edi
callq 0x88288
cmpb (%rax), %bpl
jne 0x8c991
cmpb $0x31, (%r15)
jne 0x8c980
movb 0x2(%r15), %bpl
xorl %eax, %eax
movl %eax, %edi
callq 0x88288
cmpb 0x2(%rax), %bpl
jne 0x8c991
cmpb $0x30, (%r15)
jne 0x8ca0b
cmpb $0x38, 0x2(%r15)
jg 0x8ca0b
testq %r15, %r15
je 0x8c9c0
leaq 0x1fe4f(%rip), %rdx     # 0xac7ec
xorl %eax, %eax
leaq 0x10(%rsp), %r14
movl $0x50, %esi
movq %r14, %rdi
movq %r15, %rcx
callq 0xe750
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x92e6e
xorl %ebp, %ebp
movl %ebp, %edi
callq 0x88288
movq %rax, %rcx
leaq 0x1fe4f(%rip), %rdx     # 0xac822
movl %ebp, %eax
leaq 0x10(%rsp), %r14
movl $0x50, %esi
movq %r14, %rdi
callq 0xe750
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x92e6e
movq (%rsp), %rdi
leaq 0x1fe5a(%rip), %rsi     # 0xac858
callq 0x92e6e
movl $0x1, 0xc(%rsp)
movq (%rsp), %rax
movq $0x2000, 0x1a0(%rax) # imm = 0x2000
cmpl $0x0, 0xc(%rsp)
jne 0x8ca56
movq (%rsp), %rdi
movq (%rsp), %rax
movq 0x1a0(%rax), %rsi
callq 0x92d72
movq (%rsp), %rcx
movq %rax, 0x198(%rcx)
movq (%rsp), %rax
cmpq $0x0, 0x198(%rax)
jne 0x8ca56
movl $0x1, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
movq (%rsp), %rdi
je 0x8ca98
movq (%rsp), %rax
movq 0x198(%rax), %rsi
callq 0x92d32
movq (%rsp), %rax
movq $0x0, 0x198(%rax)
movq (%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq %rbx, %rdx
callq 0x92c64
xorl %eax, %eax
jmp 0x8cac5
xorl %ebx, %ebx
movl %ebx, %r14d
movq %r14, %rsi
movq %r14, %rdx
movq %r14, %rcx
callq 0xa14fe
movq (%rsp), %rdi
movl %ebx, %esi
movl $0x1, %edx
movq %r14, %rcx
movq %r14, %r8
callq 0x8cad9
movq (%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xe270