// File: /workspace/github_c_makefile_star2_O1/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 0x3170b
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 0x1c020
leaq 0x10307(%rip), %rsi     # 0x41997
movq %r13, %rdi
movq %rax, %rdx
callq 0x17a47
movq %rax, %r8
movq 0x10(%r14), %rsi
addq %rbx, %rsi
movzwl (%r14), %eax
cmpl $0x2000, %eax           # imm = 0x2000
je 0x31744
cmpl $0xe00, %eax            # imm = 0xE00
je 0x31712
cmpl $0x4, %eax
jne 0x317b5
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
jne 0x31b4d
leaq 0x26aa8(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testl $0x300, %eax            # imm = 0x300
setne %al
orb %cl, %al
jne 0x31b4d
leaq 0x170f5(%rip), %rdi     # 0x487ec
xorl %eax, %eax
movq %r8, %rbx
callq 0x3120
movq %rbx, %r8
movl %eax, %ebp
jmp 0x31b4d
xorl %ebp, %ebp
jmp 0x31b5a
movq %rsi, (%rsp)
movq %r8, 0x10(%rsp)
movzwl %ax, %edi
movl %ebp, %esi
movl %r12d, %edx
callq 0x1c020
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
je 0x317ea
movq 0x30(%rsp), %r12
jmp 0x3181e
movq 0x8(%r14), %rax
movq %rax, (%rsp)
leaq 0x26a2d(%rip), %r14     # 0x58180
movq (%r14), %rax
cmpl $0x0, 0x8(%rsp)
movq %r8, 0x10(%rsp)
je 0x318db
btl $0x12, %eax
movq 0x20(%rsp), %r15
jae 0x31909
movl $0x40000, %edi          # imm = 0x40000
movq %rsi, %r12
movl %r15d, %edx
movq 0x28(%rsp), %rcx
callq 0x5605
leaq 0x1888f(%rip), %rdi     # 0x4a020
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x188cf(%rip), %rdi     # 0x4a070
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %ebx, %ebp
jmp 0x31a0b
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 0x191ac
movq %rbx, %r8
addq $0x20, %rsp
xorl %ebp, %ebp
jmp 0x31b4d
leaq 0x2698f(%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 0x3181e
leaq 0x16fdb(%rip), %rdi     # 0x487ec
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 0x12f22
addq $0x20, %rsp
testq %rax, %rax
jne 0x31b48
movq 0x8(%rsp), %rbx
addq $-0xc, %rbx
leaq 0x19d42(%rip), %rdi     # 0x4b5c0
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 0x12f22
addq $0x20, %rsp
testq %rax, %rax
je 0x31b48
leaq 0x268b6(%rip), %r15     # 0x58180
testb $0x3, 0x1(%r15)
je 0x31913
movq 0x8(%rsp), %rbx
movl %ebp, %r12d
jmp 0x31935
testb $0x30, %al
movq 0x20(%rsp), %r15
je 0x31909
testl $0x300, %eax            # imm = 0x300
je 0x319f4
movq %rsi, %r12
leaq 0x16e22(%rip), %rdi     # 0x4871b
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x31a09
movq %rsi, %r12
xorl %ebp, %ebp
jmp 0x31a0b
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebx
leaq 0x13ab0(%rip), %rdi     # 0x453d3
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %ebx, %r12d
movq 0x8(%rsp), %rbx
movq 0x10(%r14), %rsi
addq %rbx, %rsi
leaq 0x19ce0(%rip), %rdi     # 0x4b623
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r12d, %ebp
leaq 0x19cb2(%rip), %rdi     # 0x4b608
callq 0x5c33
testb $0x4, 0x2(%r15)
jne 0x31b48
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movq 0x10(%r14), %rsi
addq %rbx, %rsi
leaq 0xf77c(%rip), %rcx      # 0x410f9
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x20(%rsp), %rdx
callq 0x5605
movq (%r15), %rax
testl $0x3003, %eax           # imm = 0x3003
je 0x319ce
testb $0x40, %al
je 0x319af
leaq 0x13b06(%rip), %rdi     # 0x454a7
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
leaq 0x1713b(%rip), %rdi     # 0x48af1
movl $0x19, %esi
movl $0x19, %edx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
testb $0x30, (%r15)
je 0x31b48
addq 0x10(%r14), %rbx
leaq 0x16e06(%rip), %rdi     # 0x487e9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
jmp 0x31b48
leaq 0x13767(%rip), %rdi     # 0x45162
movq %rsi, %r12
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
testb $0xc, 0x2(%r14)
je 0x31a1b
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movq 0x30(%rsp), %r13
movq %r13, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r12, %rdx
callq 0x4574
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 0x112cd
addq $0x10, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x31aee
testb $0x4, 0x2(%r14)
je 0x31aee
xorl %edi, %edi
callq 0x12f15
xorl %r15d, %r15d
cmpl $0x1, %eax
sete %r15b
jne 0x31a8f
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movl %ebp, %r12d
movl %r15d, %edi
callq 0x12f15
movq (%rsp), %rax
leaq (%rax,%r13), %rsi
decq %rsi
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0x5605
leaq 0x18589(%rip), %rdi     # 0x4a049
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 0x31ae9
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movq 0x18(%rsp), %r15
xorl %eax, %eax
callq 0x9609
testw %bx, %bx
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x31b2a
movq %r15, %rdi
callq 0xfdaa
testq %rax, %rax
je 0x31b2a
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 0x31b5a
movq %r8, %rdi
callq 0x3050
movl %ebp, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17530