// File: /workspace/github_c_makefile_star2_O2/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, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x37073(%rip), %rax     # 0x57180
movzwl 0x2(%rax), %eax
testw $0x104, %ax             # imm = 0x104
je 0x2012e
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x1f71d
movl $0x0, 0x8(%rsp)
jmp 0x2014a
leaq 0x26b3a(%rip), %rdx     # 0x46c6f
pushq $0x1
popq %r8
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %ecx
callq 0x1f7e6
movl %eax, 0x8(%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%r15), %r14
movq 0x20(%r15), %rbp
movq 0x10(%r15), %r13
addq %r14, %r13
addq %rbp, %r14
movq %rbx, 0x20(%rsp)
leal 0x2(%rbx), %eax
movl %eax, 0xc(%rsp)
xorl %r15d, %r15d
testq %rbp, %rbp
sete %r15b
xorl %ebx, %ebx
testq %rbx, %rbx
sete %bl
movq %r12, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x202ad
testb $0x1, %bl
je 0x202ad
cmpq %r14, %r13
jae 0x202ad
movq %r12, %rdi
movq %r13, %rsi
callq 0x1f508
movb $0x1, %bl
testq %rax, %rax
je 0x20183
movq 0x8(%rax), %rcx
cmpq $0x636f6c72, %rcx       # imm = 0x636F6C72
je 0x201e7
cmpq $0x69686472, %rcx       # imm = 0x69686472
je 0x201f8
cmpq $0x72657320, %rcx       # imm = 0x72657320
jne 0x20216
movq %r12, %rdi
movq %rax, %rsi
movl 0xc(%rsp), %edx
callq 0x210c3
jmp 0x2020c
movq %r12, %rdi
movq %rax, %rsi
movl 0xc(%rsp), %edx
callq 0x20d1a
jmp 0x2020c
movq %r12, %rdi
movq %rax, %rsi
movq 0x10(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x20830
movq %rax, %r13
movb $0x1, %bl
jmp 0x20183
leaq -0x72657363(%rcx), %rdx
cmpq $0x2, %rdx
jb 0x2023e
cmpq $0x62706363, %rcx       # imm = 0x62706363
je 0x2023e
cmpq $0x63646566, %rcx       # imm = 0x63646566
je 0x2023e
cmpq $0x70636c72, %rcx       # imm = 0x70636C72
jne 0x20265
movq %r12, %rdi
movq %rax, %rsi
movl 0xc(%rsp), %edx
callq 0x1f71d
movl 0x8(%rsp), %edi
callq 0x160f7
movl %eax, 0x8(%rsp)
movq %r15, %rbx
addq %rbp, %r13
jmp 0x2017d
movq %r12, %rdi
movq %rax, %rsi
movl 0xc(%rsp), %edx
callq 0x1f71d
movq %r12, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x2028c
movq %r12, %rdi
callq 0x31a0
testl %eax, %eax
je 0x202a9
movq %r12, %rdi
callq 0x31b0
pushq $0x1
popq %rbx
addq %r15, %rbx
movl 0x8(%rsp), %edi
callq 0x160f7
movl %eax, 0x8(%rsp)
jmp 0x2025d
xorl %ebx, %ebx
jmp 0x20297
leaq 0x36ecc(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
jne 0x202c0
movl 0x8(%rsp), %ebx
jmp 0x202f4
movl 0x8(%rsp), %edi
callq 0x160f7
movl %eax, %ebx
decq %r13
leaq 0x1ee07(%rip), %rcx     # 0x3f0dc
movl $0x40000, %edi          # imm = 0x40000
movq %r13, %rsi
movq 0x20(%rsp), %rdx
callq 0x5100
pushq $0x1
popq %rsi
movq 0x18(%rsp), %rdi
callq 0x1f649
movl %ebx, %edi
callq 0x160f7
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq