// File: /workspace/github_cpp_makefile_star2_O1/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 0x7e6d0
cmpb $0x4a, (%r14)
jne 0x7e6d0
cmpb $0x46, 0x1(%r14)
jne 0x7e6d0
cmpb $0x49, 0x2(%r14)
jne 0x7e6d0
cmpb $0x46, 0x3(%r14)
jne 0x7e6d0
cmpb $0x0, 0x4(%r14)
je 0x7e71f
cmpl $0x6, %edx
jb 0x7e6fb
cmpb $0x4a, (%r14)
jne 0x7e6fb
cmpb $0x46, 0x1(%r14)
jne 0x7e6fb
cmpb $0x58, 0x2(%r14)
jne 0x7e6fb
cmpb $0x58, 0x3(%r14)
jne 0x7e6fb
cmpb $0x0, 0x4(%r14)
je 0x7e834
movq (%rbx), %rax
movl $0x4d, 0x28(%rax)
movl %r15d, 0x2c(%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq %rbx, %rdi
movl $0x1, %esi
popq %rbx
popq %r14
popq %r15
jmpq *%rax
movl $0x1, 0x174(%rbx)
movzbl 0x5(%r14), %eax
movb %al, 0x178(%rbx)
movb 0x6(%r14), %cl
movb %cl, 0x179(%rbx)
movb 0x7(%r14), %cl
movb %cl, 0x17a(%rbx)
movzwl 0x8(%r14), %ecx
rolw $0x8, %cx
movw %cx, 0x17c(%rbx)
movzwl 0xa(%r14), %ecx
rolw $0x8, %cx
movw %cx, 0x17e(%rbx)
cmpl $0x1, %eax
je 0x7e795
movq (%rbx), %rcx
movl $0x77, 0x28(%rcx)
movl %eax, 0x2c(%rcx)
movzbl 0x179(%rbx), %eax
movq (%rbx), %rcx
movl %eax, 0x30(%rcx)
movq (%rbx), %rax
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq *0x8(%rax)
movq (%rbx), %rax
movq 0x178(%rbx), %xmm0
pxor %xmm1, %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movq %xmm0, 0x2c(%rax)
movd 0x17c(%rbx), %xmm0
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movq %xmm0, 0x34(%rax)
movzbl 0x17a(%rbx), %ecx
movl %ecx, 0x3c(%rax)
movl $0x57, 0x28(%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq *0x8(%rax)
movb 0xd(%r14), %al
orb 0xc(%r14), %al
je 0x7e813
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
movq %rbx, %rdi
movl $0x1, %esi
callq *0x8(%rax)
addq $-0xe, %r15
movzbl 0xc(%r14), %eax
movzbl 0xd(%r14), %ecx
imulq %rax, %rcx
leaq (%rcx,%rcx,2), %rax
cmpq %rax, %r15
jne 0x7e857
popq %rbx
popq %r14
popq %r15
retq
movzbl 0x5(%r14), %ecx
movq (%rbx), %rax
cmpl $0x13, %ecx
je 0x7e872
cmpl $0x11, %ecx
je 0x7e866
cmpl $0x10, %ecx
jne 0x7e87e
movl $0x6c, 0x28(%rax)
jmp 0x7e705
movq (%rbx), %rax
movl $0x58, 0x28(%rax)
jmp 0x7e705
movl $0x6d, 0x28(%rax)
jmp 0x7e705
movl $0x6e, 0x28(%rax)
jmp 0x7e705
movl $0x59, 0x28(%rax)
movzbl 0x5(%r14), %ecx
movl %ecx, 0x2c(%rax)
movq (%rbx), %rax
movl %r15d, 0x30(%rax)
jmp 0x7e709