// File: /workspace/github_cpp_makefile_star2_O2/ticky[P]ps2iconsys/gbLib/src/gbImageLoader_BMP.cpp
// Function: GhulbusUtil::gbImageType_BMP_T::ReadFile(std::basic_ifstream<char, std::char_traits<char>>&, int*, int*, int*, unsigned char**, unsigned int**)
void gbImageType_BMP_T::ReadFile(std::ifstream& file, int* width, int* height, int* bpp, 
		                           unsigned char** pp_data, unsigned int** pp_palette) 
	{
		BITMAPFILEHEADER fheader;
		BITMAPINFOHEADER iheader;
		file.seekg(m_file_offset, ::std::ios::beg);
		file.read( reinterpret_cast<char*>(&fheader), sizeof(BITMAPFILEHEADER) );
		file.read( reinterpret_cast<char*>(&iheader), sizeof(BITMAPINFOHEADER));

		if(iheader.biClrUsed || (iheader.biHeight < 0)) { 
			throw( Ghulbus::gbException( Ghulbus::gbException::GB_NOTIMPLEMENTED ) );
		}

		unsigned int* palette = NULL;
		unsigned char* data = new unsigned char[iheader.biWidth*iheader.biHeight*((iheader.biBitCount >= 8)?(iheader.biBitCount>>3):1)];

		try {
			switch(iheader.biBitCount)
			{
			case 1:
				ReadData1Bit(file, iheader, fheader, data, &palette, m_file_offset);
				break;
			case 4:
				ReadData4Bit(file, iheader, fheader, data, &palette, m_file_offset);
				break;
			case 8:
				ReadData8Bit(file, iheader, fheader, data, &palette, m_file_offset);
				break;
			case 16:
				ReadData16Bit(file, iheader, fheader, data, &palette, m_file_offset);
				break;
			case 24:
				ReadData24Bit(file, iheader, fheader, data, &palette, m_file_offset);
				break;
			case 32:
				ReadData32Bit(file, iheader, fheader, data, &palette, m_file_offset);
				break;
			default:
				throw( Ghulbus::gbException( Ghulbus::gbException::GB_FAILED,
											 "Illegal bit depth in BMP image file") );
			}
		} catch(Ghulbus::gbException) {
			if(data)    { delete[] data; }
			if(palette) { delete[] palette; }
			throw;
		}

		FlipImageVertical(iheader, data);

		*width      = iheader.biWidth;
		*height     = iheader.biHeight;
		*bpp        = iheader.biBitCount;
		*pp_data    = data;
		*pp_palette = palette;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movl 0x8(%rdi), %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x2250
leaq 0x42(%rsp), %rsi
pushq $0xe
popq %rdx
movq %r14, %rdi
callq 0x2220
movq %rsp, %rbx
pushq $0x28
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2220
cmpl $0x0, 0x20(%rbx)
jne 0x751c
movl 0x8(%rsp), %eax
testl %eax, %eax
js 0x751c
imull 0x4(%rsp), %eax
movzwl 0xe(%rsp), %ebp
movl %ebp, %ecx
shrl $0x3, %ecx
cmpl $0x8, %ebp
pushq $0x1
popq %r13
cmovbl %r13d, %ecx
imull %eax, %ecx
movslq %ecx, %rdi
callq 0x2030
movq %rax, %rbx
cmpl $0x1, %ebp
je 0x7159
cmpl $0x4, %ebp
je 0x72c9
cmpl $0x8, %ebp
je 0x725c
cmpl $0x18, %ebp
je 0x7117
cmpl $0x20, %ebp
jne 0x7548
movl 0x8(%r15), %r15d
movl 0x10(%rsp), %eax
cmpl $0x3, %eax
je 0x7361
testl %eax, %eax
jne 0x754d
movabsq $0xff0000ff0000, %rax   # imm = 0xFF0000FF0000
movq %rax, 0x34(%rsp)
movl $0xff, 0x3c(%rsp)
jmp 0x7373
cmpl $0x0, 0x10(%rsp)
jne 0x754d
movl 0x4c(%rsp), %esi
addl 0x8(%r15), %esi
xorl %ebp, %ebp
movq %r14, %rdi
xorl %edx, %edx
callq 0x2250
movl 0x4(%rsp), %eax
imull 0x8(%rsp), %eax
shll $0x2, %eax
movslq %eax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2220
xorl %edi, %edi
jmp 0x7430
cmpl $0x0, 0x10(%rsp)
jne 0x754d
movl 0x8(%r15), %r12d
xorl %ebp, %ebp
pushq $0x8
popq %rdi
callq 0x2030
pushq $0x8
popq %rdx
movq %rax, %rbp
movq %r14, %rdi
movq %rax, %rsi
movq %rax, %r15
callq 0x2220
movq %r15, %rax
addl 0x4c(%rsp), %r12d
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2250
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
sarl $0x3, %eax
movslq %eax, %rdx
movq %r15, %rbp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2220
movq %r15, %rdi
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
decl %eax
cmpl $0x7, %eax
jl 0x7430
movl %eax, %ecx
movl %eax, %edx
shrl $0x3, %edx
movb (%rbx,%rdx), %sil
andb $0x1, %sil
movb %sil, (%rbx,%rcx)
movb (%rbx,%rdx), %sil
shrb %sil
andb $0x1, %sil
movb %sil, -0x1(%rbx,%rcx)
movb (%rbx,%rdx), %sil
shrb $0x2, %sil
andb $0x1, %sil
movb %sil, -0x2(%rbx,%rcx)
movb (%rbx,%rdx), %sil
shrb $0x3, %sil
andb $0x1, %sil
movb %sil, -0x3(%rbx,%rcx)
movb (%rbx,%rdx), %sil
shrb $0x4, %sil
andb $0x1, %sil
movb %sil, -0x4(%rbx,%rcx)
movb (%rbx,%rdx), %sil
shrb $0x5, %sil
andb $0x1, %sil
movb %sil, -0x5(%rbx,%rcx)
movb (%rbx,%rdx), %sil
shrb $0x6, %sil
andb $0x1, %sil
movb %sil, -0x6(%rbx,%rcx)
movb (%rbx,%rdx), %dl
shrb $0x7, %dl
movb %dl, -0x7(%rbx,%rcx)
addl $-0x8, %eax
jmp 0x71c9
cmpl $0x0, 0x10(%rsp)
jne 0x754d
movl 0x8(%r15), %r12d
xorl %ebp, %ebp
movl $0x400, %edi            # imm = 0x400
callq 0x2030
movl $0x400, %edx            # imm = 0x400
movq %rax, %rbp
movq %r14, %rdi
movq %rax, %rsi
movq %rax, %r15
callq 0x2220
movq %r15, %rax
addl 0x4c(%rsp), %r12d
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2250
movslq 0x4(%rsp), %rax
movslq 0x8(%rsp), %rdx
imulq %rax, %rdx
movq %r15, %rbp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2220
movq %r15, %rdi
jmp 0x7430
cmpl $0x0, 0x10(%rsp)
jne 0x754d
movl 0x8(%r15), %r12d
xorl %ebp, %ebp
pushq $0x40
popq %rdi
callq 0x2030
pushq $0x40
popq %rdx
movq %rax, %rbp
movq %r14, %rdi
movq %rax, %rsi
movq %rax, %r15
callq 0x2220
movq %r15, %rax
addl 0x4c(%rsp), %r12d
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2250
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
sarl %eax
movslq %eax, %rdx
movq %r15, %rbp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2220
movq %r15, %rdi
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
decl %eax
testl %eax, %eax
jle 0x7430
movl %eax, %ecx
movl %eax, %edx
shrl %edx
movb (%rbx,%rdx), %sil
andb $0xf, %sil
movb %sil, (%rbx,%rcx)
movb (%rbx,%rdx), %dl
shrb $0x4, %dl
movb %dl, -0x1(%rbx,%rcx)
addl $-0x2, %eax
jmp 0x7338
xorl %ebp, %ebp
leaq 0x34(%rsp), %rsi
pushq $0xc
popq %rdx
movq %r14, %rdi
callq 0x2220
addl 0x4c(%rsp), %r15d
xorl %ebp, %ebp
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2250
movl 0x4(%rsp), %eax
imull 0x8(%rsp), %eax
shll $0x2, %eax
movslq %eax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2220
movl 0x34(%rsp), %r9d
movl 0x38(%rsp), %r8d
movl %r9d, 0x28(%rsp)
shrl $0x8, %r9d
incl %r9d
movl %r8d, %r10d
shrl $0x8, %r10d
incl %r10d
movl 0x3c(%rsp), %r11d
movl %r11d, %r14d
shrl $0x8, %r14d
incl %r14d
movl 0x8(%rsp), %r15d
imull 0x4(%rsp), %r15d
testl %r15d, %r15d
cmovlel %ebp, %r15d
movl $0xff, %r12d
cmpq %rbp, %r15
je 0x742e
movl (%rbx,%rbp,4), %ecx
movl %ecx, %eax
andl 0x28(%rsp), %eax
xorl %edx, %edx
divl %r9d
movl %eax, %esi
andl %r12d, %esi
shll $0x10, %esi
movl %ecx, %eax
andl %r8d, %eax
xorl %edx, %edx
divl %r10d
shll $0x8, %eax
movzwl %ax, %edi
orl %esi, %edi
andl %r11d, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
andl %r12d, %eax
orl %edi, %eax
movl %eax, (%rbx,%rbp,4)
incq %rbp
jmp 0x73ea
xorl %edi, %edi
movq %rdi, 0x28(%rsp)
movzwl 0xe(%rsp), %ecx
movl %ecx, %eax
shrl $0x3, %eax
movl %ecx, 0x30(%rsp)
cmpl $0x8, %ecx
cmovael %eax, %r13d
movl 0x8(%rsp), %ecx
pushq $0x2
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
movslq 0x4(%rsp), %rdx
xorl %r8d, %r8d
testl %edx, %edx
movl $0x0, %r9d
cmovgl %edx, %r9d
testl %eax, %eax
cmovlel %r8d, %eax
movq %rdx, %r10
imulq %r13, %r10
leal -0x1(%rcx), %r11d
imull %edx, %r11d
movq %rbx, %r14
cmpq %rax, %r8
je 0x74d9
movslq %r11d, %r12
imulq %r13, %r12
addq %rbx, %r12
movq %r14, %rbp
xorl %esi, %esi
cmpq %r9, %rsi
je 0x74ce
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x74c3
movb (%rbp,%r15), %dil
xorb (%r12,%r15), %dil
movb %dil, (%rbp,%r15)
xorb (%r12,%r15), %dil
movb %dil, (%r12,%r15)
xorb %dil, (%rbp,%r15)
incq %r15
jmp 0x749e
incq %rsi
addq %r13, %rbp
addq %r13, %r12
jmp 0x7496
incq %r8
addq %r10, %r14
subl %edx, %r11d
jmp 0x7482
movq 0x50(%rsp), %rax
movl %edx, (%rax)
movq 0x58(%rsp), %rax
movl %ecx, (%rax)
movq 0x60(%rsp), %rax
movl 0x30(%rsp), %ecx
movl %ecx, (%rax)
movq 0x68(%rsp), %rax
movq %rbx, (%rax)
movq 0x28(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq %rax, (%rcx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x18
popq %rdi
callq 0x20e0
movq %rax, %rbx
pushq $0x5
popq %rsi
movq %rax, %rdi
callq 0x7614
leaq 0x785f(%rip), %rsi      # 0xed98
leaq 0x114(%rip), %rdx       # 0x7654
movq %rbx, %rdi
callq 0x22f0
cmpl $0x10, %ebp
jne 0x757b
pushq $0x18
popq %rdi
callq 0x20e0
movq %rax, %r14
pushq $0x5
popq %rsi
movq %rax, %rdi
callq 0x7614
xorl %ebp, %ebp
leaq 0x782c(%rip), %rsi      # 0xed98
leaq 0xe1(%rip), %rdx        # 0x7654
movq %r14, %rdi
callq 0x22f0
pushq $0x18
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0x1f87(%rip), %rdx      # 0x9514
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x7628
jmp 0x7563
movq %rax, %r14
cmpl $0x1, %edx
jne 0x75eb
movq %r14, %rdi
callq 0x2210
leaq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0x763a
movq %r14, %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2230
testq %rbp, %rbp
je 0x75d4
movq %rbp, %rdi
callq 0x2230
callq 0x2280
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x7654
callq 0x22e0
movq %r14, %rdi
callq 0x2320
movq %rax, %rdi
callq 0x398a
nop