// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movw $0x0, -0x34(%rbp)
movw $0x0, -0x38(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
leaq 0x6f4fc(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x7cab
movq -0x10(%rbp), %rsi
leaq 0x5cc4a(%rip), %rdi     # 0x648e8
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x20(%rbp)
jne 0x7cc5
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x48(%rbp)
jmp 0x7ccd
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %ax
movq -0x48(%rbp), %rdx
movzwl %ax, %esi
callq 0x4480
movw %ax, -0x32(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movzwl -0x12(%rbp), %esi
callq 0x4480
movw %ax, -0x36(%rbp)
movzwl -0x32(%rbp), %eax
cmpl $0x0, %eax
je 0x7d23
movzwl -0x36(%rbp), %eax
cmpl $0x0, %eax
je 0x7d23
movzwl -0x32(%rbp), %eax
cmpl $0x8, %eax
jg 0x7d23
movzwl -0x36(%rbp), %eax
cmpl $0x8, %eax
jle 0x7f6b
movzwl -0x12(%rbp), %eax
cmpl $0x4949, %eax           # imm = 0x4949
jne 0x7d5d
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x4480
movw %ax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4480
movw %ax, -0x38(%rbp)
jmp 0x7d8b
movq -0x8(%rbp), %rdi
movl $0x4949, %esi           # imm = 0x4949
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4480
movw %ax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl $0x4949, %esi           # imm = 0x4949
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4480
movw %ax, -0x38(%rbp)
leaq 0x6f3ee(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x7df4
movb $0x0, %al
callq 0x20a00
addl -0x60(%rbp), %eax
movl %eax, -0x64(%rbp)
movzwl -0x32(%rbp), %esi
movzwl -0x36(%rbp), %edx
movzwl -0x32(%rbp), %ecx
movzwl -0x36(%rbp), %r8d
leaq 0x5cb2f(%rip), %rdi     # 0x648f5
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x5cb2f(%rip), %rdi     # 0x64909
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
jmp 0x7e24
movzwl -0x32(%rbp), %esi
movzwl -0x36(%rbp), %edx
leaq 0x63e7c(%rip), %rdi     # 0x6bc7f
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x5cb0f(%rip), %rdi     # 0x64926
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movzwl -0x34(%rbp), %eax
cmpl $0x0, %eax
jle 0x7f69
movzwl -0x38(%rbp), %eax
cmpl $0x0, %eax
jle 0x7f69
movzwl -0x34(%rbp), %eax
cmpl $0x8, %eax
jl 0x7e54
movzwl -0x38(%rbp), %eax
cmpl $0x8, %eax
jge 0x7f69
movw -0x34(%rbp), %ax
movw %ax, -0x32(%rbp)
movw -0x38(%rbp), %ax
movw %ax, -0x36(%rbp)
leaq 0x6f315(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x7eb0
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
leaq 0x5ca97(%rip), %rcx     # 0x64924
callq 0x5ed0
movb $0x0, %al
callq 0x20a00
movl %eax, %ecx
movl -0x64(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %edi
callq 0x60e0
jmp 0x7f67
leaq 0x6f2c9(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x3003, %rax           # imm = 0x3003
cmpq $0x0, %rax
je 0x7f65
movl -0x60(%rbp), %edi
callq 0x1ef50
movl %eax, -0x60(%rbp)
movl $0x4103333, %edi        # imm = 0x4103333
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x4, %edx
leaq 0x5ca39(%rip), %rcx     # 0x64924
callq 0x5ed0
leaq 0x6f289(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x7f1c
movq -0x28(%rbp), %rsi
leaq 0x5fc6a(%rip), %rdi     # 0x67b79
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x63175(%rip), %rdi     # 0x6b09c
movl $0x1b, %edx
movl %edx, %esi
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq 0x6f23e(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x30, %rax
cmpq $0x0, %rax
je 0x7f63
leaq 0x64dc2(%rip), %rdi     # 0x6cd18
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x7f65
jmp 0x7f67
jmp 0x7f69
jmp 0x7f6b
leaq 0x6f20e(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x814c
movzwl -0x32(%rbp), %esi
movzwl -0x36(%rbp), %edx
movzwl -0x32(%rbp), %ecx
movzwl -0x36(%rbp), %r8d
leaq 0x5c958(%rip), %rdi     # 0x648f5
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movzwl -0x32(%rbp), %eax
cmpl $0x0, %eax
je 0x7fce
movzwl -0x36(%rbp), %eax
cmpl $0x0, %eax
je 0x7fce
movzwl -0x32(%rbp), %eax
cmpl $0x8, %eax
jg 0x7fce
movzwl -0x36(%rbp), %eax
cmpl $0x8, %eax
jle 0x7fe7
leaq 0x5c9a7(%rip), %rdi     # 0x6497c
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x8147
leaq 0x64d2a(%rip), %rdi     # 0x6cd18
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x50(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movzwl -0x36(%rbp), %ecx
cmpl %ecx, %eax
jge 0x811e
movl $0x5b, %edi
callq 0x3050
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
cmpl $0x2, -0x5c(%rbp)
jge 0x80ef
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movzwl -0x32(%rbp), %ecx
cmpl %ecx, %eax
jge 0x80df
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movslq -0x54(%rbp), %rax
addq %rax, %rsi
callq 0x4f20
movw %ax, -0x3a(%rbp)
movq -0x8(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
je 0x8080
jmp 0x80df
movzwl -0x3a(%rbp), %eax
cmpl $0x6, %eax
jg 0x80af
movzwl -0x3a(%rbp), %eax
andl $0xff, %eax
movzwl %ax, %edi
callq 0xb8d0
movl $0x2c, %edi
callq 0x3050
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x80cf
movl $0x3f, %edi
callq 0x3050
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ff00
jmp 0x82e8
jmp 0x80d1
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x8049
jmp 0x80e1
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x8038
leaq 0x5c862(%rip), %rdi     # 0x64958
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x50(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x800f
leaq 0x5c83a(%rip), %rdi     # 0x6495f
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
cmpw $0x0, -0x34(%rbp)
je 0x8145
leaq 0x5c824(%rip), %rdi     # 0x64964
callq 0x6860
jmp 0x8147
jmp 0x82c9
movzwl -0x32(%rbp), %esi
movzwl -0x36(%rbp), %edx
leaq 0x5c81a(%rip), %rdi     # 0x64975
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movzwl -0x32(%rbp), %eax
cmpl $0x0, %eax
je 0x818c
movzwl -0x36(%rbp), %eax
cmpl $0x0, %eax
je 0x818c
movzwl -0x32(%rbp), %eax
cmpl $0x8, %eax
jg 0x818c
movzwl -0x36(%rbp), %eax
cmpl $0x8, %eax
jle 0x81a5
leaq 0x5c7e8(%rip), %rdi     # 0x6497b
movb $0x0, %al
callq 0x3110
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x82c7
callq 0xb9a0
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x50(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movzwl -0x36(%rbp), %ecx
cmpl %ecx, %eax
jge 0x82ad
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movzwl -0x32(%rbp), %ecx
cmpl %ecx, %eax
jge 0x8278
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movslq -0x54(%rbp), %rax
addq %rax, %rsi
callq 0x4f20
movw %ax, -0x3a(%rbp)
movq -0x8(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
je 0x820b
jmp 0x8278
movzwl -0x3a(%rbp), %eax
cmpl $0x6, %eax
jge 0x8248
movzwl -0x3a(%rbp), %eax
andl $0xff, %eax
movzwl %ax, %edi
callq 0xb8d0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movzwl -0x32(%rbp), %ecx
cmpl %ecx, %eax
jge 0x823d
movl $0x2c, %edi
callq 0x3050
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x8268
movl $0x3f, %edi
callq 0x3050
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %edi
callq 0x1ff00
jmp 0x82e8
jmp 0x826a
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x81d4
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x50(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movzwl -0x36(%rbp), %ecx
cmpl %ecx, %eax
jge 0x829d
movl $0x3a, %edi
callq 0x3050
jmp 0x829f
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x81be
callq 0xb9d0
cmpw $0x0, -0x34(%rbp)
je 0x82c5
leaq 0x5c6d2(%rip), %rdi     # 0x64992
callq 0x6860
jmp 0x82c7
jmp 0x82c9
movq -0x8(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
je 0x82e0
movq -0x8(%rbp), %rdi
callq 0x31a0
movl -0x60(%rbp), %edi
callq 0x1ff00
addq $0x70, %rsp
popq %rbp
retq
nop