// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_sRGB
void /* PRIVATE */
png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   int intent;
   png_byte buf[1];

   png_debug(1, "in png_handle_sRGB");

   if (!(png_ptr->mode & PNG_HAVE_IHDR))
      png_error(png_ptr, "Missing IHDR before sRGB");
   else if (png_ptr->mode & PNG_HAVE_IDAT)
   {
      png_warning(png_ptr, "Invalid sRGB 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 sRGB chunk");

   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
   {
      png_warning(png_ptr, "Duplicate sRGB chunk");
      png_crc_finish(png_ptr, length);
      return;
   }

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

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

   intent = buf[0];
   /* Check for bad intent */
   if (intent >= PNG_sRGB_INTENT_LAST)
   {
      png_warning(png_ptr, "Unknown sRGB intent");
      return;
   }

#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA))
   {
   png_fixed_point igamma;
#ifdef PNG_FIXED_POINT_SUPPORTED
      igamma=info_ptr->int_gamma;
#else
#  ifdef PNG_FLOATING_POINT_SUPPORTED
      igamma=(png_fixed_point)(info_ptr->gamma * 100000.);
#  endif
#endif
      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
#  ifdef PNG_FIXED_POINT_SUPPORTED
         fprintf(stderr, "incorrect gamma=(%d/100000)\n",
            (int)png_ptr->int_gamma);
#  else
#    ifdef PNG_FLOATING_POINT_SUPPORTED
         fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma);
#    endif
#  endif
#endif
      }
   }
#endif /* PNG_READ_gAMA_SUPPORTED */

#ifdef PNG_READ_cHRM_SUPPORTED
#ifdef PNG_FIXED_POINT_SUPPORTED
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
      if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270,  1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900,  1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_x_red,   64000L, 1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_y_red,   33000,  1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000,  1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_x_blue,  15000,  1000) ||
          PNG_OUT_OF_RANGE(info_ptr->int_y_blue,   6000,  1000))
         {
            png_warning(png_ptr,
              "Ignoring incorrect cHRM value when sRGB is also present");
         }
#endif /* PNG_FIXED_POINT_SUPPORTED */
#endif /* PNG_READ_cHRM_SUPPORTED */

   png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x11c(%rdi), %eax
testb $0x1, %al
jne 0x9a92d
leaq 0x183af(%rip), %rsi     # 0xb2c81
movq %rbx, %rdi
callq 0x920b4
testq %r14, %r14
je 0x9a8e6
testb $0x8, 0x9(%r14)
jne 0x9a958
cmpl $0x1, %ebp
jne 0x9a946
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x99b23
movq %rbx, %rdi
xorl %esi, %esi
callq 0x99b4f
testl %eax, %eax
jne 0x9aa62
movzbl 0xf(%rsp), %ebp
cmpl $0x4, %ebp
jb 0x9a979
leaq 0x183db(%rip), %rsi     # 0xb2cfb
movq %rbx, %rdi
callq 0x9214d
jmp 0x9aa62
testb $0x4, %al
jne 0x9a94f
testb $0x2, %al
je 0x9a8da
leaq 0x18376(%rip), %rsi     # 0xb2cb2
movq %rbx, %rdi
callq 0x9214d
jmp 0x9a8da
leaq 0x18392(%rip), %rsi     # 0xb2cdf
jmp 0x9a95f
leaq 0x18344(%rip), %rsi     # 0xb2c9a
jmp 0x9a95f
leaq 0x1836b(%rip), %rsi     # 0xb2cca
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movl %ebp, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x99b4f
testq %r14, %r14
je 0x9aa55
movl 0x8(%r14), %eax
testb $0x1, %al
je 0x9a9a2
movl $0xffff4c4f, %ecx       # imm = 0xFFFF4C4F
addl 0x148(%r14), %ecx
cmpl $0xfffffc16, %ecx       # imm = 0xFFFFFC16
jbe 0x9aa6b
testb $0x4, %al
je 0x9aa55
movl $0xffff81f1, %eax       # imm = 0xFFFF81F1
addl 0x14c(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffff7b93, %eax       # imm = 0xFFFF7B93
addl 0x150(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffff0217, %eax       # imm = 0xFFFF0217
addl 0x154(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffff7b2f, %eax       # imm = 0xFFFF7B2F
addl 0x158(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffff86e7, %eax       # imm = 0xFFFF86E7
addl 0x15c(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffff11b7, %eax       # imm = 0xFFFF11B7
addl 0x160(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffffc17f, %eax       # imm = 0xFFFFC17F
addl 0x164(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9aa46
movl $0xffffe4a7, %eax       # imm = 0xFFFFE4A7
addl 0x168(%r14), %eax
cmpl $0xfffff82e, %eax       # imm = 0xFFFFF82E
ja 0x9aa55
leaq 0x181c4(%rip), %rsi     # 0xb2c11
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x88186
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1805e(%rip), %rsi     # 0xb2ad0
movq %rbx, %rdi
callq 0x9214d
movq 0x4a537(%rip), %rax     # 0xe4fb8
movq (%rax), %rdi
movl 0x40c(%rbx), %edx
leaq 0x1827e(%rip), %rsi     # 0xb2d0f
xorl %eax, %eax
callq 0xe670
movl 0x8(%r14), %eax
jmp 0x9a9a2