// File: /workspace/github_c_makefile_star2_O3/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, 0x8(%rsp)
testq %rdi, %rdi
je 0x1028a
testq %rdx, %rdx
je 0x1028a
movq %rdi, %rbx
movl 0x78(%rsp), %r14d
movl 0x70(%rsp), %ebp
movl 0x68(%rsp), %r15d
testl %ebp, %ebp
js 0x1011a
movq %r8, %r13
movl 0x80(%rsp), %eax
movq 0x10(%rdx), %r12
movl 0x8(%rdx), %ecx
movq %rcx, 0x18(%rsp)
cmpl $0x2, %ecx
jl 0x10153
leaq 0x4816e(%rip), %r14     # 0x58180
xorl %ebp, %ebp
testb $0x1, 0x3(%r14)
movl $0x0, %eax
je 0x1019e
movq %rdx, 0x10(%rsp)
movl %esi, 0x4(%rsp)
addq 0x8(%rsp), %r12
cmpq %r13, %r12
leaq 0x31b46(%rip), %rcx     # 0x41b82
leaq 0x31099(%rip), %rax     # 0x410dc
cmovbeq %rax, %rcx
testq %r13, %r13
cmoveq %rax, %rcx
movl $0x40000, %edi          # imm = 0x40000
movq %r12, %rsi
movl 0x80(%rsp), %edx
callq 0x55eb
xorl %eax, %eax
testb $0x4, 0x2(%r14)
je 0x10091
movq 0x10(%rsp), %r14
movzwl (%r14), %edi
callq 0xaad8
movq 0x8(%r14), %rdx
leaq 0x34be3(%rip), %rdi     # 0x44c67
movq %rax, %rsi
movq %r13, %rcx
xorl %eax, %eax
callq 0x3120
movl %eax, (%rsp)
movq 0x18(%rsp), %rax
leal -0x1(%rax), %r15d
movzwl 0x4(%rsp), %r13d
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x4707
movq %rax, %r14
movq %rbx, %rdi
callq 0x3190
movq %rax, %r12
leaq 0x480ba(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x100e5
addq 0x8(%rsp), %r14
leaq 0x3885c(%rip), %rdi     # 0x48934
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, (%rsp)
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x10108
movq %rbx, %rdi
callq 0x31a0
subl $0x1, %r15d
setb %cl
testl %eax, %eax
jne 0x10108
testb %cl, %cl
je 0x100a3
leaq 0x48071(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
jne 0x1018d
movl (%rsp), %eax
jmp 0x10195
leaq 0x34b72(%rip), %rdi     # 0x44c93
callq 0x5c26
leaq 0x34b7d(%rip), %rdi     # 0x44caa
movl %ebp, %esi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
callq 0x1707a
movq %rbx, %rdi
callq 0x31b0
xorl %r14d, %r14d
jmp 0x10278
subq $0x8, %rsp
movzwl %si, %esi
movq %rbx, %rdi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
movq %r13, %r8
movq 0x28(%rsp), %r9
pushq %rax
pushq %rbp
pushq %r15
pushq %r14
pushq 0x88(%rsp)
callq 0xcabc
addq $0x30, %rsp
movq %rax, %r14
xorl %edi, %edi
jmp 0x10273
movl (%rsp), %edi
callq 0x1707a
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rdx
movl %eax, (%rsp)
movq 0x10(%rdx), %r12
addq 0x8(%rsp), %r12
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x4(%rsp)
movzwl %si, %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x4707
movq %rax, %r13
movq %rbx, %rdi
callq 0x3190
movq %rax, %r12
cmpl 0x4(%rsp), %ebp
jge 0x101f0
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r15d, %esi
callq 0x4707
movq %rax, %r14
jmp 0x101f3
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x10143
movq %rbx, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x10143
movq 0x8(%rsp), %rcx
addq %rcx, %r13
movl 0x70(%rsp), %eax
addl %ebp, %eax
subq $0x8, %rsp
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
movq %r14, %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 0xcabc
addq $0x30, %rsp
incl %ebp
cmpl %ebp, 0x18(%rsp)
jne 0x101b9
movq %rax, %r14
movl (%rsp), %edi
callq 0x17a82
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x33b1
xorl %r14d, %r14d
jmp 0x10186