// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_tRNS
void /* PRIVATE */
png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   png_byte readbuf[PNG_MAX_PALETTE_LENGTH];

   png_debug(1, "in png_handle_tRNS");

   if (!(png_ptr->mode & PNG_HAVE_IHDR))
      png_error(png_ptr, "Missing IHDR before tRNS");
   else if (png_ptr->mode & PNG_HAVE_IDAT)
   {
      png_warning(png_ptr, "Invalid tRNS after IDAT");
      png_crc_finish(png_ptr, length);
      return;
   }
   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
   {
      png_warning(png_ptr, "Duplicate tRNS chunk");
      png_crc_finish(png_ptr, length);
      return;
   }

   if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
   {
      png_byte buf[2];

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

      png_crc_read(png_ptr, buf, 2);
      png_ptr->num_trans = 1;
      png_ptr->trans_color.gray = png_get_uint_16(buf);
   }
   else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
   {
      png_byte buf[6];

      if (length != 6)
      {
         png_warning(png_ptr, "Incorrect tRNS chunk length");
         png_crc_finish(png_ptr, length);
         return;
      }
      png_crc_read(png_ptr, buf, (png_size_t)length);
      png_ptr->num_trans = 1;
      png_ptr->trans_color.red = png_get_uint_16(buf);
      png_ptr->trans_color.green = png_get_uint_16(buf + 2);
      png_ptr->trans_color.blue = png_get_uint_16(buf + 4);
   }
   else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
   {
      if (!(png_ptr->mode & PNG_HAVE_PLTE))
      {
         /* Should be an error, but we can cope with it. */
         png_warning(png_ptr, "Missing PLTE before tRNS");
      }
      if (length > (png_uint_32)png_ptr->num_palette ||
          length > PNG_MAX_PALETTE_LENGTH)
      {
         png_warning(png_ptr, "Incorrect tRNS chunk length");
         png_crc_finish(png_ptr, length);
         return;
      }
      if (length == 0)
      {
         png_warning(png_ptr, "Zero length tRNS chunk");
         png_crc_finish(png_ptr, length);
         return;
      }
      png_crc_read(png_ptr, readbuf, (png_size_t)length);
      png_ptr->num_trans = (png_uint_16)length;
   }
   else
   {
      png_warning(png_ptr, "tRNS chunk not allowed with alpha channel");
      png_crc_finish(png_ptr, length);
      return;
   }

   if (png_crc_finish(png_ptr, 0))
   {
      png_ptr->num_trans = 0;
      return;
   }

   png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
      &(png_ptr->trans_color));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x11c(%rdi), %eax
testb $0x1, %al
jne 0x9b090
leaq 0x17ed9(%rip), %rsi     # 0xb2f0b
movq %rbx, %rdi
callq 0x920b4
movzbl 0x24e(%rbx), %eax
cmpl $0x3, %eax
je 0x9b128
cmpl $0x2, %eax
je 0x9b0b8
testl %eax, %eax
jne 0x9b188
cmpl $0x2, %ebp
jne 0x9b10a
movq %rsp, %r15
movl $0x2, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x99b23
movw $0x1, 0x242(%rbx)
movzwl (%r15), %eax
rolw $0x8, %ax
movw %ax, 0x2e8(%rbx)
jmp 0x9b16f
testb $0x4, %al
jne 0x9b0ac
testq %r14, %r14
je 0x9b03a
testb $0x10, 0x8(%r14)
je 0x9b03a
leaq 0x17e95(%rip), %rsi     # 0xb2f3c
jmp 0x9b198
leaq 0x17e71(%rip), %rsi     # 0xb2f24
jmp 0x9b198
cmpl $0x6, %ebp
jne 0x9b10a
movq %rsp, %r15
movl $0x6, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x99b23
movw $0x1, 0x242(%rbx)
movzwl (%r15), %eax
rolw $0x8, %ax
movw %ax, 0x2e2(%rbx)
movzwl 0x2(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x2e4(%rbx)
movzwl 0x4(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x2e6(%rbx)
jmp 0x9b16f
leaq 0x17e40(%rip), %rsi     # 0xb2f51
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x99b4f
jmp 0x9b1d3
testb $0x2, 0x11c(%rbx)
jne 0x9b140
leaq 0x17e35(%rip), %rsi     # 0xb2f6d
movq %rbx, %rdi
callq 0x9214d
cmpl $0x100, %ebp            # imm = 0x100
ja 0x9b191
movzwl 0x240(%rbx), %eax
cmpl %ebp, %eax
jb 0x9b191
testl %ebp, %ebp
je 0x9b1e1
movl %ebp, %edx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x99b23
movw %bp, 0x242(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x99b4f
testl %eax, %eax
je 0x9b1b7
movw $0x0, 0x242(%rbx)
jmp 0x9b1d3
leaq 0x17e0e(%rip), %rsi     # 0xb2f9d
jmp 0x9b198
leaq 0x17db9(%rip), %rsi     # 0xb2f51
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
movl %ebp, %esi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x99b4f
movzwl 0x242(%rbx), %ecx
leaq 0x2e0(%rbx), %r8
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x88673
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17d9e(%rip), %rsi     # 0xb2f86
movq %rbx, %rdi
callq 0x9214d
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x9b1a5