// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdmarker.c
// Function: examine_app0
LOCAL(void)
examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
	      unsigned int datalen, INT32 remaining)
/* Examine first few bytes from an APP0.
 * Take appropriate action if it is a JFIF marker.
 * datalen is # of bytes at data[], remaining is length of rest of marker data.
 */
{
  INT32 totallen = (INT32) datalen + remaining;

  if (datalen >= APP0_DATA_LEN &&
      GETJOCTET(data[0]) == 0x4A &&
      GETJOCTET(data[1]) == 0x46 &&
      GETJOCTET(data[2]) == 0x49 &&
      GETJOCTET(data[3]) == 0x46 &&
      GETJOCTET(data[4]) == 0) {
    /* Found JFIF APP0 marker: save info */
    cinfo->saw_JFIF_marker = TRUE;
    cinfo->JFIF_major_version = GETJOCTET(data[5]);
    cinfo->JFIF_minor_version = GETJOCTET(data[6]);
    cinfo->density_unit = GETJOCTET(data[7]);
    cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
    cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
    /* Check version.
     * Major version must be 1, anything else signals an incompatible change.
     * (We used to treat this as an error, but now it's a nonfatal warning,
     * because some bozo at Hijaak couldn't read the spec.)
     * Minor version should be 0..2, but process anyway if newer.
     */
    if (cinfo->JFIF_major_version != 1)
      WARNMS2(cinfo, JWRN_JFIF_MAJOR,
	      cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
    /* Generate trace messages */
    TRACEMS5(cinfo, 1, JTRC_JFIF,
	     cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
	     cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
    /* Validate thumbnail dimensions and issue appropriate messages */
    if (GETJOCTET(data[12]) | GETJOCTET(data[13]))
      TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
	       GETJOCTET(data[12]), GETJOCTET(data[13]));
    totallen -= APP0_DATA_LEN;
    if (totallen !=
	((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3))
      TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
  } else if (datalen >= 6 &&
      GETJOCTET(data[0]) == 0x4A &&
      GETJOCTET(data[1]) == 0x46 &&
      GETJOCTET(data[2]) == 0x58 &&
      GETJOCTET(data[3]) == 0x58 &&
      GETJOCTET(data[4]) == 0) {
    /* Found JFIF "JFXX" extension APP0 marker */
    /* The library doesn't actually do anything with these,
     * but we try to produce a helpful trace message.
     */
    switch (GETJOCTET(data[5])) {
    case 0x10:
      TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
      break;
    case 0x11:
      TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
      break;
    case 0x13:
      TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
      break;
    default:
      TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
	       GETJOCTET(data[5]), (int) totallen);
      break;
    }
  } else {
    /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
    TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %r15d
addq %rcx, %r15
cmpl $0xe, %edx
jb 0x7195a
cmpb $0x4a, (%r14)
jne 0x71981
cmpb $0x46, 0x1(%r14)
jne 0x71965
cmpb $0x49, 0x2(%r14)
jne 0x71965
cmpb $0x46, 0x3(%r14)
jne 0x71965
cmpb $0x0, 0x4(%r14)
jne 0x71965
movl $0x1, 0x174(%rbx)
movzbl 0x5(%r14), %edx
movb %dl, 0x178(%rbx)
movb 0x6(%r14), %cl
movb %cl, 0x179(%rbx)
movb 0x7(%r14), %al
movb %al, 0x17a(%rbx)
movzwl 0x8(%r14), %esi
rolw $0x8, %si
movw %si, 0x17c(%rbx)
movzwl 0xa(%r14), %edi
rolw $0x8, %di
movw %di, 0x17e(%rbx)
cmpl $0x1, %edx
jne 0x719cf
pushq $0x1
popq %rdx
movd %esi, %xmm0
pinsrw $0x1, %edi, %xmm0
jmp 0x71a10
cmpl $0x6, %edx
jb 0x71981
cmpb $0x4a, (%r14)
jne 0x71981
cmpb $0x46, 0x1(%r14)
jne 0x71981
cmpb $0x58, 0x2(%r14)
jne 0x71981
cmpb $0x58, 0x3(%r14)
jne 0x71981
cmpb $0x0, 0x4(%r14)
je 0x719a3
movq (%rbx), %rax
movl $0x4d, 0x28(%rax)
movl %r15d, 0x2c(%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rax
pushq $0x1
popq %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmpq *%rax
movzbl 0x5(%r14), %ecx
movq (%rbx), %rax
cmpl $0x13, %ecx
je 0x71abc
cmpl $0x11, %ecx
je 0x71ab0
cmpl $0x10, %ecx
jne 0x71ac8
movl $0x6c, 0x28(%rax)
jmp 0x7198b
movq (%rbx), %rax
movl $0x77, 0x28(%rax)
movl %edx, 0x2c(%rax)
movzbl 0x179(%rbx), %eax
movq (%rbx), %rcx
movl %eax, 0x30(%rcx)
movq (%rbx), %rax
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq *0x8(%rax)
movzbl 0x178(%rbx), %edx
movb 0x179(%rbx), %cl
movb 0x17a(%rbx), %al
movd 0x17c(%rbx), %xmm0
movq (%rbx), %r8
movl %edx, 0x2c(%r8)
movzbl %cl, %ecx
movl %ecx, 0x30(%r8)
pxor %xmm1, %xmm1
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movq %xmm0, 0x34(%r8)
movzbl %al, %eax
movl %eax, 0x3c(%r8)
movl $0x57, 0x28(%r8)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq *0x8(%r8)
movb 0xc(%r14), %cl
movb 0xd(%r14), %al
movl %eax, %edx
orb %cl, %dl
je 0x71a84
movq (%rbx), %rax
movl $0x5a, 0x28(%rax)
movzbl 0xc(%r14), %ecx
movl %ecx, 0x2c(%rax)
movzbl 0xd(%r14), %eax
movq (%rbx), %rcx
movl %eax, 0x30(%rcx)
movq (%rbx), %rax
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq *0x8(%rax)
movb 0xc(%r14), %cl
movb 0xd(%r14), %al
addq $-0xe, %r15
movzbl %cl, %ecx
movzbl %al, %eax
imulq %rcx, %rax
leaq (%rax,%rax,2), %rax
cmpq %rax, %r15
jne 0x71aa1
popq %rbx
popq %r14
popq %r15
retq
movq (%rbx), %rax
movl $0x58, 0x28(%rax)
jmp 0x7198b
movl $0x6d, 0x28(%rax)
jmp 0x7198b
movl $0x6e, 0x28(%rax)
jmp 0x7198b
movl $0x59, 0x28(%rax)
movzbl 0x5(%r14), %ecx
movl %ecx, 0x2c(%rax)
movq (%rbx), %rax
movl %r15d, 0x30(%rax)
jmp 0x7198f