// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2150
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x40, %edx
callq 0x2250
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0x18140
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rdi
addq $0x42, %rdi
callq 0x18100
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x44(%rax)
movq -0x10(%rbp), %rdi
addq $0x43, %rdi
callq 0x18100
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x45(%rax)
movq -0x10(%rbp), %rdi
addq $0x44, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x10(%rbp), %rdi
addq $0x4c, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdx
movq %rdx, 0x54(%rax)
movq 0x58(%rcx), %rcx
movq %rcx, 0x5c(%rax)
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x64(%rcx), %rdx
movq %rdx, 0x68(%rax)
movq 0x6c(%rcx), %rcx
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rdi
addq $0x74, %rdi
callq 0x181f0
movl %eax, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x444(%rax)
je 0x156e5
movq -0x10(%rbp), %rax
movzbl 0x78(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x79(%rax), %r8d
movq -0x10(%rbp), %rax
movzbl 0x7a(%rax), %r9d
movq -0x10(%rbp), %rax
movzbl 0x7b(%rax), %eax
leaq 0xa97d(%rip), %rdi      # 0x2004c
leaq 0xa575(%rip), %rsi      # 0x1fc4b
movl $0x33e, %edx            # imm = 0x33E
movl %eax, (%rsp)
movb $0x0, %al
callq 0x117c0
movq -0x10(%rbp), %rdi
addq $0x78, %rdi
callq 0x181f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x80(%rax)
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)