// File: /workspace/github_c_makefile_star2_O3/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 0x365d2(%rip), %r13     # 0x58180
movzwl 0x2(%r13), %eax
testl $0x104, %eax            # imm = 0x104
je 0x21bcb
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x209e0
xorl %ebx, %ebx
jmp 0x21be7
leaq 0x27143(%rip), %rdx     # 0x48d15
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %ecx
movl $0x1, %r8d
callq 0x20aa9
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 0x4707
movq %rax, %r15
leal 0x8(%rbp), %edx
leaq 0x22d9e(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r12, %rsi
movl %edx, 0xc(%rsp)
callq 0x55eb
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21c6b
testb $0x40, %al
je 0x21c57
leaq 0x270d1(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x2c296(%rip), %rdi     # 0x4def4
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq (%r13), %rax
movq %rbp, %r13
testb $0x30, %al
je 0x21c85
leaq 0x1f452(%rip), %rdi     # 0x410cb
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
leaq 0x4(%r12), %rbp
movq 0x10(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %rbp, %rdx
callq 0x4707
movq %rax, %r14
leaq 0x22d16(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %rbp, %rsi
movl 0xc(%rsp), %edx
callq 0x55eb
leaq 0x364b9(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21cff
testb $0x40, %al
je 0x21ce5
leaq 0x27043(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x2c1f6(%rip), %rdi     # 0x4dee2
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x36484(%rip), %rax     # 0x58180
movq (%rax), %rax
movq %r13, %rbp
testb $0x30, %al
je 0x21d19
leaq 0x1f3be(%rip), %rdi     # 0x410cb
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x36460(%rip), %r13     # 0x58180
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x21d4b
cmpq %r15, 0x78(%rdx)
jae 0x21d4b
movq %r15, 0x78(%rdx)
leaq 0x8(%r12), %r15
testq %rdx, %rdx
je 0x21d64
testq %r14, %r14
je 0x21d64
cmpq %r14, 0x70(%rdx)
jae 0x21d64
movq %r14, 0x70(%rdx)
movq 0x10(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r15, %rdx
callq 0x45af
movl %eax, %r14d
leaq 0x22c45(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x55eb
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21dc4
testb $0x40, %al
je 0x21db0
leaq 0x26f78(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x26f77(%rip), %rdi     # 0x48d2e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq (%r13), %rax
testb $0x30, %al
je 0x21ddc
movzwl %r14w, %esi
leaq 0x231cb(%rip), %rdi     # 0x44f9e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
leaq 0xa(%r12), %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4d48
movl %eax, %r14d
leaq 0x22bc4(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x55eb
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21e45
testb $0x40, %al
je 0x21e31
leaq 0x26ef7(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x26f09(%rip), %rdi     # 0x48d41
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq (%r13), %rax
testb $0x30, %al
je 0x21e5d
movzwl %r14w, %esi
leaq 0x2314a(%rip), %rdi     # 0x44f9e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
leaq 0xb(%r12), %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4d48
movl %eax, %r14d
leaq 0x22b43(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x55eb
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21ec6
testb $0x40, %al
je 0x21eb2
leaq 0x26e76(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x20978(%rip), %rdi     # 0x42831
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq (%r13), %rax
testb $0x30, %al
je 0x21ede
movzwl %r14w, %esi
leaq 0x230c9(%rip), %rdi     # 0x44f9e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x21f04
cmpl $0x0, 0xc8(%rcx)
jg 0x21f04
movzwl %r14w, %eax
movl %eax, 0xc8(%rcx)
leaq 0xc(%r12), %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4d48
movl %eax, %r14d
leaq 0x22aa5(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x55eb
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21f64
testb $0x40, %al
je 0x21f50
leaq 0x26dd8(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x26dfb(%rip), %rdi     # 0x48d52
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq (%r13), %rax
movq 0x10(%rsp), %r15
testb $0x30, %al
je 0x21f96
movzwl %r14w, %esi
testw %si, %si
leaq 0x25d5b(%rip), %rax     # 0x47cd6
leaq 0x26dec(%rip), %rdx     # 0x48d6e
cmoveq %rax, %rdx
leaq 0x26dd0(%rip), %rdi     # 0x48d5d
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
addq $0xd, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4d48
movl %eax, %r14d
leaq 0x22a0d(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r12, %rsi
movl 0xc(%rsp), %edx
callq 0x55eb
movq (%r13), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21ffc
testb $0x40, %al
je 0x21fe8
leaq 0x26d40(%rip), %rdi     # 0x48d1f
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x26d82(%rip), %rdi     # 0x48d71
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq (%r13), %rax
testb $0x30, %al
je 0x22029
movzwl %r14w, %esi
testw %si, %si
leaq 0x2bba3(%rip), %rax     # 0x4dbb1
leaq 0x26d6f(%rip), %rdx     # 0x48d84
cmoveq %rax, %rdx
leaq 0x26d58(%rip), %rdi     # 0x48d78
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x1707a
testb $0x4, 0x2(%r13)
je 0x22069
movl %eax, %ebx
leaq 0x1f09c(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq %r12, %rsi
movl %ebp, %edx
callq 0x55eb
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x208ff
movl %ebx, %edi
callq 0x1707a
movq 0x28(%rsp), %rax
addq 0x30(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq