// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdmarker.c
// Function: get_sof
LOCAL(jboolean)
get_sof (j_decompress_ptr cinfo, jboolean is_prog, jboolean is_arith)
/* Process a SOFn marker */
{
  INT32 length;
  int c, ci;
  jpeg_component_info * compptr;
  INPUT_VARS(cinfo);

  cinfo->progressive_mode = is_prog;
  cinfo->arith_code = is_arith;

  INPUT_2BYTES(cinfo, length, return FALSE);

  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);

  length -= 8;

  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
	   (int) cinfo->image_width, (int) cinfo->image_height,
	   cinfo->num_components);

  if (cinfo->marker->saw_SOF)
    ERREXIT(cinfo, JERR_SOF_DUPLICATE);

  /* We don't support files in which the image height is initially specified */
  /* as 0 and is later redefined by DNL.  As long as we have to check that,  */
  /* might as well have a general sanity check. */
  if (cinfo->image_height <= 0 || cinfo->image_width <= 0
      || cinfo->num_components <= 0)
    ERREXIT(cinfo, JERR_EMPTY_IMAGE);

  if (length != (cinfo->num_components * 3))
    ERREXIT(cinfo, JERR_BAD_LENGTH);

  if (cinfo->comp_info == NULL)	/* do only once, even if suspend */
    cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
			((j_common_ptr) cinfo, JPOOL_IMAGE,
			 cinfo->num_components * SIZEOF(jpeg_component_info));
  
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    compptr->component_index = ci;
    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
    INPUT_BYTE(cinfo, c, return FALSE);
    compptr->h_samp_factor = (c >> 4) & 15;
    compptr->v_samp_factor = (c     ) & 15;
    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);

    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
	     compptr->component_id, compptr->h_samp_factor,
	     compptr->v_samp_factor, compptr->quant_tbl_no);
  }

  cinfo->marker->saw_SOF = TRUE;

  INPUT_SYNC(cinfo);
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %r15
movq (%r15), %r12
movq 0x8(%r15), %r13
movl %esi, 0x138(%rdi)
movl %edx, 0x13c(%rdi)
testq %r13, %r13
jne 0x715d4
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %ebp
decq %r13
je 0x715e3
incq %r12
jmp 0x715f9
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %r14d
decq %r13
je 0x71608
incq %r12
jmp 0x7161e
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
movl %eax, 0x128(%rbx)
decq %r13
je 0x71633
incq %r12
jmp 0x71649
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
shll $0x8, %eax
movl %eax, 0x34(%rbx)
decq %r13
je 0x7165e
incq %r12
jmp 0x71677
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movl 0x34(%rbx), %eax
movzbl (%r12), %ecx
addl %eax, %ecx
movl %ecx, 0x34(%rbx)
decq %r13
je 0x7168b
incq %r12
jmp 0x716a1
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
shll $0x8, %eax
movl %eax, 0x30(%rbx)
decq %r13
je 0x716b6
incq %r12
jmp 0x716cf
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movl 0x30(%rbx), %eax
movzbl (%r12), %ecx
addl %eax, %ecx
movl %ecx, 0x30(%rbx)
decq %r13
je 0x716e3
incq %r12
jmp 0x716f9
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
shll $0x8, %ebp
orq %rbp, %r14
movzbl (%r12), %eax
movl %eax, 0x38(%rbx)
movq (%rbx), %rax
movl 0x21c(%rbx), %ecx
movl %ecx, 0x2c(%rax)
movl 0x30(%rbx), %ecx
movl %ecx, 0x30(%rax)
movl 0x34(%rbx), %ecx
movl %ecx, 0x34(%rax)
movl 0x38(%rbx), %ecx
movl %ecx, 0x38(%rax)
movl $0x64, 0x28(%rax)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq *0x8(%rax)
movq 0x248(%rbx), %rax
cmpl $0x0, 0x1c(%rax)
je 0x71751
movq (%rbx), %rax
movl $0x3a, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
addq $-0x8, %r14
cmpl $0x0, 0x34(%rbx)
je 0x71768
cmpl $0x0, 0x30(%rbx)
je 0x71768
movl 0x38(%rbx), %eax
testl %eax, %eax
jg 0x7177a
movq (%rbx), %rax
movl $0x20, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl 0x38(%rbx), %eax
leal (%rax,%rax,2), %eax
cltq
cmpq %rax, %r14
je 0x71793
movq (%rbx), %rax
movl $0xb, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movq 0x130(%rbx), %r14
testq %r14, %r14
jne 0x717bd
movq 0x8(%rbx), %rax
movslq 0x38(%rbx), %rcx
imulq $0x60, %rcx, %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq *(%rax)
movq %rax, %r14
movq %rax, 0x130(%rbx)
addq $0x10, %r14
xorl %ebp, %ebp
incq %r12
decq %r13
cmpl 0x38(%rbx), %ebp
jge 0x71899
movl %ebp, -0xc(%r14)
testq %r13, %r13
jne 0x717f1
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
movl %eax, -0x10(%r14)
decq %r13
je 0x71804
incq %r12
jmp 0x71816
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
movl %eax, %ecx
shrl $0x4, %ecx
andl $0xf, %eax
movl %ecx, -0x8(%r14)
movl %eax, -0x4(%r14)
decq %r13
je 0x71835
incq %r12
jmp 0x71847
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x71888
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
movl %eax, (%r14)
movq (%rbx), %rax
movl -0x10(%r14), %ecx
movl %ecx, 0x2c(%rax)
movl -0x8(%r14), %ecx
movl %ecx, 0x30(%rax)
movl -0x4(%r14), %ecx
movl %ecx, 0x34(%rax)
movl (%r14), %ecx
movl %ecx, 0x38(%rax)
movl $0x65, 0x28(%rax)
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq *0x8(%rax)
incl %ebp
addq $0x60, %r14
jmp 0x717c3
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x248(%rbx), %rax
movl $0x1, 0x1c(%rax)
movq %r12, (%r15)
movq %r13, 0x8(%r15)
pushq $0x1
popq %rax
jmp 0x7188a