// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jchuff.c
// Function: encode_mcu_huff
METHODDEF(jboolean)
encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
  working_state state;
  int blkn, ci;
  jpeg_component_info * compptr;

  /* Load up working state */
  state.next_output_byte = cinfo->dest->next_output_byte;
  state.free_in_buffer = cinfo->dest->free_in_buffer;
  ASSIGN_STATE(state.cur, entropy->saved);
  state.cinfo = cinfo;

  /* Emit restart marker if needed */
  if (cinfo->restart_interval) {
    if (entropy->restarts_to_go == 0)
      if (! emit_restart(&state, entropy->next_restart_num))
	return FALSE;
  }

  /* Encode the MCU data blocks */
  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
    ci = cinfo->MCU_membership[blkn];
    compptr = cinfo->cur_comp_info[ci];
    if (! encode_one_block(&state,
			   MCU_data[blkn][0], state.cur.last_dc_val[ci],
			   entropy->dc_derived_tbls[compptr->dc_tbl_no],
			   entropy->ac_derived_tbls[compptr->ac_tbl_no]))
      return FALSE;
    /* Update last_dc_val */
    state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
  }

  /* Completed MCU, so update state */
  cinfo->dest->next_output_byte = state.next_output_byte;
  cinfo->dest->free_in_buffer = state.free_in_buffer;
  ASSIGN_STATE(entropy->saved, state.cur);

  /* Update restart-interval state too */
  if (cinfo->restart_interval) {
    if (entropy->restarts_to_go == 0) {
      entropy->restarts_to_go = cinfo->restart_interval;
      entropy->next_restart_num++;
      entropy->next_restart_num &= 7;
    }
    entropy->restarts_to_go--;
  }

  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq 0x1f0(%rdi), %r12
movq 0x28(%rdi), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movups 0x18(%r12), %xmm0
movups 0x28(%r12), %xmm1
movups %xmm0, 0x10(%rsp)
movups %xmm1, 0x20(%rsp)
movq %rdi, 0x30(%rsp)
cmpl $0x0, 0x118(%rdi)
je 0x7841a
cmpl $0x0, 0x38(%r12)
je 0x78c01
cmpl $0x0, 0x170(%rdi)
jle 0x78b8e
xorl %ecx, %ecx
movq %r12, 0x48(%rsp)
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movslq 0x174(%rdi,%rcx,4), %rdx
movq %rcx, 0x68(%rsp)
movq (%rsi,%rcx,8), %rax
movq %rax, 0x70(%rsp)
movswl (%rax), %esi
movl 0x1c(%rsp,%rdx,4), %eax
movl %esi, %ebx
subl %eax, %ebx
movl $0x0, %r13d
subl %eax, %esi
je 0x7847b
movl %esi, %eax
negl %eax
cmovsl %esi, %eax
xorl %r13d, %r13d
movl %eax, %ecx
incl %r13d
shrl %ecx
cmpl $0x1, %eax
movl %ecx, %eax
ja 0x7846f
movq %rdx, 0x60(%rsp)
movq 0x148(%rdi,%rdx,8), %rax
movslq 0x14(%rax), %rcx
movq 0x48(%rsp), %rdx
movq 0x40(%rdx,%rcx,8), %r14
movslq 0x18(%rax), %rax
movq 0x60(%rdx,%rax,8), %rax
movq %rax, 0x40(%rsp)
cmpl $0xc, %r13d
jb 0x784c1
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movl $0x6, 0x28(%rax)
movq %rsi, %r15
callq *(%rax)
movq %r15, %rsi
movl %r13d, %eax
movl (%r14,%rax,4), %r15d
movq %rax, 0x38(%rsp)
movsbl 0x400(%r14,%rax), %ebp
movl 0x18(%rsp), %r12d
testl %ebp, %ebp
jne 0x784f6
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
movq %rsi, %r14
callq *(%rax)
movq %r14, %rsi
movq $-0x1, %rax
movl %ebp, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %r15d
addl %ebp, %r12d
movb $0x18, %cl
subb %r12b, %cl
shlq %cl, %r15
sarl $0x1f, %ebx
addl %esi, %ebx
orq 0x10(%rsp), %r15
movl %r12d, %ebp
cmpl $0x8, %r12d
jl 0x785c3
movl %r15d, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rsp)
movb %al, (%rcx)
decq 0x8(%rsp)
jne 0x78565
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x785b4
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
movl %r15d, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x785a8
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $0x0, (%rax)
decq 0x8(%rsp)
jne 0x785a8
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x785b4
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
shlq $0x8, %r15
leal -0x8(%rbp), %r12d
movb $0x1, %al
jmp 0x785b9
xorl %eax, %eax
movl %ebp, %r12d
testb %al, %al
jne 0x7851c
jmp 0x785cc
movq %r15, 0x10(%rsp)
movl %ebp, 0x18(%rsp)
xorl %r15d, %r15d
cmpl $0x7, %ebp
jg 0x78bef
testl %r13d, %r13d
je 0x786bd
movq $-0x1, %rbp
movq 0x38(%rsp), %rcx
shlq %cl, %rbp
notl %ebp
andl %ebx, %ebp
addl 0x18(%rsp), %r13d
movb $0x18, %cl
subb %r13b, %cl
shlq %cl, %rbp
orq 0x10(%rsp), %rbp
movl %r13d, %ebx
cmpl $0x8, %r13d
jl 0x786ab
movl %ebp, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rsp)
movb %al, (%rcx)
decq 0x8(%rsp)
jne 0x7864e
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x7869c
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
movl %ebp, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x78690
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $0x0, (%rax)
decq 0x8(%rsp)
jne 0x78690
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x7869c
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
shlq $0x8, %rbp
leal -0x8(%rbx), %r13d
movb $0x1, %al
jmp 0x786a1
xorl %eax, %eax
movl %ebx, %r13d
testb %al, %al
jne 0x78606
jmp 0x786b4
movq %rbp, 0x10(%rsp)
movl %ebx, 0x18(%rsp)
cmpl $0x7, %ebx
jg 0x78bef
xorl %r15d, %r15d
movl $0x1, %edx
leaq 0x325b4(%rip), %rax     # 0xaac80
movslq (%rax,%rdx,4), %rax
movq 0x70(%rsp), %rcx
movswl (%rcx,%rax,2), %r12d
testl %r12d, %r12d
je 0x78941
movq %rdx, 0x38(%rsp)
cmpl $0x10, %r15d
jl 0x78808
movq 0x40(%rsp), %rax
movl 0x3c0(%rax), %ebx
movsbl 0x4f0(%rax), %ebp
movl 0x18(%rsp), %r14d
testl %ebp, %ebp
jne 0x7871e
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
callq *(%rax)
movq $-0x1, %rax
movl %ebp, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %ebx
addl %ebp, %r14d
movb $0x18, %cl
subb %r14b, %cl
shlq %cl, %rbx
orq 0x10(%rsp), %rbx
movl %r14d, %r13d
cmpl $0x8, %r14d
jl 0x787e3
movl %ebx, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rsp)
movb %al, (%rcx)
decq 0x8(%rsp)
jne 0x78786
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x787d4
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
movl %ebx, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x787c8
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $0x0, (%rax)
decq 0x8(%rsp)
jne 0x787c8
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x787d4
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
shlq $0x8, %rbx
leal -0x8(%r13), %r14d
movb $0x1, %al
jmp 0x787d9
xorl %eax, %eax
movl %r13d, %r14d
testb %al, %al
jne 0x7873e
jmp 0x787ed
movq %rbx, 0x10(%rsp)
movl %r13d, 0x18(%rsp)
cmpl $0x7, %r13d
jg 0x78bec
leal -0x10(%r15), %eax
cmpl $0x1f, %r15d
movl %eax, %r15d
jg 0x786f2
movl %r12d, %eax
negl %eax
cmovsl %r12d, %eax
bsrl %eax, %ebp
xorl $-0x20, %ebp
addl $0x21, %ebp
cmpl $0x2, %eax
movl $0x1, %eax
cmovbl %eax, %ebp
cmpl $0xb, %ebp
jb 0x7883b
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movl $0x6, 0x28(%rax)
callq *(%rax)
shll $0x4, %r15d
addl %ebp, %r15d
movslq %r15d, %rax
movq 0x40(%rsp), %rcx
movl (%rcx,%rax,4), %ebx
movsbl 0x400(%rcx,%rax), %r15d
movl 0x18(%rsp), %r14d
testl %r15d, %r15d
jne 0x78871
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
callq *(%rax)
movq $-0x1, %rax
movl %r15d, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %ebx
movl %r12d, %r13d
addl %r15d, %r14d
movb $0x18, %cl
subb %r14b, %cl
shlq %cl, %rbx
sarl $0xf, %r13d
addl %r12d, %r13d
orq 0x10(%rsp), %rbx
movl %r14d, %r15d
cmpl $0x8, %r14d
jl 0x78949
movl %ebx, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rsp)
movb %al, (%rcx)
decq 0x8(%rsp)
jne 0x788e4
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x78932
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
movl %ebx, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x78926
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $0x0, (%rax)
decq 0x8(%rsp)
jne 0x78926
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x78932
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
shlq $0x8, %rbx
leal -0x8(%r15), %r14d
movb $0x1, %al
jmp 0x78937
xorl %eax, %eax
movl %r15d, %r14d
testb %al, %al
jne 0x7889c
jmp 0x78953
incl %r15d
jmp 0x78a40
movq %rbx, 0x10(%rsp)
movl %r15d, 0x18(%rsp)
cmpl $0x7, %r15d
jg 0x78bec
movq $-0x1, %rbx
movl %ebp, %ecx
shlq %cl, %rbx
notl %ebx
andl %r13d, %ebx
addl 0x18(%rsp), %ebp
movb $0x18, %cl
subb %bpl, %cl
shlq %cl, %rbx
orq 0x10(%rsp), %rbx
movl %ebp, %r12d
cmpl $0x8, %ebp
jl 0x78a24
movl %ebx, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rsp)
movb %al, (%rcx)
decq 0x8(%rsp)
jne 0x789c6
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x78a15
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
movl %ebx, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x78a08
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $0x0, (%rax)
decq 0x8(%rsp)
jne 0x78a08
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x78a15
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
shlq $0x8, %rbx
leal -0x8(%r12), %ebp
movb $0x1, %al
jmp 0x78a1a
xorl %eax, %eax
movl %r12d, %ebp
testb %al, %al
jne 0x7897f
jmp 0x78a2e
movq %rbx, 0x10(%rsp)
movl %r12d, 0x18(%rsp)
xorl %r15d, %r15d
cmpl $0x7, %r12d
movq 0x38(%rsp), %rdx
jg 0x78bef
incq %rdx
cmpq $0x40, %rdx
jne 0x786c5
testl %r15d, %r15d
movq 0x48(%rsp), %r12
jle 0x78b5c
movq 0x40(%rsp), %rax
movl (%rax), %ebx
movsbl 0x400(%rax), %ebp
movl 0x18(%rsp), %r15d
testl %ebp, %ebp
jne 0x78a83
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
callq *(%rax)
movq $-0x1, %rax
movl %ebp, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %ebx
addl %ebp, %r15d
movb $0x18, %cl
subb %r15b, %cl
shlq %cl, %rbx
orq 0x10(%rsp), %rbx
movl %r15d, %r14d
cmpl $0x8, %r15d
jl 0x78b48
movl %ebx, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rsp)
movb %al, (%rcx)
decq 0x8(%rsp)
jne 0x78aeb
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r15
callq *0x18(%r15)
testl %eax, %eax
je 0x78b39
movq (%r15), %rax
movq %rax, (%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x8(%rsp)
movl %ebx, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x78b2d
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $0x0, (%rax)
decq 0x8(%rsp)
jne 0x78b2d
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r15
callq *0x18(%r15)
testl %eax, %eax
je 0x78b39
movq (%r15), %rax
movq %rax, (%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x8(%rsp)
shlq $0x8, %rbx
leal -0x8(%r14), %r15d
movb $0x1, %al
jmp 0x78b3e
xorl %eax, %eax
movl %r14d, %r15d
testb %al, %al
jne 0x78aa3
jmp 0x78b52
movq %rbx, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
cmpl $0x7, %r14d
jg 0x78bec
movq 0x50(%rsp), %rsi
movq 0x68(%rsp), %rcx
movq (%rsi,%rcx,8), %rax
movswl (%rax), %eax
movq 0x60(%rsp), %rdx
movl %eax, 0x1c(%rsp,%rdx,4)
incq %rcx
movq 0x58(%rsp), %rdi
movslq 0x170(%rdi), %rax
cmpq %rax, %rcx
jl 0x78438
leaq 0x10(%rsp), %rax
leaq 0x18(%r12), %rcx
movq -0x10(%rax), %rdx
movq 0x28(%rdi), %rsi
movq %rdx, (%rsi)
movq -0x8(%rax), %rdx
movq %rdx, 0x8(%rsi)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
movl 0x118(%rdi), %eax
movl $0x1, %r15d
testl %eax, %eax
je 0x78bef
cmpl $0x0, 0x38(%r12)
jne 0x78be5
movl %eax, 0x38(%r12)
movl 0x3c(%r12), %eax
incl %eax
andl $0x7, %eax
movl %eax, 0x3c(%r12)
decl 0x38(%r12)
jmp 0x78bef
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbp
movq %rdi, %r13
movl 0x3c(%r12), %ebx
movq %rsp, %rdi
callq 0x78d56
xorl %r15d, %r15d
testl %eax, %eax
je 0x78bef
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb $-0x1, (%rax)
decq 0x8(%rsp)
jne 0x78c52
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x78bef
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
addb $-0x30, %bl
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb %bl, (%rax)
decq 0x8(%rsp)
jne 0x78c8e
movq 0x30(%rsp), %rdi
movq 0x28(%rdi), %rbx
callq *0x18(%rbx)
testl %eax, %eax
je 0x78bef
movq (%rbx), %rax
movq %rax, (%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x0, 0x144(%rax)
movq %r13, %rdi
movq %rbp, %rsi
jle 0x7841a
xorl %ecx, %ecx
movl $0x0, 0x1c(%rsp,%rcx,4)
incq %rcx
movslq 0x144(%rax), %rdx
cmpq %rdx, %rcx
jl 0x78ca8
jmp 0x7841a