// File: /workspace/github_c_makefile_star2_O3/tditlu[P]shadetabler/src/shadetabler.c
// Function: exq_feed_extened
static void exq_feed_extened(exq_data *pExq, unsigned char *pData, int nPixels, int shade, unsigned int forceBlackWhite)
{
	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++;

		r = (unsigned char)CLAMP(((int)r) + shade, 0, 255);
		g = (unsigned char)CLAMP(((int)g) + shade, 0, 255);
		b = (unsigned char)CLAMP(((int)b) + shade, 0, 255);

		if(forceBlackWhite && !pExq->transparency)
		{
			if (r == 0 && g == 0 && b == 0) { continue; }
			if (r == 255 && g == 255 && b == 255) { continue; }
		}

		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 * EXQ_SCALE_R;
			pCur->color.g = g / 255.0f * EXQ_SCALE_G;
			pCur->color.b = b / 255.0f * EXQ_SCALE_B;
			pCur->color.a = a / 255.0f * EXQ_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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x14(%rsp)
movl %ecx, 0x10(%rsp)
movl %edx, 0xc(%rsp)
testl %edx, %edx
jle 0x10cd3
movq %rdi, %r15
movb 0x86804(%rdi), %cl
movl $0xff00, %eax           # imm = 0xFF00
shrl %cl, %eax
movl %eax, 0x8(%rsp)
xorl %r11d, %r11d
movzbl (%rsi), %edx
movzbl 0x1(%rsi), %ecx
movzbl 0x2(%rsi), %eax
movl 0x10(%rsp), %edi
addl %edi, %edx
movl $0xff, %r10d
cmpl %r10d, %edx
movl $0xff, %r14d
cmovll %edx, %r14d
testl %r14d, %r14d
movl $0x0, %r9d
cmovlel %r9d, %r14d
addl %edi, %ecx
cmpl %r10d, %ecx
movl $0xff, %ebp
cmovll %ecx, %ebp
testl %ebp, %ebp
cmovlel %r9d, %ebp
addl %edi, %eax
cmpl %r10d, %eax
movl $0xff, %r13d
cmovll %eax, %r13d
testl %r13d, %r13d
cmovlel %r9d, %r13d
movb 0x3(%rsi), %r10b
cmpl $0x0, 0x14(%rsp)
je 0x10b09
cmpl $0x0, 0x8680c(%r15)
je 0x10c94
movzbl %r10b, %edi
movl %ebp, %eax
shll $0x8, %eax
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %eax
movzbl %r13b, %ecx
shll $0x10, %ecx
orl %eax, %ecx
movl %edi, %ebx
shll $0x18, %ebx
orl %ecx, %ebx
orl %r14d, %ebx
movl %ebx, %eax
roll $0x13, %eax
subl %eax, %ebx
movl %ebx, %eax
roll $0x13, %eax
subl %eax, %ebx
movl %ebx, %eax
roll $0x13, %eax
subl %eax, %ebx
movl %ebx, %eax
roll $0x13, %eax
subl %eax, %ebx
movl %ebx, %eax
shrl $0xd, %eax
subl %eax, %ebx
andl %edx, %ebx
movq (%r15,%rbx,8), %r12
testq %r12, %r12
je 0x10b82
movq %r12, %rax
cmpb %r14b, 0x20(%rax)
jne 0x10b79
cmpb %bpl, 0x21(%rax)
jne 0x10b79
cmpb %r13b, 0x22(%rax)
jne 0x10b79
cmpb %r10b, 0x23(%rax)
je 0x10cce
movq 0x68(%rax), %rax
testq %rax, %rax
jne 0x10b5d
movl %r11d, 0x1c(%rsp)
movq %rsi, 0x20(%rsp)
movl %edi, 0x18(%rsp)
movl $0x70, %edi
movb %r10b, 0x7(%rsp)
callq 0x1140
movq %r12, 0x68(%rax)
movq %rax, (%r15,%rbx,8)
movb %r14b, 0x20(%rax)
movb %bpl, 0x21(%rax)
movb %r13b, 0x22(%rax)
movb 0x7(%rsp), %cl
movb %cl, 0x23(%rax)
movl 0x8(%rsp), %edx
andb %dl, %r14b
andb %dl, %bpl
movzbl %r14b, %ecx
cvtsi2ss %ecx, %xmm0
movzbl %bpl, %ecx
cvtsi2ss %ecx, %xmm1
andb %dl, %r13b
movss 0x14c1(%rip), %xmm3     # 0x120a0
divss %xmm3, %xmm0
divss %xmm3, %xmm1
mulss 0x14b5(%rip), %xmm1     # 0x120a4
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtps2pd %xmm0, %xmm0
movupd %xmm0, (%rax)
movzbl %r13b, %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
divss %xmm3, %xmm1
mulss 0x1498(%rip), %xmm1     # 0x120a8
cvtss2sd %xmm1, %xmm1
movsd %xmm1, 0x10(%rax)
cvtsi2ssl 0x18(%rsp), %xmm2
divss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0x18(%rax)
cmpl $0x0, 0x8680c(%r15)
je 0x10c4d
movaps %xmm2, %xmm3
movlhps %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
mulpd %xmm0, %xmm3
movupd %xmm3, (%rax)
mulsd %xmm2, %xmm1
movsd %xmm1, 0x10(%rax)
movl $0x1, 0x58(%rax)
movl $0xffffffff, 0x24(%rax) # imm = 0xFFFFFFFF
movdqa 0x13bd(%rip), %xmm0     # 0x12020
movdqu %xmm0, 0x38(%rax)
movdqu %xmm0, 0x28(%rax)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x48(%rax)
movq 0x20(%rsp), %rsi
movl 0x1c(%rsp), %r11d
addq $0x4, %rsi
incl %r11d
cmpl 0xc(%rsp), %r11d
jne 0x10a96
jmp 0x10cd3
testl %edx, %edx
setle %r9b
testl %ecx, %ecx
setle %dil
andb %r9b, %dil
testl %eax, %eax
setle %r9b
testb %r9b, %dil
jne 0x10c80
movl $0xff, %edi
cmpl %edi, %edx
setge %dl
cmpl %edi, %ecx
setge %cl
andb %dl, %cl
cmpl %edi, %eax
setge %al
testb %al, %cl
je 0x10b09
jmp 0x10c80
incl 0x58(%rax)
jmp 0x10c80
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq