// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jquant1.c
// Function: jinit_1pass_quantizer
GLOBAL(void)
jinit_1pass_quantizer (j_decompress_ptr cinfo)
{
  my_cquantize_ptr cquantize;

  cquantize = (my_cquantize_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				SIZEOF(my_cquantizer));
  cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
  cquantize->pub.start_pass = start_pass_1_quant;
  cquantize->pub.finish_pass = finish_pass_1_quant;
  cquantize->pub.new_color_map = new_color_map_1_quant;
  cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */
  cquantize->odither[0] = NULL;	/* Also flag odither arrays not allocated */

  /* Make sure my internal arrays won't overflow */
  if (cinfo->out_color_components > MAX_Q_COMPS)
    ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS);
  /* Make sure colormap indexes can be represented by JSAMPLEs */
  if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1))
    ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1);

  /* Create the colormap and color index table. */
  create_colormap(cinfo);
  create_colorindex(cinfo);

  /* Allocate Floyd-Steinberg workspace now if requested.
   * We do this now since it is FAR storage and may affect the memory
   * manager's space calculations.  If the user changes to FS dither
   * mode in a later pass, we will allocate the space then, and will
   * possibly overrun the max_memory_to_use setting.
   */
  if (cinfo->dither_mode == JDITHER_FS)
    alloc_fs_workspace(cinfo);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movl $0x98, %edx
movl $0x1, %esi
callq *(%rax)
movq %rax, 0x270(%rbx)
leaq 0x418(%rip), %rcx       # 0x847bb
movq %rcx, (%rax)
leaq 0x5fe(%rip), %rcx       # 0x849ab
movq %rcx, 0x10(%rax)
leaq 0x5f4(%rip), %rcx       # 0x849ac
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x70(%rax)
movq %rcx, 0x50(%rax)
cmpl $0x5, 0x90(%rbx)
jl 0x843e8
movq (%rbx), %rax
movabsq $0x400000037, %rcx      # imm = 0x400000037
movq %rcx, 0x28(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
cmpl $0x101, 0x78(%rbx)      # imm = 0x101
jl 0x8440a
movq (%rbx), %rax
movabsq $0x10000000039, %rcx    # imm = 0x10000000039
movq %rcx, 0x28(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x270(%rbx), %r14
movl 0x90(%rbx), %r15d
movslq 0x78(%rbx), %r12
leal -0x1(%r15), %eax
movl $0x1, %edx
movq %rdx, %r13
incq %rdx
movq %rdx, %rcx
cmpl $0x2, %r15d
jl 0x84441
movl %eax, %esi
movq %rdx, %rcx
imulq %rdx, %rcx
decl %esi
jne 0x84439
cmpq %r12, %rcx
jle 0x84425
cmpq $0x1, %r13
ja 0x84461
movq (%rbx), %rax
movl $0x38, 0x28(%rax)
movl %ecx, 0x2c(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
testl %r15d, %r15d
jle 0x845fa
leal 0x3(%r15), %eax
leaq -0x1(%r15), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movd %r13d, %xmm1
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x2607b(%rip), %xmm4    # 0xaa510
movdqa 0x1dde3(%rip), %xmm5    # 0xa2280
movdqa 0x25b8a(%rip), %xmm12   # 0xaa030
xorl %ecx, %ecx
movdqa 0x1dde0(%rip), %xmm6    # 0xa2290
pxor %xmm6, %xmm0
pcmpeqd %xmm7, %xmm7
movdqa 0x2667f(%rip), %xmm9    # 0xaab40
movdqa %xmm12, %xmm3
movdqa %xmm5, %xmm8
pxor %xmm6, %xmm8
movdqa %xmm8, %xmm2
pcmpgtd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm8
pshufd $0xf5, %xmm8, %xmm11    # xmm11 = xmm8[1,1,3,3]
pand %xmm2, %xmm11
pshufd $0xf5, %xmm2, %xmm10    # xmm10 = xmm2[1,1,3,3]
por %xmm11, %xmm10
movd %xmm10, %edx
notl %edx
testb $0x1, %dl
je 0x84505
movl %r13d, 0x3c(%r14,%rcx)
pxor %xmm7, %xmm10
pextrw $0x4, %xmm10, %edx
testb $0x1, %dl
je 0x8451a
movl %r13d, 0x40(%r14,%rcx)
movdqa %xmm4, %xmm11
pxor %xmm6, %xmm11
movdqa %xmm11, %xmm10
pcmpgtd %xmm0, %xmm10
pcmpeqd %xmm0, %xmm11
pshufd $0xf5, %xmm11, %xmm13   # xmm13 = xmm11[1,1,3,3]
pand %xmm10, %xmm13
pshufd $0xf5, %xmm10, %xmm12   # xmm12 = xmm10[1,1,3,3]
por %xmm13, %xmm12
pxor %xmm7, %xmm12
pextrw $0x0, %xmm12, %edx
testb $0x1, %dl
je 0x8455e
movl %r13d, 0x44(%r14,%rcx)
pextrw $0x4, %xmm12, %edx
testb $0x1, %dl
je 0x8456e
movl %r13d, 0x48(%r14,%rcx)
movdqa %xmm3, %xmm12
pmuludq %xmm1, %xmm12
pshufd $0xe8, %xmm12, %xmm12   # xmm12 = xmm12[0,2,2,3]
pshufd $0xf5, %xmm1, %xmm13    # xmm13 = xmm1[1,1,3,3]
pshufd $0xf5, %xmm3, %xmm14    # xmm14 = xmm3[1,1,3,3]
pmuludq %xmm13, %xmm14
pshufd $0xe8, %xmm14, %xmm13   # xmm13 = xmm14[0,2,2,3]
punpckldq %xmm13, %xmm12  # xmm12 = xmm12[0],xmm13[0],xmm12[1],xmm13[1]
paddq %xmm9, %xmm5
paddq %xmm9, %xmm4
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x844c1
movdqa %xmm2, %xmm0
shufps $0x88, %xmm10, %xmm0    # xmm0 = xmm0[0,2],xmm10[0,2]
shufps $0xdd, %xmm11, %xmm8    # xmm8 = xmm8[1,3],xmm11[1,3]
andps %xmm0, %xmm8
shufps $0xdd, %xmm10, %xmm2    # xmm2 = xmm2[1,3],xmm10[1,3]
orps %xmm8, %xmm2
pand %xmm2, %xmm3
pandn %xmm12, %xmm2
por %xmm3, %xmm2
pshufd $0xee, %xmm2, %xmm0     # xmm0 = xmm2[2,3,2,3]
pshufd $0xff, %xmm2, %xmm1     # xmm1 = xmm2[3,3,3,3]
pshufd $0xf5, %xmm2, %xmm3     # xmm3 = xmm2[1,1,3,3]
pmuludq %xmm1, %xmm3
pmuludq %xmm2, %xmm0
pmuludq %xmm3, %xmm0
movd %xmm0, %ebp
jmp 0x845ff
movl $0x1, %ebp
leaq 0x2664a(%rip), %rcx     # 0xaac50
movb $0x1, %sil
testl %r15d, %r15d
jle 0x84652
movq %rcx, %rdi
xorl %r8d, %r8d
cmpl $0x2, 0x40(%rbx)
jne 0x8461e
movl (%rdi), %eax
jmp 0x84621
movl %r8d, %eax
movslq %eax, %r9
movslq 0x3c(%r14,%r9,4), %r10
movl %ebp, %eax
cltd
idivl %r10d
cltq
incq %r10
imulq %r10, %rax
cmpq %r12, %rax
jg 0x84652
movl %r10d, 0x3c(%r14,%r9,4)
incq %r8
addq $0x4, %rdi
xorl %esi, %esi
movl %eax, %ebp
cmpq %r8, %r15
jne 0x84614
testb $0x1, %sil
je 0x84606
cmpl $0x3, 0x90(%rbx)
movq (%rbx), %rax
jne 0x84685
movl %ebp, 0x2c(%rax)
movl 0x3c(%r14), %ecx
movl %ecx, 0x30(%rax)
movl 0x40(%r14), %ecx
movl %ecx, 0x34(%rax)
movl 0x44(%r14), %ecx
movl %ecx, 0x38(%rax)
movl $0x5e, 0x28(%rax)
jmp 0x84692
movl $0x5f, 0x28(%rax)
movl %ebp, 0x2c(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x8(%rax)
movq 0x8(%rbx), %rax
movl 0x90(%rbx), %ecx
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
callq *0x10(%rax)
movq %rax, %rcx
cmpl $0x0, 0x90(%rbx)
jle 0x84780
movslq %ebp, %r8
xorl %r9d, %r9d
movl %ebp, %edi
movq %rbx, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movslq 0x3c(%r14,%r9,4), %r10
movl %edi, %eax
cltd
idivl %r10d
movl %eax, %esi
testq %r10, %r10
jle 0x84761
leaq -0x1(%r10), %rdx
movl %edx, %eax
shrl $0x1f, %eax
movq %rdx, 0x20(%rsp)
addl %edx, %eax
sarl %eax
cltq
movq %rax, 0x18(%rsp)
movslq %esi, %r12
movslq %edi, %rdi
movl %esi, %r13d
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %rbx, %rax
imulq %r12, %rax
cmpq %r8, %rax
jge 0x84756
movq %rbx, %rax
shlq $0x8, %rax
subq %rbx, %rax
addq 0x18(%rsp), %rax
cqto
idivq 0x20(%rsp)
movq %r14, %rdx
testl %esi, %esi
jle 0x8474e
xorl %r15d, %r15d
movq (%rcx,%r9,8), %r11
addq %rdx, %r11
movb %al, (%r15,%r11)
incq %r15
cmpq %r15, %r13
jne 0x8473b
addq %rdi, %rdx
cmpq %r8, %rdx
jl 0x84734
incq %rbx
addq %r12, %r14
cmpq %r10, %rbx
jne 0x8470f
incq %r9
movq 0x10(%rsp), %rbx
movslq 0x90(%rbx), %rax
movl %esi, %edi
cmpq %rax, %r9
movq 0x8(%rsp), %r14
jl 0x846d6
movq %rcx, 0x20(%r14)
movl %ebp, 0x28(%r14)
movq %rbx, %rdi
callq 0x849b8
cmpl $0x2, 0x70(%rbx)
jne 0x847ac
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84aed
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq