// File: /workspace/github_c_makefile_star2_O1/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 0x3730c(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
testl $0x104, %eax            # imm = 0x104
je 0x20e90
movq %r13, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x2041a
xorl %ebp, %ebp
jmp 0x20eac
leaq 0x27de8(%rip), %rdx     # 0x48c7f
movq %r13, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x204e6
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 0x21033
cmpq %r14, %r15
jae 0x21033
leal 0x2(%rbx), %r12d
xorl %eax, %eax
cmpq $0x0, (%rsp)
sete %al
movq %rax, 0x8(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x201f8
testq %rax, %rax
je 0x20fca
movq 0x8(%rax), %rcx
cmpq $0x70636c71, %rcx       # imm = 0x70636C71
jg 0x20f3d
cmpq $0x636f6c71, %rcx       # imm = 0x636F6C71
jg 0x20f92
cmpq $0x62706363, %rcx       # imm = 0x62706363
je 0x20f70
cmpq $0x63646566, %rcx       # imm = 0x63646566
je 0x20f70
jmp 0x20fe8
leaq -0x72657363(%rcx), %rdx
cmpq $0x2, %rdx
jb 0x20f70
cmpq $0x70636c72, %rcx       # imm = 0x70636C72
je 0x20f70
cmpq $0x72657320, %rcx       # imm = 0x72657320
jne 0x20fe8
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x21e5e
jmp 0x20fc7
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x2041a
addq (%rsp), %r15
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movq 0x8(%rsp), %rbx
jmp 0x20fcc
cmpq $0x636f6c72, %rcx       # imm = 0x636F6C72
je 0x20fb9
cmpq $0x69686472, %rcx       # imm = 0x69686472
jne 0x20fe8
movq %r13, %rdi
movq %rax, %rsi
movq 0x20(%rsp), %rdx
movl %r12d, %ecx
callq 0x215c7
jmp 0x20fc7
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x21ab5
movq %rax, %r15
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x21033
testq %rbx, %rbx
jne 0x21033
cmpq %r14, %r15
jb 0x20efc
jmp 0x21033
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x2041a
movq %r13, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x2100e
movq %r13, %rdi
callq 0x31a0
testl %eax, %eax
je 0x2102f
movq %r13, %rdi
callq 0x31b0
movl $0x1, %ebx
addq (%rsp), %r15
addq 0x8(%rsp), %rbx
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
jmp 0x20fcc
xorl %ebx, %ebx
jmp 0x2101b
leaq 0x37146(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x21074
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
decq %r15
leaq 0x20089(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x5605
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x2033b
movl %ebp, %edi
callq 0x16b56
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq