// File: /workspace/github_c_makefile_star2_O1/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 0x1017f
testq %rdx, %rdx
je 0x1017f
movq %rdi, %rbx
movl 0x78(%rsp), %r14d
movl 0x70(%rsp), %ebp
movl 0x68(%rsp), %r15d
testl %ebp, %ebp
js 0xffff
movq %r8, %r13
movl 0x80(%rsp), %eax
movq 0x10(%rdx), %r12
movl 0x8(%rdx), %ecx
cmpl $0x2, %ecx
jl 0x10038
leaq 0x4829a(%rip), %r14     # 0x58180
xorl %ebp, %ebp
testb $0x1, 0x3(%r14)
movl $0x0, %eax
je 0x10088
movq %rcx, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, 0x4(%rsp)
addq 0x10(%rsp), %r12
cmpq %r13, %r12
leaq 0x31c6d(%rip), %rcx     # 0x41b82
leaq 0x311c0(%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 0x5605
xorl %eax, %eax
testb $0x4, 0x2(%r14)
je 0xff6a
movq 0x18(%rsp), %r14
movzwl (%r14), %edi
callq 0xa958
movq 0x8(%r14), %rdx
leaq 0x34cc6(%rip), %rdi     # 0x44c23
movq %rax, %rsi
movq %r13, %rcx
xorl %eax, %eax
callq 0x3120
movl %eax, (%rsp)
movq 0x8(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %r15d
cmovgel %eax, %r15d
decl %r15d
movzwl 0x4(%rsp), %r13d
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x46cc
movq %rax, %r14
movq %rbx, %rdi
callq 0x3190
movq %rax, %r12
leaq 0x481d5(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0xffca
addq 0x10(%rsp), %r14
leaq 0x38937(%rip), %rdi     # 0x488f4
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, (%rsp)
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0xffed
movq %rbx, %rdi
callq 0x31a0
subl $0x1, %r15d
setb %cl
testl %eax, %eax
jne 0xffed
testb %cl, %cl
je 0xff88
leaq 0x4818c(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
jne 0x10072
movl (%rsp), %eax
jmp 0x1007a
leaq 0x34c49(%rip), %rdi     # 0x44c4f
callq 0x5c33
leaq 0x34c54(%rip), %rdi     # 0x44c66
movl %ebp, %esi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
callq 0x16b56
movq %rbx, %rdi
callq 0x31b0
xorl %r14d, %r14d
jmp 0x1016d
subq $0x8, %rsp
movzwl %si, %esi
movq %rbx, %rdi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
movq %r13, %r8
movq 0x28(%rsp), %r9
pushq %rax
pushq %rbp
pushq %r15
pushq %r14
pushq 0x88(%rsp)
callq 0xc93c
addq $0x30, %rsp
movq %rax, %r14
xorl %edi, %edi
jmp 0x10168
movl (%rsp), %edi
callq 0x16b56
movl 0x4(%rsp), %esi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rcx
movl %eax, (%rsp)
movq 0x10(%rdx), %r15
addq 0x10(%rsp), %r15
leal -0x1(%rcx), %eax
movl %eax, 0x4(%rsp)
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
movl %eax, 0x8(%rsp)
movzwl %si, %r12d
movq %rbx, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x46cc
movq %rax, %r13
movq %rbx, %rdi
callq 0x3190
movq %rax, %r15
cmpl 0x4(%rsp), %ebp
jge 0x100e5
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r12d, %esi
callq 0x46cc
movq %rax, %r14
jmp 0x100e8
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x10028
movq %rbx, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x10028
movq 0x10(%rsp), %rcx
addq %rcx, %r13
movl 0x70(%rsp), %eax
addl %ebp, %eax
subq $0x8, %rsp
movq %rbx, %rdi
movl %r12d, %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 0xc93c
addq $0x30, %rsp
incl %ebp
cmpl %ebp, 0x8(%rsp)
jne 0x100ae
movq %rax, %r14
movl (%rsp), %edi
callq 0x17530
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 0x1006b