// File: /workspace/github_c_makefile_star2_O1/hfiguiere[P]exifprobe/maker_olympus.c
// Function: olympus2020_offset_value
void
olympus2020_offset_value(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)
{
    static unsigned long jpegthumbnailoffset = 0UL;
    static unsigned long jpegthumbnailvalid = 1UL;
    unsigned long value_offset,max_offset;
    unsigned long count;
    unsigned short marker;
    char *nameoftag;
    char *fulldirname = CNULL;
    int status = 0;
    int chpr = 0;

    if(entry_ptr)
    {
        nameoftag = maker_tagname(entry_ptr->tag,make,model); 
        if((PRINT_LONGNAMES))
        {
            fulldirname = splice(parent_name,".",nameoftag);
            nameoftag = fulldirname;
        }
        value_offset = fileoffset_base + entry_ptr->value;
        count = entry_ptr->count;
        switch(entry_ptr->tag)
        {
            case 0x0100: /* JPEG Thumbnail valid                      */
                /* The default is 1 (valid), so this can turn off     */
                /* processing if present and 0. Better to attempt     */
                /* processing when invalid than miss a valid image.   */
                jpegthumbnailvalid = value_offset;
                break;
            case 0x0101: /* JPEG Thumbnail offset                     */
                jpegthumbnailoffset = value_offset;
                if(!(PRINT_VALUE_AT_OFFSET))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu",jpegthumbnailoffset);
                }
                break;
            case 0x0102: /* JPEG Thumbnail length                     */
                if(jpegthumbnailvalid == 0)
                {
                    jpegthumbnailvalid = 0;
                    break;
                }
                if(jpegthumbnailoffset)
                {
                    count = entry_ptr->value;
                    value_offset = jpegthumbnailoffset;
                    jpegthumbnailoffset = 0UL;
                }
                else
                {
                    printred("# Warning: no thumbnail offset");
                    break;
                }
                indent += SMALLINDENT;
                if(at_offset && (PRINT_SECTION))
                {
                    print_tag_address(VALUE_AT_OFFSET,value_offset,indent,prefix);
                    chpr += printf("# Start of JPEG Thumbnail from MakerNote SubIFD");
                    chpr += printf(" length %ld",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+MEDIUMINDENT);
                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,"-");
                        chpr += printf("# End of JPEG Thumbnail from MakerNote SubIFD");
                        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_SUBIFD;
                        summary_entry->subfiletype = REDUCED_RES_TYPE;
                    }
                }
                /* make certain we're at the end                      */
                clearerr(inptr);
                fseek(inptr,value_offset + count,SEEK_SET);
                break;
            case 0x0304:
            case 0x0503:
            case 0x0505:
            case 0x0506:
            case 0x050f:
            default:
                print_private_offset_value(inptr,byteorder,entry_ptr,
                                        fileoffset_base,0x2020,
                                        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 0x2fd3c
movq %r9, %r12
movq %rcx, %r15
movq %rdx, %r14
movl %esi, %ebx
movq %r8, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movl 0x90(%rsp), %eax
movq %rax, 0x18(%rsp)
movl 0x88(%rsp), %r13d
movl 0x80(%rsp), %ebp
movl 0x78(%rsp), %eax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x8(%rsp)
movzwl (%rdx), %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x1c020
leaq 0x2844e(%rip), %rcx     # 0x58180
testb $0x40, (%rcx)
jne 0x2fd43
xorl %r9d, %r9d
jmp 0x2fd5e
xorl %ebp, %ebp
jmp 0x2feca
leaq 0x11c4d(%rip), %rsi     # 0x41997
movq %r12, %rdi
movq %rax, %rdx
movq %rcx, %r12
callq 0x17a47
movq %r12, %rcx
movq %rax, %r9
movq 0x10(%r14), %r12
movzwl (%r14), %eax
cmpl $0x102, %eax            # imm = 0x102
je 0x2fdc1
addq %r15, %r12
cmpl $0x101, %eax            # imm = 0x101
je 0x2fd8e
cmpl $0x100, %eax            # imm = 0x100
jne 0x2fe64
movq %r12, 0x29667(%rip)     # 0x593f0
jmp 0x2febb
movq %r12, 0x2db63(%rip)     # 0x5d8f8
xorl %ebp, %ebp
testl $0x1000300, (%rcx)      # imm = 0x1000300
jne 0x2febd
leaq 0x18a42(%rip), %rdi     # 0x487ec
movq %r12, %rsi
xorl %eax, %eax
movq %r9, %rbx
callq 0x3120
movq %rbx, %r9
movl %eax, %ebp
jmp 0x2febd
cmpq $0x0, 0x29627(%rip)     # 0x593f0
je 0x2fe9c
movq 0x2db22(%rip), %rbx     # 0x5d8f8
testq %rbx, %rbx
je 0x2fea9
movq $0x0, 0x2db0e(%rip) # 0x5d8f8
movq 0x10(%rsp), %rax
addl $0x2, %eax
movl %eax, 0x24(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x18(%rsp)
je 0x2fedf
testb $0x4, 0x2(%rcx)
movq 0x28(%rsp), %r13
je 0x2fee4
movl $0x1000000, %edi        # imm = 0x1000000
movq %rbx, %rsi
movl 0x24(%rsp), %edx
movq %rcx, %rbp
movq 0x8(%rsp), %rcx
movq %r9, %r14
callq 0x5605
leaq 0x1b371(%rip), %rdi     # 0x4b1a6
xorl %eax, %eax
callq 0x3120
movq %rbx, %r15
movl %eax, %ebx
leaq 0x1a228(%rip), %rdi     # 0x4a070
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movq %rbp, %rcx
movq %r14, %r9
movl %eax, %ebp
addl %ebx, %ebp
movq %r15, %rbx
jmp 0x2fee4
subq $0x8, %rsp
movzwl %bx, %esi
movq 0x30(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x2020, %r8d           # imm = 0x2020
movq %r9, %rbx
pushq 0x20(%rsp)
pushq %r13
pushq %rbp
pushq 0x30(%rsp)
pushq 0x30(%rsp)
callq 0xa60a
movq %rbx, %r9
addq $0x30, %rsp
jmp 0x2febb
movq $0x0, 0x29549(%rip) # 0x593f0
jmp 0x2febb
leaq 0x1b2d7(%rip), %rdi     # 0x4b187
movq %r9, %rbx
callq 0x5c33
movq %rbx, %r9
xorl %ebp, %ebp
testq %r9, %r9
je 0x2feca
movq %r9, %rdi
callq 0x3050
movl %ebp, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17530
movq 0x28(%rsp), %r13
movq %r9, %r15
movq %rcx, %r14
testb $0xc, 0x2(%rcx)
je 0x2fef9
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movq %r13, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %rbx, %rdx
callq 0x4574
movq 0x10(%rsp), %r10
addl $0x6, %r10d
movw %ax, 0x10(%rsp)
movzwl %ax, %edx
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rcx
movq 0x30(%rsp), %r8
movq %r15, %r9
pushq %r10
pushq 0x10(%rsp)
callq 0x112cd
addq $0x10, %rsp
cmpl $0x0, 0x18(%rsp)
je 0x2ffc8
testb $0x4, 0x2(%r14)
je 0x2ffc8
movq %rbx, 0x18(%rsp)
xorl %edi, %edi
callq 0x12f15
xorl %ebx, %ebx
cmpl $0x1, %eax
sete %bl
jne 0x2ff6b
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
movl %ebp, 0x8(%rsp)
movl %ebx, %edi
callq 0x12f15
movq 0x18(%rsp), %rbx
leaq (%r12,%rbx), %rsi
decq %rsi
leaq 0x11170(%rip), %rcx     # 0x410f9
movl $0x1000000, %edi        # imm = 0x1000000
movl 0x24(%rsp), %edx
callq 0x5605
leaq 0x1b238(%rip), %rdi     # 0x4b1d6
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl 0x8(%rsp), %ebp
movq (%r14), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x2ffc8
movl %ebp, %edi
callq 0x16b56
movl %eax, %ebp
xorl %eax, %eax
callq 0x9609
cmpw $0x0, 0x10(%rsp)
sete %al
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x30009
callq 0xfdaa
testq %rax, %rax
je 0x30009
orb $0x1, 0x19(%rax)
movl $0x6, 0x118(%rax)
movl $0x5, 0xc4(%rax)
movq %r13, %rdi
callq 0x31b0
addq %r12, %rbx
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3210
movq %r15, %r9
jmp 0x2febd