// File: /workspace/github_c_makefile_star2_O3/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
movl %edx, -0x30(%rbp)
testl %edx, %edx
jle 0x1729
movq %rdi, %r14
movb 0x86804(%rdi), %cl
movl $0xff00, %eax           # imm = 0xFF00
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
xorl %r8d, %r8d
movzbl (%rsi), %r13d
movzbl 0x1(%rsi), %r12d
movzbl 0x2(%rsi), %r15d
movzbl 0x3(%rsi), %r9d
movl %r12d, %eax
shll $0x8, %eax
movl %r15d, %ecx
shll $0x10, %ecx
movl %r9d, %edx
shll $0x18, %edx
orl %r13d, %eax
orl %ecx, %eax
orl %edx, %eax
movl %eax, %ecx
roll $0x13, %ecx
subl %ecx, %eax
movl %eax, %ecx
roll $0x13, %ecx
subl %ecx, %eax
movl %eax, %ecx
roll $0x13, %ecx
subl %ecx, %eax
movl %eax, %ecx
roll $0x13, %ecx
subl %ecx, %eax
movl %eax, %ecx
shrl $0xd, %ecx
subl %ecx, %eax
movzwl %ax, %ecx
movq (%r14,%rcx,8), %rbx
testq %rbx, %rbx
je 0x1603
movq %rbx, %rax
cmpb %r13b, 0x20(%rax)
jne 0x15fa
cmpb %r12b, 0x21(%rax)
jne 0x15fa
cmpb %r15b, 0x22(%rax)
jne 0x15fa
cmpb %r9b, 0x23(%rax)
je 0x1724
movq 0x68(%rax), %rax
testq %rax, %rax
jne 0x15de
movl %r8d, -0x38(%rbp)
movq %rsi, -0x48(%rbp)
movl $0x70, %edi
movl %r9d, -0x34(%rbp)
movq %rcx, -0x40(%rbp)
callq 0x11d0
movq %rbx, 0x68(%rax)
movq -0x40(%rbp), %rcx
movq %rax, (%r14,%rcx,8)
movb %r13b, 0x20(%rax)
movb %r12b, 0x21(%rax)
movb %r15b, 0x22(%rax)
movl -0x34(%rbp), %edx
movb %dl, 0x23(%rax)
movl -0x2c(%rbp), %ecx
andb %cl, %r13b
andb %cl, %r12b
andb %cl, %r15b
movzbl %r13b, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss 0x109e6(%rip), %xmm4    # 0x12040
divss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rax)
movzbl %r12b, %ecx
cvtsi2ss %ecx, %xmm1
divss %xmm4, %xmm1
mulss 0x109ca(%rip), %xmm1    # 0x12044
cvtss2sd %xmm1, %xmm1
movsd %xmm1, 0x8(%rax)
movzbl %r15b, %ecx
cvtsi2ss %ecx, %xmm2
divss %xmm4, %xmm2
mulss 0x109b1(%rip), %xmm2    # 0x12048
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0x10(%rax)
movzbl %dl, %ecx
cvtsi2ss %ecx, %xmm3
divss %xmm4, %xmm3
cvtss2sd %xmm3, %xmm3
movsd %xmm3, 0x18(%rax)
cmpl $0x0, 0x8680c(%r14)
je 0x16d8
mulsd %xmm3, %xmm0
movsd %xmm0, (%rax)
mulsd %xmm3, %xmm1
movsd %xmm1, 0x8(%rax)
mulsd %xmm3, %xmm2
movsd %xmm2, 0x10(%rax)
movl $0x1, 0x58(%rax)
movl $0xffffffff, 0x24(%rax) # imm = 0xFFFFFFFF
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)
movq -0x48(%rbp), %rsi
movl -0x38(%rbp), %r8d
addq $0x4, %rsi
incl %r8d
cmpl -0x30(%rbp), %r8d
jne 0x1580
jmp 0x1729
incl 0x58(%rax)
jmp 0x1711
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq