// File: /workspace/github_cpp_makefile_star2_O3/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 $0x88, %rsp
movq 0x1f0(%rdi), %r14
movq 0x28(%rdi), %rax
movq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rax), %r12
movq %r12, 0x10(%rsp)
movups 0x18(%r14), %xmm0
movups 0x28(%r14), %xmm1
movups %xmm0, 0x18(%rsp)
movups %xmm1, 0x28(%rsp)
movq %rdi, 0x38(%rsp)
cmpl $0x0, 0x118(%rdi)
je 0x774e9
cmpl $0x0, 0x38(%r14)
je 0x77d2d
cmpl $0x0, 0x170(%rdi)
jle 0x77cc3
xorl %ecx, %ecx
movq %r14, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
movq %rsi, 0x48(%rsp)
movslq 0x174(%rdi,%rcx,4), %rdx
movq %rcx, 0x80(%rsp)
movq (%rsi,%rcx,8), %rax
movq %rax, 0x58(%rsp)
movswl (%rax), %ebx
movl 0x24(%rsp,%rdx,4), %eax
movl %ebx, %ecx
subl %eax, %ecx
movq %rcx, 0x50(%rsp)
movq %rdx, 0x78(%rsp)
movq 0x148(%rdi,%rdx,8), %rcx
movslq 0x14(%rcx), %rdx
movq 0x40(%r14,%rdx,8), %r13
movslq 0x18(%rcx), %rcx
movq 0x60(%r14,%rcx,8), %rcx
movq %rcx, 0x60(%rsp)
movl $0x0, %ebp
subl %eax, %ebx
je 0x7758f
movl %ebx, %ecx
negl %ecx
cmovsl %ebx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %ecx, %edx
shrl %edx
incl %eax
cmpl $0x1, %ecx
movl %edx, %ecx
ja 0x7756b
leal 0x1(%rax), %ebp
cmpl $0xb, %eax
jb 0x7758f
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
movl $0x6, 0x28(%rax)
callq *(%rax)
movl %ebp, %r15d
movl (%r13,%r15,4), %r14d
movsbl 0x400(%r13,%r15), %ebp
movl 0x20(%rsp), %r13d
testl %ebp, %ebp
jne 0x775ba
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
callq *(%rax)
movq $-0x1, %rax
movl %ebp, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %r14d
addl %ebp, %r13d
movb $0x18, %cl
subb %r13b, %cl
shlq %cl, %r14
orq 0x18(%rsp), %r14
cmpl $0x8, %r13d
jl 0x7769f
movl %r14d, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movb %al, (%rcx)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77633
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r12
callq *0x18(%r12)
testl %eax, %eax
je 0x77d17
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r12), %r12
movq %r12, 0x10(%rsp)
movl %r14d, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x77688
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77688
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r12
callq *0x18(%r12)
testl %eax, %eax
je 0x77d17
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r12), %r12
movq %r12, 0x10(%rsp)
shlq $0x8, %r14
leal -0x8(%r13), %ebp
cmpl $0xf, %r13d
movl %ebp, %r13d
jg 0x775e5
jmp 0x776a2
movl %r13d, %ebp
movq %r14, 0x18(%rsp)
movl %ebp, 0x20(%rsp)
testq %r15, %r15
je 0x7779a
movq 0x50(%rsp), %rax
sarl $0x1f, %eax
addl %ebx, %eax
movq $-0x1, %rbx
movl %r15d, %ecx
shlq %cl, %rbx
notl %ebx
andl %eax, %ebx
addl %r15d, %ebp
movb $0x18, %cl
subb %bpl, %cl
shlq %cl, %rbx
orq %r14, %rbx
cmpl $0x8, %ebp
movq 0x58(%rsp), %r13
jl 0x777a1
movl %ebx, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movb %al, (%rcx)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77735
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x77d17
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %r12
movq %r12, 0x10(%rsp)
movl %ebx, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x77786
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77786
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x77d17
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %r12
movq %r12, 0x10(%rsp)
shlq $0x8, %rbx
leal -0x8(%rbp), %eax
cmpl $0xf, %ebp
movl %eax, %ebp
jg 0x776eb
jmp 0x777a3
movq 0x58(%rsp), %r13
jmp 0x777b1
movl %ebp, %eax
movq %rbx, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movq %rbx, %r14
movl %eax, %ebp
movl $0x1, %ebx
incq %rbx
xorl %r15d, %r15d
leaq 0x334fd(%rip), %rcx     # 0xaacc0
movslq -0x4(%rcx,%rbx,4), %rax
movswl (%r13,%rax,2), %eax
testl %eax, %eax
jne 0x777e3
incl %r15d
incq %rbx
cmpq $0x41, %rbx
jne 0x777c3
jmp 0x77b84
movl %eax, 0x50(%rsp)
cmpl $0x10, %r15d
jb 0x77922
movq 0x60(%rsp), %rax
movl 0x3c0(%rax), %r13d
movsbl 0x4f0(%rax), %ecx
testl %ecx, %ecx
jne 0x77821
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
movl %ecx, 0x44(%rsp)
callq *(%rax)
movl 0x44(%rsp), %ecx
movq $-0x1, %rax
shlq %cl, %rax
notl %eax
andl %eax, %r13d
addl %ecx, %ebp
movb $0x18, %cl
subb %bpl, %cl
shlq %cl, %r13
orq %r13, %r14
cmpl $0x8, %ebp
jl 0x778ff
movl %r14d, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movb %al, (%rcx)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77894
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r12
callq *0x18(%r12)
testl %eax, %eax
je 0x77d17
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r12), %r12
movq %r12, 0x10(%rsp)
movl %r14d, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x778e9
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x778e9
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r12
callq *0x18(%r12)
testl %eax, %eax
je 0x77d17
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r12), %r12
movq %r12, 0x10(%rsp)
shlq $0x8, %r14
leal -0x8(%rbp), %r13d
cmpl $0xf, %ebp
movl %r13d, %ebp
ja 0x77846
jmp 0x77902
movl %ebp, %r13d
movq %r14, 0x18(%rsp)
movl %r13d, 0x20(%rsp)
leal -0x10(%r15), %edx
movl %r13d, %ebp
cmpl $0x1f, %r15d
movl %edx, %r15d
jg 0x777f1
jmp 0x77928
movl %ebp, %r13d
movl %r15d, %edx
movl 0x50(%rsp), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movl $0x1, %ebp
cmpl $0x2, %eax
jb 0x77964
bsrl %eax, %ebp
xorl $-0x20, %ebp
addl $0x21, %ebp
cmpl $0x400, %eax            # imm = 0x400
jb 0x77964
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
movl $0x6, 0x28(%rax)
movl %edx, %r15d
callq *(%rax)
movl %r15d, %edx
shll $0x4, %edx
movl %ebp, 0x44(%rsp)
addl %ebp, %edx
movslq %edx, %rax
movq 0x60(%rsp), %rcx
movl (%rcx,%rax,4), %r15d
movsbl 0x400(%rcx,%rax), %ebp
testl %ebp, %ebp
jne 0x77996
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
callq *(%rax)
movq $-0x1, %rax
movl %ebp, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %r15d
addl %ebp, %r13d
movb $0x18, %cl
subb %r13b, %cl
shlq %cl, %r15
orq %r15, %r14
cmpl $0x8, %r13d
jl 0x77a73
movl %r14d, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movb %al, (%rcx)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77a0a
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r15
callq *0x18(%r15)
testl %eax, %eax
je 0x77d17
movq (%r15), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r15), %r12
movq %r12, 0x10(%rsp)
movl %r14d, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x77a5c
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77a5c
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r15
callq *0x18(%r15)
testl %eax, %eax
je 0x77d17
movq (%r15), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r15), %r12
movq %r12, 0x10(%rsp)
shlq $0x8, %r14
leal -0x8(%r13), %r15d
cmpl $0xf, %r13d
movl %r15d, %r13d
jg 0x779bf
jmp 0x77a76
movl %r13d, %r15d
movl 0x50(%rsp), %ecx
movl %ecx, %eax
sarl $0xf, %eax
addl %ecx, %eax
movq $-0x1, %r13
movl 0x44(%rsp), %ecx
shlq %cl, %r13
notl %r13d
andl %eax, %r13d
addl %ecx, %r15d
movb $0x18, %cl
subb %r15b, %cl
shlq %cl, %r13
orq %r14, %r13
cmpl $0x8, %r15d
jl 0x77b61
movl %r13d, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movb %al, (%rcx)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77af8
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x77d17
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %r12
movq %r12, 0x10(%rsp)
movl %r13d, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x77b4a
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77b4a
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x77d17
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %r12
movq %r12, 0x10(%rsp)
shlq $0x8, %r13
leal -0x8(%r15), %ebp
cmpl $0xf, %r15d
movl %ebp, %r15d
jg 0x77aad
jmp 0x77b64
movl %r15d, %ebp
movq %r13, 0x18(%rsp)
movl %ebp, 0x20(%rsp)
movq %r13, %r14
cmpq $0x40, %rbx
movq 0x58(%rsp), %r13
jne 0x777b6
jmp 0x77c89
movq 0x60(%rsp), %rax
movl (%rax), %r15d
movsbl 0x400(%rax), %ebx
testl %ebx, %ebx
jne 0x77ba8
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
movl $0x28, 0x28(%rax)
callq *(%rax)
movq $-0x1, %rax
movl %ebx, %ecx
shlq %cl, %rax
notl %eax
andl %eax, %r15d
addl %ebx, %ebp
movb $0x18, %cl
subb %bpl, %cl
shlq %cl, %r15
orq %r15, %r14
cmpl $0x8, %ebp
jl 0x77c7e
movl %r14d, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movb %al, (%rcx)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77c19
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %rbx
callq *0x18(%rbx)
testl %eax, %eax
je 0x77d17
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %r12
movq %r12, 0x10(%rsp)
movl %r14d, %eax
notl %eax
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x77c6a
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %r12
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77c6a
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %rbx
callq *0x18(%rbx)
testl %eax, %eax
je 0x77d17
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %r12
movq %r12, 0x10(%rsp)
shlq $0x8, %r14
leal -0x8(%rbp), %eax
cmpl $0xf, %ebp
movl %eax, %ebp
jg 0x77bcf
jmp 0x77c80
movl %ebp, %eax
movq %r14, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movq 0x48(%rsp), %rsi
movq 0x80(%rsp), %rcx
movq (%rsi,%rcx,8), %rax
movswl (%rax), %eax
movq 0x78(%rsp), %rdx
movl %eax, 0x24(%rsp,%rdx,4)
incq %rcx
movq 0x68(%rsp), %rdi
movslq 0x170(%rdi), %rax
cmpq %rax, %rcx
movq 0x70(%rsp), %r14
jl 0x77507
leaq 0x18(%rsp), %rax
leaq 0x18(%r14), %rcx
movq -0x10(%rax), %rdx
movq 0x28(%rdi), %rsi
movq %rdx, (%rsi)
movq %r12, 0x8(%rsi)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
movl 0x118(%rdi), %eax
movl $0x1, %ebp
testl %eax, %eax
je 0x77d19
movl 0x38(%r14), %ecx
testl %ecx, %ecx
jne 0x77d0f
movl 0x3c(%r14), %ecx
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x3c(%r14)
movl %eax, %ecx
decl %ecx
movl %ecx, 0x38(%r14)
jmp 0x77d19
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, 0x48(%rsp)
movq %rdi, %r13
movl 0x3c(%r14), %ebx
leaq 0x8(%rsp), %rdi
callq 0x77e9f
xorl %ebp, %ebp
testl %eax, %eax
je 0x77d19
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb $-0x1, (%rax)
decq 0x10(%rsp)
je 0x77d68
movq 0x8(%rsp), %rax
jmp 0x77d8b
movq %r14, %r15
movq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r14
callq *0x18(%r14)
testl %eax, %eax
je 0x77d19
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rcx, 0x10(%rsp)
movq %r15, %r14
addb $-0x30, %bl
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb %bl, (%rax)
movq 0x10(%rsp), %r12
movq 0x38(%rsp), %r15
decq %r12
movq %r12, 0x10(%rsp)
jne 0x77dd0
movq 0x28(%r15), %rbx
movq %r15, %rdi
callq *0x18(%rbx)
testl %eax, %eax
je 0x77d19
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %r12
movq %r12, 0x10(%rsp)
cmpl $0x0, 0x144(%r15)
jle 0x77e00
xorl %eax, %eax
movq %r13, %rdi
movq 0x48(%rsp), %rsi
movl $0x0, 0x24(%rsp,%rax,4)
incq %rax
movslq 0x144(%r15), %rcx
cmpq %rcx, %rax
jl 0x77de4
jmp 0x774e9
movq %r13, %rdi
movq 0x48(%rsp), %rsi
jmp 0x774e9