// File: /workspace/github_c_makefile_star2_O1/hfiguiere[P]exifprobe/jp2000.c
// Function: process_jp2_ihdr
unsigned long
process_jp2_ihdr(FILE *inptr,struct jp2box *box,struct image_summary *summary_entry,
                                                        int indent)
{
    unsigned long boxoffset,max_offset,dataoffset;
    unsigned long boxlength;
    unsigned long imgheight = 0UL;
    unsigned long imgwidth = 0UL;
    unsigned short nc = 0;
    unsigned short bpc = 0;
    unsigned short comp = 0;
    unsigned short hasUNK = 0;
    unsigned short hasIPR = 0;
    int chpr = 0;

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

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

    imgheight = read_ulong(inptr,TIFF_MOTOROLA,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("ImageHeight");
    }
    if((PRINT_VALUE))
        chpr += printf(" = %lu",imgheight);
    chpr = newline(chpr);
    dataoffset += 4;

    imgwidth = read_ulong(inptr,TIFF_MOTOROLA,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("ImageWidth");
    }
    if((PRINT_VALUE))
        chpr += printf(" = %lu",imgwidth);
    chpr = newline(chpr);
    dataoffset += 4;
    if(summary_entry && (imgheight > 0) &&
                            (summary_entry->pixel_height < imgheight))
    {
        summary_entry->pixel_height = imgheight;
    }
    if(summary_entry && (imgwidth > 0) &&
                            (summary_entry->pixel_width < imgwidth))
    {
        summary_entry->pixel_width = imgwidth;
    }

    nc = read_ushort(inptr,TIFF_MOTOROLA,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("NumberOfComponents");
    }
    if((PRINT_VALUE))
        chpr += printf(" = %u",nc);
    chpr = newline(chpr);
    dataoffset += 2;

    bpc = read_ubyte(inptr,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("BitsPerComponent");
    }
    if((PRINT_VALUE))
        chpr += printf(" = %u",bpc);
    chpr = newline(chpr);
    dataoffset++;

    comp = read_ubyte(inptr,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("Compression");
    }
    if((PRINT_VALUE))
        chpr += printf(" = %u",comp);
    chpr = newline(chpr);
    /* This is always 7 according to spec, and tells us nothing;  */
    /* it will be over-written with the transform type from a COD */
    /* segement, if one is found. I imagine that "extensions" to  */
    /* the spec will quickly overwhelm this.                      */
    if((summary_entry) && (summary_entry->compression <= 0))
        summary_entry->compression = comp;
    dataoffset++;

    hasUNK = read_ubyte(inptr,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("Colorspace");
    }
    if((PRINT_VALUE))
            chpr += printf(" = %#x = %sknown",hasUNK,hasUNK ? "un" : "");
    chpr = newline(chpr);
    dataoffset++;

    hasIPR = read_ubyte(inptr,dataoffset);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2h.ihdr.");
        chpr += printf("IPRbox");
    }
        if((PRINT_VALUE))
            chpr += printf(" = %#x = %s",hasIPR,hasIPR ? "yes" : "no");
    chpr = newline(chpr);
    dataoffset++;

    if((PRINT_SECTION))
    {
        print_tag_address(SECTION,dataoffset - 1,indent,"@");
        print_jp2type(box->tbox,1);
        chpr = newline(chpr);
    }
    return(max_offset);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movq %rdx, 0x18(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0x36b97(%rip), %r13     # 0x58180
movzwl 0x2(%r13), %eax
testl $0x104, %eax            # imm = 0x104
je 0x21606
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x2041a
xorl %ebx, %ebx
jmp 0x21622
leaq 0x276c8(%rip), %rdx     # 0x48cd5
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %ecx
movl $0x1, %r8d
callq 0x204e6
movl %eax, %ebx
movq 0x18(%r14), %rax
movq 0x20(%r14), %rcx
movq %rcx, 0x28(%rsp)
movq %r14, 0x20(%rsp)
movq 0x10(%r14), %r12
movq %rax, 0x30(%rsp)
addq %rax, %r12
movq %r15, 0x10(%rsp)
movq %r15, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r12, %rdx
callq 0x46cc
movq %rax, %r15
leal 0x8(%rbp), %edx
leaq 0x2331f(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r12, %rsi
movl %edx, 0xc(%rsp)
callq 0x5605
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x216a2
testb $0x40, %al
je 0x21692
leaq 0x27656(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x2c81b(%rip), %rdi     # 0x4deb4
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
testb $0x30, (%r13)
je 0x216c1
movq %rbp, %r13
leaq 0x1fa18(%rip), %rdi     # 0x410cb
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
jmp 0x216c4
movq %rbp, %r13
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
leaq 0x4(%r12), %rbp
movq 0x10(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %rbp, %rdx
callq 0x46cc
movq %rax, %r14
leaq 0x23293(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %rbp, %rsi
movl 0xc(%rsp), %edx
callq 0x5605
leaq 0x36a7a(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21734
testb $0x40, %al
je 0x21724
leaq 0x275c4(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x2c777(%rip), %rdi     # 0x4dea2
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq %r13, %rbp
leaq 0x36a42(%rip), %r13     # 0x58180
testb $0x30, (%r13)
je 0x21758
leaq 0x1f97f(%rip), %rdi     # 0x410cb
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x21783
cmpq %r15, 0x78(%rdx)
jae 0x21783
movq %r15, 0x78(%rdx)
leaq 0x8(%r12), %r15
testq %rdx, %rdx
je 0x2179c
testq %r14, %r14
je 0x2179c
cmpq %r14, 0x70(%rdx)
jae 0x2179c
movq %r14, 0x70(%rdx)
movq 0x10(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r15, %rdx
callq 0x4574
movl %eax, %r14d
leaq 0x231c9(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x5605
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x217f8
testb $0x40, %al
je 0x217e8
leaq 0x27500(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x274ff(%rip), %rdi     # 0x48cee
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
testb $0x30, (%r13)
je 0x21813
movzwl %r14w, %esi
leaq 0x23750(%rip), %rdi     # 0x44f5a
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
leaq 0xa(%r12), %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4d44
movl %eax, %r14d
leaq 0x23149(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x5605
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21878
testb $0x40, %al
je 0x21868
leaq 0x27480(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x27492(%rip), %rdi     # 0x48d01
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
testb $0x30, (%r13)
je 0x21893
movzwl %r14w, %esi
leaq 0x236d0(%rip), %rdi     # 0x44f5a
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
leaq 0xb(%r12), %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4d44
movl %eax, %r14d
leaq 0x230c9(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x5605
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x218f8
testb $0x40, %al
je 0x218e8
leaq 0x27400(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x20f42(%rip), %rdi     # 0x42831
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
testb $0x30, (%r13)
je 0x21913
movzwl %r14w, %esi
leaq 0x23650(%rip), %rdi     # 0x44f5a
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x21939
cmpl $0x0, 0xc8(%rcx)
jg 0x21939
movzwl %r14w, %eax
movl %eax, 0xc8(%rcx)
leaq 0xc(%r12), %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4d44
movl %eax, %r14d
leaq 0x2302c(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x5605
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21995
testb $0x40, %al
je 0x21985
leaq 0x27363(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x27386(%rip), %rdi     # 0x48d12
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq 0x10(%rsp), %r15
testb $0x30, (%r13)
je 0x219ca
movzwl %r14w, %esi
testw %si, %si
leaq 0x262e7(%rip), %rax     # 0x47c96
leaq 0x27378(%rip), %rdx     # 0x48d2e
cmoveq %rax, %rdx
leaq 0x2735c(%rip), %rdi     # 0x48d1d
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
addq $0xd, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4d44
movl %eax, %r14d
leaq 0x22f95(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r12, %rsi
movl 0xc(%rsp), %edx
callq 0x5605
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21a2c
testb $0x40, %al
je 0x21a1c
leaq 0x272cc(%rip), %rdi     # 0x48cdf
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x2730e(%rip), %rdi     # 0x48d31
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
testb $0x30, (%r13)
je 0x21a5c
movzwl %r14w, %esi
testw %si, %si
leaq 0x2c130(%rip), %rax     # 0x4db71
leaq 0x272fc(%rip), %rdx     # 0x48d44
cmoveq %rax, %rdx
leaq 0x272e5(%rip), %rdi     # 0x48d38
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16b56
testb $0x4, 0x2(%r13)
je 0x21a9c
movl %eax, %ebx
leaq 0x1f669(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq %r12, %rsi
movl %ebp, %edx
callq 0x5605
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2033b
movl %ebx, %edi
callq 0x16b56
movq 0x28(%rsp), %rax
addq 0x30(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq