// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
callq 0x31a0
testl %eax, %eax
je 0x20619
xorl %r12d, %r12d
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r12, %rsi
callq 0x201f8
testq %rax, %rax
je 0x20604
movq %rax, %rbp
xorl %ebx, %ebx
movl %r13d, 0x14(%rsp)
testq %r15, %r15
je 0x2063f
cmpl $0x0, 0x10(%r15)
je 0x20651
movq %r15, %rdi
xorl %esi, %esi
movl $0xd0a870a, %edx        # imm = 0xD0A870A
callq 0xfb61
movq %rax, %r15
movq 0x8(%rbp), %rax
cmpq $0x6a703268, %rax       # imm = 0x6A703268
jle 0x2068c
cmpq $0x75756963, %rax       # imm = 0x75756963
jg 0x206be
cmpq $0x6a703269, %rax       # imm = 0x6A703269
je 0x20735
cmpq $0x75696e66, %rax       # imm = 0x75696E66
jne 0x206f4
movq %r14, %rdi
movq %rbp, %rsi
movl %r13d, %ecx
callq 0x2146c
jmp 0x20777
cmpq $0x66747970, %rax       # imm = 0x66747970
je 0x206e1
cmpq $0x6a703263, %rax       # imm = 0x6A703263
je 0x20758
cmpq $0x6a703268, %rax       # imm = 0x6A703268
jne 0x206f4
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r13d, %ecx
callq 0x20e52
jmp 0x20777
cmpq $0x75756964, %rax       # imm = 0x75756964
je 0x20745
cmpq $0x786d6c20, %rax       # imm = 0x786D6C20
jne 0x206f4
movq %r14, %rdi
movq %rbp, %rsi
movl %r13d, %edx
callq 0x20bce
jmp 0x20777
movq %r14, %rdi
movq %rbp, %rsi
movl %r13d, %ecx
callq 0x208ac
jmp 0x20777
cmpq $0x0, 0x20(%rbp)
je 0x20707
movq %r14, %rdi
callq 0x5109
testl %eax, %eax
je 0x2070c
movl $0x1, %ebx
leaq 0x37a6d(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
movq %r14, %rdi
movq %rbp, %rsi
testl $0x104, %eax            # imm = 0x104
je 0x207c5
movl %r13d, %edx
callq 0x2041a
jmp 0x207e1
movq %r14, %rdi
movq %rbp, %rsi
movl %r13d, %edx
callq 0x20d18
jmp 0x20777
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r13d, %ecx
callq 0x2108d
jmp 0x20777
cmpq $0x0, 0x20(%rbp)
movl $0x1, %eax
cmoveq %rax, %rbx
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r13d, %ecx
callq 0x213a0
movq %rax, %r12
xorl %edi, %edi
callq 0x16b56
movq %r14, %rdi
callq 0x5109
cmpl $0x1, %eax
sbbq $-0x1, %rbx
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x20607
testq %rbx, %rbx
jne 0x20607
movq %r14, %rdi
movq %r12, %rsi
callq 0x201f8
movq %rax, %rbp
testq %rax, %rax
jne 0x20633
jmp 0x20607
leaq 0x284b3(%rip), %rdx     # 0x48c7f
movl %r13d, %ecx
movl $0x1, %r8d
callq 0x204e6
movl %eax, %edi
callq 0x17530
movq 0x20(%rbp), %r13
movq 0x18(%rbp), %r12
addq %r13, %r12
leaq 0x3798d(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x2085d
leaq 0x38c08(%rip), %rax     # 0x59408
movq (%rax), %rax
testq %rax, %rax
je 0x2081b
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x20828
cmpq %r13, %rax
cmovbq %rax, %r13
jmp 0x20828
cmpq $0x30, %r13
movl $0x30, %eax
cmovaeq %rax, %r13
xorl %edi, %edi
callq 0x16b56
movq 0x18(%rbp), %rsi
movl $0x2, (%rsp)
movq %r14, %rdi
movq %r13, %rdx
movq %r13, %rcx
movl $0x10, %r8d
movl 0x14(%rsp), %r9d
callq 0x7446
movl $0x1, %edi
callq 0x16b56
leaq 0x3791c(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
jne 0x20874
movl 0x14(%rsp), %r13d
jmp 0x2077a
xorl %edi, %edi
callq 0x16b56
leaq -0x1(%r12), %rsi
movl $0x40000, %edi          # imm = 0x40000
movl 0x14(%rsp), %r13d
movl %r13d, %edx
leaq 0x20848(%rip), %rcx     # 0x410dc
callq 0x5605
movq 0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x2033b
jmp 0x2077a