// File: /workspace/github_c_makefile_star2_O2/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, 0x28(%rsp)
movq %rcx, %rdx
callq 0x42ba
movq %rax, %rbx
movq %rbp, %rdi
movl %r14d, %esi
movq %rax, %rdx
callq 0x42ba
movq %rax, 0x30(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x416a
movw %ax, 0x8(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x416a
movw %ax, 0x6(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
movl %r14d, %esi
callq 0x42ba
movq %rax, 0x20(%rsp)
movq %rbp, %rdi
callq 0x3190
movq %rax, %r13
xorl %r15d, %r15d
movzwl %r14w, %r12d
xorl %r14d, %r14d
cmpq %r15, 0x20(%rsp)
je 0x27f8a
movq %rbp, %rdi
movl %r12d, %esi
movq %r14, %rdx
movq %r13, %rcx
callq 0x281e3
movq %rax, %r14
movq %rbp, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x27f3b
testq %r14, %r14
je 0x27f62
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 0x28265
popq %rax
popq %rcx
incq %r15
jmp 0x27eda
movq 0x2f0b6(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x3051c(%rip), %rax     # 0x58468
movq (%rax), %rdx
leaq 0x1e7cb(%rip), %rsi     # 0x46721
movq %r13, %rcx
xorl %eax, %eax
callq 0x3180
jmp 0x27f8a
movq 0x2f08f(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x304f5(%rip), %rax     # 0x58468
movq (%rax), %rdx
leaq 0x1e7ce(%rip), %rsi     # 0x4674b
xorl %r14d, %r14d
movl %r15d, %ecx
xorl %eax, %eax
callq 0x3180
xorl %edi, %edi
callq 0x160f7
movl %eax, %r15d
leaq 0x2f1e5(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
je 0x27fde
leaq 0x17134(%rip), %rcx     # 0x3f0dc
movl $0x40000, %edi          # imm = 0x40000
movq %rbx, %rsi
movl 0x78(%rsp), %edx
callq 0x5100
movzwl 0x6(%rsp), %esi
movzwl 0x8(%rsp), %edx
leaq 0x1f9ed(%rip), %rdi     # 0x479b7
leaq 0x30(%rsp), %rcx
movq 0x20(%rsp), %r8
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x160f7
movl %eax, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
addq $0xc, %rbx
xorl %r15d, %r15d
cmpq %r15, 0x20(%rsp)
je 0x280a0
movq %rbp, %rdi
movl %r12d, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x281e3
movq %rax, %r14
movq %rbp, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x28051
testq %r14, %r14
je 0x28078
movq %rbp, %rdi
callq 0x3190
movq %rax, %r13
movq %r14, %rsi
movq %rbx, %rdx
movq 0x18(%rsp), %rcx
movl %r15d, %r8d
movl 0x78(%rsp), %r9d
callq 0x28be9
incq %r15
movq %r13, %rbx
jmp 0x27ff6
movq 0x2efa0(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x30406(%rip), %rax     # 0x58468
movq (%rax), %rdx
leaq 0x1e6b5(%rip), %rsi     # 0x46721
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3180
jmp 0x280a0
movq 0x2ef79(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x303df(%rip), %rax     # 0x58468
movq (%rax), %rdx
leaq 0x1e6b8(%rip), %rsi     # 0x4674b
xorl %r14d, %r14d
movl %r15d, %ecx
xorl %eax, %eax
callq 0x3180
movq %rbp, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x2f0ce(%rip), %r12     # 0x57180
testb $0x4, 0x2(%r12)
movl 0x10(%rsp), %r15d
je 0x280f4
leaq -0x1(%rbx), %rsi
leaq 0x17012(%rip), %rcx     # 0x3f0dc
movl $0x40000, %edi          # imm = 0x40000
movl 0x78(%rsp), %edx
callq 0x5100
leaq 0x1f90a(%rip), %rdi     # 0x479e9
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x160f7
movl %eax, %r15d
leaq 0x16fe1(%rip), %rcx     # 0x3f0dc
movl $0x4003333, %edi        # imm = 0x4003333
movq 0x28(%rsp), %rsi
movl 0x78(%rsp), %edx
callq 0x5100
movq (%r12), %rax
testw $0x3003, %ax            # imm = 0x3003
je 0x28175
testb $0x40, %al
je 0x28132
leaq 0x1b384(%rip), %rdi     # 0x434a7
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %ebp
leaq 0x16f5b(%rip), %rdi     # 0x3f097
leaq 0x1f8b3(%rip), %rsi     # 0x479f6
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %ebp, %r15d
movq (%r12), %rax
testb $0x30, %al
je 0x28175
pushq $0x3
popq %rdi
callq 0x521b
leaq 0x203f1(%rip), %rdi     # 0x48558
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movq (%r12), %rax
testb $0x30, %al
je 0x281c1
movl %eax, %ecx
notl %ecx
testw $0x300, %cx             # imm = 0x300
jne 0x2819c
leaq 0x1b082(%rip), %rdi     # 0x4320d
movq 0x8(%rsp), %rdx
movq %rdx, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x281be
btl $0x8, %eax
jb 0x281ab
leaq 0x1e633(%rip), %rdi     # 0x467dc
jmp 0x281b2
leaq 0x1b068(%rip), %rdi     # 0x4321a
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x160f7
movq %r14, %rdi
callq 0x3050
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq