// File: /workspace/github_c_makefile_star2_O2/hfiguiere[P]exifprobe/print.c
// Function: print_cfapattern
void
print_cfapattern(FILE *inptr,unsigned long count,unsigned short byteorder,
                    unsigned long offset,char *parent_name,char *nameoftag)
{
    unsigned short horiz_repeat;
    unsigned short hr = 0;
    unsigned short vert_repeat;
    unsigned short vr = 0;
    unsigned short color;
    unsigned long cfaoffset,hoffset;
    int h,v,show;
    int chpr = 0;
    int curindent = 0;

#define MAX_REPEAT  8
#define MAX_COLOR   6
    if((PRINT_SECTION))
        chpr += printf("length %lu: ",count);
    if(offset == HERE)
        cfaoffset = ftell(inptr);
    else
        cfaoffset = offset;
    horiz_repeat = read_ushort(inptr,byteorder,cfaoffset);
    vert_repeat = read_ushort(inptr,byteorder,HERE);

    if((horiz_repeat == 0) || (vert_repeat == 0) ||
        (horiz_repeat > MAX_REPEAT) || (vert_repeat > MAX_REPEAT))
    {
        /* This section checks for possible byteorder reversal in the */
        /* repeat counts.                                             */
        if(byteorder == TIFF_INTEL)
        {
            hr = read_ushort(inptr,TIFF_MOTOROLA,cfaoffset);
            vr = read_ushort(inptr,TIFF_MOTOROLA,HERE);
        }
        else
        {
            hr = read_ushort(inptr,TIFF_INTEL,HERE);
            vr = read_ushort(inptr,TIFF_INTEL,HERE);
        }
        if(PRINT_SECTION)
        {
            curindent = charsprinted() + chpr;
            chpr += printf("H=%#x/%u, V=%#x/%u ",horiz_repeat,vert_repeat,
                                                 horiz_repeat,vert_repeat);
            PUSHCOLOR(RED);
            chpr += printf(" (INVALID or BYTE SWAPPED!)*");
            POPCOLOR();
            chpr = newline(chpr);
        }
        else
        {
            PUSHCOLOR(RED);
            chpr += printf("%ux%u",horiz_repeat,vert_repeat);
            chpr += printf(" # WARNING: repeat counts INVALID or BYTE SWAPPED");
            POPCOLOR();
        }
        if((hr > 0) && (vr > 0) &&
            ((hr < MAX_REPEAT) || (vr < MAX_REPEAT)))
        {
            horiz_repeat = hr;
            vert_repeat = vr;
            if(PRINT_SECTION)
            {
                print_tag_address(ENTRY|APP_ENTRY,HERE,0,"*");
                curindent -= charsprinted();
                putindent(curindent);
            }
            else if(PRINT_TAGINFO)
            {
                chpr = newline(chpr);
                print_tag_address(ENTRY|APP_ENTRY,HERE,MEDIUMINDENT,"*");
                if((PRINT_LONGNAMES))
                    chpr += printf("%s.",parent_name);
                chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,nameoftag);
                if((PRINT_VALUE))
                    chpr += printf(" = ");
            }
        }
    }
    if(PRINT_SECTION)
    {
        chpr += printf("H=%#x/%u, V=%#x/%u ",horiz_repeat,vert_repeat,
                                             horiz_repeat,vert_repeat);
        /* Some sanity checks                                             */
        if((horiz_repeat == 0) || (vert_repeat == 0) ||
            (horiz_repeat > MAX_REPEAT) || (vert_repeat > MAX_REPEAT))
        {
            PUSHCOLOR(RED);
            chpr += printf(" INVALID REPEAT COUNT");
            POPCOLOR();
        }
        else
        {
            chpr += printf(" = ");
            hoffset = ftell(inptr);
            for(v = 0; v < vert_repeat; ++v)
            {
                putchar('[');
                ++chpr;
                /* show 2 repetitions */
                for(show = 0; show < 2; ++show)
                {
                    for(h = 0; h < horiz_repeat; ++h)
                    {
                        color = read_ubyte(inptr,hoffset+h);
                        if(ferror(inptr))
                            break;
                        if(color <= MAX_COLOR)
                        {
                            putcolorchar(color & 0xff);
                            putchar(',');
                            ++chpr;
                        }
                        else
                        {
                            putchar('?');
                            ++chpr;
                            setcharsprinted(chpr);
                            return;
                        }
                    }
                }
                chpr += printf(" ...],");
                hoffset = ftell(inptr);
            }
            chpr += printf(" ...");
            if(hr)
                printred(" (BYTE SWAPPED) ");
        }
    }
    else
    {
        chpr += printf("%dx%d",horiz_repeat,vert_repeat);
        if((horiz_repeat == 0) || (vert_repeat == 0) ||
            (horiz_repeat > MAX_REPEAT) || (vert_repeat > MAX_REPEAT))
        {
            PUSHCOLOR(RED);
            chpr += printf("# INVALID REPEAT COUNT");
            POPCOLOR();
        }
        else
        {
            print_startvalue();
            hoffset = ftell(inptr);
            for(v = 0; v < vert_repeat; ++v)
            {
                for(h = 0; h < horiz_repeat; ++h)
                {
                    color = read_ubyte(inptr,hoffset+h);
                    if(ferror(inptr))
                        break;
                    if(color < MAX_COLOR)
                    {
                        putcolorchar(color & 0xff);
                        if((h + 1) < horiz_repeat)
                            putchar(',');
                        ++chpr;
                    }
                    else
                    {
                        putchar('?');
                        ++chpr;
                        setcharsprinted(chpr);
                        return;
                    }
                }
                hoffset = ftell(inptr);
                if((v + 1) < vert_repeat)
                    putchar(':');
            }
            print_endvalue();
            if(hr)
                printred(" # BYTE SWAPPED");
        }
    }
    if(ferror(inptr))
        clearerr(inptr);
    setcharsprinted(chpr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, %r14
movl %edx, %r13d
movq %rdi, %rbx
leaq 0x50e04(%rip), %rax     # 0x57180
xorl %ebp, %ebp
testb $0x4, 0x2(%rax)
je 0x6394
leaq 0x39592(%rip), %rdi     # 0x3f91d
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r14
jne 0x63a9
movq %rbx, %rdi
callq 0x3190
movq %rax, %r14
movzwl %r13w, %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x416a
movl %eax, %r12d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r15d, %esi
callq 0x416a
movl %eax, %r15d
leal -0x9(%r12), %eax
cmpw $-0x8, %ax
setb %al
leal -0x9(%r15), %ecx
cmpw $-0x8, %cx
setb %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x6412
cmpw $0x4949, %r13w          # imm = 0x4949
jne 0x641f
movq %rbx, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r14, %rdx
callq 0x416a
movw %ax, 0x8(%rsp)
movw $0x4d4d, %ax            # imm = 0x4D4D
jmp 0x643a
movl $0x0, 0x4(%rsp)
jmp 0x6605
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl $0x4949, %esi           # imm = 0x4949
callq 0x416a
movw %ax, 0x8(%rsp)
movw $0x4949, %ax            # imm = 0x4949
movzwl %r12w, %r14d
movzwl %r15w, %r13d
movzwl %ax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x416a
movw %ax, 0x10(%rsp)
leaq 0x50d22(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
jne 0x6497
leaq 0x40fe4(%rip), %rdi     # 0x4744f
movl $0x0, (%rsp)
movl %r14d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
leaq 0x394d2(%rip), %rdi     # 0x3f95b
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
addl %r14d, %ebp
jmp 0x64dc
xorl %eax, %eax
callq 0x16f6e
addl %ebp, %eax
movl %eax, (%rsp)
leaq 0x39480(%rip), %rdi     # 0x3f92a
movl %r14d, %esi
movl %r13d, %edx
movl %r14d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
leaq 0x39477(%rip), %rdi     # 0x3f93e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
addl %r14d, %ebp
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movzwl 0x8(%rsp), %r13d
testw %r13w, %r13w
setne %al
movzwl 0x10(%rsp), %r14d
testw %r14w, %r14w
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x65cd
cmpw $0x8, %r13w
setb %al
cmpw $0x8, %r14w
setb %cl
orb %al, %cl
movw $0x1, %ax
movl %eax, 0x4(%rsp)
cmpb $0x1, %cl
jne 0x6605
leaq 0x50c55(%rip), %rax     # 0x57180
movq (%rax), %rax
btl $0x12, %eax
jb 0x65d6
testw $0x3003, %ax            # imm = 0x3003
je 0x65ff
movl %ebp, %edi
callq 0x160f7
movl %eax, %r14d
leaq 0x39406(%rip), %rcx     # 0x3f959
pushq $0x4
popq %rdx
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5100
leaq 0x50c14(%rip), %rax     # 0x57180
testb $0x40, (%rax)
je 0x6587
leaq 0x3cf2f(%rip), %rdi     # 0x434a7
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x40553(%rip), %rdi     # 0x46ae1
pushq $0x1b
popq %rdx
movl %edx, %esi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
leaq 0x50bd5(%rip), %rax     # 0x57180
testb $0x30, (%rax)
je 0x65c0
leaq 0x41fa1(%rip), %rdi     # 0x48558
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
movl %r13d, %r12d
movzwl 0x10(%rsp), %eax
movl %eax, %r15d
jmp 0x6605
movl %r13d, %eax
movl %eax, 0x4(%rsp)
jmp 0x6605
leaq 0x3937c(%rip), %rcx     # 0x3f959
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x5100
xorl %eax, %eax
callq 0x16f6e
movl (%rsp), %edi
subl %eax, %edi
callq 0x521b
movl %r13d, %r12d
movl %r14d, %r15d
leal -0x9(%r12), %eax
cmpw $-0x8, %ax
setb %al
leal -0x9(%r15), %ecx
cmpw $-0x8, %cx
setb %r14b
orb %al, %r14b
leaq 0x50b59(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
movzwl %r12w, %r13d
movzwl %r15w, %edx
movl %edx, 0x20(%rsp)
jne 0x666b
leaq 0x3936a(%rip), %rdi     # 0x3f9aa
movl %r13d, %esi
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %ebp, %r12d
testb %r14b, %r14b
je 0x66c2
leaq 0x39354(%rip), %rdi     # 0x3f9b0
xorl %eax, %eax
callq 0x3120
addl %r12d, %eax
movl %eax, %r12d
jmp 0x66a5
leaq 0x392b8(%rip), %rdi     # 0x3f92a
movl %r13d, %esi
movl %r13d, %ecx
movl %edx, %r8d
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %ebp, %r15d
testb %r14b, %r14b
je 0x6781
leaq 0x39319(%rip), %rdi     # 0x3f9b1
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %r15d, %r12d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
je 0x689f
movq %rbx, %rdi
callq 0x31b0
jmp 0x689f
callq 0x8f81
movq %rbx, %rdi
callq 0x3190
movq %rax, %rbp
movq %r13, 0x10(%rsp)
movl %r13d, %r13d
movl 0x20(%rsp), %eax
xorl %r14d, %r14d
cmpl %eax, %r14d
je 0x68b5
movq %r14, 0x18(%rsp)
movq 0x10(%rsp), %rax
addl %r12d, %eax
movl %eax, 0x8(%rsp)
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x6744
leaq (%r14,%rbp), %rsi
movq %rbx, %rdi
callq 0x48de
movl %eax, %r15d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x674d
cmpw $0x5, %r15w
ja 0x6891
movzwl %r15w, %edi
callq 0x8f48
incq %r14
cmpq %r13, %r14
jae 0x66fe
pushq $0x2c
popq %rdi
callq 0x3060
jmp 0x66fe
movl 0x8(%rsp), %eax
movl %eax, %r12d
jmp 0x6750
addl %r14d, %r12d
movq %rbx, %rdi
callq 0x3190
movq %rax, %rbp
movq 0x18(%rsp), %r14
incl %r14d
movl 0x20(%rsp), %eax
cmpl %eax, %r14d
jae 0x66e1
pushq $0x3a
popq %rdi
callq 0x3060
movl 0x20(%rsp), %eax
jmp 0x66e1
leaq 0x41dd0(%rip), %rdi     # 0x48558
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %r15d, %r12d
movq %rbx, %rdi
callq 0x3190
movq %rax, 0x8(%rsp)
movl %r13d, %r14d
negq %r14
pushq $0x5b
popq %rdi
xorl %eax, %eax
movq %r13, 0x10(%rsp)
cmpl 0x20(%rsp), %eax
je 0x68cf
movl %eax, 0x2c(%rsp)
callq 0x3060
incl %r12d
xorl %eax, %eax
cmpl $0x2, %eax
je 0x6849
movl %eax, 0x18(%rsp)
leal (%r12,%r13), %eax
movl %eax, (%rsp)
movq 0x8(%rsp), %rbp
movq %r12, %rax
xorl %r12d, %r12d
movq %rax, 0x30(%rsp)
movl %eax, %r13d
cmpq %r12, %r14
je 0x682f
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x48de
movl %eax, %r15d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x6839
cmpw $0x6, %r15w
ja 0x687a
movzwl %r15w, %edi
callq 0x8f48
pushq $0x2c
popq %rdi
callq 0x3060
incl %r13d
decq %r12
incq %rbp
jmp 0x67ed
movl 0x18(%rsp), %eax
movl (%rsp), %r13d
jmp 0x683d
movl 0x18(%rsp), %eax
incl %eax
movl %r13d, %r12d
movq 0x10(%rsp), %r13
jmp 0x67ca
leaq 0x3913d(%rip), %rdi     # 0x3f98d
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r12d, %ebp
movq %rbx, %rdi
callq 0x3190
movq %rax, 0x8(%rsp)
movl 0x2c(%rsp), %eax
incl %eax
movl %ebp, %r12d
pushq $0x5b
popq %rdi
jmp 0x67b2
pushq $0x3f
popq %rdi
callq 0x3060
movq 0x30(%rsp), %rax
subl %r12d, %eax
incl %eax
movl %eax, %r12d
jmp 0x689f
pushq $0x3f
popq %rdi
callq 0x3060
addl %r14d, %r12d
incl %r12d
movl %r12d, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16a4f
callq 0x8fa0
cmpw $0x0, 0x4(%rsp)
je 0x66a5
leaq 0x390fa(%rip), %rdi     # 0x3f9c7
jmp 0x68f9
leaq 0x390be(%rip), %rdi     # 0x3f994
xorl %eax, %eax
callq 0x3120
movq %r12, %rcx
movl %eax, %r12d
addl %ecx, %r12d
cmpw $0x0, 0x4(%rsp)
je 0x66a5
leaq 0x390a0(%rip), %rdi     # 0x3f999
callq 0x56e2
jmp 0x66a5