// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/x3f.c
// Function: process_x3f_dir
unsigned long
process_x3f_dir(FILE *inptr,unsigned short byteorder,struct x3f_header *x3fheader,
                                                unsigned long directory_pointer,
                                                struct image_summary *summary_entry,
                                                char *parent_name,int level,int indent)
{
    struct x3f_direntry *entry;
    unsigned long directory_offset = 0UL;
    unsigned long section_id;
    unsigned long max_dir_offset = 0L;
    unsigned long entry_offset,next_entry_offset;
    unsigned long num_entries;
    unsigned short version_major;
    unsigned short version_minor;
    int i;
    int chpr = 0;

    directory_offset = read_ulong(inptr,byteorder,directory_pointer);

    section_id = read_ulong(inptr,byteorder,directory_offset);
    version_minor = read_ushort(inptr,byteorder,HERE);
    version_major = read_ushort(inptr,byteorder,HERE);
    num_entries = read_ulong(inptr,byteorder,HERE);
    entry = NULL;

    entry_offset = ftell(inptr);

    /* Print the entries first, in order                              */
    for(i = 0; i < num_entries; ++i)
    {
        entry = read_x3f_direntry(inptr,byteorder,entry,entry_offset);
        if(ferror(inptr))
        {
            fprintf(stderr,"%s: error reading directory entry at %lu\n",
                                                Progname,entry_offset);
            break;
        }
        if(entry == NULL)
        {
            fprintf(stderr,"%s: null entry %d\n",Progname,i);
            break;
        }
        next_entry_offset = ftell(inptr);
        process_x3f_direntry(inptr,byteorder,entry,entry_offset,
                                            summary_entry,parent_name,i,indent);
        entry_offset = next_entry_offset;
    }
    chpr = newline(chpr);
    
    /* Now show the directory itself                                  */

    if((PRINT_SECTION))
    {
        print_tag_address(SECTION,directory_offset,indent,"@");
        chpr += printf("<DIRECTORY> version %d.%d id \"%4.4s\", %lu entries",
                                            version_major,version_minor,
                                            (char *)&section_id,num_entries);
    }
    chpr = newline(chpr);
    entry_offset = directory_offset + 12;
    for(i = 0; i < num_entries; ++i)
    {
        entry = read_x3f_direntry(inptr,byteorder,entry,entry_offset);
        if(ferror(inptr))
        {
            fprintf(stderr,"%s: error reading directory entry at %lu\n",
                                                Progname,entry_offset);
            break;
        }
        if(entry == NULL)
        {
            fprintf(stderr,"%s: null entry %d\n",Progname,i);
            break;
        }
        next_entry_offset = ftell(inptr);
        print_x3f_direntry(inptr,entry,entry_offset,
                                    parent_name,i,indent);
        entry_offset = next_entry_offset;
    }
    max_dir_offset = ftell(inptr);
    if((PRINT_SECTION))
    {
        print_tag_address(SECTION,max_dir_offset - 1,indent,"@");
        chpr += printf("</DIRECTORY>");
        chpr = newline(chpr);
    }

    print_tag_address(ENTRY,directory_pointer,indent,"@");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("%s.",parent_name);
        chpr += printf("%s","DirectoryOffset");
        if((PRINT_VALUE))
        {
            putindent(X3FTAGWIDTH - 15);
            chpr += printf(" = ");
        }
    }
    if((PRINT_VALUE))
    {
        if(PRINT_BOTH_OFFSET)
            chpr += printf("@%#lx=%lu",directory_offset,directory_offset);
        else if(PRINT_HEX_OFFSET)
            chpr += printf("@%#lx",directory_offset);
        else 
            chpr += printf("@%lu",directory_offset);
    }
    chpr = newline(chpr);
    
    if(entry)
        free(entry);
    return(max_dir_offset);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x18(%rsp)
