// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x258, %rax            # imm = 0x258
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
callq 0x18170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rdi
addq $0x1a, %rdi
callq 0x18170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rdi
addq $0x1c, %rdi
callq 0x18170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
addq $0x1e, %rdi
callq 0x18170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
callq 0x18170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x18(%rbp), %rdi
addq $0x2c, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x18(%rbp), %rdi
addq $0x38, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rdi
addq $0x3c, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x18(%rbp), %rdi
addq $0x44, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
shrq %cl, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
addq $0x4c, %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jae 0x153a9
cmpl $0x6d, -0x24(%rbp)
jb 0x1537d
jmp 0x153a9
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
shll $0x2, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x181f0
movl %eax, %edx
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %edx, 0x38(%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x15369
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)