// File: /workspace/github_cpp_makefile_star2_O2/ticky[P]ps2iconsys/gbLib/src/gbImageLoader_TGA.cpp
// Function: GhulbusUtil::gbImageType_TGA_T::ReadFile(std::basic_ifstream<char, std::char_traits<char>>&, int*, int*, int*, unsigned char**, unsigned int**)
void gbImageType_TGA_T::ReadFile(std::ifstream& file, int* width, int* height, int* bpp, 
			                       unsigned char** pp_data, unsigned int** pp_palette)
	{
		TGAHEADER header;
		file.seekg(m_file_offset, ::std::ios::beg);
		file.read( reinterpret_cast<char*>(&header), sizeof(TGAHEADER));
		unsigned char* data = new unsigned char[header.Width*header.Height*header.ImagePixelSize];

		switch(header.ImageTypeCode) {
			case 2:	//Unmapped RBG
				ReadUnmappedRBG(file, header, data, m_file_offset);
				if((header.ImageDescByte & 0x20) == 0) {		//Truvision?
					FlipImageVertical(header, data);
				}
				break;
			case 1:	case 3:	case 9:	case 10: case 11: case 32: case 33:
			default:
				delete[] data;
				throw( Ghulbus::gbException( Ghulbus::gbException::GB_NOTIMPLEMENTED ) );
		}

		if(file.fail()) {
			delete[] data;
			throw( Ghulbus::gbException( Ghulbus::gbException::GB_FAILED,
			                             "Error while reading TGA image file" ) );
		}
				
		*width      = header.Width;
		*height     = header.Height;
		*bpp        = header.ImagePixelSize;
		*pp_data    = data;
		*pp_palette = NULL;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
movl 0x8(%rdi), %esi
movq %r13, %rdi
xorl %edx, %edx
callq 0x2250
leaq 0x6(%rsp), %r14
pushq $0x12
popq %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0x2220
movzwl 0xc(%r14), %eax
movzwl 0xe(%r14), %ecx
imull %eax, %ecx
movzbl 0x10(%r14), %edi
imull %ecx, %edi
callq 0x2030
movq %rax, %rbp
cmpb $0x2, 0x2(%r14)
jne 0x6f29
movl 0x8(%rbx), %eax
movzbl 0x6(%rsp), %ecx
leaq (%rax,%rcx), %rsi
addq $0x12, %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x2250
movzwl 0x12(%rsp), %eax
movzwl 0x14(%rsp), %ecx
imull %eax, %ecx
movzbl 0x16(%rsp), %edx
imull %ecx, %edx
shrl $0x3, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2220
testb $0x20, 0x17(%rsp)
jne 0x6ed5
movzbl 0x16(%rsp), %eax
shrl $0x3, %eax
movzwl 0x14(%rsp), %ecx
leaq -0x1(%rcx), %r8
shrl %ecx
movzwl 0x12(%rsp), %edx
movq %rax, %rsi
imulq %rdx, %rsi
imulq %rsi, %r8
movq %rbp, %rdi
addq %r8, %rdi
movq %rsi, %r8
negq %r8
xorl %r9d, %r9d
movq %rbp, %r10
cmpq %rcx, %r9
je 0x6ed5
movq %rdi, %r11
movq %r10, %rbx
xorl %r14d, %r14d
cmpq %rdx, %r14
je 0x6eca
xorl %r15d, %r15d
cmpq %r15, %rax
je 0x6ebf
movb (%rbx,%r15), %r12b
xorb (%r11,%r15), %r12b
movb %r12b, (%rbx,%r15)
xorb (%r11,%r15), %r12b
movb %r12b, (%r11,%r15)
xorb %r12b, (%rbx,%r15)
incq %r15
jmp 0x6e9d
incq %r14
addq %rax, %rbx
addq %rax, %r11
jmp 0x6e95
incq %r9
addq %rsi, %r10
addq %r8, %rdi
jmp 0x6e87
movq (%r13), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%r13,%rax)
jne 0x6f49
movq 0x70(%rsp), %rax
movzwl 0x12(%rsp), %ecx
movq 0x18(%rsp), %rdx
movl %ecx, (%rdx)
movzwl 0x14(%rsp), %ecx
movq 0x20(%rsp), %rdx
movl %ecx, (%rdx)
movzbl 0x16(%rsp), %ecx
movq 0x28(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x30(%rsp), %rcx
movq %rbp, (%rcx)
andq $0x0, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0x2230
pushq $0x18
popq %rdi
callq 0x20e0
movq %rax, %rbx
pushq $0x5
popq %rsi
movq %rax, %rdi
callq 0x7614
jmp 0x6f6e
movq %rbp, %rdi
callq 0x2230
pushq $0x18
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x256b(%rip), %rdx      # 0x94ce
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x7628
leaq 0x7e23(%rip), %rsi      # 0xed98
leaq 0x6d8(%rip), %rdx       # 0x7654
movq %rbx, %rdi
callq 0x22f0