// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_gAMA
void /* PRIVATE */
png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   png_fixed_point igamma;
#ifdef PNG_FLOATING_POINT_SUPPORTED
   float file_gamma;
#endif
   png_byte buf[4];

   png_debug(1, "in png_handle_gAMA");

   if (!(png_ptr->mode & PNG_HAVE_IHDR))
      png_error(png_ptr, "Missing IHDR before gAMA");
   else if (png_ptr->mode & PNG_HAVE_IDAT)
   {
      png_warning(png_ptr, "Invalid gAMA after IDAT");
      png_crc_finish(png_ptr, length);
      return;
   }
   else if (png_ptr->mode & PNG_HAVE_PLTE)
      /* Should be an error, but we can cope with it */
      png_warning(png_ptr, "Out of place gAMA chunk");

   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
#ifdef PNG_READ_sRGB_SUPPORTED
      && !(info_ptr->valid & PNG_INFO_sRGB)
#endif
      )
   {
      png_warning(png_ptr, "Duplicate gAMA chunk");
      png_crc_finish(png_ptr, length);
      return;
   }

   if (length != 4)
   {
      png_warning(png_ptr, "Incorrect gAMA chunk length");
      png_crc_finish(png_ptr, length);
      return;
   }

   png_crc_read(png_ptr, buf, 4);
   if (png_crc_finish(png_ptr, 0))
      return;

   igamma = (png_fixed_point)png_get_uint_32(buf);
   /* Check for zero gamma */
   if (igamma == 0)
      {
         png_warning(png_ptr,
           "Ignoring gAMA chunk with gamma=0");
         return;
      }

#ifdef PNG_READ_sRGB_SUPPORTED
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
      if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
      {
         png_warning(png_ptr,
           "Ignoring incorrect gAMA value when sRGB is also present");
#ifdef PNG_CONSOLE_IO_SUPPORTED
         fprintf(stderr, "gamma = (%d/100000)", (int)igamma);
#endif
         return;
      }
#endif /* PNG_READ_sRGB_SUPPORTED */

#ifdef PNG_FLOATING_POINT_SUPPORTED
   file_gamma = (float)igamma / (float)100000.0;
#  ifdef PNG_READ_GAMMA_SUPPORTED
     png_ptr->gamma = file_gamma;
#  endif
     png_set_gAMA(png_ptr, info_ptr, file_gamma);
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
   png_set_gAMA_fixed(png_ptr, info_ptr, igamma);
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x11c(%rdi), %eax
testb $0x1, %al
jne 0x9a3f9
leaq 0x186f7(%rip), %rsi     # 0xb2a35
movq %rbx, %rdi
callq 0x920b4
testq %r14, %r14
je 0x9a365
movl $0x801, %eax            # imm = 0x801
andl 0x8(%r14), %eax
cmpl $0x1, %eax
jne 0x9a365
leaq 0x1871e(%rip), %rsi     # 0xb2a7e
jmp 0x9a429
cmpl $0x4, %ebp
jne 0x9a419
leaq 0x4(%rsp), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x99b23
movq %rbx, %rdi
xorl %esi, %esi
callq 0x99b4f
testl %eax, %eax
jne 0x9a454
movl 0x4(%rsp), %r15d
bswapl %r15d
testl %r15d, %r15d
je 0x9a445
testq %r14, %r14
je 0x9a3c5
leal -0xb3b1(%r15), %eax
cmpl $0xfffffc16, %eax       # imm = 0xFFFFFC16
ja 0x9a3c5
movl $0x800, %eax            # imm = 0x800
andl 0x8(%r14), %eax
jne 0x9a45f
cvtsi2ss %r15d, %xmm0
divss 0x1847a(%rip), %xmm0    # 0xb284c
movss %xmm0, 0x28c(%rbx)
cvtss2sd %xmm0, %xmm0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x87bc4
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x87c57
jmp 0x9a454
testb $0x4, %al
jne 0x9a422
testb $0x2, %al
je 0x9a346
leaq 0x1865a(%rip), %rsi     # 0xb2a66
movq %rbx, %rdi
callq 0x9214d
jmp 0x9a346
leaq 0x18673(%rip), %rsi     # 0xb2a93
jmp 0x9a429
leaq 0x18625(%rip), %rsi     # 0xb2a4e
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movl %ebp, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x99b4f
leaq 0x18663(%rip), %rsi     # 0xb2aaf
movq %rbx, %rdi
callq 0x9214d
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl %r15d, %esi
callq 0xee86
jmp 0x9a454