// File: tomfunkhouser[P]gaps/pkgs/png/pngrtran.c
// Function: png_set_crc_action
void PNGAPI
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
{
   png_debug(1, "in png_set_crc_action");
 
   if (png_ptr == NULL)
      return;

   /* Tell libpng how we react to CRC errors in critical chunks */
   switch (crit_action)
   {
      case PNG_CRC_NO_CHANGE:                        /* Leave setting as is */
         break;

      case PNG_CRC_WARN_USE:                               /* Warn/use data */
         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;
         break;

      case PNG_CRC_QUIET_USE:                             /* Quiet/use data */
         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |
                           PNG_FLAG_CRC_CRITICAL_IGNORE;
         break;

      case PNG_CRC_WARN_DISCARD:    /* Not a valid action for critical data */
         png_warning(png_ptr,
            "Can't discard critical data on CRC error");
      case PNG_CRC_ERROR_QUIT:                                /* Error/quit */

      case PNG_CRC_DEFAULT:
      default:
         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
         break;
   }

   /* Tell libpng how we react to CRC errors in ancillary chunks */
   switch (ancil_action)
   {
      case PNG_CRC_NO_CHANGE:                       /* Leave setting as is */
         break;

      case PNG_CRC_WARN_USE:                              /* Warn/use data */
         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;
         break;

      case PNG_CRC_QUIET_USE:                            /* Quiet/use data */
         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |
                           PNG_FLAG_CRC_ANCILLARY_NOWARN;
         break;

      case PNG_CRC_ERROR_QUIT:                               /* Error/quit */
         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;
         break;

      case PNG_CRC_WARN_DISCARD:                      /* Warn/discard data */

      case PNG_CRC_DEFAULT:
      default:
         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
         break;
   }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x10604e
jmp 0x1061db
movl 0x1c(%rsp), %eax
movq %rax, 0x10(%rsp)
subq $0x5, %rax
ja 0x1060ee
movq 0x10(%rsp), %rax
leaq 0x33573(%rip), %rcx     # 0x1395e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x106105
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffff3ff, %ecx       # imm = 0xFFFFF3FF
movl %ecx, 0x120(%rax)
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x120(%rax)
jmp 0x106105
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffff3ff, %ecx       # imm = 0xFFFFF3FF
movl %ecx, 0x120(%rax)
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0xc00, %ecx            # imm = 0xC00
movl %ecx, 0x120(%rax)
jmp 0x106105
movq 0x20(%rsp), %rdi
leaq 0x33681(%rip), %rsi     # 0x139768
callq 0x113940
jmp 0x1060ee
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffff3ff, %ecx       # imm = 0xFFFFF3FF
movl %ecx, 0x120(%rax)
movl 0x18(%rsp), %eax
movq %rax, 0x8(%rsp)
subq $0x5, %rax
ja 0x1061c4
movq 0x8(%rsp), %rax
leaq 0x334d4(%rip), %rcx     # 0x1395f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x1061db
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffffcff, %ecx       # imm = 0xFFFFFCFF
movl %ecx, 0x120(%rax)
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, 0x120(%rax)
jmp 0x1061db
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffffcff, %ecx       # imm = 0xFFFFFCFF
movl %ecx, 0x120(%rax)
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0x300, %ecx            # imm = 0x300
movl %ecx, 0x120(%rax)
jmp 0x1061db
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffffcff, %ecx       # imm = 0xFFFFFCFF
movl %ecx, 0x120(%rax)
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x120(%rax)
jmp 0x1061db
jmp 0x1061c4
movq 0x20(%rsp), %rax
movl 0x120(%rax), %ecx
andl $0xfffffcff, %ecx       # imm = 0xFFFFFCFF
movl %ecx, 0x120(%rax)
addq $0x28, %rsp
retq