// File: /workspace/github_cpp_makefile_star2_O3/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 0x7d6f2
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %ebp
decq %r13
je 0x7d701
incq %r12
jmp 0x7d717
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %r14d
decq %r13
je 0x7d726
incq %r12
jmp 0x7d73c
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
movl %eax, 0x128(%rbx)
decq %r13
je 0x7d751
incq %r12
jmp 0x7d767
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
shll $0x8, %eax
movl %eax, 0x34(%rbx)
decq %r13
je 0x7d77c
incq %r12
jmp 0x7d795
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movl 0x34(%rbx), %eax
movzbl (%r12), %ecx
addl %eax, %ecx
movl %ecx, 0x34(%rbx)
decq %r13
je 0x7d7a9
incq %r12
jmp 0x7d7bf
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
shll $0x8, %eax
movl %eax, 0x30(%rbx)
decq %r13
je 0x7d7d4
incq %r12
jmp 0x7d7ed
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movl 0x30(%rbx), %eax
movzbl (%r12), %ecx
addl %eax, %ecx
movl %ecx, 0x30(%rbx)
decq %r13
je 0x7d801
incq %r12
jmp 0x7d817
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
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)
movq %rbx, %rdi
movl $0x1, %esi
callq *0x8(%rax)
movq 0x248(%rbx), %rax
cmpl $0x0, 0x1c(%rax)
je 0x7d871
movq (%rbx), %rax
movl $0x3a, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
addq $-0x8, %r14
cmpl $0x0, 0x34(%rbx)
je 0x7d888
cmpl $0x0, 0x30(%rbx)
je 0x7d888
movl 0x38(%rbx), %eax
testl %eax, %eax
jg 0x7d89a
movq (%rbx), %rax
movl $0x20, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl 0x38(%rbx), %eax
leal (%rax,%rax,2), %ecx
movslq %ecx, %rcx
cmpq %rcx, %r14
je 0x7d8b7
movq (%rbx), %rax
movl $0xb, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl 0x38(%rbx), %eax
movq 0x130(%rbx), %r14
testq %r14, %r14
jne 0x7d8e8
movq 0x8(%rbx), %rcx
cltq
shlq $0x5, %rax
leaq (%rax,%rax,2), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq *(%rcx)
movq %rax, %r14
movq %rax, 0x130(%rbx)
movl 0x38(%rbx), %eax
incq %r12
decq %r13
testl %eax, %eax
jle 0x7d9c2
addq $0x10, %r14
xorl %ebp, %ebp
movl %ebp, -0xc(%r14)
testq %r13, %r13
jne 0x7d91b
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
movq (%r15), %r12
movq 0x8(%r15), %r13
movzbl (%r12), %eax
movl %eax, -0x10(%r14)
decq %r13
je 0x7d92e
incq %r12
jmp 0x7d944
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
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 0x7d963
incq %r12
jmp 0x7d975
movq %rbx, %rdi
callq *0x18(%r15)
testl %eax, %eax
je 0x7d9de
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
movl $0x1, %esi
callq *0x8(%rax)
incl %ebp
incq %r12
decq %r13
addq $0x60, %r14
cmpl 0x38(%rbx), %ebp
jl 0x7d8fc
movq 0x248(%rbx), %rax
movl $0x1, 0x1c(%rax)
movq %r12, (%r15)
movq %r13, 0x8(%r15)
movl $0x1, %eax
jmp 0x7d9e0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq