// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
testb $0x1, 0x11c(%rdi)
je 0x8bb07
leaq 0x17ac0(%rip), %rsi     # 0xa35bf
movq %r14, %rdi
callq 0x849c0
cmpl $0xd, %ebp
je 0x8bb1b
leaq 0x17abe(%rip), %rsi     # 0xa35d1
movq %r14, %rdi
callq 0x849c0
orb $0x1, 0x11c(%r14)
leaq 0x3(%rsp), %r15
pushq $0xd
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x8b6d7
movq %r14, %rdi
xorl %esi, %esi
callq 0x8b703
movq %r14, %rdi
movq %r15, %rsi
callq 0x8b5b0
movl %eax, %ebp
leaq 0x7(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x8b5b0
movl %eax, %ecx
movzbl 0x4(%r15), %r8d
movzbl 0x5(%r15), %r9d
movzbl 0x6(%r15), %r10d
movzbl 0x7(%r15), %r12d
movzbl 0x8(%r15), %r11d
movl %ebp, 0x1bc(%r14)
movl %eax, 0x1c0(%r14)
movb %r8b, 0x24f(%r14)
movb %r11b, 0x24b(%r14)
movb %r9b, 0x24e(%r14)
movb %r12b, 0x410(%r14)
movb %r10b, 0x450(%r14)
cmpq $0x6, %r9
ja 0x8bbcb
leaq 0x1789a(%rip), %rax     # 0xa3450
movslq (%rax,%r9,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movb $0x1, 0x252(%r14)
movb $0x1, %al
jmp 0x8bbf6
movb 0x252(%r14), %al
jmp 0x8bbf6
movb $0x3, 0x252(%r14)
movb $0x3, %al
jmp 0x8bbf6
movb $0x2, 0x252(%r14)
movb $0x2, %al
jmp 0x8bbf6
movb $0x4, 0x252(%r14)
movb $0x4, %al
mulb %r8b
movb %al, 0x251(%r14)
movl %ebp, %edx
cmpb $0x8, %al
jb 0x8bc12
shrb $0x3, %al
movzbl %al, %eax
imulq %rdx, %rax
jmp 0x8bc21
movzbl %al, %eax
imulq %rdx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, 0x1d0(%r14)
subq $0x8, %rsp
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
pushq %r12
pushq %r10
pushq %r11
callq 0x7b0d1
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq