// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %r9, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, %r15
movl %edx, %r14d
movq %rdi, %rbx
leaq 0x518de(%rip), %rax     # 0x58180
xorl %ebp, %ebp
testb $0x4, 0x2(%rax)
je 0x68ba
leaq 0x3b06c(%rip), %rdi     # 0x4191d
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
jne 0x68cf
movq %rbx, %rdi
callq 0x3190
movq %rax, %r15
movzwl %r14w, %r13d
movq %rbx, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x4574
movl %eax, %r12d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4574
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
movq %rbx, 0x8(%rsp)
jne 0x693e
cmpl $0x4949, %r13d          # imm = 0x4949
jne 0x6946
movq %rbx, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r15, %rdx
callq 0x4574
movw %ax, 0x18(%rsp)
movw $0x4d4d, %ax            # imm = 0x4D4D
jmp 0x6961
xorl %r13d, %r13d
jmp 0x6b22
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl $0x4949, %esi           # imm = 0x4949
callq 0x4574
movw %ax, 0x18(%rsp)
movw $0x4949, %ax            # imm = 0x4949
movzwl %r12w, %r15d
movzwl %r14w, %r13d
movzwl %ax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x4574
movw %ax, 0x14(%rsp)
leaq 0x517fb(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
jne 0x69bf
leaq 0x42acd(%rip), %rdi     # 0x4945f
movl $0x0, 0x20(%rsp)
movl %r15d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
leaq 0x3afaa(%rip), %rdi     # 0x4195b
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
addl %r15d, %ebp
jmp 0x6a05
xorl %eax, %eax
callq 0x17a98
addl %ebp, %eax
movl %eax, 0x20(%rsp)
leaq 0x3af57(%rip), %rdi     # 0x4192a
movl %r15d, %esi
movl %r13d, %edx
movl %r15d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
leaq 0x3af4e(%rip), %rdi     # 0x4193e
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
addl %r15d, %ebp
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movzwl 0x18(%rsp), %ebx
testw %bx, %bx
setne %al
movzwl 0x14(%rsp), %r15d
testw %r15w, %r15w
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6aed
cmpw $0x8, %bx
setb %al
cmpw $0x8, %r15w
setb %cl
orb %al, %cl
movw $0x1, %r13w
cmpb $0x1, %cl
jne 0x6b22
leaq 0x51732(%rip), %rax     # 0x58180
movq (%rax), %rax
btl $0x12, %eax
jb 0x6af2
testl $0x3003, %eax           # imm = 0x3003
je 0x6b1c
movl %ebp, %edi
callq 0x16b56
movl %eax, %r14d
leaq 0x3aee2(%rip), %rcx     # 0x41959
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x4, %edx
callq 0x5605
leaq 0x516ee(%rip), %rax     # 0x58180
testb $0x40, (%rax)
je 0x6aad
leaq 0x3ea09(%rip), %rdi     # 0x454a7
movq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
leaq 0x4203d(%rip), %rdi     # 0x48af1
movl $0x1b, %esi
movl $0x1b, %edx
movq 0x38(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
leaq 0x516aa(%rip), %rax     # 0x58180
testb $0x30, (%rax)
je 0x6b1c
leaq 0x43a86(%rip), %rdi     # 0x4a568
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
jmp 0x6b1c
movl %ebx, %r13d
jmp 0x6b22
leaq 0x3ae60(%rip), %rcx     # 0x41959
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x5605
xorl %eax, %eax
callq 0x17a98
movl 0x20(%rsp), %edi
subl %eax, %edi
callq 0x5730
movl %ebx, %r12d
movl %r15d, %r14d
leal -0x9(%r12), %eax
cmpw $-0x8, %ax
setb %al
leal -0x9(%r14), %ecx
cmpw $-0x8, %cx
setb %bl
orb %al, %bl
leaq 0x5163e(%rip), %rax     # 0x58180
testb $0x4, 0x2(%rax)
movzwl %r12w, %r12d
movzwl %r14w, %r15d
jne 0x6b84
leaq 0x3ae53(%rip), %rdi     # 0x419aa
movl %r12d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %ebp, %r14d
testb %bl, %bl
je 0x6bcf
leaq 0x3ae3b(%rip), %rdi     # 0x419b0
xorl %eax, %eax
callq 0x3120
addl %r14d, %eax
movl %eax, %r14d
jmp 0x6bc5
movl %r13d, 0x30(%rsp)
leaq 0x3ad9a(%rip), %rdi     # 0x4192a
movl %r12d, %esi
movl %r15d, %edx
movl %r12d, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %ebp, %r13d
testb %bl, %bl
je 0x6d17
leaq 0x3adf9(%rip), %rdi     # 0x419b1
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %r13d, %r14d
movq 0x8(%rsp), %rbx
jmp 0x6e80
movl %r13d, 0x30(%rsp)
leaq 0x3a4bc(%rip), %rdi     # 0x41097
leaq 0x3aac6(%rip), %rsi     # 0x416a8
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3120
movl $0x5, %edi
callq 0x17530
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3190
testl %r15d, %r15d
je 0x6ce4
movq %rax, %r13
movl %r15d, %eax
movl %r12d, %r15d
movq %r15, 0x38(%rsp)
negq %r15
movq %r12, 0x18(%rsp)
movl %eax, 0x14(%rsp)
testl %r12d, %r12d
je 0x6cb0
movl %ebp, 0x20(%rsp)
leal (%r14,%r12), %eax
movl %eax, 0x2c(%rsp)
movl $0x1, %ebx
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x4d44
movl %eax, %ebp
movq %r12, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x6c9c
cmpw $0x5, %bp
ja 0x6e33
movzwl %bp, %edi
callq 0x9595
cmpq 0x38(%rsp), %rbx
jae 0x6c80
movl $0x2c, %edi
callq 0x3060
incq %r13
leaq (%r15,%rbx), %rax
incq %rax
incq %rbx
cmpq $0x1, %rax
jne 0x6c3f
movl 0x2c(%rsp), %eax
movl %eax, %r14d
jmp 0x6ca2
addl %ebx, %r14d
decl %r14d
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r12
movl 0x20(%rsp), %ebp
movq %rbx, %rdi
callq 0x3190
movq %rax, %r13
incl %ebp
movl 0x14(%rsp), %eax
cmpl %eax, %ebp
jae 0x6cdc
movl $0x3a, %edi
movl %ebp, %ebx
movl %eax, %ebp
callq 0x3060
movl %ebp, %eax
movl %ebx, %ebp
movq 0x8(%rsp), %rbx
cmpl %eax, %ebp
jne 0x6c25
movl $0x27, %edi
callq 0x3060
movl $0x2, %edi
callq 0x17530
cmpw $0x0, 0x30(%rsp)
je 0x6e80
leaq 0x3a38c(%rip), %rdi     # 0x41097
leaq 0x3acb5(%rip), %rsi     # 0x419c7
jmp 0x6e72
leaq 0x4384a(%rip), %rdi     # 0x4a568
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %r13d, %r14d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3190
movq %rax, 0x38(%rsp)
testl %r15d, %r15d
je 0x6e42
movl %r12d, %eax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
movq %r12, 0x18(%rsp)
movl %r15d, 0x14(%rsp)
movl %eax, 0x44(%rsp)
movl $0x5b, %edi
callq 0x3060
incl %r14d
xorl %r15d, %r15d
testl %r12d, %r12d
je 0x6dda
leal (%r14,%r12), %eax
movl %eax, 0x2c(%rsp)
movq 0x20(%rsp), %r12
movq 0x38(%rsp), %rbp
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4d44
movl %eax, %r13d
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x6dd0
cmpw $0x6, %r13w
ja 0x6e24
movzwl %r13w, %edi
callq 0x9595
movl $0x2c, %edi
callq 0x3060
incl %r14d
incq %rbp
decq %r12
jne 0x6d85
movl 0x2c(%rsp), %eax
movl %eax, %r14d
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r12
leal 0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
je 0x6d6e
leaq 0x3aba0(%rip), %rdi     # 0x4198d
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
movq %rbx, %rdi
callq 0x3190
movq %rax, 0x38(%rsp)
movl 0x44(%rsp), %eax
incl %eax
movl %ebp, %r14d
movl 0x14(%rsp), %r15d
cmpl %r15d, %eax
movl 0x30(%rsp), %r13d
jne 0x6d5a
jmp 0x6e4a
movl $0x3f, %edi
callq 0x3060
incl %r14d
jmp 0x6e94
movl $0x3f, %edi
callq 0x3060
addl %ebx, %r14d
jmp 0x6e94
movl %r14d, %ebp
movl 0x30(%rsp), %r13d
leaq 0x3ab43(%rip), %rdi     # 0x41994
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %ebp, %r14d
testw %r13w, %r13w
je 0x6e80
leaq 0x3a22c(%rip), %rdi     # 0x41097
leaq 0x3ab27(%rip), %rsi     # 0x41999
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
callq 0x17530
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
je 0x6e94
movq %rbx, %rdi
callq 0x31b0
movl %r14d, %edi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17530