// File: /workspace/github_cpp_makefile_star2_O2/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 0x8c449
leaq 0x17541(%rip), %rsi     # 0xa3931
movq %rbx, %rdi
callq 0x849c0
testq %r14, %r14
je 0x8c404
testb $0x8, 0x9(%r14)
jne 0x8c474
cmpl $0x1, %ebp
jne 0x8c462
leaq 0xf(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x8b6d7
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8b703
testl %eax, %eax
jne 0x8c57e
movzbl 0xf(%rsp), %ebp
cmpl $0x4, %ebp
jb 0x8c495
leaq 0x1756f(%rip), %rsi     # 0xa39ab
movq %rbx, %rdi
callq 0x84a53
jmp 0x8c57e
testb $0x4, %al
jne 0x8c46b
testb $0x2, %al
je 0x8c3f8
leaq 0x1750a(%rip), %rsi     # 0xa3962
movq %rbx, %rdi
callq 0x84a53
jmp 0x8c3f8
leaq 0x17526(%rip), %rsi     # 0xa398f
jmp 0x8c47b
leaq 0x174d8(%rip), %rsi     # 0xa394a
jmp 0x8c47b
leaq 0x174ff(%rip), %rsi     # 0xa397a
movq %rbx, %rdi
callq 0x84a53
movq %rbx, %rdi
movl %ebp, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x8b703
testq %r14, %r14
je 0x8c571
movl 0x8(%r14), %eax
testb $0x1, %al
je 0x8c4be
movl $0xffff4c4f, %ecx       # imm = 0xFFFF4C4F
addl 0x148(%r14), %ecx
cmpl $0xfffffc16, %ecx       # imm = 0xFFFFFC16
jbe 0x8c587
testb $0x4, %al
je 0x8c571
movl $0xffff81f1, %eax       # imm = 0xFFFF81F1
addl 0x14c(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffff7b93, %eax       # imm = 0xFFFF7B93
addl 0x150(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffff0217, %eax       # imm = 0xFFFF0217
addl 0x154(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffff7b2f, %eax       # imm = 0xFFFF7B2F
addl 0x158(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffff86e7, %eax       # imm = 0xFFFF86E7
addl 0x15c(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffff11b7, %eax       # imm = 0xFFFF11B7
addl 0x160(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffffc17f, %eax       # imm = 0xFFFFC17F
addl 0x164(%r14), %eax
cmpl $0xfffff82f, %eax       # imm = 0xFFFFF82F
jb 0x8c562
movl $0xffffe4a7, %eax       # imm = 0xFFFFE4A7
addl 0x168(%r14), %eax
cmpl $0xfffff82e, %eax       # imm = 0xFFFFF82E
ja 0x8c571
leaq 0x17358(%rip), %rsi     # 0xa38c1
movq %rbx, %rdi
callq 0x84a53
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x7b4d9
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x171f2(%rip), %rsi     # 0xa3780
movq %rbx, %rdi
callq 0x84a53
movq 0x4da23(%rip), %rax     # 0xd9fc0
movq (%rax), %rdi
movl 0x40c(%rbx), %edx
leaq 0x17412(%rip), %rsi     # 0xa39bf
xorl %eax, %eax
callq 0xe6a0
movl 0x8(%r14), %eax
jmp 0x8c4be