movq %r8, 0x10(%rsp)
movl %esi, %r14d
movq %rdi, %rbp
movq %rcx, 0x20(%rsp)
movq %rcx, %rdx
callq 0x4707
movq %rbp, %rdi
movl %r14d, %esi
movq %rax, 0x8(%rsp)
movq %rax, %rdx
callq 0x4707
movq %rax, 0x30(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x45af
movw %ax, 0x6(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x45af
movw %ax, 0x4(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x4707
movq %rax, %rbx
movq %rbp, %rdi
callq 0x3190
movzwl %r14w, %r12d
testq %rbx, %rbx
je 0x294d8
movq %rax, %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rbp, %rdi
movl %r12d, %esi
movq %r14, %rdx
movq %r13, %rcx
callq 0x29726
movq %rax, %r14
movq %rbp, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x294c6
testq %r14, %r14
je 0x294d0
movq %rbp, %rdi
callq 0x3190
movq %rax, %r13
movq %rbp, %rdi
movl %r12d, %esi
movq %r14, %rdx
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
movl 0x78(%rsp), %eax
pushq %rax
pushq %r15
callq 0x297aa
addq $0x10, %rsp
incq %r15
cmpq %r15, %rbx
jne 0x29469
jmp 0x294db
movq %r13, %rdi
callq 0x361a
jmp 0x294db
movq %r15, %rdi
callq 0x363f
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1707a
movl %eax, %r15d
leaq 0x2ec94(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x2952f
leaq 0x17be3(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq 0x8(%rsp), %rsi
movl 0x78(%rsp), %edx
callq 0x55eb
movzwl 0x4(%rsp), %esi
movzwl 0x6(%rsp), %edx
leaq 0x204ea(%rip), %rdi     # 0x49a07
leaq 0x30(%rsp), %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x1707a
movl %eax, 0x10(%rsp)
testq %rbx, %rbx
je 0x295bd
movq 0x8(%rsp), %r13
addq $0xc, %r13
xorl %r15d, %r15d
movq %rbp, 0x28(%rsp)
movq %rbp, %rdi
movl %r12d, %esi
movq %r14, %rdx
movq %r13, %rcx
callq 0x29726
movq %rax, %r14
movq %rbp, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x29709
testq %r14, %r14
je 0x29716
movq %rbp, %rdi
callq 0x3190
movl %r12d, %ebp
movq %rbx, %r12
movq %rax, %rbx
movq %r14, %rsi
movq %r13, %rdx
movq 0x18(%rsp), %rcx
movl %r15d, %r8d
movl 0x78(%rsp), %r9d
callq 0x2a158
incq %r15
movq %rbx, %r13
movq %r12, %rbx
movl %ebp, %r12d
movq 0x28(%rsp), %rbp
cmpq %r15, %rbx
jne 0x29551
movq %rbp, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x2ebb1(%rip), %r12     # 0x58180
testb $0x4, 0x2(%r12)
movl 0x10(%rsp), %r15d
je 0x29611
leaq -0x1(%rbx), %rsi
leaq 0x17af5(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movl 0x78(%rsp), %edx
callq 0x55eb
leaq 0x2043d(%rip), %rdi     # 0x49a39
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x1707a
movl %eax, %r15d
leaq 0x17ac4(%rip), %rcx     # 0x410dc
movl $0x4003333, %edi        # imm = 0x4003333
movq 0x20(%rsp), %rsi
movl 0x78(%rsp), %edx
callq 0x55eb
movq (%r12), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x29695
testb $0x40, %al
je 0x29650
leaq 0x1beaa(%rip), %rdi     # 0x454eb
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %ebp
leaq 0x17a3d(%rip), %rdi     # 0x41097
leaq 0x203e5(%rip), %rsi     # 0x49a46
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %ebp, %r15d
movq (%r12), %rax
testb $0x30, %al
je 0x29695
movl $0x3, %edi
callq 0x5716
leaq 0x20f21(%rip), %rdi     # 0x4a5a8
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movq (%r12), %rax
testb $0x30, %al
je 0x296e2
movl %eax, %ecx
notl %ecx
testl $0x300, %ecx            # imm = 0x300
jne 0x296bd
leaq 0x1bba5(%rip), %rdi     # 0x45251
movq 0x8(%rsp), %rdx
movq %rdx, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x296df
btl $0x8, %eax
jb 0x296cc
leaq 0x1f162(%rip), %rdi     # 0x4882c
jmp 0x296d3
leaq 0x1bb8b(%rip), %rdi     # 0x4525e
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x1707a
testq %r14, %r14
je 0x296f7
movq %r14, %rdi
callq 0x3050
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x3664
jmp 0x295bd
movq %r15, %rdi
callq 0x368f
xorl %r14d, %r14d
jmp 0x295bd