// File: /workspace/github_c_makefile_star2_O2/hfiguiere[P]exifprobe/process.c
// Function: process_subifd
unsigned long
process_subifd(FILE *inptr,unsigned short byteorder,
                    struct ifd_entry *subfile_entry,
                    unsigned long fileoffset_base,unsigned long max_offset,
                    struct image_summary *summary_entry,char *parent_name,
                    int ifdnum,int subifdnum,int ifdtype,int indent)
{
    unsigned long entry_offset;
    unsigned long subifd_offset;
    unsigned long max_value_offset = 0L;
    int chpr = 0;
    int nsubifds,num;

    if(inptr && subfile_entry)
    {
        entry_offset = subfile_entry->value + fileoffset_base;
        nsubifds = subfile_entry->count;

        if(subifdnum >= 0)
        {
            if(nsubifds > 1)
            {
                if((PRINT_VALUE_AT_OFFSET))
                {
                    if(max_offset && (entry_offset > max_offset))
                        print_tag_address(SECTION,entry_offset,indent,"+");
                    else
                        print_tag_address(SECTION,entry_offset,indent,"@");
                    if(PRINT_SECTION)
                    {
                        chpr += printf("%s - %lu offsets: [max parent offset = %lu]",
                                tagname(subfile_entry->tag),subfile_entry->count,
                                max_offset);
                    }
                    for(num = 0; num < nsubifds; ++num)
                    {
                        subifd_offset = read_ulong(inptr,byteorder,entry_offset)
                                                            + fileoffset_base;
                        entry_offset = ftell(inptr); /* where to get next one */
                        if((PRINT_SECTION))
                            chpr += printf(" %lu",subifd_offset);
                        if(ferror(inptr) || feof(inptr))
                            break;
                        /* goto blewit;                               */
                    }
                    if(PRINT_SECTION)
                        chpr = newline(chpr);
                }

                entry_offset = subfile_entry->value + fileoffset_base;
                for(num = 0; num < nsubifds; ++num)
                {
                    subifd_offset = read_ulong(inptr,byteorder,entry_offset) +
                                                        fileoffset_base;
                    /* where to get next one                          */
                    entry_offset = ftell(inptr);
                    /* The next subifd offset suggests a maximum for  */
                    /* this subifd; at least until some nitwit writes */
                    /* the second one first. Doesn't help for the     */
                    /* last one, though.                              */
                    if(num < (nsubifds - 1))
                        max_offset = read_ulong(inptr,byteorder,HERE);
                    else
                        max_offset = 0;
                    if(ferror(inptr) || feof(inptr))
                        goto blewit;
                    max_value_offset = process_tiff_ifd(inptr,byteorder,
                                            subifd_offset,fileoffset_base,
                                            max_offset,summary_entry,parent_name,
                                            ifdtype,ifdnum,subifdnum + num,
                                            indent);
                    /* ###%%% don't we check for errors here???           */
                }
            }
            else
            {
                max_value_offset = process_tiff_ifd(inptr,byteorder,
                                            subfile_entry->value,fileoffset_base,
                                            max_offset,summary_entry,parent_name,
                                            ifdtype,ifdnum,subifdnum,
                                            indent);
            }
        }
        else
        {
            printred("Negative subifd number");
            chpr += printf(" %d, ifdtype %d not processed for IFD %d",subifdnum,ifdtype,ifdnum);
            chpr = newline(chpr);
            goto blewit;
        }
    }
    else
    {
        fprintf(stderr,"%s: no open file pointer to read EXIF\n",Progname);
        max_value_offset = 0L;
    }
    setcharsprinted(chpr);
    return(max_value_offset);
blewit:
    /* we're going to keep trying, because the caller's next offset   */
    /* may be ok.                                                     */
    clearerr(inptr);
    return(0L);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %rcx, 0x10(%rsp)
testq %rdi, %rdi
je 0xf4c1
testq %rdx, %rdx
je 0xf4c1
movq %rdi, %rbx
movl 0x78(%rsp), %r15d
movl 0x70(%rsp), %ebp
movl 0x68(%rsp), %r13d
testl %ebp, %ebp
js 0xf438
movq %r8, %r14
movl %esi, 0x4(%rsp)
movl 0x80(%rsp), %eax
movq 0x10(%rdx), %r12
movl 0x8(%rdx), %ecx
movq %rcx, 0x18(%rsp)
cmpl $0x2, %ecx
jl 0xf46e
leaq 0x47f2c(%rip), %r15     # 0x57180
xorl %ebp, %ebp
testb $0x1, 0x3(%r15)
movl $0x0, %eax
je 0xf35c
movq %rdx, 0x8(%rsp)
addq 0x10(%rsp), %r12
cmpq %r14, %r12
leaq 0x30908(%rip), %rcx     # 0x3fb82
leaq 0x2fe5b(%rip), %rax     # 0x3f0dc
cmovbeq %rax, %rcx
testq %r14, %r14
cmoveq %rax, %rcx
movl $0x40000, %edi          # imm = 0x40000
movq %r12, %rsi
movl 0x80(%rsp), %edx
callq 0x5100
xorl %eax, %eax
testb $0x4, 0x2(%r15)
je 0xf2cf
movq 0x8(%rsp), %r15
movzwl (%r15), %edi
callq 0xa1c8
movq 0x8(%r15), %rdx
leaq 0x33961(%rip), %rdi     # 0x42c23
movq %rax, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x3120
movl %eax, (%rsp)
movq 0x18(%rsp), %rax
leal 0x1(%rax), %r15d
movzwl 0x4(%rsp), %r14d
decl %r15d
je 0xf340
movq %rbx, %rdi
movl %r14d, %esi
movq %r12, %rdx
callq 0x42ba
movq %rax, %r13
movq %rbx, %rdi
callq 0x3190
movq %rax, %r12
leaq 0x47e77(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
je 0xf328
addq 0x10(%rsp), %r13
leaq 0x375c9(%rip), %rdi     # 0x468e4
movq %r13, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, (%rsp)
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0xf340
movq %rbx, %rdi
callq 0x31a0
testl %eax, %eax
je 0xf2e1
leaq 0x47e39(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
movl (%rsp), %eax
je 0xf357
movl %eax, %edi
callq 0x160f7
movq 0x8(%rsp), %rdx
movl %eax, (%rsp)
movq 0x10(%rdx), %r12
addq 0x10(%rsp), %r12
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x8(%rsp)
movzwl 0x4(%rsp), %r15d
xorl %r14d, %r14d
cmpl %ebp, 0x18(%rsp)
je 0xf4a7
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x42ba
movq %rax, %r14
movq %rbx, %rdi
callq 0x3190
movq %rax, %r12
cmpl 0x8(%rsp), %ebp
jge 0xf3bd
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r15d, %esi
callq 0x42ba
movq %rax, %r13
jmp 0xf3c0
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0xf461
movq %rbx, %rdi
callq 0x31a0
testl %eax, %eax
jne 0xf461
movq 0x10(%rsp), %rcx
addq %rcx, %r14
movl 0x70(%rsp), %eax
addl %ebp, %eax
subq $0x8, %rsp
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
movq %r13, %r8
movq 0x28(%rsp), %r9
movl 0x88(%rsp), %r10d
pushq %r10
pushq %rax
movl 0x80(%rsp), %eax
pushq %rax
movl 0x98(%rsp), %eax
pushq %rax
pushq 0x88(%rsp)
callq 0xc004
addq $0x30, %rsp
movq %rax, %r14
incl %ebp
jmp 0xf37c
leaq 0x33810(%rip), %rdi     # 0x42c4f
callq 0x56e2
leaq 0x3381b(%rip), %rdi     # 0x42c66
movl %ebp, %esi
movl %r15d, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
callq 0x160f7
movq %rbx, %rdi
callq 0x31b0
xorl %r14d, %r14d
jmp 0xf4af
subq $0x8, %rsp
movzwl 0xc(%rsp), %esi
movq %rbx, %rdi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
movq %r14, %r8
movq 0x28(%rsp), %r9
pushq %rax
pushq %rbp
pushq %r13
pushq %r15
pushq 0x88(%rsp)
callq 0xc004
addq $0x30, %rsp
movq %rax, %r14
xorl %edi, %edi
jmp 0xf4aa
movl (%rsp), %edi
callq 0x16a4f
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x47b30(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x48f96(%rip), %rax     # 0x58468
movq (%rax), %rdx
leaq 0x337b3(%rip), %rsi     # 0x42c8f
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x3180
jmp 0xf4a3