// File: /workspace/github_cpp_makefile_star2_O2/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 0x8bf21
leaq 0x1787d(%rip), %rsi     # 0xa36e5
movq %rbx, %rdi
callq 0x849c0
testq %r14, %r14
je 0x8be8f
movl $0x801, %eax            # imm = 0x801
andl 0x8(%r14), %eax
cmpl $0x1, %eax
jne 0x8be8f
leaq 0x178a4(%rip), %rsi     # 0xa372e
jmp 0x8bf51
cmpl $0x4, %ebp
jne 0x8bf41
leaq 0x4(%rsp), %rsi
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x8b6d7
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8b703
testl %eax, %eax
jne 0x8bf7c
movl 0x4(%rsp), %r15d
bswapl %r15d
testl %r15d, %r15d
je 0x8bf6d
testq %r14, %r14
je 0x8beed
leal -0xb3b1(%r15), %eax
cmpl $0xfffffc16, %eax       # imm = 0xFFFFFC16
ja 0x8beed
movl $0x800, %eax            # imm = 0x800
andl 0x8(%r14), %eax
jne 0x8bf87
cvtsi2ss %r15d, %xmm0
divss 0x17602(%rip), %xmm0    # 0xa34fc
movss %xmm0, 0x28c(%rbx)
cvtss2sd %xmm0, %xmm0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7af28
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x7afbb
jmp 0x8bf7c
testb $0x4, %al
jne 0x8bf4a
testb $0x2, %al
je 0x8be70
leaq 0x177e2(%rip), %rsi     # 0xa3716
movq %rbx, %rdi
callq 0x84a53
jmp 0x8be70
leaq 0x177fb(%rip), %rsi     # 0xa3743
jmp 0x8bf51
leaq 0x177ad(%rip), %rsi     # 0xa36fe
movq %rbx, %rdi
callq 0x84a53
movq %rbx, %rdi
movl %ebp, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8b703
leaq 0x177eb(%rip), %rsi     # 0xa375f
movq %rbx, %rdi
callq 0x84a53
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x177f2(%rip), %rsi     # 0xa3780
movq %rbx, %rdi
callq 0x84a53
movq 0x4e023(%rip), %rax     # 0xd9fc0
movq (%rax), %rdi
leaq 0x17811(%rip), %rsi     # 0xa37b8
movl %r15d, %edx
xorl %eax, %eax
callq 0xe6a0
jmp 0x8bf7c