// File: /workspace/github_c_makefile_star2_O2/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, 0x10(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdi, %r15
movb 0x86804(%rdi), %cl
movl $0xff00, %eax           # imm = 0xFF00
shrl %cl, %eax
movl %eax, 0x8(%rsp)
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movl %edx, 0x14(%rsp)
xorl %r11d, %r11d
cmpl 0x14(%rsp), %r11d
je 0xe935
movzbl (%rsi), %edx
movzbl 0x1(%rsi), %ecx
movzbl 0x2(%rsi), %eax
movl 0xc(%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, %r13d
cmovll %ecx, %r13d
testl %r13d, %r13d
cmovlel %r9d, %r13d
addl %edi, %eax
cmpl %r10d, %eax
movl $0xff, %r12d
cmovll %eax, %r12d
testl %r12d, %r12d
cmovlel %r9d, %r12d
movb 0x3(%rsi), %bpl
cmpl $0x0, 0x10(%rsp)
je 0xe780
cmpl $0x0, 0x8680c(%r15)
je 0xe8f6
movzbl %bpl, %edi
movl %r13d, %eax
shll $0x8, %eax
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %eax
movzbl %r12b, %ecx
shll $0x10, %ecx
orl %eax, %ecx
movl %edi, %eax
shll $0x18, %eax
orl %ecx, %eax
orl %r14d, %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
andl %edx, %eax
leaq (%r15,%rax,8), %rbx
movq %rbx, %rax
movq (%rax), %rax
testq %rax, %rax
je 0xe7fa
cmpb %r14b, 0x20(%rax)
jne 0xe7f4
cmpb %r13b, 0x21(%rax)
jne 0xe7f4
cmpb %r12b, 0x22(%rax)
jne 0xe7f4
cmpb %bpl, 0x23(%rax)
je 0xe930
addq $0x68, %rax
jmp 0xe7d0
movl %r11d, 0x1c(%rsp)
movq %rsi, 0x20(%rsp)
movl %edi, 0x18(%rsp)
pushq $0x70
popq %rdi
callq 0x1130
movq (%rbx), %rcx
movq %rcx, 0x68(%rax)
movq %rax, (%rbx)
movb %r14b, 0x20(%rax)
movb %r13b, 0x21(%rax)
movb %r12b, 0x22(%rax)
movb %bpl, 0x23(%rax)
movl 0x8(%rsp), %edx
andb %dl, %r14b
andb %dl, %r13b
movzbl %r14b, %ecx
cvtsi2ss %ecx, %xmm0
movzbl %r13b, %ecx
cvtsi2ss %ecx, %xmm1
andb %dl, %r12b
movss 0x851(%rip), %xmm3      # 0xf0a0
divss %xmm3, %xmm0
divss %xmm3, %xmm1
mulss 0x845(%rip), %xmm1      # 0xf0a4
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtps2pd %xmm0, %xmm0
movupd %xmm0, (%rax)
movzbl %r12b, %ecx
cvtsi2ss %ecx, %xmm1
divss %xmm3, %xmm1
mulss 0x82b(%rip), %xmm1      # 0xf0a8
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 0xe8ba
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)
orl $-0x1, 0x24(%rax)
movdqa 0x753(%rip), %xmm0      # 0xf020
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
jmp 0xe6ff
testl %edx, %edx
setle %r9b
testl %ecx, %ecx
setle %dil
andb %r9b, %dil
testl %eax, %eax
setle %r9b
testb %r9b, %dil
jne 0xe8ea
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 0xe780
jmp 0xe8ea
incl 0x58(%rax)
jmp 0xe8ea
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq