// File: /workspace/github_c_makefile_star2_O3/inflex[P]ripMIME/ripOLE/ole.c
// Function: OLE_convert_directory
int OLE_convert_directory( struct OLE_object *ole, unsigned char *buf, struct OLE_directory_entry *dir )
{
	/** Converts a  raw block of 128 bytes from the file to a 
	 ** struct OLE_directory_entry data structure
	 **/

	/** Flush the element name **/
	memset( dir->element_name, '\0', OLE_DIRECTORY_ELEMENT_NAME_SIZE);

	/** The first 64 bytes of the structure are the element's name 
	 ** in 16-bite UNICODE, meaning a maximum of 31 characters when
	 ** we account for the trailing zero byte 
	 **/

	/** Copy the first 64 bytes of our *buf parameter into the element name **/
	memcpy( dir->element_name, buf, OLE_DIRECTORY_ELEMENT_NAME_SIZE );

	/** how many bytes of the above 64 bytes are used for the name (NOT CHARACTERS!), **
	 ** example, for a 8 character string with a trailing zero we use **
	 ** (8+1)*2 = 18 bytes
	 **/
	dir->element_name_byte_count = get_int16( (char *) buf + 0x40 );

	/** Element type is of the following: 
	 ** 0x00 - empty 
	 ** 0x01 - user storage  
	 ** 0x02 - user stream
	 ** 0x03 - lock bytes (we don't know what this is for)
	 ** 0x04 - property (again, we don't know)
	 ** 0x05 - root storage
	 **/
	dir->element_type = get_int8((char *) buf +0x42 );

	/** Element colour for the red-black tree:
	 ** 0x00 - Red
	 ** 0x01 - Black
	 **/
	dir->element_colour = get_int8((char*) buf +0x43 );

	/** Directory ID (DID) of the left child, -1 if no sibling **/
	dir->left_child = get_uint32((char*) buf +0x44 );

	/** Directory ID (DID) of the right child, -1 if no sibling **/
	dir->right_child = get_uint32((char *) buf +0x48 );


	/** Directory ID (DID) of the root node entry of the RB tree of all
	 ** storage members (if this entry is a storage), else -1. 
	 **/
	dir->root = get_uint32((char*) buf +0x4c );

	memcpy( dir->class, buf +0x50, 16 );
	dir->userflags = get_uint32((char*) buf +0x60 );
	memcpy( dir->timestamps, buf +0x64, 16 ); /** Actually consists of 2 8 byte stamps **/

	/** Sector ID of the first sector or short-sector **/
	dir->start_sector = get_uint32((char*) buf +0x74 );

	/** Size of this stream **/
	DOLE LOGGER_log("%s:%d:OLE_directory_entry:DEBUG: stream size = 0x%x %x %x %x"
			,FL
			,*(buf +0x78)
			,*(buf +0x79)
			,*(buf +0x7A)
			,*(buf +0x7B)
			);
	dir->stream_size = get_uint32((char *) buf +0x78 );

	return OLE_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdx)
movups %xmm0, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, (%rdx)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movups 0x20(%rsi), %xmm2
movups 0x30(%rsi), %xmm3
movups %xmm0, (%rdx)
movups %xmm1, 0x10(%rdx)
movups %xmm2, 0x20(%rdx)
movups %xmm3, 0x30(%rdx)
leaq 0x40(%rsi), %rdi
callq 0x10ee0
movl %eax, 0x40(%rbx)
leaq 0x42(%r14), %rdi
callq 0x10ed8
movb %al, 0x44(%rbx)
leaq 0x43(%r14), %rdi
callq 0x10ed8
movb %al, 0x45(%rbx)
leaq 0x44(%r14), %rdi
callq 0x10eeb
movl %eax, 0x48(%rbx)
leaq 0x48(%r14), %rdi
callq 0x10eeb
movl %eax, 0x4c(%rbx)
leaq 0x4c(%r14), %rdi
callq 0x10eeb
movl %eax, 0x50(%rbx)
movups 0x50(%r14), %xmm0
movups %xmm0, 0x54(%rbx)
leaq 0x60(%r14), %rdi
callq 0x10eeb
movl %eax, 0x64(%rbx)
movups 0x64(%r14), %xmm0
movups %xmm0, 0x68(%rbx)
leaq 0x74(%r14), %rdi
callq 0x10eeb
movl %eax, %eax
movq %rax, 0x78(%rbx)
cmpl $0x0, 0x444(%r15)
je 0xf0be
movzbl 0x78(%r14), %ecx
movzbl 0x79(%r14), %r8d
movzbl 0x7a(%r14), %r9d
movzbl 0x7b(%r14), %eax
movl %eax, (%rsp)
leaq 0xa18f(%rip), %rdi      # 0x1923a
leaq 0x9d87(%rip), %rsi      # 0x18e39
movl $0x33e, %edx            # imm = 0x33E
xorl %eax, %eax
callq 0xc84f
addq $0x78, %r14
movq %r14, %rdi
callq 0x10eeb
movl %eax, 0x80(%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq