// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]n64graphics_ci/exoquant/exoquant.c
// Function: exq_feed
void exq_feed(exq_data *pExq, unsigned char *pData, int nPixels)
{
	int i;
	unsigned int hash;
	unsigned char r, g, b, a;
	exq_histogram *pCur;
	unsigned char channelMask = 0xff00 >> pExq->numBitsPerChannel;

	for(i = 0; i < nPixels; i++)
	{
		r = *pData++; g = *pData++; b = *pData++; a = *pData++;
		hash = exq_make_hash(((unsigned int)r) | (((unsigned int)g) << 8) | (((unsigned int)b) << 16) | (((unsigned int)a) << 24));

		pCur = pExq->pHash[hash];
		while(pCur != NULL && (pCur->ored != r || pCur->ogreen != g ||
			pCur->oblue != b || pCur->oalpha != a))
			pCur = pCur->pNextInHash;

		if(pCur != NULL)
			pCur->num++;
		else
		{
			pCur = (exq_histogram*)malloc(sizeof(exq_histogram));
			pCur->pNextInHash = pExq->pHash[hash];
			pExq->pHash[hash] = pCur;
			pCur->ored = r; pCur->ogreen = g; pCur->oblue = b; pCur->oalpha = a;
			r &= channelMask; g &= channelMask; b &= channelMask;
			pCur->color.r = r / 255.0f * SCALE_R;
			pCur->color.g = g / 255.0f * SCALE_G;
			pCur->color.b = b / 255.0f * SCALE_B;
			pCur->color.a = a / 255.0f * SCALE_A;

			if(pExq->transparency)
			{
				pCur->color.r *= pCur->color.a;
				pCur->color.g *= pCur->color.a;
				pCur->color.b *= pCur->color.a;
			}

			pCur->num = 1;
			pCur->palIndex = -1;
			pCur->ditherScale.r = pCur->ditherScale.g = pCur->ditherScale.b =
				pCur->ditherScale.a = -1;
			pCur->ditherIndex[0] = pCur->ditherIndex[1] = pCur->ditherIndex[2] =
				pCur->ditherIndex[3] = -1;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, -0x40(%rbp)
movb 0x86804(%rdi), %cl
movl $0xff00, %eax           # imm = 0xFF00
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movl %edx, -0x30(%rbp)
cmpl -0x30(%rbp), %eax
je 0x15ee
movl %eax, -0x34(%rbp)
movzbl (%rsi), %r12d
movzbl 0x1(%rsi), %r13d
movzbl 0x2(%rsi), %r14d
movzbl 0x3(%rsi), %ebx
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
movl %r13d, %edi
shll $0x8, %edi
movl %r14d, %eax
shll $0x10, %eax
movl %ebx, %ecx
shll $0x18, %ecx
orl %r12d, %edi
orl %eax, %edi
orl %ecx, %edi
callq 0x15fd
movl %eax, %eax
movq -0x40(%rbp), %rcx
leaq (%rcx,%rax,8), %r15
movq %r15, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x14ef
cmpb %r12b, 0x20(%rax)
jne 0x14e9
cmpb %r13b, 0x21(%rax)
jne 0x14e9
cmpb %r14b, 0x22(%rax)
jne 0x14e9
cmpb %bl, 0x23(%rax)
je 0x15e9
addq $0x68, %rax
jmp 0x14c6
pushq $0x70
popq %rdi
callq 0x11d0
movq (%r15), %rcx
movq %rcx, 0x68(%rax)
movq %rax, (%r15)
movb %r12b, 0x20(%rax)
movb %r13b, 0x21(%rax)
movb %r14b, 0x22(%rax)
movb %bl, 0x23(%rax)
movl -0x2c(%rbp), %ecx
andb %cl, %r12b
andb %cl, %r13b
andb %cl, %r14b
movzbl %r12b, %ecx
cvtsi2ss %ecx, %xmm0
movss 0xfad8(%rip), %xmm4     # 0x11004
divss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rax)
movzbl %r13b, %ecx
cvtsi2ss %ecx, %xmm1
divss %xmm4, %xmm1
mulss 0xfabc(%rip), %xmm1     # 0x11008
cvtss2sd %xmm1, %xmm1
movsd %xmm1, 0x8(%rax)
movzbl %r14b, %ecx
cvtsi2ss %ecx, %xmm2
divss %xmm4, %xmm2
mulss 0xfaa3(%rip), %xmm2     # 0x1100c
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0x10(%rax)
movzbl %bl, %ecx
cvtsi2ss %ecx, %xmm3
divss %xmm4, %xmm3
cvtss2sd %xmm3, %xmm3
movsd %xmm3, 0x18(%rax)
movq -0x40(%rbp), %rcx
cmpl $0x0, 0x8680c(%rcx)
je 0x15ad
mulsd %xmm3, %xmm0
movsd %xmm0, (%rax)
mulsd %xmm3, %xmm1
movsd %xmm1, 0x8(%rax)
mulsd %xmm3, %xmm2
movsd %xmm2, 0x10(%rax)
movl $0x1, 0x58(%rax)
orl $-0x1, 0x24(%rax)
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
movq %rcx, 0x40(%rax)
movq %rcx, 0x38(%rax)
movq %rcx, 0x30(%rax)
movq %rcx, 0x28(%rax)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x48(%rax)
movl -0x34(%rbp), %eax
incl %eax
movq -0x48(%rbp), %rsi
jmp 0x1476
incl 0x58(%rax)
jmp 0x15db
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq