// File: /workspace/github_cpp_makefile_star2_O3/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 0x420(%rip), %rcx       # 0x839d7
movq %rcx, (%rax)
leaq 0x607(%rip), %rcx       # 0x83bc8
movq %rcx, 0x10(%rax)
leaq 0x5fd(%rip), %rcx       # 0x83bc9
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x70(%rax)
movq %rcx, 0x50(%rax)
cmpl $0x5, 0x90(%rbx)
jl 0x835fc
movq (%rbx), %rax
movabsq $0x400000037, %rcx      # imm = 0x400000037
movq %rcx, 0x28(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movl 0x78(%rbx), %eax
cmpl $0x101, %eax            # imm = 0x101
jl 0x83622
movq (%rbx), %rax
movabsq $0x10000000039, %rcx    # imm = 0x10000000039
movq %rcx, 0x28(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movl 0x78(%rbx), %eax
movq 0x270(%rbx), %r14
movl 0x90(%rbx), %r15d
movslq %eax, %r12
leal -0x1(%r15), %eax
movl $0x1, %edx
movq %rdx, %r13
incq %rdx
movq %rdx, %rcx
cmpl $0x2, %r15d
jl 0x83658
movl %eax, %esi
movq %rdx, %rcx
imulq %rdx, %rcx
decl %esi
jne 0x83650
cmpq %r12, %rcx
jle 0x8363c
cmpq $0x1, %r13
ja 0x83678
movq (%rbx), %rax
movl $0x38, 0x28(%rax)
movl %ecx, 0x2c(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
testl %r15d, %r15d
jle 0x8386b
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 0x26e74(%rip), %xmm4    # 0xaa520
movdqa 0x1ebcc(%rip), %xmm5    # 0xa2280
movdqa 0x26233(%rip), %xmm12   # 0xa98f0
xorl %ecx, %ecx
movdqa 0x1ebc9(%rip), %xmm6    # 0xa2290
pxor %xmm6, %xmm0
pcmpeqd %xmm7, %xmm7
movdqa 0x27478(%rip), %xmm9    # 0xaab50
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 0x8371c
movl %r13d, 0x3c(%r14,%rcx)
pxor %xmm7, %xmm10
pextrw $0x4, %xmm10, %edx
testb $0x1, %dl
je 0x83731
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 0x83775
movl %r13d, 0x44(%r14,%rcx)
pextrw $0x4, %xmm12, %edx
testb $0x1, %dl
je 0x83785
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 0x836d8
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, %r10d
testl %r15d, %r15d
jle 0x83871
movb $0x1, %dil
xorl %esi, %esi
leaq 0x2743f(%rip), %rcx     # 0xaac60
cmpl $0x2, 0x40(%rbx)
movl %esi, %eax
jne 0x8382c
movl (%rcx,%rsi,4), %eax
movslq %eax, %r8
movslq 0x3c(%r14,%r8,4), %r9
movl %r10d, %eax
cltd
idivl %r9d
cltq
incq %r9
imulq %r9, %rax
cmpq %r12, %rax
jg 0x8385b
movl %r9d, 0x3c(%r14,%r8,4)
incq %rsi
xorl %edi, %edi
movl %eax, %r10d
cmpq %r15, %rsi
jne 0x83821
movl $0x0, %esi
testb $0x1, %dil
movb $0x1, %dil
je 0x83821
jmp 0x83871
movl $0x1, %r10d
cmpl $0x3, 0x90(%rbx)
movq (%rbx), %rax
movl %r10d, 0x2c(%rax)
movl %r10d, 0xc(%rsp)
jne 0x838a5
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, %edx
movq %rax, %rcx
jmp 0x838ad
movq (%rbx), %rcx
movl $0x5f, %edx
movl %edx, 0x28(%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq *0x8(%rcx)
movq 0x8(%rbx), %rax
movl 0x90(%rbx), %ecx
movq %rbx, %rdi
movl $0x1, %esi
movl 0xc(%rsp), %edx
callq *0x10(%rax)
movq %rax, %rcx
movl 0x90(%rbx), %r11d
testl %r11d, %r11d
jle 0x83998
movl 0xc(%rsp), %edi
movslq %edi, %r8
xorl %r9d, %r9d
movq %rbx, 0x18(%rsp)
movq %r14, 0x10(%rsp)
movslq 0x3c(%r14,%r9,4), %r10
movl %edi, %eax
cltd
idivl %r10d
movl %eax, %esi
testq %r10, %r10
jle 0x83987
leal -0x1(%r10), %r15d
movq %r15, 0x20(%rsp)
shrl %r15d
movslq %esi, %r12
movslq %edi, %rdi
movl %esi, %r13d
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %rbx, %rax
imulq %r12, %rax
cmpq %r8, %rax
jge 0x8396b
movq %rbx, %rax
shlq $0x8, %rax
subq %rbx, %rax
addq %r15, %rax
xorl %edx, %edx
divq 0x20(%rsp)
movq %rbp, %rdx
testl %esi, %esi
jle 0x83963
xorl %r14d, %r14d
movq (%rcx,%r9,8), %r11
addq %rdx, %r11
movb %al, (%r14,%r11)
incq %r14
cmpq %r14, %r13
jne 0x83950
addq %rdi, %rdx
cmpq %r8, %rdx
jl 0x83949
incq %rbx
addq %r12, %rbp
cmpq %r10, %rbx
jne 0x83926
movq 0x18(%rsp), %rbx
movl 0x90(%rbx), %r11d
movq 0x10(%rsp), %r14
incq %r9
movslq %r11d, %rax
movl %esi, %edi
cmpq %rax, %r9
jl 0x838fb
movq %rcx, 0x20(%r14)
movl 0xc(%rsp), %eax
movl %eax, 0x28(%r14)
movq %rbx, %rdi
callq 0x83bd5
cmpl $0x2, 0x70(%rbx)
jne 0x839c8
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x83d0b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq