// File: ticky[P]ps2iconsys/gbLib/src/gbImageLoader_BMP.cpp
// Function: GhulbusUtil::ReadData32Bit(std::basic_ifstream<char, std::char_traits<char>>&, GhulbusUtil::BITMAPINFOHEADER const&, GhulbusUtil::BITMAPFILEHEADER const&, unsigned char*, unsigned int**, unsigned int)
static void ReadData32Bit(std::ifstream& file, BITMAPINFOHEADER const& iheader, BITMAPFILEHEADER const& fheader, 
		                     unsigned char* data, unsigned int** palette, unsigned int file_offset)
	{
		switch(iheader.biCompression)
		{
		case 0:						//uncompressed rgb (32 bit)
		case 3:						//uncompressed rgb with color masks (32 bits)
			//file uses 3 dword color masks:
			unsigned int colormasks[3];
			if(iheader.biCompression == 0) {
				colormasks[0] = 0x00FF0000;		//R
				colormasks[1] = 0x0000FF00;		//G
				colormasks[2] = 0x000000FF;		//B
			} else {
				file.read( reinterpret_cast<char*>(colormasks), 12 );
			}
			//read image data:
			file.seekg( file_offset+fheader.bfOffBits, ::std::ios::beg );
			file.read( reinterpret_cast<char*>(data), iheader.biWidth*iheader.biHeight*4 );
			unsigned int tmp, *ptmp;
			for(int i=0; i<iheader.biWidth*iheader.biHeight; i++) {		//apply color masks
				ptmp = (unsigned int*)(&data[i*4]);
				tmp = *ptmp;
				*ptmp = ( ((((tmp & colormasks[0]) / ((colormasks[0]>>8)+1)) & 0xff) << 16) |
						  ((((tmp & colormasks[1]) / ((colormasks[1]>>8)+1)) & 0xff) <<  8) |
						  ((((tmp & colormasks[2]) / ((colormasks[2]>>8)+1)) & 0xff)      ) );
			}
			break;
		default:
			throw( Ghulbus::gbException( Ghulbus::gbException::GB_NOTIMPLEMENTED ) );
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x50(%rbp)
testl %eax, %eax
je 0xed5e
jmp 0xed50
movl -0x50(%rbp), %eax
subl $0x3, %eax
jne 0xee75
jmp 0xed5e
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xed7f
movl $0xff0000, -0x38(%rbp)  # imm = 0xFF0000
movl $0xff00, -0x34(%rbp)    # imm = 0xFF00
movl $0xff, -0x30(%rbp)
jmp 0xed91
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0xc, %edx
callq 0x2260
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
addl 0xa(%rcx), %eax
movl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2290
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x8(%rcx), %eax
shll $0x2, %eax
movslq %eax, %rdx
callq 0x2260
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq -0x10(%rbp), %rdx
imull 0x8(%rdx), %ecx
cmpl %ecx, %eax
jge 0xee73
movq -0x20(%rbp), %rax
movl -0x4c(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
andl -0x38(%rbp), %eax
movl -0x38(%rbp), %ecx
shrl $0x8, %ecx
addl $0x1, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
andl $0xff, %ecx
shll $0x10, %ecx
movl -0x3c(%rbp), %eax
andl -0x34(%rbp), %eax
movl -0x34(%rbp), %esi
shrl $0x8, %esi
addl $0x1, %esi
xorl %edx, %edx
divl %esi
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movl -0x3c(%rbp), %eax
andl -0x30(%rbp), %eax
movl -0x30(%rbp), %esi
shrl $0x8, %esi
addl $0x1, %esi
xorl %edx, %edx
divl %esi
andl $0xff, %eax
orl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xedd3
jmp 0xeea7
movl $0x18, %edi
callq 0x20f0
movq %rax, %rdi
movq %rdi, -0x58(%rbp)
movl $0x5, %esi
callq 0xf060
movq -0x58(%rbp), %rdi
leaq 0x8ef5(%rip), %rsi      # 0x17d90
leaq 0x2ae(%rip), %rdx       # 0xf150
callq 0x2340
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)