// File: /workspace/github_c_makefile_star2_O1/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 0x11166
movq %rdi, %r12
movb 0x86804(%rdi), %cl
movl $0xff00, %eax           # imm = 0xFF00
shrl %cl, %eax
movl %eax, 0x8(%rsp)
movl $0xff, %r9d
xorl %r10d, %r10d
movzbl (%rsi), %edx
movzbl 0x1(%rsi), %ecx
movzbl 0x2(%rsi), %eax
movl 0x10(%rsp), %r11d
addl %r11d, %edx
cmpl %r9d, %edx
movl $0xff, %r13d
cmovll %edx, %r13d
testl %r13d, %r13d
movl $0x0, %edi
cmovlel %edi, %r13d
addl %r11d, %ecx
cmpl %r9d, %ecx
movl $0xff, %r14d
cmovll %ecx, %r14d
testl %r14d, %r14d
cmovlel %edi, %r14d
addl %r11d, %eax
cmpl %r9d, %eax
movl $0xff, %ebp
cmovll %eax, %ebp
testl %ebp, %ebp
cmovlel %edi, %ebp
movb 0x3(%rsi), %r11b
cmpl $0x0, 0x14(%rsp)
je 0x10f88
cmpl $0x0, 0x8680c(%r12)
je 0x1112b
movzbl %r11b, %r15d
movl %r13d, %eax
andl %r9d, %eax
movl %r14d, %ecx
shll $0x8, %ecx
movl $0xffff, %edi           # imm = 0xFFFF
andl %edi, %ecx
movl %ebp, %edx
andl %r9d, %edx
shll $0x10, %edx
orl %ecx, %edx
movl %r15d, %ebx
shll $0x18, %ebx
orl %edx, %ebx
orl %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
roll $0x13, %eax
subl %eax, %ebx
movl %ebx, %eax
shrl $0xd, %eax
subl %eax, %ebx
andl %edi, %ebx
movq (%r12,%rbx,8), %rax
testq %rax, %rax
je 0x11003
cmpb %r13b, 0x20(%rax)
jne 0x10ffd
cmpb %r14b, 0x21(%rax)
jne 0x10ffd
cmpb %bpl, 0x22(%rax)
jne 0x10ffd
cmpb %r11b, 0x23(%rax)
je 0x11161
movq 0x68(%rax), %rax
jmp 0x10fdc
movq %rsi, 0x20(%rsp)
movl %r10d, 0x1c(%rsp)
movl $0x70, %edi
movl %r15d, 0x18(%rsp)
movl %r11d, %r15d
callq 0x1140
movq (%r12,%rbx,8), %rcx
movq %rcx, 0x68(%rax)
movq %rax, (%r12,%rbx,8)
movb %r13b, 0x20(%rax)
movb %r14b, 0x21(%rax)
movb %bpl, 0x22(%rax)
movb %r15b, 0x23(%rax)
movl 0x8(%rsp), %edx
andb %dl, %r13b
andb %dl, %r14b
movzbl %r13b, %ecx
cvtsi2ss %ecx, %xmm0
andb %dl, %bpl
movss 0xfe8(%rip), %xmm4      # 0x12040
divss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rax)
movzbl %r14b, %ecx
cvtsi2ss %ecx, %xmm1
divss %xmm4, %xmm1
mulss 0xfcc(%rip), %xmm1      # 0x12044
cvtss2sd %xmm1, %xmm1
movsd %xmm1, 0x8(%rax)
movzbl %bpl, %ecx
cvtsi2ss %ecx, %xmm2
divss %xmm4, %xmm2
mulss 0xfb3(%rip), %xmm2      # 0x12048
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0x10(%rax)
cvtsi2ssl 0x18(%rsp), %xmm3
divss %xmm4, %xmm3
cvtss2sd %xmm3, %xmm3
movsd %xmm3, 0x18(%rax)
cmpl $0x0, 0x8680c(%r12)
je 0x110d6
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)
movl $0xff, %r9d
movl 0x1c(%rsp), %r10d
movq 0x20(%rsp), %rsi
addq $0x4, %rsi
incl %r10d
cmpl 0xc(%rsp), %r10d
jne 0x10f18
jmp 0x11166
testl %edx, %edx
setle %bl
testl %ecx, %ecx
setle %dil
andb %bl, %dil
testl %eax, %eax
setle %bl
testb %bl, %dil
jne 0x11117
cmpl %r9d, %edx
setge %dl
cmpl %r9d, %ecx
setge %cl
andb %dl, %cl
cmpl %r9d, %eax
setge %al
testb %al, %cl
je 0x10f88
jmp 0x11117
incl 0x58(%rax)
jmp 0x11117
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq