// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/jp2000.c
// Function: process_jp2
unsigned long
process_jp2(FILE *inptr,unsigned long offset,struct image_summary *summary_entry,
                                    char *parent_name,int indent)
{
    struct jp2box *box;
    unsigned long max_offset = 0L;
    unsigned long lastbox = 0L;
    unsigned long dumplength;

    while(!feof(inptr) && !lastbox)
    {
        box = read_jp2box(inptr,offset);
        if(box)
        {
            /* This routine is currently called only from main(),     */
            /* where the summary_entry will already have been created */

            /* nonetheless...                                         */
            if((summary_entry == NULL) || summary_entry->entry_lock)
                summary_entry = new_summary_entry(summary_entry,0,IMGFMT_JPEG2000);
            switch(box->tbox)
            {
                case JP2_FTYP:
                    max_offset = process_jp2_ftyp(inptr,box,summary_entry,indent);
                    break;
                case JP2_XML:
                    max_offset = process_jp2_xml(inptr,box,indent);
                    break;
                case JP2_JP2I:
                    max_offset = process_jp2_jp2i(inptr,box,indent);
                    break;
                case JP2_JP2H:
                    max_offset = process_jp2_jp2h(inptr,box,summary_entry,indent);
                    break;
                case JP2_UUID:
                    max_offset = process_jp2_uuid(inptr,box,summary_entry,indent);
                    break;
                case JP2_JP2C:
                    if(box->boxlength == 0)
                        ++lastbox;
                    max_offset = process_jp2_jp2c(inptr,box,summary_entry,indent);
                    break;
                case JP2_UINF:
                    max_offset = process_jp2_uinf(inptr,box,summary_entry,indent);
                    break;
                case JP2_PRFL:  /* apparently not in the final spec   */
                default:
                    if((box->boxlength == 0) || ateof(inptr))
                        ++lastbox;
                    if((LIST_MODE))
                        setcharsprinted(list_jp2box(inptr,box,"JP2.",indent,1));
                    else
                        print_jp2box(inptr,box,indent);
                    max_offset = box->boxoffset + box->boxlength;
                    if((PRINT_SECTION))
                    {
                        /* Dump unrecognized boxes.                   */
                        if(Max_undefined > 0)
                        {
                            if(Max_undefined == DUMPALL)
                                dumplength = box->boxlength;
                            else if(Max_undefined > box->boxlength)
                                    dumplength = box->boxlength;
                            else
                                dumplength = Max_undefined;
                        }
                        else
                        {
                            /* Always dump a little of undefined  */
                            /* boxes                              */
                            if(box->boxlength < 48)
                                dumplength = box->boxlength;
                            else
                                dumplength = 48;
                        }

                        (void)newline(0);
                        hexdump(inptr,box->boxoffset,dumplength,dumplength,
                                                            16,indent,SUBINDENT);
                        (void)newline(1);
                    }
                    if((PRINT_SECTION))
                    {
                        (void)newline(0);
                        print_tag_address(SECTION,max_offset - 1,indent,"@");
                        print_jp2type(box->tbox,1);
                    }
                    break;
            }
            (void)newline(0);
            offset = max_offset;
            if(ateof(inptr))
                ++lastbox;
        }
        else
            break;
    }
    return(max_offset);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
callq 0x31a0
testl %eax, %eax
je 0x20be2
xorl %r13d, %r13d
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r12, %rsi
callq 0x207bc
testq %rax, %rax
je 0x20bcd
movq %rax, %rbp
movl %ebx, 0x14(%rsp)
testq %r15, %r15
je 0x20c05
cmpl $0x0, 0x10(%r15)
je 0x20c17
movq %r15, %rdi
xorl %esi, %esi
movl $0xd0a870a, %edx        # imm = 0xD0A870A
callq 0xfc85
movq %rax, %r15
movl 0x14(%rsp), %r12d
movq 0x8(%rbp), %rax
cmpq $0x6a703268, %rax       # imm = 0x6A703268
jle 0x20c57
cmpq $0x75756963, %rax       # imm = 0x75756963
jg 0x20c86
cmpq $0x6a703269, %rax       # imm = 0x6A703269
je 0x20cd7
cmpq $0x75696e66, %rax       # imm = 0x75696E66
jne 0x20cb6
movq %r14, %rdi
movq %rbp, %rsi
movl %r12d, %ecx
callq 0x21a31
jmp 0x20cf8
cmpq $0x66747970, %rax       # imm = 0x66747970
je 0x20ca6
cmpq $0x6a703263, %rax       # imm = 0x6A703263
je 0x20d4d
cmpq $0x6a703268, %rax       # imm = 0x6A703268
jne 0x20cb6
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x21417
jmp 0x20cf8
cmpq $0x75756964, %rax       # imm = 0x75756964
je 0x20ce7
cmpq $0x786d6c20, %rax       # imm = 0x786D6C20
jne 0x20cb6
movq %r14, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0x21193
jmp 0x20cf8
movq %r14, %rdi
movq %rbp, %rsi
movl %r12d, %ecx
callq 0x20e73
jmp 0x20cf8
cmpq $0x0, 0x20(%rbp)
je 0x20ccd
movq %r14, %rdi
callq 0x50cb
testl %eax, %eax
je 0x20d6d
movl $0x1, %ebx
jmp 0x20d6f
movq %r14, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0x212dd
jmp 0x20cf8
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x21652
movq %rax, %r13
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x1707a
movq %r14, %rdi
callq 0x50cb
xorl %r12d, %r12d
testl %eax, %eax
setne %bpl
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x20bd0
movb %bpl, %r12b
orq %r12, %rbx
jne 0x20bd0
movq %r14, %rdi
movq %r13, %rsi
callq 0x207bc
movq %rax, %rbp
testq %rax, %rax
jne 0x20bf9
jmp 0x20bd0
xorl %ebx, %ebx
cmpq $0x0, 0x20(%rbp)
sete %bl
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x21965
movq %rax, %r13
jmp 0x20cfd
xorl %ebx, %ebx
leaq 0x3740a(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
movq %r14, %rdi
movq %rbp, %rsi
testl $0x104, %eax            # imm = 0x104
je 0x20d91
movl %r12d, %edx
callq 0x209e0
jmp 0x20dad
leaq 0x27f27(%rip), %rdx     # 0x48cbf
movl %r12d, %ecx
movl $0x1, %r8d
callq 0x20aa9
movl %eax, %edi
callq 0x17a82
movq 0x20(%rbp), %r12
movq 0x18(%rbp), %r13
addq %r12, %r13
leaq 0x373c1(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x20cfd
leaq 0x38638(%rip), %rax     # 0x59408
movq (%rax), %rax
testq %rax, %rax
je 0x20deb
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x20df8
cmpq %r12, %rax
cmovbq %rax, %r12
jmp 0x20df8
cmpq $0x30, %r12
movl $0x30, %eax
cmovaeq %rax, %r12
xorl %edi, %edi
callq 0x1707a
movq 0x18(%rbp), %rsi
movl $0x2, (%rsp)
movq %r14, %rdi
movq %r12, %rdx
movq %r12, %rcx
movl $0x10, %r8d
movl 0x14(%rsp), %r12d
movl %r12d, %r9d
callq 0x7480
movl $0x1, %edi
callq 0x1707a
leaq 0x37349(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x20cfd
xorl %edi, %edi
callq 0x1707a
leaq -0x1(%r13), %rsi
movl $0x40000, %edi          # imm = 0x40000
movl %r12d, %edx
leaq 0x20281(%rip), %rcx     # 0x410dc
callq 0x55eb
movq 0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x208ff
jmp 0x20cfd