// File: /workspace/github_c_makefile_star2_O1/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 0x378b7(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
testl $0x104, %eax            # imm = 0x104
je 0x208e9
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x2041a
movq %rbx, %rdi
xorl %r15d, %r15d
jmp 0x20909
leaq 0x2838f(%rip), %rdx     # 0x48c7f
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %ecx
movl $0x1, %r8d
callq 0x204e6
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 0x46cc
movq %rax, 0x20(%rsp)
movq %r14, 0x28(%rsp)
addq %rbx, %r14
addq $0x4, %r14
movq %rbp, 0x18(%rsp)
addl $0x8, %ebp
leaq 0x2402e(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r14, %rsi
movl %ebp, %edx
callq 0x5605
leaq 0x37817(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x20999
testb $0x40, %al
je 0x20988
leaq 0x28306(%rip), %rdi     # 0x48c84
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
leaq 0x282ff(%rip), %rdi     # 0x48c8e
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
leaq 0x377e0(%rip), %rax     # 0x58180
testb $0x30, (%rax)
movq %r12, 0x10(%rsp)
je 0x209f0
leaq 0x282ea(%rip), %rdi     # 0x48c9b
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 0x2033b
cmpq $0x6a703220, %r12       # imm = 0x6A703220
je 0x209e4
leaq 0x282ca(%rip), %rdi     # 0x48ca9
callq 0x5c33
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %r12
jmp 0x209f8
movl %r15d, %ebx
movq 0x8(%rsp), %r15
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
leaq 0x23f79(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r14, %rsi
movl %ebp, %edx
callq 0x5605
movq %r15, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r14, %rdx
callq 0x46cc
movq %rax, %r14
leaq 0x3774f(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x20a5f
testb $0x40, %al
je 0x20a4f
leaq 0x2823e(%rip), %rdi     # 0x48c84
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x2826b(%rip), %rdi     # 0x48cc1
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
leaq 0x3771a(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x20a88
leaq 0x28229(%rip), %rdi     # 0x48c9b
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2033b
addq $0x8, %r13
movl %ebx, %edi
callq 0x16b56
movl %eax, %r14d
movq %r12, %rax
movq 0x20(%r12), %r12
subq 0x10(%rax), %r12
addq $-0x8, %r12
cmpq $0x4, %r12
jb 0x20b63
shrq $0x2, %r12
cmpq $0x1, %r12
adcq $0x0, %r12
leaq 0x23ebe(%rip), %r15     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %r13, %rsi
movl %ebp, %edx
movq %r15, %rcx
callq 0x5605
movq 0x8(%rsp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r13, %rdx
callq 0x46cc
movq %rax, %rbx
leaq 0x3768f(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x20b21
testb $0x40, %al
je 0x20b10
leaq 0x2817e(%rip), %rdi     # 0x48c84
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x281b7(%rip), %rdi     # 0x48cce
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x37658(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x20b4b
leaq 0x28167(%rip), %rdi     # 0x48c9b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2033b
movl %r14d, %edi
callq 0x16b56
movl %eax, %r14d
addq $0x4, %r13
decq %r12
jne 0x20ac3
leaq 0x37616(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
je 0x20baa
movl %r14d, %edi
callq 0x16b56
movl %eax, %r14d
decq %r13
leaq 0x20557(%rip), %rcx     # 0x410dc
movl $0x40000, %edi          # imm = 0x40000
movq %r13, %rsi
movq 0x18(%rsp), %rdx
callq 0x5605
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2033b
movq 0x30(%rsp), %rbx
addq 0x28(%rsp), %rbx
movl %r14d, %edi
callq 0x16b56
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq