// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movw $0x0, -0x52(%rbp)
movw $0x0, -0x54(%rbp)
movw $0x0, -0x56(%rbp)
movw $0x0, -0x58(%rbp)
movw $0x0, -0x5a(%rbp)
movl $0x0, -0x60(%rbp)
leaq 0x46f8d(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x1040000, %rax        # imm = 0x1040000
cmpq $0x0, %rax
jne 0x30224
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %ecx
leaq 0x3b29d(%rip), %rdx     # 0x6b4b1
movl $0x1, %r8d
callq 0x2eab0
movl %eax, -0x60(%rbp)
jmp 0x30234
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x2e980
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x10(%rcx), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x4610
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x36dbf(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x46ee0(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x302eb
leaq 0x46eca(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x302d7
leaq 0x3b1f1(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x40356(%rip), %rdi     # 0x70634
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46e8e(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x30317
movq -0x48(%rbp), %rsi
leaq 0x33dc1(%rip), %rdi     # 0x640cb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x4610
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x36cf9(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x46e1a(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x303b1
leaq 0x46e04(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x3039d
leaq 0x3b12b(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x4027e(%rip), %rdi     # 0x70622
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46dc8(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x303dd
movq -0x50(%rbp), %rsi
leaq 0x33cfb(%rip), %rdi     # 0x640cb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x3041c
cmpq $0x0, -0x48(%rbp)
jbe 0x3041c
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rax
cmpq -0x48(%rbp), %rax
jae 0x3041c
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x78(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x30444
cmpq $0x0, -0x50(%rbp)
jbe 0x30444
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
cmpq -0x50(%rbp), %rax
jae 0x30444
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x4480
movw %ax, -0x52(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x36be3(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x46d04(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x304c7
leaq 0x46cee(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x304b3
leaq 0x3b015(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x3b010(%rip), %rdi     # 0x6b4ca
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46cb2(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x304f3
movzwl -0x52(%rbp), %esi
leaq 0x37146(%rip), %rdi     # 0x6762c
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4f20
movw %ax, -0x54(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x36b22(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x46c43(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x30588
leaq 0x46c2d(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x30574
leaq 0x3af54(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x3af62(%rip), %rdi     # 0x6b4dd
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46bf1(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x305b4
movzwl -0x54(%rbp), %esi
leaq 0x37085(%rip), %rdi     # 0x6762c
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4f20
movw %ax, -0x56(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x36a61(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x46b82(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x30649
leaq 0x46b6c(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x30635
leaq 0x3ae93(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x349fd(%rip), %rdi     # 0x65039
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46b30(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x30675
movzwl -0x56(%rbp), %esi
leaq 0x36fc4(%rip), %rdi     # 0x6762c
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x306a2
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc8(%rax)
jg 0x306a2
movzwl -0x56(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc8(%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4f20
movw %ax, -0x58(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x3697e(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x46a9f(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x3072c
leaq 0x46a89(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x30718
leaq 0x3adb0(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x3adcf(%rip), %rdi     # 0x6b4ee
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46a4d(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x30771
movzwl -0x58(%rbp), %esi
movzwl -0x58(%rbp), %ecx
leaq 0x39bcb(%rip), %rdx     # 0x6a31a
leaq 0x3adb4(%rip), %rax     # 0x6b50a
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x3ad95(%rip), %rdi     # 0x6b4f9
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4f20
movw %ax, -0x5a(%rbp)
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
addl $0x8, %edx
movl $0x4003333, %edi        # imm = 0x4003333
leaq 0x368a4(%rip), %rcx     # 0x67053
callq 0x5ed0
leaq 0x469c5(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x30806
leaq 0x469af(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x307f2
leaq 0x3acd6(%rip), %rdi     # 0x6b4bb
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x3ad14(%rip), %rdi     # 0x6b50d
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x46973(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x3084b
movzwl -0x5a(%rbp), %esi
movzwl -0x5a(%rbp), %ecx
leaq 0x3fac8(%rip), %rdx     # 0x702f1
leaq 0x3acf0(%rip), %rax     # 0x6b520
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x3acd6(%rip), %rdi     # 0x6b514
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
leaq 0x46917(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x308b1
movq -0x38(%rbp), %rsi
subq $0x1, %rsi
movl -0x1c(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x3384d(%rip), %rcx     # 0x640dc
callq 0x5ed0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2e830
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movq -0x30(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)