// File: /workspace/github_c_makefile_star2_O2/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 0x30572
movq %r9, %r13
movq %rcx, %r14
movq %rdx, %rbx
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 0x1b2e4
leaq 0xf49e(%rip), %rsi      # 0x3f997
movq %r13, %rdi
movq %rax, %rdx
callq 0x16f1d
movq %rax, %r8
movq 0x10(%rbx), %rsi
addq %r14, %rsi
movzwl (%rbx), %eax
cmpl $0x2000, %eax           # imm = 0x2000
je 0x305ad
cmpl $0xe00, %eax            # imm = 0xE00
je 0x30579
cmpl $0x4, %eax
jne 0x30620
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
jne 0x309b4
leaq 0x26c40(%rip), %rax     # 0x57180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testw $0x300, %ax             # imm = 0x300
setne %al
orb %cl, %al
jne 0x309b4
leaq 0x1627e(%rip), %rdi     # 0x467dc
xorl %eax, %eax
movq %r8, %rbx
callq 0x3120
movq %rbx, %r8
movl %eax, %ebp
jmp 0x309b4
xorl %ebp, %ebp
jmp 0x309bc
movq %rsi, (%rsp)
movq %r8, 0x10(%rsp)
movl $0xe00, %edi            # imm = 0xE00
movl %ebp, %esi
movl %r12d, %edx
callq 0x1b2e4
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
je 0x30655
movq 0x30(%rsp), %r12
jmp 0x30688
movq 0x8(%rbx), %rax
movq %rax, (%rsp)
leaq 0x26bc4(%rip), %rbx     # 0x57180
movq (%rbx), %rax
cmpl $0x0, 0x8(%rsp)
movq %r8, 0x10(%rsp)
je 0x30746
btl $0x12, %eax
movq 0x20(%rsp), %r15
jae 0x30773
movl $0x40000, %edi          # imm = 0x40000
movq %rsi, %r12
movl %r15d, %edx
movq 0x28(%rsp), %rcx
callq 0x5100
leaq 0x17a16(%rip), %rdi     # 0x48010
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
leaq 0x17a55(%rip), %rdi     # 0x48060
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
jmp 0x30871
movzwl %r15w, %esi
movq 0x30(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movq %r8, %rbx
movq 0x28(%rsp), %r9
pushq 0x8(%rsp)
pushq %r12
pushq %rbp
pushq 0x38(%rsp)
callq 0x185a8
movq %rbx, %r8
addq $0x20, %rsp
xorl %ebp, %ebp
jmp 0x309b4
leaq 0x26b24(%rip), %rax     # 0x57180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testw $0x300, %ax             # imm = 0x300
setne %al
orb %cl, %al
movq 0x30(%rsp), %r12
jne 0x30688
leaq 0x16161(%rip), %rdi     # 0x467dc
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
movq %r12, %rdi
callq 0x3190
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %r8
movq 0x10(%rbx), %rdx
subq $0x8, %rsp
movzwl %r15w, %esi
movq %r12, %rdi
movl %esi, 0x8(%rsp)
movq %r14, %rcx
movq 0x20(%rsp), %r15
movq %r15, %r9
movq 0x28(%rsp), %r12
pushq %r12
movq 0x38(%rsp), %r14
pushq %r14
pushq %r13
callq 0x125a8
addq $0x20, %rsp
testq %rax, %rax
jne 0x309af
movq 0x8(%rsp), %r14
addq $-0xc, %r14
leaq 0x18ec7(%rip), %rdi     # 0x495b0
xorl %eax, %eax
callq 0x3120
addl %ebp, %eax
movl %eax, %ebp
movq 0x8(%rbx), %r8
movq 0x10(%rbx), %rdx
subq $0x8, %rsp
movq 0x38(%rsp), %rdi
movl 0x8(%rsp), %esi
movq %r14, 0x10(%rsp)
movq %r14, %rcx
movq %r15, %r9
pushq %r12
pushq 0x38(%rsp)
pushq %r13
callq 0x125a8
addq $0x20, %rsp
testq %rax, %rax
je 0x309af
leaq 0x26a4b(%rip), %r15     # 0x57180
testb $0x3, 0x1(%r15)
je 0x3077d
movq 0x8(%rsp), %r14
movl %ebp, %r12d
jmp 0x307a0
testb $0x30, %al
movq 0x20(%rsp), %r15
je 0x30773
testw $0x300, %ax             # imm = 0x300
je 0x3085a
movq %rsi, %r12
leaq 0x15fa8(%rip), %rdi     # 0x4670b
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x3086f
movq %rsi, %r12
xorl %ebp, %ebp
jmp 0x30871
movl %ebp, %edi
callq 0x160f7
movl %eax, %r14d
leaq 0x12c45(%rip), %rdi     # 0x433d3
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %r14d, %r12d
movq 0x8(%rsp), %r14
movq 0x10(%rbx), %rsi
addq %r14, %rsi
leaq 0x18e65(%rip), %rdi     # 0x49613
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r12d, %ebp
leaq 0x18e37(%rip), %rdi     # 0x495f8
callq 0x56e2
testb $0x4, 0x2(%r15)
jne 0x309af
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movq 0x10(%rbx), %rsi
addq %r14, %rsi
leaq 0xe911(%rip), %rcx      # 0x3f0f9
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x20(%rsp), %rdx
callq 0x5100
movq (%r15), %rax
testw $0x3003, %ax            # imm = 0x3003
je 0x30836
testb $0x40, %al
je 0x30819
leaq 0x12c9c(%rip), %rdi     # 0x434a7
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
leaq 0x162c1(%rip), %rdi     # 0x46ae1
pushq $0x19
popq %rdx
movl %edx, %esi
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
movq (%r15), %rax
testb $0x30, %al
je 0x309af
addq 0x10(%rbx), %r14
leaq 0x15f90(%rip), %rdi     # 0x467d9
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
jmp 0x309af
leaq 0x12901(%rip), %rdi     # 0x43162
movq %rsi, %r12
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
testb $0xc, 0x2(%rbx)
je 0x30880
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movq 0x30(%rsp), %r13
movq %r13, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r12, %rdx
callq 0x416a
movl %eax, %r14d
leal 0x2(%r15), %eax
movzwl %r14w, %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 0x105af
addq $0x10, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x30954
testb $0x4, 0x2(%rbx)
je 0x30954
xorl %edi, %edi
callq 0x1259b
xorl %r15d, %r15d
cmpl $0x1, %eax
sete %r15b
jne 0x308f5
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movl %ebp, %r12d
movl %r15d, %edi
callq 0x1259b
movq (%rsp), %rax
leaq (%rax,%r13), %rsi
decq %rsi
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0x5100
leaq 0x17713(%rip), %rdi     # 0x48039
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r12d, %ebp
movq (%rbx), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x3094f
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movq 0x18(%rsp), %r15
xorl %eax, %eax
callq 0x8fb2
testw %r14w, %r14w
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x30991
movq %r15, %rdi
callq 0xf111
testq %rax, %rax
je 0x30991
orb $0x1, 0x19(%rax)
movl $0x5, 0x118(%rax)
movl $0x2, 0xc4(%rax)
movq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x31b0
addq (%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3210
movq 0x10(%rsp), %r8
movq %r8, %rdi
callq 0x3050
movl %ebp, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16a4f