// File: /workspace/github_c_makefile_star2_O3/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, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, %r15
movl %edx, %r14d
movq %rdi, %rbx
leaq 0x51866(%rip), %rax     # 0x58180
xorl %ebp, %ebp
testb $0x4, 0x2(%rax)
je 0x6932
leaq 0x3aff4(%rip), %rdi     # 0x4191d
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
jne 0x6947
movq %rbx, %rdi
callq 0x3190
movq %rax, %r15
movzwl %r14w, %r13d
movq %rbx, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x45af
movl %eax, %r12d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r13d, %esi
callq 0x45af
movl %eax, %r14d
leal -0x9(%r12), %eax
cmpw $-0x8, %ax
setb %al
leal -0x9(%r14), %ecx
cmpw $-0x8, %cx
setb %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x69b1
cmpl $0x4949, %r13d          # imm = 0x4949
jne 0x69b9
movq %rbx, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r15, %rdx
callq 0x45af
movw %ax, 0x4(%rsp)
movw $0x4d4d, %ax            # imm = 0x4D4D
jmp 0x69d4
xorl %r13d, %r13d
jmp 0x6b9a
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl $0x4949, %esi           # imm = 0x4949
callq 0x45af
movw %ax, 0x4(%rsp)
movw $0x4949, %ax            # imm = 0x4949
movzwl %r12w, %r15d
movzwl %r14w, %r13d
movzwl %ax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x45af
movw %ax, 0x8(%rsp)
leaq 0x51788(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
jne 0x6a32
leaq 0x42a9a(%rip), %rdi     # 0x4949f
movl $0x0, 0x10(%rsp)
movl %r15d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
leaq 0x3af37(%rip), %rdi     # 0x4195b
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
addl %r15d, %ebp
jmp 0x6a78
xorl %eax, %eax
callq 0x17fea
addl %ebp, %eax
movl %eax, 0x10(%rsp)
leaq 0x3aee4(%rip), %rdi     # 0x4192a
movl %r15d, %esi
movl %r13d, %edx
movl %r15d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
leaq 0x3aedb(%rip), %rdi     # 0x4193e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
addl %r15d, %ebp
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movzwl 0x4(%rsp), %r15d
testw %r15w, %r15w
setne %al
movzwl 0x8(%rsp), %edx
testw %dx, %dx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6b60
cmpw $0x8, %r15w
setb %al
cmpw $0x8, %dx
setb %cl
orb %al, %cl
movw $0x1, %r13w
cmpb $0x1, %cl
jne 0x6b9a
leaq 0x516bf(%rip), %rax     # 0x58180
movq (%rax), %rax
btl $0x12, %eax
jb 0x6b65
testl $0x3003, %eax           # imm = 0x3003
je 0x6b8f
movl %ebp, %edi
callq 0x1707a
movl %eax, %r14d
leaq 0x3ae6f(%rip), %rcx     # 0x41959
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x4, %edx
callq 0x55eb
leaq 0x5167b(%rip), %rax     # 0x58180
testb $0x40, (%rax)
je 0x6b20
leaq 0x3e9da(%rip), %rdi     # 0x454eb
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x4200a(%rip), %rdi     # 0x48b31
movl $0x1b, %esi
movl $0x1b, %edx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
leaq 0x51637(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x6b8f
leaq 0x43a53(%rip), %rdi     # 0x4a5a8
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
jmp 0x6b8f
movl %r15d, %r13d
jmp 0x6b9a
leaq 0x3aded(%rip), %rcx     # 0x41959
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x55eb
xorl %eax, %eax
callq 0x17fea
movl 0x10(%rsp), %edi
subl %eax, %edi
callq 0x5716
movl %r15d, %r12d
movzwl 0x8(%rsp), %eax
movl %eax, %r14d
leal -0x9(%r12), %eax
cmpw $-0x8, %ax
setb %al
leal -0x9(%r14), %ecx
cmpw $-0x8, %cx
setb %r15b
orb %al, %r15b
leaq 0x515c4(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
movzwl %r12w, %r12d
movzwl %r14w, %edx
movl %edx, 0x28(%rsp)
jne 0x6c08
leaq 0x3add5(%rip), %rdi     # 0x419aa
movl $0x0, 0x4(%rsp)
movl %r12d, %esi
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %ebp, %r14d
testb %r15b, %r15b
je 0x6c62
leaq 0x3adb7(%rip), %rdi     # 0x419b0
xorl %eax, %eax
callq 0x3120
addl %r14d, %eax
movl %eax, %r14d
jmp 0x6c45
leaq 0x3ad1b(%rip), %rdi     # 0x4192a
movl %r12d, %esi
movl %r12d, %ecx
movl %edx, %r8d
xorl %eax, %eax
callq 0x3120
movq %r12, %r14
movl %eax, %r12d
addl %ebp, %r12d
testb %r15b, %r15b
je 0x6d90
leaq 0x3ad79(%rip), %rdi     # 0x419b1
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %r12d, %r14d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
je 0x6ef6
movq %rbx, %rdi
callq 0x31b0
jmp 0x6ef6
movl %r13d, 0x1c(%rsp)
leaq 0x3a429(%rip), %rdi     # 0x41097
leaq 0x3aa33(%rip), %rsi     # 0x416a8
xorl %eax, %eax
callq 0x3120
movl $0x5, %edi
callq 0x17a82
movq %rbx, %rdi
callq 0x3190
movq %rax, %r13
movq %r12, %rax
movl %eax, %r12d
movq %r12, %r15
negq %r15
movq %rax, 0x20(%rsp)
movq %r14, 0x8(%rsp)
addl %r14d, %eax
movl %eax, 0x10(%rsp)
movl $0x1, %r14d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4d48
movl %eax, %ebp
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x6d0a
cmpw $0x5, %bp
ja 0x6ee1
movzwl %bp, %edi
callq 0x96c0
cmpq %r12, %r14
jae 0x6cee
movl $0x2c, %edi
callq 0x3060
incq %r13
leaq (%r15,%r14), %rax
incq %rax
incq %r14
cmpq $0x1, %rax
jne 0x6cb4
movl 0x10(%rsp), %eax
movl %eax, %r14d
jmp 0x6d17
movq 0x8(%rsp), %rax
addl %r14d, %eax
decl %eax
movq %rax, %r14
movq %rbx, %rdi
callq 0x3190
movq %rax, %r13
movl 0x4(%rsp), %ebp
incl %ebp
movl 0x28(%rsp), %eax
cmpl %eax, %ebp
jae 0x6d3e
movl $0x3a, %edi
callq 0x3060
movl 0x28(%rsp), %eax
movl %ebp, 0x4(%rsp)
cmpl %eax, %ebp
movq 0x20(%rsp), %rax
jne 0x6ca2
movl $0x27, %edi
callq 0x3060
movl $0x2, %edi
callq 0x17a82
cmpw $0x0, 0x1c(%rsp)
je 0x6c45
leaq 0x3a321(%rip), %rdi     # 0x41097
leaq 0x3ac4a(%rip), %rsi     # 0x419c7
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
callq 0x17a82
jmp 0x6c45
movl %r13d, 0x1c(%rsp)
leaq 0x4380c(%rip), %rdi     # 0x4a5a8
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %r12d, %r13d
movq %rbx, %rdi
callq 0x3190
movq %rax, 0x10(%rsp)
movl %r14d, %ebp
negq %rbp
xorl %eax, %eax
movq %r14, %r15
movq %r14, 0x20(%rsp)
movl %eax, 0x30(%rsp)
movl $0x5b, %edi
callq 0x3060
incl %r13d
movb $0x1, %al
movl %r13d, %r14d
movl %eax, 0x4(%rsp)
leal (%r14,%r15), %eax
movl %eax, 0x34(%rsp)
movq %r14, %rax
xorl %r14d, %r14d
movq 0x10(%rsp), %r13
movq %rax, 0x8(%rsp)
movl %eax, %r15d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4d48
movl %eax, %r12d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x6e4a
cmpw $0x6, %r12w
ja 0x6ec7
movzwl %r12w, %edi
callq 0x96c0
movl $0x2c, %edi
callq 0x3060
incl %r15d
incq %r13
decq %r14
cmpq %r14, %rbp
jne 0x6dfb
movl 0x34(%rsp), %eax
movl %eax, %r14d
jmp 0x6e4d
movl %r15d, %r14d
movl 0x4(%rsp), %eax
testb $0x1, %al
movl $0x0, %eax
movq 0x20(%rsp), %r15
jne 0x6ddc
leaq 0x3ab23(%rip), %rdi     # 0x4198d
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %r14d, %r13d
movq %rbx, %rdi
callq 0x3190
movq %rax, 0x10(%rsp)
movl 0x30(%rsp), %eax
incl %eax
cmpl 0x28(%rsp), %eax
jne 0x6dc6
leaq 0x3aaf9(%rip), %rdi     # 0x41994
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %r13d, %r14d
cmpw $0x0, 0x1c(%rsp)
je 0x6c45
leaq 0x3a1dc(%rip), %rdi     # 0x41097
leaq 0x3aad7(%rip), %rsi     # 0x41999
jmp 0x6d7d
movl $0x3f, %edi
callq 0x3060
movq 0x8(%rsp), %rax
subl %r14d, %eax
movq %rax, %r14
incl %r14d
jmp 0x6ef6
movl $0x3f, %edi
callq 0x3060
movq 0x8(%rsp), %rax
addl %r14d, %eax
movq %rax, %r14
movl %r14d, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17a82