// File: /workspace/github_c_makefile_star2_O3/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, %ebp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x372f0(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
testl $0x104, %eax            # imm = 0x104
je 0x20eb0
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x209e0
movq %rbx, %rdi
xorl %r15d, %r15d
jmp 0x20ed0
leaq 0x27e08(%rip), %rdx     # 0x48cbf
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %ecx
movl $0x1, %r8d
callq 0x20aa9
movq %rbx, %rdi
movl %eax, %r15d
movq 0x10(%r12), %rbx
movq 0x18(%r12), %r14
movq 0x20(%r12), %rax
movq %rax, 0x30(%rsp)
leaq (%rbx,%r14), %r13
movq %rdi, 0x8(%rsp)
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r13, %rdx
callq 0x4707
movq %rax, 0x20(%rsp)
movq %r14, 0x28(%rsp)
addq %rbx, %r14
addq $0x4, %r14
movq %rbp, 0x18(%rsp)
addl $0x8, %ebp
leaq 0x23aab(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r14, %rsi
movl %ebp, %edx
callq 0x55eb
leaq 0x37250(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x20f6a
testb $0x40, %al
je 0x20f4f
leaq 0x27d7f(%rip), %rdi     # 0x48cc4
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
leaq 0x27d78(%rip), %rdi     # 0x48cce
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
leaq 0x37219(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
movq %r12, 0x10(%rsp)
je 0x20fb9
leaq 0x27d61(%rip), %rdi     # 0x48cdb
movq 0x20(%rsp), %r12
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
addl %r15d, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x208ff
cmpq $0x6a703220, %r12       # imm = 0x6A703220
je 0x20fad
leaq 0x27d41(%rip), %rdi     # 0x48ce9
callq 0x5c26
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %r12
jmp 0x20fc1
movl %r15d, %ebx
movq 0x8(%rsp), %r15
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
leaq 0x239f4(%rip), %rcx     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r14, %rsi
movl %ebp, %edx
callq 0x55eb
movq %r15, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r14, %rdx
callq 0x4707
movq %rax, %r14
leaq 0x37186(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x21032
testb $0x40, %al
je 0x21018
leaq 0x27cb5(%rip), %rdi     # 0x48cc4
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x27ce2(%rip), %rdi     # 0x48d01
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x37151(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
je 0x21053
leaq 0x27c9e(%rip), %rdi     # 0x48cdb
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0x208ff
addq $0x8, %r13
movl %ebx, %edi
callq 0x1707a
movl %eax, %r14d
movq %r12, %rax
movq 0x20(%r12), %r12
subq 0x10(%rax), %r12
addq $-0x8, %r12
cmpq $0x4, %r12
jb 0x21128
shrq $0x2, %r12
leaq 0x2393f(%rip), %r15     # 0x449c5
movl $0x4003333, %edi        # imm = 0x4003333
movq %r13, %rsi
movl %ebp, %edx
movq %r15, %rcx
callq 0x55eb
movq 0x8(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r13, %rdx
callq 0x4707
movq %rax, %rbx
leaq 0x370cc(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x210ee
testb $0x40, %al
je 0x210d3
leaq 0x27bfb(%rip), %rdi     # 0x48cc4
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x27c34(%rip), %rdi     # 0x48d0e
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x37095(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
je 0x21110
leaq 0x27be2(%rip), %rdi     # 0x48cdb
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x208ff
movl %r14d, %edi
callq 0x1707a
movl %eax, %r14d
addq $0x4, %r13
decq %r12
jne 0x21086
leaq 0x37051(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x2116f
movl %r14d, %edi
callq 0x1707a
movl %eax, %r14d
decq %r13
leaq 0x1ff92(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq %r13, %rsi
movq 0x18(%rsp), %rdx
callq 0x55eb
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x208ff
movq 0x30(%rsp), %rbx
addq 0x28(%rsp), %rbx
movl %r14d, %edi
callq 0x1707a
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq