// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
testq %rdx, %rdx
je 0x3055d
movq %r9, %r12
movq %rcx, %r15
movq %rdx, %r14
movl %esi, %ebx
movq %r8, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movl 0xa0(%rsp), %eax
movq %rax, 0x8(%rsp)
movl 0x98(%rsp), %r13d
movl 0x90(%rsp), %ebp
movl 0x88(%rsp), %eax
movq %rax, 0x20(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x18(%rsp)
movzwl (%rdx), %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x1c518
leaq 0x27c2d(%rip), %rdx     # 0x58180
testb $0x40, (%rdx)
jne 0x30564
xorl %r9d, %r9d
jmp 0x3057f
xorl %ebp, %ebp
jmp 0x3080c
leaq 0x1142c(%rip), %rsi     # 0x41997
movq %r12, %rdi
movq %rdx, %r12
movq %rax, %rdx
callq 0x17f99
movq %r12, %rdx
movq %rax, %r9
movq 0x10(%r14), %r12
movzwl (%r14), %eax
cmpl $0x102, %eax            # imm = 0x102
je 0x305e2
addq %r15, %r12
cmpl $0x101, %eax            # imm = 0x101
je 0x305af
cmpl $0x100, %eax            # imm = 0x100
jne 0x307c7
movq %r12, 0x28e46(%rip)     # 0x593f0
jmp 0x307fd
movq %r12, 0x2d342(%rip)     # 0x5d8f8
xorl %ebp, %ebp
testl $0x1000300, (%rdx)      # imm = 0x1000300
jne 0x307ff
leaq 0x18261(%rip), %rdi     # 0x4882c
movq %r12, %rsi
xorl %eax, %eax
movq %r9, %rbx
callq 0x3120
movq %rbx, %r9
movl %eax, %ebp
jmp 0x307ff
xorl %ebp, %ebp
cmpq $0x0, 0x28e04(%rip)     # 0x593f0
je 0x307ff
movq 0x2d2ff(%rip), %r14     # 0x5d8f8
testq %r14, %r14
je 0x30821
movq %r9, 0x30(%rsp)
movq $0x0, 0x2d2e6(%rip) # 0x5d8f8
movq 0x20(%rsp), %rax
leal 0x2(%rax), %r13d
cmpl $0x0, 0x8(%rsp)
sete %cl
movq %rdx, %r15
movq (%rdx), %rax
btl $0x12, %eax
setae %dl
xorl %ebp, %ebp
orb %cl, %dl
jne 0x30673
movl $0x1000000, %edi        # imm = 0x1000000
movq %r14, %rsi
movl %r13d, %edx
movq 0x18(%rsp), %rcx
callq 0x55eb
leaq 0x1ab94(%rip), %rdi     # 0x4b1e6
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x19a4e(%rip), %rdi     # 0x4a0b0
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %ebx, %ebp
movq (%r15), %rax
movl %r13d, 0x2c(%rsp)
testl $0xc0000, %eax          # imm = 0xC0000
movq 0x40(%rsp), %r13
je 0x3068d
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movq %r13, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r14, %rdx
callq 0x45af
movl %eax, %ebx
movq 0x20(%rsp), %rax
addl $0x6, %eax
movzwl %bx, %edx
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rcx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
pushq %rax
pushq 0x20(%rsp)
callq 0x11455
addq $0x10, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x3076a
testb $0x4, 0x2(%r15)
je 0x3076a
movw %bx, 0x8(%rsp)
xorl %edi, %edi
callq 0x1336d
xorl %ebx, %ebx
cmpl $0x1, %eax
sete %bl
movq %r14, 0x10(%rsp)
jne 0x30705
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movl %ebp, %r14d
movl %ebx, %edi
callq 0x1336d
movq 0x10(%rsp), %rax
leaq (%r12,%rax), %rsi
decq %rsi
leaq 0x109d7(%rip), %rcx     # 0x410f9
movl $0x1000000, %edi        # imm = 0x1000000
movl 0x2c(%rsp), %edx
callq 0x55eb
leaq 0x1aadf(%rip), %rdi     # 0x4b216
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
addl %r14d, %ebp
movq (%r15), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x30760
movl %ebp, %edi
callq 0x1707a
movl %eax, %ebp
movq 0x10(%rsp), %r14
movzwl 0x8(%rsp), %ebx
xorl %eax, %eax
callq 0x9734
testw %bx, %bx
sete %al
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x307a8
callq 0xfed1
testq %rax, %rax
je 0x307a8
orb $0x1, 0x19(%rax)
movl $0x6, 0x118(%rax)
movl $0x5, 0xc4(%rax)
movq %r13, %rdi
callq 0x31b0
addq %r12, %r14
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3210
movq 0x30(%rsp), %r9
jmp 0x307ff
subq $0x8, %rsp
movzwl %bx, %esi
movq 0x48(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x2020, %r8d           # imm = 0x2020
movq %r9, %rbx
pushq 0x10(%rsp)
pushq %r13
pushq %rbp
pushq 0x40(%rsp)
pushq 0x40(%rsp)
callq 0xa76a
movq %rbx, %r9
addq $0x30, %rsp
xorl %ebp, %ebp
testq %r9, %r9
je 0x3080c
movq %r9, %rdi
callq 0x3050
movl %ebp, %edi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17a82
leaq 0x1a99f(%rip), %rdi     # 0x4b1c7
movq %r9, %rbx
callq 0x5c26
movq %rbx, %r9
jmp 0x307ff