// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/maker_casio.c
// Function: casio2_offset_makervalue
void
casio2_offset_makervalue(FILE *inptr,unsigned short byteorder,
    struct ifd_entry *entry_ptr,unsigned long fileoffset_base,
    struct image_summary *summary_entry,char *parent_name,char*prefix,
    int indent,int make,int model,int at_offset)
{
    unsigned long value_offset,current_offset;
    unsigned long count;
    unsigned short marker;
    char *nameoftag;
    char *fulldirname = NULL;
    unsigned long max_offset = 0;
    int status = 0;
    int chpr = 0;

    if(entry_ptr)
    {
        nameoftag = maker_tagname(entry_ptr->tag,make,model); 
        fulldirname = splice(parent_name,".",nameoftag);
        value_offset = fileoffset_base + entry_ptr->value;
        count = entry_ptr->count;

        switch(entry_ptr->tag)
        {
            case 0x0004:    /* JpegThumbnailOffset                    */
                /* When this tag is present, the 0x2000 tag is        */
                /* present as well. Both entries point to the same    */
                /* thumbnail, so just print values for length and     */
                /* offset tags, and display the thumbnail on the      */
                /* (self-contained) 0x2000 tag                        */
                if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu",value_offset);
                }
                break;
            case 0x2000:   /* JpegThumbnail                           */
                if(at_offset && (PRINT_SECTION))
                {
                    print_tag_address(SECTION,value_offset,indent,prefix);
                    chpr += printf("# Start of JPEG Thumbnail from MakerNote");
                    chpr += printf(" length %ld",count); 
                }
                else if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu:%lu",value_offset,entry_ptr->count);
                    else
                        chpr += printf("length %lu", entry_ptr->count);
                }
                if((PRINT_SECTION) || (PRINT_SEGMENT))
                    chpr = newline(chpr);
                marker = read_ushort(inptr,TIFF_MOTOROLA,value_offset);
                max_offset = process_jpeg_segments(inptr,value_offset,marker,
                                    count,summary_entry,fulldirname,
                                    prefix,indent+SMALLINDENT);
                if(at_offset)
                {
                    if((PRINT_SECTION))
                    {
                        if((status = jpeg_status(0) == JPEG_EARLY_EOI))
                            chpr = newline(chpr);
                        jpeg_status(status);
                        print_tag_address(VALUE_AT_OFFSET,value_offset + count - 1,
                                                    indent,prefix);
                        chpr += printf("# End of JPEG Thumbnail from MakerNote");
                        if((PRINT_ENTRY) && !(PRINT_VALUE))
                            chpr = newline(chpr);
                    }
                }
                print_jpeg_status();
                if(marker && summary_entry)
                { 
                    /* The new one is on the end of the chain         */
                    if((summary_entry = last_summary_entry(summary_entry)))
                    {
                        summary_entry->filesubformat |= FILESUBFMT_MNOTE;
                        summary_entry->datatype = MAKER_IFD;
                        summary_entry->subfiletype = THUMBNAIL_TYPE;
                    }
                }
                /* make certain we're at the end                      */
                clearerr(inptr);
                fseek(inptr,value_offset + count,SEEK_SET);
                break;
            case 0x0e00: /* PrintIM (Epson Print Image matching)  */
                nameoftag = maker_tagname(entry_ptr->tag,make,model); 
                if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu",value_offset);
                }
                current_offset = ftell(inptr);
                if(process_pim(inptr,byteorder,entry_ptr->value,fileoffset_base,
                    entry_ptr->count,nameoftag,parent_name,prefix,indent) == 0)
                {
                    /* At least one QV4000 image uses a PIM offset    */
                    /* relative to the entry address, even though     */
                    /* other entries in the note are TIFF-relative;   */
                    /* check for a PIM entry at that location if the  */
                    /* previous one failed. GROSS HACK!               */
                    fileoffset_base = current_offset - 12;
                    PUSHCOLOR(HI_BLACK);
                    /* We've already seen an error message            */
                    chpr += printf(" checking for entry-relative offset bug");
                    POPCOLOR();
                    if(process_pim(inptr,byteorder,entry_ptr->value,fileoffset_base,
                                    entry_ptr->count,nameoftag,parent_name,
                                    prefix,indent))
                    {
                        if(!(PRINT_OFFSET))
                        {
                            chpr = newline(chpr);
                            chpr += printf("# WARNING:");
                        }
                        PUSHCOLOR(HI_BLACK);
                        chpr += printf(" PrintImage data found at offset %lu - ",
                                                    entry_ptr->value + fileoffset_base);
                        printred("start offset is incorrect!");
                        POPCOLOR();
                        if(!(PRINT_SECTION))
                        {
                            chpr = newline(chpr);
                            print_tag_address(VALUE_AT_OFFSET,entry_ptr->value + fileoffset_base,
                                                        indent,"-");
                            if((PRINT_TAGINFO))
                            {
                                if((PRINT_LONGNAMES))
                                    chpr += printf("%s.",fulldirname);
                                chpr += printf("%-*.*s",MAKERTAGWIDTH,MAKERTAGWIDTH,nameoftag);
                            }
                            if((PRINT_VALUE))
                                chpr += printf(" = @%lu",entry_ptr->value + fileoffset_base);
                        }
                    }
                }
                break;
            default:
                print_generic_offset_makervalue(inptr,byteorder,entry_ptr,
                                        fileoffset_base,fulldirname,prefix,indent,
                                        make,model,at_offset);
                break;
        }
        if(fulldirname)
            free(fulldirname);
    }
    setcharsprinted(chpr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rdx, %rdx
je 0x31f97
movq %r9, %r13
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, %r15d
movq %r8, 0x18(%rsp)
movq %rdi, 0x30(%rsp)
movl 0x90(%rsp), %eax
movq %rax, 0x8(%rsp)
movl 0x88(%rsp), %r12d
movl 0x80(%rsp), %ebp
movl 0x78(%rsp), %eax
movq %rax, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x28(%rsp)
movzwl (%rdx), %edi
movl %ebp, %esi
movl %r12d, %edx
callq 0x1c518
leaq 0xfa7b(%rip), %rsi      # 0x41997
movq %r13, %rdi
movq %rax, %rdx
callq 0x17f99
movq %rax, %r8
movq 0x10(%r14), %rsi
addq %rbx, %rsi
movzwl (%r14), %eax
cmpl $0x2000, %eax           # imm = 0x2000
je 0x31fd2
cmpl $0xe00, %eax            # imm = 0xE00
je 0x31f9e
cmpl $0x4, %eax
jne 0x32043
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
jne 0x323dc
leaq 0x2621c(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testl $0x300, %eax            # imm = 0x300
setne %al
orb %cl, %al
jne 0x323dc
leaq 0x168a9(%rip), %rdi     # 0x4882c
xorl %eax, %eax
movq %r8, %rbx
callq 0x3120
movq %rbx, %r8
movl %eax, %ebp
jmp 0x323dc
xorl %ebp, %ebp
jmp 0x323e9
movq %rsi, (%rsp)
movq %r8, 0x10(%rsp)
movl $0xe00, %edi            # imm = 0xE00
movl %ebp, %esi
movl %r12d, %edx
callq 0x1c518
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
je 0x32078
movq 0x30(%rsp), %r12
jmp 0x320ac
movq 0x8(%r14), %rax
movq %rax, (%rsp)
leaq 0x2619f(%rip), %r14     # 0x58180
movq (%r14), %rax
cmpl $0x0, 0x8(%rsp)
movq %r8, 0x10(%rsp)
je 0x32169
btl $0x12, %eax
movq 0x20(%rsp), %r15
jae 0x32197
movl $0x40000, %edi          # imm = 0x40000
movq %rsi, %r12
movl %r15d, %edx
movq 0x28(%rsp), %rcx
callq 0x55eb
leaq 0x18041(%rip), %rdi     # 0x4a060
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x18081(%rip), %rdi     # 0x4a0b0
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %ebx, %ebp
jmp 0x3229a
movzwl %r15w, %esi
movq 0x30(%rsp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
movq %r8, %rbx
movq 0x28(%rsp), %r9
pushq 0x8(%rsp)
pushq %r12
pushq %rbp
pushq 0x38(%rsp)
callq 0x19706
movq %rbx, %r8
addq $0x20, %rsp
xorl %ebp, %ebp
jmp 0x323dc
leaq 0x26101(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testl $0x300, %eax            # imm = 0x300
setne %al
orb %cl, %al
movq 0x30(%rsp), %r12
jne 0x320ac
leaq 0x1678d(%rip), %rdi     # 0x4882c
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
movq %r12, %rdi
callq 0x3190
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %r8
movq 0x10(%r14), %rdx
subq $0x8, %rsp
movzwl %r15w, %esi
movq %r12, %rdi
movl %esi, 0x8(%rsp)
movq %rbx, %rcx
movq 0x20(%rsp), %r15
movq %r15, %r9
movq 0x28(%rsp), %r12
pushq %r12
movq 0x38(%rsp), %rbx
pushq %rbx
pushq %r13
callq 0x1337a
addq $0x20, %rsp
testq %rax, %rax
jne 0x323d7
movq 0x8(%rsp), %rbx
addq $-0xc, %rbx
leaq 0x194f4(%rip), %rdi     # 0x4b600
xorl %eax, %eax
callq 0x3120
addl %ebp, %eax
movl %eax, %ebp
movq 0x8(%r14), %r8
movq 0x10(%r14), %rdx
subq $0x8, %rsp
movq 0x38(%rsp), %rdi
movl 0x8(%rsp), %esi
movq %rbx, 0x10(%rsp)
movq %rbx, %rcx
movq %r15, %r9
pushq %r12
pushq 0x38(%rsp)
pushq %r13
callq 0x1337a
addq $0x20, %rsp
testq %rax, %rax
je 0x323d7
leaq 0x26028(%rip), %r15     # 0x58180
testb $0x3, 0x1(%r15)
je 0x321a1
movq 0x8(%rsp), %rbx
movl %ebp, %r12d
jmp 0x321c3
testb $0x30, %al
movq 0x20(%rsp), %r15
je 0x32197
testl $0x300, %eax            # imm = 0x300
je 0x32283
movq %rsi, %r12
leaq 0x165d4(%rip), %rdi     # 0x4875b
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x32298
movq %rsi, %r12
xorl %ebp, %ebp
jmp 0x3229a
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebx
leaq 0x13266(%rip), %rdi     # 0x45417
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %ebx, %r12d
movq 0x8(%rsp), %rbx
movq 0x10(%r14), %rsi
addq %rbx, %rsi
leaq 0x19492(%rip), %rdi     # 0x4b663
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r12d, %ebp
leaq 0x19464(%rip), %rdi     # 0x4b648
callq 0x5c26
testb $0x4, 0x2(%r15)
jne 0x323d7
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movq 0x10(%r14), %rsi
addq %rbx, %rsi
leaq 0xeeee(%rip), %rcx      # 0x410f9
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x20(%rsp), %rdx
callq 0x55eb
movq (%r15), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x3225f
testb $0x40, %al
je 0x3223d
leaq 0x132bc(%rip), %rdi     # 0x454eb
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
leaq 0x168ed(%rip), %rdi     # 0x48b31
movl $0x19, %esi
movl $0x19, %edx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
movq (%r15), %rax
testb $0x30, %al
je 0x323d7
addq 0x10(%r14), %rbx
leaq 0x165b7(%rip), %rdi     # 0x48829
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
jmp 0x323d7
leaq 0x12f1c(%rip), %rdi     # 0x451a6
movq %rsi, %r12
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
testb $0xc, 0x2(%r14)
je 0x322aa
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movq 0x30(%rsp), %r13
movq %r13, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r12, %rdx
callq 0x45af
movl %eax, %ebx
leal 0x2(%r15), %eax
movzwl %bx, %edx
movq %r13, %rdi
movq %r12, %r13
movq %r12, %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r15
movq %r15, %r8
movq 0x10(%rsp), %r9
pushq %rax
pushq 0x30(%rsp)
callq 0x11455
addq $0x10, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x3237d
testb $0x4, 0x2(%r14)
je 0x3237d
xorl %edi, %edi
callq 0x1336d
xorl %r15d, %r15d
cmpl $0x1, %eax
sete %r15b
jne 0x3231e
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movl %ebp, %r12d
movl %r15d, %edi
callq 0x1336d
movq (%rsp), %rax
leaq (%rax,%r13), %rsi
decq %rsi
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0x55eb
leaq 0x17d3a(%rip), %rdi     # 0x4a089
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r12d, %ebp
movq (%r14), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x32378
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movq 0x18(%rsp), %r15
xorl %eax, %eax
callq 0x9734
testw %bx, %bx
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x323b9
movq %r15, %rdi
callq 0xfed1
testq %rax, %rax
je 0x323b9
orb $0x1, 0x19(%rax)
movl $0x5, 0x118(%rax)
movl $0x2, 0xc4(%rax)
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x31b0
addq (%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3210
movq 0x10(%rsp), %r8
testq %r8, %r8
je 0x323e9
movq %r8, %rdi
callq 0x3050
movl %ebp, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17a82