// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/jp2000.c
// Function: process_jp2_jp2h
unsigned long
process_jp2_jp2h(FILE *inptr,struct jp2box *box,struct image_summary *summary_entry,
                                                        int indent)
{
    unsigned long lastbox = 0L;
    unsigned long boxoffset,max_offset,dataoffset,tbox;
    unsigned long boxlength;
    int chpr = 0;

    if((LIST_MODE))
        chpr = list_jp2box(inptr,box,"JP2.",indent,1);
    else
        print_jp2box(inptr,box,indent);
    boxoffset = box->boxoffset;
    boxlength = box->boxlength;
    tbox = box->tbox;

    dataoffset = boxoffset + box->dataoffset;
    max_offset = boxoffset + boxlength;


    while(!feof(inptr) && !lastbox && (dataoffset < max_offset))
    {
        box = read_jp2box(inptr,dataoffset);
        if(box)
        {
            switch(box->tbox)
            {
                case JP2_ihdr:
                    dataoffset = process_jp2_ihdr(inptr,box,summary_entry,indent + SUBINDENT);
                    break;
                case JP2_colr:
                    dataoffset = process_jp2_colr(inptr,box,indent + SUBINDENT);
                    break;
                case JP2_res:
                    dataoffset = process_jp2_res(inptr,box,indent + SUBINDENT);
                    break;
                case JP2_bpcc:
                case JP2_pclr:
                case JP2_cdef:
                case JP2_resc:  /* handled in process_jp2_res().  */
                case JP2_resd:  /* handled in process_jp2_res().  */
                    /* These fields are reported but not expanded */
                    print_jp2box(inptr,box,indent + SUBINDENT);
                    if(boxlength)
                        dataoffset += boxlength;
                    else
                        ++lastbox;
                    chpr = newline(chpr);
                    break;
                default:
                    /* report the unknown box and try to continue. If */
                    /* the box is properly constructed, that may be   */
                    /* possible; most likely this is garbled data.    */
                    print_jp2box(inptr,box,indent + SUBINDENT);
                    if(ferror(inptr) || feof(inptr))
                    {
                        clearerr(inptr);
                        ++lastbox;
                    }
                    if(boxlength)
                        dataoffset += boxlength;
                    else
                        ++lastbox;
                    chpr = newline(chpr);
                    break;
            }
        }
    }
    if((PRINT_SECTION))
    {
        chpr = newline(chpr);
        print_tag_address(SECTION,dataoffset - 1,indent,"@");
        print_jp2type(tbox,1);
    }
    chpr = newline(chpr);
    return(max_offset);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movq %rdx, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, %r13
leaq 0x36d47(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
testl $0x104, %eax            # imm = 0x104
je 0x21455
movq %r13, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x209e0
xorl %ebp, %ebp
jmp 0x21471
leaq 0x27863(%rip), %rdx     # 0x48cbf
movq %r13, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x20aa9
movl %eax, %ebp
movq 0x8(%r15), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%r15), %r14
movq 0x20(%r15), %rax
movq 0x10(%r15), %r15
addq %r14, %r15
movq %rax, (%rsp)
addq %rax, %r14
movq %r13, %rdi
callq 0x31a0
testl %eax, %eax
movq %rbx, 0x18(%rsp)
jne 0x215f8
cmpq %r14, %r15
jae 0x215f8
leal 0x2(%rbx), %r12d
xorl %eax, %eax
cmpq $0x0, (%rsp)
sete %al
movq %rax, 0x8(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x207bc
testq %rax, %rax
je 0x2158f
movq 0x8(%rax), %rcx
cmpq $0x70636c71, %rcx       # imm = 0x70636C71
jg 0x21502
cmpq $0x636f6c71, %rcx       # imm = 0x636F6C71
jg 0x21557
cmpq $0x62706363, %rcx       # imm = 0x62706363
je 0x21535
cmpq $0x63646566, %rcx       # imm = 0x63646566
je 0x21535
jmp 0x215ad
leaq -0x72657363(%rcx), %rdx
cmpq $0x2, %rdx
jb 0x21535
cmpq $0x70636c72, %rcx       # imm = 0x70636C72
je 0x21535
cmpq $0x72657320, %rcx       # imm = 0x72657320
jne 0x215ad
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x22435
jmp 0x2158c
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x209e0
addq (%rsp), %r15
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movq 0x8(%rsp), %rbx
jmp 0x21591
cmpq $0x636f6c72, %rcx       # imm = 0x636F6C72
je 0x2157e
cmpq $0x69686472, %rcx       # imm = 0x69686472
jne 0x215ad
movq %r13, %rdi
movq %rax, %rsi
movq 0x20(%rsp), %rdx
movl %r12d, %ecx
callq 0x21b8c
jmp 0x2158c
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x22082
movq %rax, %r15
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x215f8
testq %rbx, %rbx
jne 0x215f8
cmpq %r14, %r15
jb 0x214c1
jmp 0x215f8
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x209e0
movq %r13, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x215d3
movq %r13, %rdi
callq 0x31a0
testl %eax, %eax
je 0x215f4
movq %r13, %rdi
callq 0x31b0
movl $0x1, %ebx
addq (%rsp), %r15
addq 0x8(%rsp), %rbx
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
jmp 0x21591
xorl %ebx, %ebx
jmp 0x215e0
leaq 0x36b81(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x21639
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
decq %r15
leaq 0x1fac4(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x55eb
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x208ff
movl %ebp, %edi
callq 0x1707a
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq