// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_IHDR
void /* PRIVATE */
png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   png_byte buf[13];
   png_uint_32 width, height;
   int bit_depth, color_type, compression_type, filter_type;
   int interlace_type;

   png_debug(1, "in png_handle_IHDR");

   if (png_ptr->mode & PNG_HAVE_IHDR)
      png_error(png_ptr, "Out of place IHDR");

   /* Check the length */
   if (length != 13)
      png_error(png_ptr, "Invalid IHDR chunk");

   png_ptr->mode |= PNG_HAVE_IHDR;

   png_crc_read(png_ptr, buf, 13);
   png_crc_finish(png_ptr, 0);

   width = png_get_uint_31(png_ptr, buf);
   height = png_get_uint_31(png_ptr, buf + 4);
   bit_depth = buf[8];
   color_type = buf[9];
   compression_type = buf[10];
   filter_type = buf[11];
   interlace_type = buf[12];

   /* Set internal variables */
   png_ptr->width = width;
   png_ptr->height = height;
   png_ptr->bit_depth = (png_byte)bit_depth;
   png_ptr->interlaced = (png_byte)interlace_type;
   png_ptr->color_type = (png_byte)color_type;
#ifdef PNG_MNG_FEATURES_SUPPORTED
   png_ptr->filter_type = (png_byte)filter_type;
#endif
   png_ptr->compression_type = (png_byte)compression_type;

   /* Find number of channels */
   switch (png_ptr->color_type)
   {
      case PNG_COLOR_TYPE_GRAY:
      case PNG_COLOR_TYPE_PALETTE:
         png_ptr->channels = 1;
         break;

      case PNG_COLOR_TYPE_RGB:
         png_ptr->channels = 3;
         break;

      case PNG_COLOR_TYPE_GRAY_ALPHA:
         png_ptr->channels = 2;
         break;

      case PNG_COLOR_TYPE_RGB_ALPHA:
         png_ptr->channels = 4;
         break;
   }

   /* Set up other useful info */
   png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
   png_ptr->channels);
   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
   png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
   png_debug1(3, "channels = %d", png_ptr->channels);
   png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes);
   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
      color_type, interlace_type, compression_type, filter_type);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
testb $0x1, 0x11c(%rdi)
je 0x9a94a
leaq 0x17f79(%rip), %rsi     # 0xb28bb
movq %r14, %rdi
callq 0x92dd0
cmpl $0xd, %ebp
je 0x9a95e
leaq 0x17f77(%rip), %rsi     # 0xb28cd
movq %r14, %rdi
callq 0x92dd0
orb $0x1, 0x11c(%r14)
leaq 0x3(%rsp), %r15
movl $0xd, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x9a4db
movq %r14, %rdi
xorl %esi, %esi
callq 0x9a507
movzbl (%r15), %r12d
shll $0x18, %r12d
movzbl 0x1(%r15), %r13d
movzbl 0x2(%r15), %ebp
movzbl 0x3(%r15), %r15d
jns 0x9a9ad
leaq 0x17e57(%rip), %rsi     # 0xb27fc
movq %r14, %rdi
callq 0x92dd0
shll $0x10, %r13d
orl %r15d, %r13d
shll $0x8, %ebp
orl %r13d, %ebp
orl %r12d, %ebp
movzbl 0x7(%rsp), %r12d
shll $0x18, %r12d
movzbl 0x8(%rsp), %r13d
movzbl 0x9(%rsp), %r15d
movzbl 0xa(%rsp), %ebx
jns 0x9a9e9
leaq 0x17e1b(%rip), %rsi     # 0xb27fc
movq %r14, %rdi
callq 0x92dd0
shll $0x10, %r13d
orl %ebx, %r13d
shll $0x8, %r15d
orl %r13d, %r15d
orl %r12d, %r15d
movzbl 0xb(%rsp), %r8d
movzbl 0xc(%rsp), %r9d
movzbl 0xd(%rsp), %r10d
movzbl 0xe(%rsp), %r12d
movzbl 0xf(%rsp), %r11d
movl %ebp, 0x1bc(%r14)
movl %r15d, 0x1c0(%r14)
movb %r8b, 0x24f(%r14)
movb %r11b, 0x24b(%r14)
movb %r9b, 0x24e(%r14)
movb %r12b, 0x410(%r14)
movb %r10b, 0x450(%r14)
cmpl $0x6, %r9d
ja 0x9aa76
movl $0x5d, %eax
btl %r9d, %eax
jae 0x9aa76
leal (,%r9,8), %ecx
movabsq $0x4010201030101, %rax  # imm = 0x4010201030101
shrq %cl, %rax
movb %al, 0x252(%r14)
movb 0x252(%r14), %al
mulb %r8b
movb %al, 0x251(%r14)
movl %ebp, %ecx
cmpb $0x8, %al
jb 0x9aa99
shrb $0x3, %al
movzbl %al, %eax
imulq %rcx, %rax
jmp 0x9aaa8
movzbl %al, %eax
imulq %rcx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, 0x1d0(%r14)
subq $0x8, %rsp
movq %r14, %rdi
movq 0x18(%rsp), %rsi
movl %ebp, %edx
movl %r15d, %ecx
pushq %r12
pushq %r10
pushq %r11
callq 0x88b68
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq