// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdcoefct.c
// Function: smoothing_ok
LOCAL(jboolean)
smoothing_ok (j_decompress_ptr cinfo)
{
  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
  jboolean smoothing_useful = FALSE;
  int ci, coefi;
  jpeg_component_info *compptr;
  JQUANT_TBL * qtable;
  int * coef_bits;
  int * coef_bits_latch;

  if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
    return FALSE;

  /* Allocate latch area if not already done */
  if (coef->coef_bits_latch == NULL)
    coef->coef_bits_latch = (int *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				  cinfo->num_components *
				  (SAVED_COEFS * SIZEOF(int)));
  coef_bits_latch = coef->coef_bits_latch;

  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    /* All components' quantization values must already be latched. */
    if ((qtable = compptr->quant_table) == NULL)
      return FALSE;
    /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
    if (qtable->quantval[0] == 0 ||
	qtable->quantval[Q01_POS] == 0 ||
	qtable->quantval[Q10_POS] == 0 ||
	qtable->quantval[Q20_POS] == 0 ||
	qtable->quantval[Q11_POS] == 0 ||
	qtable->quantval[Q02_POS] == 0)
      return FALSE;
    /* DC values must be at least partly known for all components. */
    coef_bits = cinfo->coef_bits[ci];
    if (coef_bits[0] < 0)
      return FALSE;
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
    for (coefi = 1; coefi <= 5; coefi++) {
      coef_bits_latch[coefi] = coef_bits[coefi];
      if (coef_bits[coefi] != 0)
	smoothing_useful = TRUE;
    }
    coef_bits_latch += SAVED_COEFS;
  }

  return smoothing_useful;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq 0x230(%rax), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movq 0x38(%rsp), %rax
cmpl $0x0, 0x138(%rax)
je 0xeddef
movq 0x38(%rsp), %rax
cmpq $0x0, 0xc0(%rax)
jne 0xeddfc
movl $0x0, 0x44(%rsp)
jmp 0xedfb0
movq 0x30(%rsp), %rax
cmpq $0x0, 0xd8(%rax)
jne 0xede3f
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rdi
movq 0x38(%rsp), %rcx
movslq 0x38(%rcx), %rcx
imulq $0x18, %rcx, %rdx
movl $0x1, %esi
callq *%rax
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0xd8(%rax)
movq 0x30(%rsp), %rax
movq 0xd8(%rax), %rax
movq %rax, (%rsp)
movl $0x0, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x130(%rax), %rax
movq %rax, 0x18(%rsp)
movl 0x28(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x38(%rcx), %eax
jge 0xedfa8
movq 0x18(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
jne 0xede9b
movl $0x0, 0x44(%rsp)
jmp 0xedfb0
movq 0x10(%rsp), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
je 0xedeee
movq 0x10(%rsp), %rax
movzwl 0x2(%rax), %eax
cmpl $0x0, %eax
je 0xedeee
movq 0x10(%rsp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x0, %eax
je 0xedeee
movq 0x10(%rsp), %rax
movzwl 0x20(%rax), %eax
cmpl $0x0, %eax
je 0xedeee
movq 0x10(%rsp), %rax
movzwl 0x12(%rax), %eax
cmpl $0x0, %eax
je 0xedeee
movq 0x10(%rsp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x0, %eax
jne 0xedefb
movl $0x0, 0x44(%rsp)
jmp 0xedfb0
movq 0x38(%rsp), %rax
movq 0xc0(%rax), %rax
movslq 0x28(%rsp), %rcx
shlq $0x8, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jge 0xedf2f
movl $0x0, 0x44(%rsp)
jmp 0xedfb0
movl $0x1, 0x24(%rsp)
cmpl $0x5, 0x24(%rsp)
jg 0xedf7e
movq 0x8(%rsp), %rax
movslq 0x24(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq (%rsp), %rax
movslq 0x24(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x8(%rsp), %rax
movslq 0x24(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xedf6f
movl $0x1, 0x2c(%rsp)
jmp 0xedf71
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0xedf37
movq (%rsp), %rax
addq $0x18, %rax
movq %rax, (%rsp)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
movq 0x18(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x18(%rsp)
jmp 0xede68
movl 0x2c(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopl (%rax)