// File: /workspace/github_cpp_makefile_star2_O1/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 0x9adaf
leaq 0x17ced(%rip), %rsi     # 0xb29e1
movq %rbx, %rdi
callq 0x92dd0
testq %r14, %r14
je 0x9ad1b
movl $0x801, %eax            # imm = 0x801
andl 0x8(%r14), %eax
cmpl $0x1, %eax
jne 0x9ad1b
leaq 0x17d14(%rip), %rsi     # 0xb2a2a
jmp 0x9addf
cmpl $0x4, %ebp
jne 0x9adcf
leaq 0x4(%rsp), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x9a4db
movq %rbx, %rdi
xorl %esi, %esi
callq 0x9a507
testl %eax, %eax
jne 0x9ae0a
movl 0x4(%rsp), %r15d
bswapl %r15d
testl %r15d, %r15d
je 0x9adfb
testq %r14, %r14
je 0x9ad7b
leal -0xb3b1(%r15), %eax
cmpl $0xfffffc16, %eax       # imm = 0xFFFFFC16
ja 0x9ad7b
movl $0x800, %eax            # imm = 0x800
andl 0x8(%r14), %eax
jne 0x9ae15
cvtsi2ss %r15d, %xmm0
divss 0x179c8(%rip), %xmm0    # 0xb2750
movss %xmm0, 0x28c(%rbx)
cvtss2sd %xmm0, %xmm0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x889b4
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x88a47
jmp 0x9ae0a
testb $0x4, %al
jne 0x9add8
testb $0x2, %al
je 0x9acfc
leaq 0x17c50(%rip), %rsi     # 0xb2a12
movq %rbx, %rdi
callq 0x92e6e
jmp 0x9acfc
leaq 0x17c69(%rip), %rsi     # 0xb2a3f
jmp 0x9addf
leaq 0x17c1b(%rip), %rsi     # 0xb29fa
movq %rbx, %rdi
callq 0x92e6e
movq %rbx, %rdi
movl %ebp, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9a507
leaq 0x17c59(%rip), %rsi     # 0xb2a5b
movq %rbx, %rdi
callq 0x92e6e
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl %r15d, %esi
callq 0xee7d
jmp 0x9ae0a