// File: /workspace/github_c_makefile_star2_O2/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, 0x14(%rsp)
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x1fb50
testq %rbx, %rbx
jne 0x1fb50
movq %r14, %rdi
movq %r13, %rsi
callq 0x1f508
testq %rax, %rax
je 0x1fb50
movq %rax, %r12
testq %r15, %r15
je 0x1f93d
cmpl $0x0, 0x10(%r15)
je 0x1f94f
movq %r15, %rdi
xorl %esi, %esi
movl $0xd0a870a, %edx        # imm = 0xD0A870A
callq 0xef13
movq %rax, %r15
movl 0x14(%rsp), %ebp
pushq $0x1
popq %r13
movq 0x8(%r12), %rax
cmpq $0x786d6c20, %rax       # imm = 0x786D6C20
je 0x1f9db
cmpq $0x6a703263, %rax       # imm = 0x6A703263
je 0x1fa36
cmpq $0x6a703268, %rax       # imm = 0x6A703268
je 0x1fa03
cmpq $0x6a703269, %rax       # imm = 0x6A703269
je 0x1f9ab
cmpq $0x75696e66, %rax       # imm = 0x75696E66
je 0x1f9cc
cmpq $0x75756964, %rax       # imm = 0x75756964
je 0x1f9ba
cmpq $0x66747970, %rax       # imm = 0x66747970
jne 0x1f9ea
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %ecx
callq 0x1fb62
jmp 0x1fa13
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x1ffb5
jmp 0x1fa13
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x2030d
jmp 0x1fa13
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %ecx
callq 0x206da
jmp 0x1fa13
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x1fe71
jmp 0x1fa13
cmpq $0x0, 0x20(%r12)
je 0x1f9fe
movq %r14, %rdi
callq 0x4c47
testl %eax, %eax
je 0x1fa56
pushq $0x1
popq %rbx
jmp 0x1fa58
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x200eb
movq %rax, %r13
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x160f7
movq %r14, %rdi
callq 0x4c47
cmpl $0x1, %eax
sbbq $-0x1, %rbx
movq %r13, %rbp
jmp 0x1f901
xorl %ebx, %ebx
cmpq $0x0, 0x20(%r12)
sete %bl
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x20613
movq %rax, %r13
jmp 0x1fa18
xorl %ebx, %ebx
leaq 0x37721(%rip), %rax     # 0x57180
movzwl 0x2(%rax), %eax
movq %r14, %rdi
movq %r12, %rsi
testw $0x104, %ax             # imm = 0x104
je 0x1fa78
movl %ebp, %edx
callq 0x1f71d
jmp 0x1fa90
leaq 0x271f0(%rip), %rdx     # 0x46c6f
movl %ebp, %ecx
movl %r13d, %r8d
callq 0x1f7e6
movl %eax, %edi
callq 0x16a4f
movq 0x20(%r12), %rbp
movq 0x18(%r12), %r13
addq %rbp, %r13
leaq 0x376dc(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
je 0x1fa18
leaq 0x38953(%rip), %rax     # 0x58408
movq (%rax), %rax
testq %rax, %rax
je 0x1fad0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1fadb
cmpq %rbp, %rax
cmovbq %rax, %rbp
jmp 0x1fadb
cmpq $0x30, %rbp
pushq $0x30
popq %rax
cmovaeq %rax, %rbp
xorl %edi, %edi
callq 0x160f7
movq 0x18(%r12), %rsi
movl $0x2, (%rsp)
movq %r14, %rdi
movq %rbp, %rdx
movq %rbp, %rcx
pushq $0x10
popq %r8
movl 0x14(%rsp), %ebp
movl %ebp, %r9d
callq 0x6e93
pushq $0x1
popq %rdi
callq 0x160f7
leaq 0x3766a(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
je 0x1fa18
xorl %edi, %edi
callq 0x160f7
leaq -0x1(%r13), %rsi
movl $0x40000, %edi          # imm = 0x40000
movl %ebp, %edx
leaq 0x1f5a3(%rip), %rcx     # 0x3f0dc
callq 0x5100
movq 0x8(%r12), %rdi
pushq $0x1
popq %rsi
callq 0x1f649
jmp 0x1fa18
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq