// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdmarker.c
// Function: jpeg_save_markers
GLOBAL(void)
jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
		   unsigned int length_limit)
{
  my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
  long maxlength;
  jpeg_marker_parser_method processor;

  /* Length limit mustn't be larger than what we can allocate
   * (should only be a concern in a 16-bit environment).
   */
  maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct);
  if (((long) length_limit) > maxlength)
    length_limit = (unsigned int) maxlength;

  /* Choose processor routine to use.
   * APP0/APP14 have special requirements.
   */
  if (length_limit) {
    processor = save_marker;
    /* If saving APP0/APP14, save at least enough for our internal use. */
    if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN)
      length_limit = APP0_DATA_LEN;
    else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN)
      length_limit = APP14_DATA_LEN;
  } else {
    processor = skip_variable;
    /* If discarding APP0/APP14, use our regular on-the-fly processor. */
    if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14)
      processor = get_interesting_appn;
  }

  if (marker_code == (int) M_COM) {
    marker->process_COM = processor;
    marker->length_limit_COM = length_limit;
  } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) {
    marker->process_APPn[marker_code - (int) M_APP0] = processor;
    marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit;
  } else
    ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x248(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x60(%rax), %rax
subq $0x20, %rax
movq %rax, 0x8(%rsp)
movl 0x18(%rsp), %eax
cmpq 0x8(%rsp), %rax
jle 0xe630c
movq 0x8(%rsp), %rax
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x18(%rsp)
je 0xe6356
leaq 0x126(%rip), %rax       # 0xe6440
movq %rax, (%rsp)
cmpl $0xe0, 0x1c(%rsp)
jne 0xe6339
cmpl $0xe, 0x18(%rsp)
jae 0xe6339
movl $0xe, 0x18(%rsp)
jmp 0xe6354
cmpl $0xee, 0x1c(%rsp)
jne 0xe6352
cmpl $0xc, 0x18(%rsp)
jae 0xe6352
movl $0xc, 0x18(%rsp)
jmp 0xe6354
jmp 0xe6382
leaq -0x53d(%rip), %rax      # 0xe5e20
movq %rax, (%rsp)
cmpl $0xe0, 0x1c(%rsp)
je 0xe6375
cmpl $0xee, 0x1c(%rsp)
jne 0xe6380
leaq -0x39c(%rip), %rax      # 0xe5fe0
movq %rax, (%rsp)
jmp 0xe6382
cmpl $0xfe, 0x1c(%rsp)
jne 0xe63ad
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x28(%rax)
movl 0x18(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0xb0(%rax)
jmp 0xe642d
cmpl $0xe0, 0x1c(%rsp)
jl 0xe63fb
cmpl $0xef, 0x1c(%rsp)
jg 0xe63fb
movq (%rsp), %rdx
movq 0x10(%rsp), %rax
movl 0x1c(%rsp), %ecx
subl $0xe0, %ecx
movslq %ecx, %rcx
movq %rdx, 0x30(%rax,%rcx,8)
movl 0x18(%rsp), %edx
movq 0x10(%rsp), %rax
movl 0x1c(%rsp), %ecx
subl $0xe0, %ecx
movslq %ecx, %rcx
movl %edx, 0xb4(%rax,%rcx,4)
jmp 0xe642b
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl $0x44, 0x28(%rax)
movl 0x1c(%rsp), %ecx
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl %ecx, 0x2c(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdi
callq *%rax
jmp 0xe642d
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)