// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-zoe/tex-to_image.c
// Function: texToRgba
void texToRgba( textureAttributes header, paletteEntry *paletteTable, unsigned char *texPixelData, unsigned char *rgbaPixelData, unsigned int bpp, unsigned int totalTexPixels, unsigned int widthAligned ) {
	unsigned int curTexPixel = 0, curRgbaPixel = 0, skipPixel = widthAligned - header.textureWidth, currentRow = 0;
	if( bpp == palMode4bpp ) {
		uint8_t pixelA, pixelB;
		for( curTexPixel = 0; curTexPixel < totalTexPixels; curTexPixel++ ) {
			if( curTexPixel == (header.textureWidth/2)*(currentRow + 1) + (skipPixel/2)*currentRow ) {
				curTexPixel += (skipPixel/2);
				currentRow++;
			}
			pixelB = texPixelData[curTexPixel] >> 4;
			pixelA = texPixelData[curTexPixel] & 0x0F;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelA].red;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelA].green;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelA].blue;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelA].alpha;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelB].red;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelB].green;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelB].blue;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[pixelB].alpha;
			curRgbaPixel++;
		}
	}
	else if( bpp == palMode8bpp ) {
		for( curTexPixel = 0; curTexPixel < totalTexPixels; curTexPixel++ ) {
			if( curTexPixel == header.textureWidth*(currentRow + 1) + skipPixel*currentRow ) {
				curTexPixel += skipPixel;
				currentRow++;
			}
			rgbaPixelData[curRgbaPixel] = paletteTable[texPixelData[curTexPixel]].red;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[texPixelData[curTexPixel]].green;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[texPixelData[curTexPixel]].blue;
			curRgbaPixel++;
			rgbaPixelData[curRgbaPixel] = paletteTable[texPixelData[curTexPixel]].alpha;
			curRgbaPixel++;
		}
	}
	// printf("Done with frame\n");
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl 0x18(%rbp), %eax
movzwl -0x8(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x11dae
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x10(%rbp), %eax
jae 0x11da9
movl -0x30(%rbp), %eax
movl %eax, -0x44(%rbp)
movzwl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x44(%rbp), %eax
movl -0x3c(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
movl -0x38(%rbp), %edx
shrl %edx
imull -0x3c(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jne 0x11c83
movl -0x38(%rbp), %eax
shrl %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
movb %al, -0x3e(%rbp)
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
movb %al, -0x3d(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3d(%rbp), %ecx
movb (%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3d(%rbp), %ecx
movb 0x1(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3d(%rbp), %ecx
movb 0x2(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3d(%rbp), %ecx
movb 0x3(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3e(%rbp), %ecx
movb (%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3e(%rbp), %ecx
movb 0x1(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3e(%rbp), %ecx
movb 0x2(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movzbl -0x3e(%rbp), %ecx
movb 0x3(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x11c34
jmp 0x11ea3
cmpl $0x1, -0x2c(%rbp)
jne 0x11ea1
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x10(%rbp), %eax
jae 0x11e9f
movl -0x30(%rbp), %eax
movzwl -0x8(%rbp), %ecx
movl -0x3c(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
movl -0x38(%rbp), %edx
imull -0x3c(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jne 0x11dfa
movl -0x38(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movb (%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movb 0x1(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movb 0x2(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movb 0x3(%rax,%rcx,4), %dl
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x11dbf
jmp 0x11ea1
jmp 0x11ea3
popq %rbp
retq
nopw %cs:(%rax,%rax)