// File: /workspace/github_c_makefile_star2_O2/hfiguiere[P]exifprobe/jp2000.c
// Function: process_jp2_ftyp
unsigned long
process_jp2_ftyp(FILE *inptr,struct jp2box *box,struct image_summary *summary_entry,
                                                        int indent)
{
    unsigned long boxoffset,max_offset,dataoffset;
    unsigned long boxlength;
    unsigned long mjv,mnv,cl,ncl;
    int compat = 0;
    int chpr = 0;
    int i;

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

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

        
    mjv = read_ulong(inptr,TIFF_MOTOROLA,dataoffset);
    dataoffset += 4;
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.ftyp.");
        chpr += printf("MajorVersion");
    }
    if((PRINT_VALUE))
    {
        chpr += printf(" = %#-10lx = ",mjv);
        print_jp2type(mjv,0);
        if(mjv != JP2_BR)
            printred( " (INVALID MAJOR VERSION");
    }
    chpr = newline(chpr);
    print_tag_address(ENTRY,dataoffset,indent + 8,"=");
    mnv = read_ulong(inptr,TIFF_MOTOROLA,dataoffset); 
    dataoffset += 4;
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.ftyp.");
        chpr += printf("MinorVersion");
    }
    if((PRINT_VALUE))
    {
        chpr += printf(" = %#-10lx = ",mnv);
        print_jp2type(mnv,0);
    }
    chpr = newline(chpr);
    ncl = box->boxlength - box->dataoffset - 8;
    ncl /= 4;
    for(i = 0; i < ncl; ++i)
    {
        print_tag_address(ENTRY,dataoffset,indent + 8,"=");
        cl = read_ulong(inptr,TIFF_MOTOROLA,dataoffset); 
        dataoffset += 4;
        if((PRINT_TAGINFO))
        {
            if((PRINT_LONGNAMES))
                chpr += printf("JP2.ftyp.");
            chpr += printf("Compat");
        }
        if((PRINT_VALUE))
        {
            chpr += printf(" = %#-10lx = ",cl);
            print_jp2type(cl,0);
        }
        chpr =  newline(chpr);
        if(cl == JP2_BR)
            compat++;
    }
    if((PRINT_SECTION))
    {
        chpr = newline(chpr);
        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, %r13d
movq %rsi, %r15
movq %rdi, %r14
leaq 0x37600(%rip), %rax     # 0x57180
movzwl 0x2(%rax), %eax
testw $0x104, %ax             # imm = 0x104
je 0x1fb9c
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x1f71d
xorl %ebx, %ebx
jmp 0x1fbb7
leaq 0x270cc(%rip), %rdx     # 0x46c6f
pushq $0x1
popq %r8
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %ecx
callq 0x1f7e6
movl %eax, %ebx
movq 0x10(%r15), %r12
movq 0x18(%r15), %rbp
movq %r15, 0x8(%rsp)
movq 0x20(%r15), %rax
movq %rax, 0x30(%rsp)
leaq (%r12,%rbp), %rdx
movq %r14, 0x18(%rsp)
movq %r14, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x42ba
movq %rax, %r15
movq %rbp, 0x10(%rsp)
movq %r12, 0x28(%rsp)
leaq (%r12,%rbp), %r14
addq $0x4, %r14
leal 0x8(%r13), %ebp
leaq 0x22d7e(%rip), %rcx     # 0x42981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r14, %rsi
movl %ebp, %edx
callq 0x5100
leaq 0x37567(%rip), %rax     # 0x57180
movq (%rax), %rax
testw $0x3003, %ax            # imm = 0x3003
je 0x1fc50
testb $0x40, %al
je 0x1fc36
leaq 0x27047(%rip), %rdi     # 0x46c74
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x27041(%rip), %rdi     # 0x46c7e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x37533(%rip), %rax     # 0x57180
movq (%rax), %rax
movq %r13, 0x20(%rsp)
testb $0x30, %al
je 0x1fc91
leaq 0x2702b(%rip), %rdi     # 0x46c8b
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %ebx, %r13d
movq %r15, %rdi
xorl %esi, %esi
callq 0x1f649
cmpq $0x6a703220, %r15       # imm = 0x6A703220
je 0x1fc94
leaq 0x2700f(%rip), %rdi     # 0x46c99
callq 0x56e2
jmp 0x1fc94
movl %ebx, %r13d
movq 0x8(%rsp), %r15
movl %r13d, %edi
callq 0x160f7
movl %eax, %ebx
leaq 0x22cd7(%rip), %rcx     # 0x42981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r14, %rsi
movl %ebp, %edx
callq 0x5100
movq 0x18(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r14, %rdx
callq 0x42ba
movq %rax, %r14
leaq 0x374ab(%rip), %rax     # 0x57180
movq (%rax), %rax
testw $0x3003, %ax            # imm = 0x3003
je 0x1fd0c
testb $0x40, %al
je 0x1fcf2
leaq 0x26f8b(%rip), %rdi     # 0x46c74
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x26fb8(%rip), %rdi     # 0x46cb1
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x37477(%rip), %rax     # 0x57180
movq (%rax), %rax
testb $0x30, %al
je 0x1fd2d
leaq 0x26f74(%rip), %rdi     # 0x46c8b
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0x1f649
movl %ebx, %edi
callq 0x160f7
movq 0x20(%r15), %r12
subq 0x10(%r15), %r12
movl %eax, %r13d
addq $-0x8, %r12
shrq $0x2, %r12
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax), %r14
addq $0x7, %r14
leaq 0x22c21(%rip), %r15     # 0x42981
subq $0x1, %r12
jb 0x1fe0b
leaq 0x1(%r14), %rbx
movl $0x4003333, %edi        # imm = 0x4003333
movq %rbx, %rsi
movl %ebp, %edx
movq %r15, %rcx
callq 0x5100
movq 0x18(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %rbx, %rdx
callq 0x42ba
movq %rax, %rbx
leaq 0x373e4(%rip), %rax     # 0x57180
movq (%rax), %rax
testw $0x3003, %ax            # imm = 0x3003
je 0x1fdd5
testb $0x40, %al
je 0x1fdba
leaq 0x26ec4(%rip), %rdi     # 0x46c74
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
leaq 0x26efd(%rip), %rdi     # 0x46cbe
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
leaq 0x373ae(%rip), %rax     # 0x57180
movq (%rax), %rax
testb $0x30, %al
je 0x1fdf7
leaq 0x26eab(%rip), %rdi     # 0x46c8b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f649
movl %r13d, %edi
callq 0x160f7
movl %eax, %r13d
addq $0x4, %r14
jmp 0x1fd60
leaq 0x3736e(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
je 0x1fe4d
movl %r13d, %edi
callq 0x160f7
movl %eax, %r13d
leaq 0x1f2b2(%rip), %rcx     # 0x3f0dc
movl $0x40000, %edi          # imm = 0x40000
movq %r14, %rsi
movq 0x20(%rsp), %rdx
callq 0x5100
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x1f649
movq 0x30(%rsp), %rbx
addq 0x10(%rsp), %rbx
movl %r13d, %edi
callq 0x160f7
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq