// File: /workspace/github_c_makefile_star2_O1/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 0x46cc
movq %rbp, %rdi
movl %r14d, %esi
movq %rax, 0x8(%rsp)
movq %rax, %rdx
callq 0x46cc
movq %rax, 0x30(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x4574
movw %ax, 0x6(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x4574
movw %ax, 0x4(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x46cc
movq %rax, %rbx
movq %rbp, %rdi
callq 0x3190
movzwl %r14w, %r12d
testq %rbx, %rbx
je 0x28d56
movq %rax, %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rbp, %rdi
movl %r12d, %esi
movq %r14, %rdx
movq %r13, %rcx
callq 0x28fa3
movq %rax, %r14
movq %rbp, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x28d44
testq %r14, %r14
je 0x28d4e
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 0x29027
addq $0x10, %rsp
incq %r15
cmpq %r15, %rbx
jne 0x28ce7
jmp 0x28d59
movq %r13, %rdi
callq 0x361a
jmp 0x28d59
movq %r15, %rdi
callq 0x363f
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x16b56
movl %eax, %r15d
leaq 0x2f416(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x28dad
leaq 0x18365(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq 0x8(%rsp), %rsi
movl 0x78(%rsp), %edx
callq 0x5605
movzwl 0x4(%rsp), %esi
movzwl 0x6(%rsp), %edx
leaq 0x20c2c(%rip), %rdi     # 0x499c7
leaq 0x30(%rsp), %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x16b56
movl %eax, 0x10(%rsp)
testq %rbx, %rbx
je 0x28e3b
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 0x28fa3
movq %rax, %r14
movq %rbp, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x28f86
testq %r14, %r14
je 0x28f93
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 0x299df
incq %r15
movq %rbx, %r13
movq %r12, %rbx
movl %ebp, %r12d
movq 0x28(%rsp), %rbp
cmpq %r15, %rbx
jne 0x28dcf
movq %rbp, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x2f333(%rip), %r12     # 0x58180
testb $0x4, 0x2(%r12)
movl 0x10(%rsp), %r15d
je 0x28e8f
leaq -0x1(%rbx), %rsi
leaq 0x18277(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movl 0x78(%rsp), %edx
callq 0x5605
leaq 0x20b7f(%rip), %rdi     # 0x499f9
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x16b56
movl %eax, %r15d
leaq 0x18246(%rip), %rcx     # 0x410dc
movl $0x4003333, %edi        # imm = 0x4003333
movq 0x20(%rsp), %rsi
movl 0x78(%rsp), %edx
callq 0x5605
movq (%r12), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x28f0e
testb $0x40, %al
je 0x28ece
leaq 0x1c5e8(%rip), %rdi     # 0x454a7
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %ebp
leaq 0x181bf(%rip), %rdi     # 0x41097
leaq 0x20b27(%rip), %rsi     # 0x49a06
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %ebp, %r15d
testb $0x30, (%r12)
je 0x28f0e
movl $0x3, %edi
callq 0x5730
leaq 0x21664(%rip), %rdi     # 0x4a568
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movq (%r12), %rax
testb $0x30, %al
je 0x28f5f
movl %eax, %ecx
notl %ecx
testl $0x300, %ecx            # imm = 0x300
jne 0x28f3a
leaq 0x1c2e4(%rip), %rdi     # 0x4520d
movq 0x8(%rsp), %rdx
movq %rdx, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x28f5c
btl $0x8, %eax
jb 0x28f49
leaq 0x1f8a5(%rip), %rdi     # 0x487ec
jmp 0x28f50
leaq 0x1c2ca(%rip), %rdi     # 0x4521a
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x16b56
testq %r14, %r14
je 0x28f74
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 0x28e3b
movq %r15, %rdi
callq 0x368f
xorl %r14d, %r14d
jmp 0x28e3b