// File: /workspace/github_cpp_makefile_star2_O2/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)
pushq $0x1
popq %rdi
movq %r9, %rsi
movq %r8, %rdx
callq 0x847ed
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
je 0x7e9fa
movq (%rsp), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
movl %ecx, 0x454(%rax)
movq (%rsp), %rax
movl %ecx, 0x458(%rax)
movq (%rsp), %rdi
movq 0x5b755(%rip), %rsi     # 0xd9f88
movl $0xc8, %edx
callq 0x84bd8
movq %rax, %rdi
callq 0xe6b0
testl %eax, %eax
jne 0x7ea38
movq 0xa0(%rsp), %rcx
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x84993
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x84bfa
testq %r15, %r15
je 0x7e8b1
xorl %ebp, %ebp
movl %ebp, %r14d
movb (%r15,%r14), %r12b
movl %ebp, %edi
callq 0x7a86f
cmpb (%rax,%r14), %r12b
je 0x7e89c
movq (%rsp), %rax
orb $0x2, 0x122(%rax)
movl %ebp, %edi
callq 0x7a86f
leaq 0x1(%r14), %rcx
cmpb $0x0, (%rax,%r14)
movq %rcx, %r14
jne 0x7e880
movq (%rsp), %rax
testb $0x2, 0x122(%rax)
je 0x7e974
testq %r15, %r15
je 0x7e92b
movb (%r15), %bpl
xorl %eax, %eax
movl %eax, %edi
callq 0x7a86f
cmpb (%rax), %bpl
jne 0x7e903
movb (%r15), %cl
movl %ecx, %eax
cmpb $0x31, %cl
jne 0x7e8f8
movb 0x2(%r15), %bpl
xorl %eax, %eax
movl %eax, %edi
callq 0x7a86f
cmpb 0x2(%rax), %bpl
jne 0x7e903
movb (%r15), %al
cmpb $0x30, %al
jne 0x7e974
cmpb $0x39, 0x2(%r15)
jge 0x7e974
leaq 0x1ec02(%rip), %rdx     # 0x9d50c
xorl %eax, %eax
leaq 0x10(%rsp), %r14
pushq $0x50
popq %rsi
movq %r14, %rdi
movq %r15, %rcx
callq 0xe780
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x84a53
xorl %ebp, %ebp
movl %ebp, %edi
callq 0x7a86f
movq %rax, %rcx
leaq 0x1ec04(%rip), %rdx     # 0x9d542
movl %ebp, %eax
leaq 0x10(%rsp), %r14
pushq $0x50
popq %rsi
movq %r14, %rdi
callq 0xe780
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x84a53
movq (%rsp), %rdi
leaq 0x1ec11(%rip), %rsi     # 0x9d578
callq 0x84a53
movl $0x1, 0xc(%rsp)
movq (%rsp), %rax
movq $0x2000, 0x1a0(%rax) # imm = 0x2000
cmpl $0x0, 0xc(%rsp)
jne 0x7e9bf
movq (%rsp), %rdi
movq (%rsp), %rax
movq 0x1a0(%rax), %rsi
callq 0x84960
movq (%rsp), %rcx
movq %rax, 0x198(%rcx)
movq (%rsp), %rax
cmpq $0x0, 0x198(%rax)
jne 0x7e9bf
movl $0x1, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
movq (%rsp), %rdi
je 0x7e9fe
movq (%rsp), %rax
movq 0x198(%rax), %rsi
callq 0x84923
movq (%rsp), %rax
andq $0x0, 0x198(%rax)
movq (%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq %rbx, %rdx
callq 0x8486a
xorl %eax, %eax
jmp 0x7ea29
xorl %ebx, %ebx
movl %ebx, %r14d
movq %r14, %rsi
movq %r14, %rdx
movq %r14, %rcx
callq 0x92250
movq (%rsp), %rdi
pushq $0x1
popq %rdx
movl %ebx, %esi
movq %r14, %rcx
movq %r14, %r8
callq 0x7ea3d
movq (%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xe280