// File: /workspace/github_c_makefile_star2_O1/hfiguiere[P]exifprobe/jp2000.c
// Function: process_jpc_qcd
unsigned long
process_jpc_qcd(FILE *inptr,unsigned long marker_offset,unsigned short tag,
                                    struct image_summary *summary_entry,
                                    int indent)
{
    unsigned long max_offset;
    unsigned short seg_length;
    unsigned short qstyle;
    unsigned short guardbits;
    unsigned short stepsize,rawstepsize;
    char *name;
    int chpr = 0;
    int i;

    name = jp2000tagname(tag);
    seg_length = read_ushort(inptr,TIFF_MOTOROLA,marker_offset +2 );
    print_tag_address(SECTION|ENTRY,marker_offset,indent,"@");

    if((LIST_MODE))
    {
        if((PRINT_TAGINFO))
        {
            if((PRINT_LONGNAMES))
                chpr += printf("JP2.jp2c.");
            chpr += printf("%s",name);
        }
        if((PRINT_VALUE))
            chpr += printf(" = @%lu:%u",marker_offset,seg_length + 2);
    }
    else
        chpr += printf("<%#x=%s> length %u",tag,name,seg_length);
    max_offset = marker_offset + seg_length + 2;
    marker_offset += 4;

    qstyle = read_ubyte(inptr,marker_offset);
    ++marker_offset;
    chpr = newline(chpr);
    print_tag_address(ENTRY,marker_offset,indent + 8,"=");
    if((PRINT_TAGINFO))
    {
        if((PRINT_LONGNAMES))
            chpr += printf("JP2.jp2c.qcd.");
        chpr += printf("QuantizationStyle");
    }
    if((PRINT_VALUE))
    {
        chpr += printf(" = %#x",qstyle & 0xff);
        chpr += printf(" = ");
        if((qstyle & 0x1f) == 0)
            chpr += printf("no quantization");
        else if((qstyle & 0x1f) == 1)
            chpr += printf("implicit quantization");
        else if((qstyle & 0x1f) == 2)
            chpr += printf("explicit quantization");
        guardbits = (qstyle >> 5) & 0x7;

        chpr += printf(", %u guard bit%s",guardbits,guardbits > 1 ? "s" : "");
    }
    /* Record quantization in the second byte of the summary      */
    /* compression                                                */
    if(summary_entry)
        summary_entry->compression |= (((qstyle & 3) << 8) & 0xff00);
    for(i = 0;marker_offset < (max_offset - 1); ++i)
    {
        chpr = newline(chpr);
        print_tag_address(ENTRY,marker_offset,indent + 8,"=");
        if((qstyle & 0x1f) == 0)
        {
            rawstepsize = read_ubyte(inptr,marker_offset);
            stepsize = rawstepsize >> 3;
            if(stepsize & ~0x1f)
            {
                PUSHCOLOR(RED);
                print_tag_address(ENTRY,marker_offset,indent + SUBINDENT,"@");
                chpr += printf("# WARNING: stepsize exponent %d out of range (%#x => %#x)",
                                                                    i,rawstepsize,stepsize);
                POPCOLOR();
                marker_offset++;
                continue;
                break;
            }
            stepsize <<= 11;
            if((PRINT_TAGINFO))
            {
                if((PRINT_LONGNAMES))
                    chpr += printf("JP2.jp2c.");
                chpr += printf("qcd.Stepsize[%d]",i);
            }
            if((PRINT_VALUE))
                chpr += printf(" = %#x -> %u",rawstepsize,stepsize);
            marker_offset++;
        }
        else
        {
            stepsize = read_ushort(inptr,TIFF_MOTOROLA,marker_offset);
            marker_offset += 2;
            if((PRINT_TAGINFO))
            {
                if((PRINT_LONGNAMES))
                    chpr += printf("JP2.jp2c.qcd.");
                chpr += printf("Stepsize[%d]",i);
            }
            if((PRINT_VALUE))
                chpr += printf(" = %u",stepsize);
        }
    }
    if(!(LIST_MODE))
    {
        chpr = newline(chpr);
        print_tag_address(SECTION|ENTRY,marker_offset - 1,indent,"@");
        chpr += printf("</%#x=%s> ",tag,name);
    }
    if(marker_offset > max_offset)
        printred(" READ PAST END OF BOX");
    chpr = newline(chpr);

    return(max_offset);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %r15d
movq %rcx, 0x18(%rsp)
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r13
movl %edx, %edi
callq 0xc7cf
movq %rax, %r14
leaq 0x2(%r12), %rdx
movq %r13, 0x10(%rsp)
movq %r13, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x4574
movl %eax, %ebp
leaq 0x1c45c(%rip), %rcx     # 0x410dc
movl $0x4043333, %edi        # imm = 0x4043333
movq %r12, %rsi
movl %r15d, %edx
callq 0x5605
leaq 0x334e9(%rip), %rax     # 0x58180
movq (%rax), %rax
movzwl %bp, %r13d
movzwl %bx, %esi
testl $0x1040000, %eax        # imm = 0x1040000
movq %r14, 0x40(%rsp)
movl %esi, 0x20(%rsp)
movq %r13, 0x30(%rsp)
je 0x24ccf
leaq 0x2427d(%rip), %rdi     # 0x48f3a
movq %r14, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
jmp 0x24d2c
testl $0x3003, %eax           # imm = 0x3003
je 0x24d05
xorl %ebx, %ebx
testb $0x40, %al
je 0x24cec
leaq 0x24225(%rip), %rdi     # 0x48f08
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x1c3a4(%rip), %rdi     # 0x41097
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %ebx, %r14d
jmp 0x24d08
xorl %r14d, %r14d
leaq 0x33471(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x24d2c
leal 0x2(%r13), %edx
leaq 0x24210(%rip), %rdi     # 0x48f2f
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x4(%r12), %rsi
movq 0x10(%rsp), %rdi
callq 0x4d44
movl %eax, 0xc(%rsp)
movq %r12, 0x38(%rsp)
leaq 0x5(%r12), %rbp
movl %r14d, %edi
callq 0x16b56
movl %eax, %r13d
leal 0x8(%r15), %edx
leaq 0x1fc22(%rip), %rcx     # 0x44981
movl $0x4003333, %edi        # imm = 0x4003333
movq %rbp, %rsi
movl %edx, 0x24(%rsp)
callq 0x5605
leaq 0x33409(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x24da7
testb $0x40, %al
je 0x24d96
leaq 0x24507(%rip), %rdi     # 0x49293
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
leaq 0x24504(%rip), %rdi     # 0x492a1
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
movq 0x10(%rsp), %r12
leaq 0x333cd(%rip), %rax     # 0x58180
testb $0x30, (%rax)
movq %r15, 0x28(%rsp)
je 0x24e4c
movzwl 0xc(%rsp), %ebx
movzbl %bl, %esi
leaq 0x242f4(%rip), %rdi     # 0x490c4
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %r13d, %r15d
leaq 0x25784(%rip), %rdi     # 0x4a568
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %r15d, %r14d
andl $0x1f, %ebx
cmpl $0x2, %ebx
ja 0x24e13
movl %ebx, %eax
leaq 0x2451a(%rip), %rcx     # 0x4931c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movl 0xc(%rsp), %esi
shrl $0x5, %esi
andl $0x7, %esi
cmpw $0x2, %si
leaq 0x1c270(%rip), %rax     # 0x41098
leaq 0x22e67(%rip), %rdx     # 0x47c96
cmovaeq %rax, %rdx
leaq 0x24479(%rip), %rdi     # 0x492b3
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %r14d, %r13d
movq 0x28(%rsp), %r15
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax), %rbx
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x24e74
movl 0xc(%rsp), %eax
andl $0x3, %eax
shll $0x8, %eax
orl %eax, 0xc8(%rcx)
incq %rbx
cmpq %rbx, %rbp
jae 0x25004
leal 0x2(%r15), %eax
movl %eax, 0x18(%rsp)
xorl %r15d, %r15d
movl %r13d, %edi
callq 0x16b56
movl %eax, %r13d
movl $0x4003333, %edi        # imm = 0x4003333
movq %rbp, %rsi
movl 0x24(%rsp), %edx
leaq 0x1fad8(%rip), %rcx     # 0x44981
callq 0x5605
testb $0x1f, 0xc(%rsp)
je 0x24f30
movq %r12, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %rbp, %rdx
callq 0x4574
movl %eax, %r14d
leaq 0x332b1(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x24f02
testb $0x40, %al
je 0x24eee
leaq 0x243af(%rip), %rdi     # 0x49293
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
leaq 0x2440d(%rip), %rdi     # 0x49302
movl %r15d, %esi
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
addq $0x2, %rbp
leaq 0x33273(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x24ff8
movzwl %r14w, %esi
leaq 0x20039(%rip), %rdi     # 0x44f5a
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
jmp 0x24ff8
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4d44
movzwl %ax, %r12d
movl %r12d, %eax
shrl $0x3, %eax
movzwl %ax, %r14d
cmpl $0x100, %r12d           # imm = 0x100
jae 0x24fbe
leaq 0x33227(%rip), %rax     # 0x58180
movq (%rax), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x24f8c
testb $0x40, %al
je 0x24f78
leaq 0x23f9a(%rip), %rdi     # 0x48f08
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
leaq 0x2437f(%rip), %rdi     # 0x492fe
movl %r15d, %esi
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
leaq 0x331ed(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x24fb4
shll $0xb, %r14d
movzwl %r14w, %edx
leaq 0x24368(%rip), %rdi     # 0x4930f
movl %r12d, %esi
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
movq 0x10(%rsp), %r12
incq %rbp
jmp 0x24ff8
movl $0x4003333, %edi        # imm = 0x4003333
movq %rbp, %rsi
movl 0x18(%rsp), %edx
leaq 0x1c10b(%rip), %rcx     # 0x410dc
callq 0x5605
leaq 0x242e7(%rip), %rdi     # 0x492c4
movl %r15d, %esi
movl %r12d, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x3120
addl %eax, %r13d
incq %rbp
movq 0x10(%rsp), %r12
incl %r15d
cmpq %rbx, %rbp
jb 0x24e8b
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax), %rbx
addq $0x2, %rbx
leaq 0x33163(%rip), %rax     # 0x58180
movzwl 0x2(%rax), %eax
testl $0x104, %eax            # imm = 0x104
je 0x2506a
movl %r13d, %edi
callq 0x16b56
movl %eax, %r14d
leaq -0x1(%rbp), %rsi
leaq 0x1c09e(%rip), %rcx     # 0x410dc
movl $0x4043333, %edi        # imm = 0x4043333
movq 0x28(%rsp), %rdx
callq 0x5605
leaq 0x24035(%rip), %rdi     # 0x49089
movl 0x20(%rsp), %esi
movq 0x40(%rsp), %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %r14d, %r13d
cmpq %rbx, %rbp
jbe 0x2507b
leaq 0x2401e(%rip), %rdi     # 0x49094
callq 0x5c33
movl %r13d, %edi
callq 0x16b56
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)