// File: /workspace/github_c_makefile_star2_O0/hfiguiere[P]exifprobe/process.c
// Function: process_app3
unsigned long
process_app3(FILE *inptr,unsigned long app3_offset,unsigned short tag,
                struct image_summary *summary_entry,char *parent_name,
                int indent)
{
    unsigned long max_offset = 0UL;
    unsigned long ifd_offset,fileoffset_base;
    unsigned long dumplength = 0UL;
    unsigned short app_length = 0;
    int chpr = 0;
    struct fileheader *header;
    char *app_string,*name;
    char *fulldirname = CNULL;

    if(inptr)
    {
        if(summary_entry)
        {
            summary_entry->filesubformat |= FILESUBFMT_APPN;
            summary_entry->filesubformatAPPN[3] = 1;
        }
        /* display the APP3 header                                    */
        name = tagname(tag);    /* never null                         */
        if(PRINT_SECTION)
        {
            print_tag_address(SECTION,app3_offset,indent,"@");
            chpr += printf("<%s> %#x ",name,tag);
        }

        app_length = read_ushort(inptr,TIFF_MOTOROLA,HERE);
        if(ferror(inptr) || feof(inptr))
        {
            clearerr(inptr);
            goto appdump;
        }
        if(PRINT_SECTION)
            chpr += printf("length %u, ",app_length);
        else if((PRINT_ENTRY))
        {
            /* ###%%% pseudo-tags fpr LIST Mode here */
            print_tag_address(ENTRY,HERE,indent,"*");
            if((PRINT_TAGINFO))
            {
                if((PRINT_LONGNAMES))
                    chpr += printf("%s.",parent_name);
                chpr += printf("%-14.14s","APP3");
            }
            if((PRINT_VALUE))
                chpr += printf(" = @%lu:%-9u",app3_offset,app_length);
            chpr = newline(chpr);
        }

        app_string = read_appstring(inptr,JPEG_APP3,HERE);
        if(ferror(inptr) || feof(inptr))
        {
            clearerr(inptr);
            goto appdump;
        }

        if(app_string)
        {
            if(PRINT_SECTION)
                chpr += printf("\'%s\'",app_string);

            /* The next thing we see should be a TIFF header tag      */
            /* indicating byte order used in the IFD, followed by the */
            /* offset from the start of the header to the start of    */
            /* the IFD (number of entries).                           */

            fileoffset_base = ftell(inptr);
            /* If this is a valid Meta segment, skip the pad byte.    */
            if(strncmp(app_string,"Meta",4) == 0)
            {
                fulldirname = splice(parent_name,".","APP3");
                ++fileoffset_base;
                if(PRINT_SECTION)
                {
                    chpr = newline(chpr);
                    print_tag_address(SECTION,fileoffset_base,indent + SMALLINDENT,"@");
                }
                header = read_imageheader(inptr,fileoffset_base);
                if(header && (print_header(header,SECTION) == 0) &&
                    (header->probe_magic == TIFF_MAGIC))
                {
                    ifd_offset = read_ulong(inptr,header->file_marker,HERE);
                    if(PRINT_SECTION)
                    {
                        chpr += printf(" ifd offset = %lu (+ %lu = %#lx/%lu)",ifd_offset,
                                    fileoffset_base,fileoffset_base + ifd_offset,
                                    fileoffset_base + ifd_offset);
                        chpr = newline(chpr);
                    }
                    max_offset = process_tiff_ifd(inptr,header->file_marker,ifd_offset,
                                            fileoffset_base,0L,summary_entry,fulldirname,
                                            TIFF_IFD,0,-1,indent + SMALLINDENT);

                    if(max_offset < app3_offset + app_length + 2)
                        max_offset = app3_offset + app_length +2;
                }
                else
                {
                    max_offset = app3_offset + app_length + 2;
                    if(PRINT_SECTION)
                    {
                        extraindent(indent + ADDRWIDTH);
                        if(header)
                        {
                            chpr += printf(" INVALID MAGIC %lu (%s) where TIFF header should be",
                                           header->probe_magic,tagname(header->probe_magic));
                        }
                        else
                        {
                            chpr += printf(" INVALID HEADER for TIFF");
                        }
#define PRINT_A_BIT 48
                        if(app_length > PRINT_A_BIT)
                            dumplength = PRINT_A_BIT;
                        else
                            dumplength = app_length;
                        goto appdump;
                    }
                }
                if(fulldirname)
                    free(fulldirname);
            }
            else
            {
                max_offset = app3_offset + app_length + 2;
                if(PRINT_SECTION)
                {
                    chpr += printf(" - unknown format");
                    goto appdump;
                }
            }
        }
        else if(PRINT_SECTION)
        {
            chpr += printf("  No APP3 header name string found");
            chpr = newline(chpr);
        }
        /* offset of last byte of segment                             */
        if(PRINT_SECTION)
        {
            print_tag_address(SECTION,max_offset - 1,indent,"-");
            chpr += printf("</%s>",name);
            chpr = newline(chpr);
        }
    }
    return(max_offset);

appdump:
    if(app_length > 0L)
    {
        if((PRINT_APPNDUMP) || (dumplength > 0))
        {
            if((Max_appdump == DUMPALL) || (Max_appdump > (app_length + 2)))
                dumplength = app_length + 2;
            else if(Max_appdump > 0L)
                dumplength = Max_appdump;
            else if(dumplength == 0)
                dumplength = Max_undefined;
            if(dumplength)
            {
                chpr = newline(1);
                hexdump(inptr,app3_offset,app_length + 2,dumplength,16,
                            indent + SMALLINDENT,SMALLINDENT);
                chpr = newline(1);
            }
        }
        else
        {
            if(PRINT_SEGMENT)
            {
                chpr += printf(" - (not dumped: use -A)");
                chpr = newline(chpr);
            }
        }
        max_offset = app3_offset + app_length + 2;
        /* close off the segment; a start "tag" was printed           */
        print_tag_address(SECTION,app3_offset + app_length + 1,indent,"-");
        if(PRINT_SECTION)
        {
            chpr += printf("</%s>",name);
            chpr = newline(chpr);
        }
    }
    setcharsprinted(chpr);
    return(max_offset);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x58(%rbp)
movw $0x0, -0x5a(%rbp)
movl $0x0, -0x60(%rbp)
movq $0x0, -0x80(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1cdfd
cmpq $0x0, -0x28(%rbp)
je 0x1c898
movq -0x28(%rbp), %rax
movl 0x18(%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
movl %ecx, 0x18(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x28(%rax)
movzwl -0x1a(%rbp), %edi
callq 0xd580
movq %rax, -0x78(%rbp)
leaq 0x5a8d4(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1c8ef
movq -0x18(%rbp), %rsi
movl -0x34(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x4780e(%rip), %rcx     # 0x640dc
callq 0x5ed0
movq -0x78(%rbp), %rsi
movzwl -0x1a(%rbp), %edx
leaq 0x4b058(%rip), %rdi     # 0x6793a
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4480
movw %ax, -0x5a(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
jne 0x1c922
movq -0x10(%rbp), %rdi
callq 0x3190
cmpl $0x0, %eax
je 0x1c930
movq -0x10(%rbp), %rdi
callq 0x31a0
jmp 0x1ce0a
leaq 0x5a849(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1c963
movzwl -0x5a(%rbp), %esi
leaq 0x4ae16(%rip), %rdi     # 0x67767
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x1ca30
leaq 0x5a816(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x4003333, %rax        # imm = 0x4003333
cmpq $0x0, %rax
je 0x1ca2e
movl -0x34(%rbp), %edx
movl $0x4003333, %edi        # imm = 0x4003333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x47f93(%rip), %rcx     # 0x64924
callq 0x5ed0
leaq 0x5a7e3(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x1c9f3
leaq 0x5a7cd(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x1c9d8
movq -0x30(%rbp), %rsi
leaq 0x4b1ae(%rip), %rdi     # 0x67b79
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x4ad94(%rip), %rdi     # 0x67773
leaq 0x498c8(%rip), %rsi     # 0x662ae
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x5a786(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x1ca23
movq -0x18(%rbp), %rsi
movzwl -0x5a(%rbp), %edx
leaq 0x4ad66(%rip), %rdi     # 0x6777c
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x1ca30
movq -0x10(%rbp), %rdi
movl $0xffe3, %esi           # imm = 0xFFE3
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5450
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
jne 0x1ca63
movq -0x10(%rbp), %rdi
callq 0x3190
cmpl $0x0, %eax
je 0x1ca71
movq -0x10(%rbp), %rdi
callq 0x31a0
jmp 0x1ce0a
cmpq $0x0, -0x70(%rbp)
je 0x1cd6f
leaq 0x5a6fd(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1caaa
movq -0x70(%rbp), %rsi
leaq 0x4d073(%rip), %rdi     # 0x69b10
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3180
movq %rax, -0x50(%rbp)
movq -0x70(%rbp), %rdi
leaq 0x4af29(%rip), %rsi     # 0x679eb
movl $0x4, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x1cd29
movq -0x30(%rbp), %rdi
leaq 0x47e82(%rip), %rsi     # 0x64962
leaq 0x497c7(%rip), %rdx     # 0x662ae
callq 0x20960
movq %rax, -0x80(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
leaq 0x5a67d(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cb38
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x50(%rbp), %rsi
movl -0x34(%rbp), %edx
addl $0x2, %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x475a9(%rip), %rcx     # 0x640dc
callq 0x5ed0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3f70
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x1cc63
movq -0x68(%rbp), %rdi
movl $0x40000, %esi          # imm = 0x40000
callq 0x55c0
cmpl $0x0, %eax
jne 0x1cc63
movq -0x68(%rbp), %rax
cmpq $0x2a, 0x8(%rax)
jne 0x1cc63
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movzwl (%rax), %esi
callq 0x4610
movq %rax, -0x48(%rbp)
leaq 0x5a5e6(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cbe0
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x50(%rbp), %rcx
addq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
addq -0x48(%rbp), %r8
leaq 0x4ad7c(%rip), %rdi     # 0x67944
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rax
movw (%rax), %si
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %r9
movq -0x80(%rbp), %r10
movl -0x34(%rbp), %eax
addl $0x2, %eax
xorl %r8d, %r8d
xorl %r11d, %r11d
movzwl %si, %esi
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movl %eax, 0x20(%rsp)
callq 0x112e0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movzwl -0x5a(%rbp), %edx
addq %rdx, %rcx
addq $0x2, %rcx
cmpq %rcx, %rax
jae 0x1cc5e
movq -0x18(%rbp), %rax
movzwl -0x5a(%rbp), %ecx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
jmp 0x1cd17
movq -0x18(%rbp), %rax
movzwl -0x5a(%rbp), %ecx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
leaq 0x5a503(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cd15
movl -0x34(%rbp), %edi
addl $0x8, %edi
callq 0xb970
cmpq $0x0, -0x68(%rbp)
je 0x1cce1
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movzwl %ax, %edi
callq 0xd580
movq -0x88(%rbp), %rsi
movq %rax, %rdx
leaq 0x4ac97(%rip), %rdi     # 0x67969
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x1ccf5
leaq 0x4acb5(%rip), %rdi     # 0x6799d
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movzwl -0x5a(%rbp), %eax
cmpl $0x30, %eax
jle 0x1cd08
movq $0x30, -0x58(%rbp)
jmp 0x1cd10
movzwl -0x5a(%rbp), %eax
movq %rax, -0x58(%rbp)
jmp 0x1ce0a
jmp 0x1cd17
cmpq $0x0, -0x80(%rbp)
je 0x1cd27
movq -0x80(%rbp), %rdi
callq 0x3040
jmp 0x1cd6d
movq -0x18(%rbp), %rax
movzwl -0x5a(%rbp), %ecx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
leaq 0x5a43d(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cd6b
leaq 0x4ac5d(%rip), %rdi     # 0x679b6
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x1ce0a
jmp 0x1cd6d
jmp 0x1cda6
leaq 0x5a40a(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cda4
leaq 0x4ac64(%rip), %rdi     # 0x679f0
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x1cda6
leaq 0x5a3d3(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cdfb
movq -0x40(%rbp), %rsi
subq $0x1, %rsi
movl -0x34(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x47326(%rip), %rcx     # 0x640f9
callq 0x5ed0
movq -0x78(%rbp), %rsi
leaq 0x47d17(%rip), %rdi     # 0x64afa
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x1cdfd
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1cfb3
movzwl -0x5a(%rbp), %eax
cmpq $0x0, %rax
jle 0x1cfa3
leaq 0x5a361(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x400000, %rax         # imm = 0x400000
cmpq $0x0, %rax
jne 0x1ce39
cmpq $0x0, -0x58(%rbp)
jbe 0x1cefb
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x5b5d3(%rip), %rax     # 0x78418
cmpq %rcx, (%rax)
je 0x1ce63
leaq 0x5b5c7(%rip), %rax     # 0x78418
movq (%rax), %rax
movzwl -0x5a(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jbe 0x1ce72
movzwl -0x5a(%rbp), %eax
addl $0x2, %eax
cltq
movq %rax, -0x58(%rbp)
jmp 0x1cea8
leaq 0x5b59f(%rip), %rax     # 0x78418
cmpq $0x0, (%rax)
jbe 0x1ce8f
leaq 0x5b592(%rip), %rax     # 0x78418
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x1cea6
cmpq $0x0, -0x58(%rbp)
jne 0x1cea4
leaq 0x5b56b(%rip), %rax     # 0x78408
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x1cea6
jmp 0x1cea8
cmpq $0x0, -0x58(%rbp)
je 0x1cef9
movl $0x1, %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movzwl -0x5a(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rdx
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %r9d
addl $0x2, %r9d
movl $0x10, %r8d
movl $0x2, (%rsp)
callq 0x8aa0
movl $0x1, %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x1cf32
leaq 0x5a27e(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x80000, %rax          # imm = 0x80000
cmpq $0x0, %rax
je 0x1cf30
leaq 0x4aa0a(%rip), %rdi     # 0x67922
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x1cf32
movq -0x18(%rbp), %rax
movzwl -0x5a(%rbp), %ecx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rsi
movzwl -0x5a(%rbp), %eax
addq %rax, %rsi
addq $0x1, %rsi
movl -0x34(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x47196(%rip), %rcx     # 0x640f9
callq 0x5ed0
leaq 0x5a211(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x1cfa1
movq -0x78(%rbp), %rsi
leaq 0x47b71(%rip), %rdi     # 0x64afa
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x1cfa3
movl -0x60(%rbp), %edi
callq 0x1ff00
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq