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

   png_debug(1, "in png_handle_sBIT");

   buf[0] = buf[1] = buf[2] = buf[3] = 0;

   if (!(png_ptr->mode & PNG_HAVE_IHDR))
      png_error(png_ptr, "Missing IHDR before sBIT");
   else if (png_ptr->mode & PNG_HAVE_IDAT)
   {
      png_warning(png_ptr, "Invalid sBIT 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 sBIT chunk");
   }
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
   {
      png_warning(png_ptr, "Duplicate sBIT chunk");
      png_crc_finish(png_ptr, length);
      return;
   }

   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
      truelen = 3;
   else
      truelen = (png_size_t)png_ptr->channels;

   if (length != truelen || length > 4)
   {
      png_warning(png_ptr, "Incorrect sBIT chunk length");
      png_crc_finish(png_ptr, length);
      return;
   }

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

   if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
   {
      png_ptr->sig_bit.red = buf[0];
      png_ptr->sig_bit.green = buf[1];
      png_ptr->sig_bit.blue = buf[2];
      png_ptr->sig_bit.alpha = buf[3];
   }
   else
   {
      png_ptr->sig_bit.gray = buf[0];
      png_ptr->sig_bit.red = buf[0];
      png_ptr->sig_bit.green = buf[0];
      png_ptr->sig_bit.blue = buf[0];
      png_ptr->sig_bit.alpha = buf[1];
   }
   png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl $0x0, 0xc(%rsp)
movl 0x11c(%rdi), %eax
testb $0x1, %al
jne 0x9a4da
leaq 0x18687(%rip), %rsi     # 0xb2b1c
movq %rbx, %rdi
callq 0x920b4
testq %r14, %r14
je 0x9a4ad
testb $0x2, 0x8(%r14)
jne 0x9a539
movl $0x3, %edx
cmpb $0x3, 0x24e(%rbx)
je 0x9a4c2
movzbl 0x252(%rbx), %edx
cmpl %ebp, %edx
sete %al
cmpl $0x5, %ebp
setb %cl
testb %al, %cl
jne 0x9a4f3
leaq 0x186a2(%rip), %rsi     # 0xb2b7a
jmp 0x9a540
testb $0x4, %al
jne 0x9a530
testb $0x2, %al
je 0x9a49d
leaq 0x18664(%rip), %rsi     # 0xb2b4d
movq %rbx, %rdi
callq 0x9214d
jmp 0x9a49d
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0x99b23
movq %rbx, %rdi
xorl %esi, %esi
callq 0x99b4f
testl %eax, %eax
jne 0x9a595
testb $0x2, 0x24e(%rbx)
movb 0xc(%rsp), %al
jne 0x9a55a
leaq 0xd(%rsp), %rcx
movb %al, 0x2cb(%rbx)
movl %eax, %esi
movl %eax, %edi
jmp 0x9a567
leaq 0x185fe(%rip), %rsi     # 0xb2b35
jmp 0x9a540
leaq 0x18625(%rip), %rsi     # 0xb2b65
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movl %ebp, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x99b4f
leaq 0xf(%rsp), %rcx
movb -0x2(%rcx), %sil
movb -0x1(%rcx), %dil
movb (%rcx), %cl
leaq 0x2c8(%rbx), %rdx
movb %al, 0x2c8(%rbx)
movb %sil, 0x2c9(%rbx)
movb %dil, 0x2ca(%rbx)
movb %cl, 0x2cc(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8814e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq