// File: /workspace/github_c_makefile_star2_O2/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 0x2ecbb
movq %r9, %r12
movq %rcx, %r15
movq %rdx, %r13
movl %esi, %r14d
movq %r8, 0x28(%rsp)
movq %rdi, (%rsp)
movl 0x90(%rsp), %eax
movq %rax, 0x18(%rsp)
movl 0x88(%rsp), %ebx
movl 0x80(%rsp), %ebp
movl 0x78(%rsp), %eax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x30(%rsp)
movzwl (%rdx), %edi
movl %ebp, %esi
movl %ebx, %edx
callq 0x1b2e4
leaq 0x284cf(%rip), %rdx     # 0x57180
testb $0x40, (%rdx)
jne 0x2ecc2
xorl %r9d, %r9d
jmp 0x2ecdd
xorl %ebp, %ebp
jmp 0x2ef5e
leaq 0x10cce(%rip), %rsi     # 0x3f997
movq %r12, %rdi
movq %rdx, %r12
movq %rax, %rdx
callq 0x16f1d
movq %r12, %rdx
movq %rax, %r9
movq 0x10(%r13), %r12
movzwl (%r13), %eax
cmpl $0x102, %eax            # imm = 0x102
je 0x2ed41
addq %r15, %r12
cmpl $0x101, %eax            # imm = 0x101
je 0x2ed0e
cmpl $0x100, %eax            # imm = 0x100
jne 0x2ef1e
movq %r12, 0x296e7(%rip)     # 0x583f0
jmp 0x2ef54
movq %r12, 0x2dbe3(%rip)     # 0x5c8f8
xorl %ebp, %ebp
testl $0x1000300, (%rdx)      # imm = 0x1000300
jne 0x2ef56
leaq 0x17ab2(%rip), %rdi     # 0x467dc
movq %r12, %rsi
xorl %eax, %eax
movq %r9, %rbx
callq 0x3120
movq %rbx, %r9
movl %eax, %ebp
jmp 0x2ef56
xorl %ebp, %ebp
cmpq $0x0, 0x296a5(%rip)     # 0x583f0
je 0x2ef56
movq 0x2dba0(%rip), %r13     # 0x5c8f8
testq %r13, %r13
je 0x2ef73
movq %r9, 0x20(%rsp)
andq $0x0, 0x2db8a(%rip)     # 0x5c8f8
movq 0x10(%rsp), %rax
addl $0x2, %eax
movl %eax, 0xc(%rsp)
cmpl $0x0, 0x18(%rsp)
sete %cl
movq (%rdx), %rax
btl $0x12, %eax
setae %dl
xorl %ebp, %ebp
orb %cl, %dl
movq 0x30(%rsp), %r14
jne 0x2edda
movl $0x1000000, %edi        # imm = 0x1000000
movq %r13, %rsi
movl 0xc(%rsp), %edx
movq %r14, %rcx
callq 0x5100
leaq 0x1a3e4(%rip), %rdi     # 0x49196
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x1929e(%rip), %rdi     # 0x48060
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %ebx, %ebp
leaq 0x283a9(%rip), %rax     # 0x57180
movq (%rax), %rax
testl $0xc0000, %eax          # imm = 0xC0000
je 0x2edea
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r13, %rdx
callq 0x416a
movq 0x10(%rsp), %r10
addl $0x6, %r10d
movl %eax, %r15d
movzwl %ax, %edx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rcx
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %r9
pushq %r10
pushq %r14
callq 0x105af
addq $0x10, %rsp
cmpl $0x0, 0x18(%rsp)
je 0x2eec0
leaq 0x28341(%rip), %rax     # 0x57180
testb $0x4, 0x2(%rax)
je 0x2eec0
xorl %edi, %edi
callq 0x1259b
xorl %ebx, %ebx
cmpl $0x1, %eax
sete %bl
jne 0x2ee5f
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movl %ebp, %r14d
movl %ebx, %edi
callq 0x1259b
leaq (%r12,%r13), %rsi
decq %rsi
leaq 0x10282(%rip), %rcx     # 0x3f0f9
movl $0x1000000, %edi        # imm = 0x1000000
movl 0xc(%rsp), %edx
callq 0x5100
leaq 0x1a33a(%rip), %rdi     # 0x491c6
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
leaq 0x282e1(%rip), %rax     # 0x57180
movq (%rax), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x2eebc
movl %ebp, %edi
callq 0x160f7
movl %eax, %ebp
movq (%rsp), %rbx
xorl %eax, %eax
callq 0x8fb2
testw %r15w, %r15w
sete %al
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x2eeff
callq 0xf111
testq %rax, %rax
je 0x2eeff
orb $0x1, 0x19(%rax)
movl $0x6, 0x118(%rax)
movl $0x5, 0xc4(%rax)
movq %rbx, %rdi
callq 0x31b0
addq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3210
movq 0x20(%rsp), %r9
jmp 0x2ef56
subq $0x8, %rsp
movzwl %r14w, %esi
movq 0x8(%rsp), %rdi
movq %r13, %rdx
movq %r15, %rcx
movl $0x2020, %r8d           # imm = 0x2020
movq %r9, %r14
pushq 0x20(%rsp)
pushq %rbx
pushq %rbp
pushq 0x30(%rsp)
pushq 0x58(%rsp)
callq 0x9e7b
movq %r14, %r9
addq $0x30, %rsp
xorl %ebp, %ebp
movq %r9, %rdi
callq 0x3050
movl %ebp, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16a4f
leaq 0x1a1fd(%rip), %rdi     # 0x49177
movq %r9, %rbx
callq 0x56e2
movq %rbx, %r9
jmp 0x2ef56