// File: /workspace/github_c_makefile_star2_O3/inflex[P]ripMIME/ripOLE/ole.c
// Function: OLE_convert_header
int OLE_convert_header( struct OLE_object *ole )
{
	struct OLE_header *h;
	unsigned char *hb; /** pointer to the header block **/
	unsigned char *fat_start;
	unsigned int i;

	h = &(ole->header);
	hb = ole->header_block;

	/** Note that the header_*(hb) calls are actually macros which are
	 ** defined in the ole.h file.  These macros basically take the
	 ** hb value and add the required offset, they don't affect the
	 ** value of hb (or they certainly SHOULD NOT! )
	 **/

	h->minor_version = get_uint16((char *)header_minor_version(hb));
	h->dll_version = get_uint16((char *)header_dll_version(hb));
	h->byte_order = get_uint16((char *)header_byte_order(hb)); /** 0xFEFF = Little endian, 0xFFFE = big endian **/
	h->sector_shift = get_uint16((char *)header_sector_shift(hb));
	h->sector_size = 1 << h->sector_shift;

	h->mini_sector_shift = get_uint16((char *)header_mini_sector_shift(hb));
	h->mini_sector_size = 1 << h->mini_sector_shift;

	h->fat_sector_count = get_uint32((char *)header_fat_sector_count(hb)); /** Total number of sectors use for the SAT **/
	h->directory_stream_start_sector = get_uint32((char *)header_directory_stream_start_sector(hb)); /** Start sector-ID for the DIRECTORY STREAM **/
	h->mini_cutoff_size = get_uint32((char *)header_mini_cutoff_size(hb)); 
	h->mini_fat_start = get_uint32((char *)header_mini_fat_start(hb));
	h->mini_fat_sector_count = get_uint32((char *)header_mini_fat_sector_count(hb));
	h->dif_start_sector = get_uint32((char *)header_dif_start_sector(hb));
	h->dif_sector_count = get_uint32((char *)header_dif_sector_count(hb));

	/** Compute the maximum possible sector number by taking our OLE filesize
	 ** and dividing it by the size of our sector size.  While this isn't 
	 ** absolutely accurate it is at least useful in providing us with an 
	 ** upper-bound of what is an acceptable sector ID **/
	ole->last_sector = ole->file_size  >> h->sector_shift;

	/** Decode our first 109 sector-ID's into the master sector allocation table (MSAT/FAT) **/
	fat_start = header_fat_sectors(hb);
	for (i = 0; i < h->fat_sector_count; i++)
	{
		if (i >= OLE_HEADER_FAT_SECTOR_COUNT_LIMIT) break;
		h->FAT[i] = get_uint32( (char *)( fat_start +(LEN_ULONG *i)));
	}

	return OLE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
addq $0x60, %rdi
callq 0x10ee4
movl %eax, 0x258(%rbx)
leaq 0x62(%rbx), %rdi
callq 0x10ee4
movl %eax, 0x25c(%rbx)
leaq 0x64(%rbx), %rdi
callq 0x10ee4
movl %eax, 0x260(%rbx)
leaq 0x66(%rbx), %rdi
callq 0x10ee4
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movl %eax, 0x264(%rbx)
movl $0x1, %ebp
movl %edx, 0x268(%rbx)
leaq 0x68(%rbx), %rdi
callq 0x10ee4
movl %eax, %ecx
shll %cl, %ebp
movl %eax, 0x26c(%rbx)
movl %ebp, 0x270(%rbx)
leaq 0x74(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x274(%rbx)
leaq 0x78(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x278(%rbx)
leaq 0x80(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x27c(%rbx)
leaq 0x84(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x280(%rbx)
leaq 0x88(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x284(%rbx)
leaq 0x8c(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x288(%rbx)
leaq 0x90(%rbx), %rdi
callq 0x10eeb
movl %eax, 0x28c(%rbx)
movq 0x8(%rbx), %rax
movb 0x264(%rbx), %cl
shrq %cl, %rax
movl %eax, 0x10(%rbx)
cmpl $0x0, 0x274(%rbx)
je 0xee92
leaq 0x94(%rbx), %r14
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x10eeb
movl %eax, 0x290(%rbx,%r15,4)
cmpq $0x6b, %r15
ja 0xee92
incq %r15
movl 0x274(%rbx), %eax
addq $0x4, %r14
cmpq %rax, %r15
jb 0xee6a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq