// File: /workspace/github_cpp_makefile_star2_O1/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 0x9b2e7
leaq 0x179a1(%rip), %rsi     # 0xb2c2d
movq %rbx, %rdi
callq 0x92dd0
testq %r14, %r14
je 0x9b2a0
testb $0x8, 0x9(%r14)
jne 0x9b312
cmpl $0x1, %ebp
jne 0x9b300
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x9a4db
movq %rbx, %rdi
xorl %esi, %esi
callq 0x9a507
testl %eax, %eax
jne 0x9b41d
movzbl 0xf(%rsp), %ebp
cmpl $0x4, %ebp
jb 0x9b333
leaq 0x179cd(%rip), %rsi     # 0xb2ca7
movq %rbx, %rdi
callq 0x92e6e
jmp 0x9b41d
testb $0x4, %al
jne 0x9b309
testb $0x2, %al
je 0x9b294
leaq 0x17968(%rip), %rsi     # 0xb2c5e
movq %rbx, %rdi
callq 0x92e6e
jmp 0x9b294
leaq 0x17984(%rip), %rsi     # 0xb2c8b
jmp 0x9b319
leaq 0x17936(%rip), %rsi     # 0xb2c46
jmp 0x9b319
leaq 0x1795d(%rip), %rsi     # 0xb2c76
movq %rbx, %rdi
callq 0x92e6e
movq %rbx, %rdi
movl %ebp, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x9a507
testq %r14, %r14
je 0x9b410
testb $0x1, 0x8(%r14)
je 0x9b35a
movl $0xffff4c4f, %eax       # imm = 0xFFFF4C4F
addl 0x148(%r14), %eax
cmpl $0xfffffc16, %eax       # imm = 0xFFFFFC16
jbe 0x9b426
testb $0x4, 0x8(%r14)
je 0x9b410
movl $0xffff81f1, %eax       # imm = 0xFFFF81F1
addl 0x14c(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffff7b93, %eax       # imm = 0xFFFF7B93
addl 0x150(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffff0217, %eax       # imm = 0xFFFF0217
addl 0x154(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffff7b2f, %eax       # imm = 0xFFFF7B2F
addl 0x158(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffff86e7, %eax       # imm = 0xFFFF86E7
addl 0x15c(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffff11b7, %eax       # imm = 0xFFFF11B7
addl 0x160(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffffc17f, %eax       # imm = 0xFFFFC17F
addl 0x164(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x9b401
movl $0xffffe4a7, %eax       # imm = 0xFFFFE4A7
addl 0x168(%r14), %eax
cmpl $0xfffff82e, %eax       # imm = 0xFFFFF82E
ja 0x9b410
leaq 0x177b5(%rip), %rsi     # 0xb2bbd
movq %rbx, %rdi
callq 0x92e6e
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x88f6d
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
callq 0xeea8
jmp 0x9b35a