// File: /workspace/github_cpp_makefile_star2_O1/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 0x9ae90
leaq 0x17c7d(%rip), %rsi     # 0xb2ac8
movq %rbx, %rdi
callq 0x92dd0
testq %r14, %r14
je 0x9ae63
testb $0x2, 0x8(%r14)
jne 0x9aef7
movl $0x3, %edx
cmpb $0x3, 0x24e(%rbx)
je 0x9ae78
movzbl 0x252(%rbx), %edx
cmpl %ebp, %edx
sete %al
cmpl $0x5, %ebp
setb %cl
testb %al, %cl
jne 0x9aea9
leaq 0x17c98(%rip), %rsi     # 0xb2b26
jmp 0x9aefe
testb $0x4, %al
jne 0x9aeee
testb $0x2, %al
je 0x9ae53
leaq 0x17c5a(%rip), %rsi     # 0xb2af9
movq %rbx, %rdi
callq 0x92e6e
jmp 0x9ae53
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0x9a4db
movq %rbx, %rdi
xorl %esi, %esi
callq 0x9a507
testl %eax, %eax
jne 0x9af4f
testb $0x2, 0x24e(%rbx)
movb 0xc(%rsp), %al
jne 0x9af18
leaq 0xd(%rsp), %rcx
movb %al, 0x2cb(%rbx)
movb %al, 0x2c8(%rbx)
movb %al, 0x2c9(%rbx)
jmp 0x9af2f
leaq 0x17bec(%rip), %rsi     # 0xb2ae1
jmp 0x9aefe
leaq 0x17c13(%rip), %rsi     # 0xb2b11
movq %rbx, %rdi
callq 0x92e6e
movq %rbx, %rdi
movl %ebp, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x9a507
leaq 0xf(%rsp), %rcx
movb %al, 0x2c8(%rbx)
movb -0x2(%rcx), %al
movb %al, 0x2c9(%rbx)
movb -0x1(%rcx), %al
movb %al, 0x2ca(%rbx)
movb (%rcx), %al
movb %al, 0x2cc(%rbx)
leaq 0x2c8(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x88f35
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq