// File: /workspace/github_c_makefile_star2_O2/hfiguiere[P]exifprobe/maker_minolta.c
// Function: minolta1_offset_makervalue
void
minolta1_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)
{
    static unsigned long jpegthumbnailoffset = 0UL;
    unsigned long value_offset;
    unsigned long dumplength;
    unsigned long count;
    unsigned long max_offset = 0;
    unsigned short marker;
    char *nameoftag,*tagprefix;
    char *fulldirname = NULL;
    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 0x0001:    /* Camera Settings, old                   */
            case 0x0003:    /* Camera Settings, new                   */
                if(at_offset)
                {
                    if((PRINT_SECTION))
                    {
                        print_tag_address(SECTION,value_offset,indent,prefix);
                        chpr += printf("<%s> ",nameoftag);
                        chpr += printf("%lu entries",count / 4);
                    }
                }
                else if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu",value_offset);
                }
                if((PRINT_LONGNAMES))
                    tagprefix = fulldirname;
                else
                    tagprefix = nameoftag;
                max_offset = minolta_camerasetting(inptr,byteorder,model,tagprefix,
                                    entry_ptr,value_offset,indent + MEDIUMINDENT);
                if(PRINT_SECTION)
                {
                    chpr = newline(0);
                    print_tag_address(SECTION,max_offset - 1,indent,prefix);
                    chpr += printf("</%s> ",nameoftag);
                }
                setcharsprinted(chpr);
                break;
            case 0x0040:    /* ImageByteSize                      */
                break;      /* should have a count of 1               */
            case 0x0088:    /* JpegThumbnailOffset                    */
                /* It's not magic, there's a trick to it. The offset  */
                /* length will normally be the next entry tag in the  */
                /* IFD, and this will work iff it is. Remember the    */
                /* offset and handle it when the length tag is seen.  */
                /* This is necessary because we do not save entries.  */
                jpegthumbnailoffset = value_offset;
                if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu",jpegthumbnailoffset);
                }
                break;
            case 0x0089:    /* JpegThumbnailLength                    */
                if(jpegthumbnailoffset == 0UL)
                {
                    printred("# WARNING: JpegThumbnailLength encountered with 0 offset");
                    break;  /* must have the offset.                  */
                }
                value_offset = jpegthumbnailoffset;
                count = entry_ptr->value;
                jpegthumbnailoffset = 0L;
                /* fall through                                       */
            case 0x0081:    /* Jpeg Thumbnail                         */
                /* Minolta seems to use EITHER 0x0088/0x0089 OR       */
                /* 0x0081, not both.                                  */
                if(at_offset && (PRINT_SECTION))
                {
                    print_tag_address(VALUE_AT_OFFSET,value_offset,indent,
                                                        prefix);
                    chpr += printf("# Start of JPEG Thumbnail from MakerNote");
                    chpr += printf(" length %lu",count); 
                }
                else if(!at_offset && (PRINT_VALUE) && (entry_ptr->tag == 0x0081))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu:%lu",value_offset,count);
                    else
                        chpr = printf(":%lu",count);
                    if(!(PRINT_VALUE_AT_OFFSET))
                        chpr += printf(" # UNDEFINED");
                }
                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,"-");
                        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                                   */
                if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                    {
                        chpr += printf("@%lu:%lu",value_offset,count);
                        chpr = newline(chpr);
                    }
                }
                process_pim(inptr,byteorder,entry_ptr->value,fileoffset_base,
                    count,nameoftag,parent_name,prefix,indent);
                break;
            case 0x0f00: /* Data                                      */
                if(at_offset && (PRINT_ENTRY))
                {
                    print_tag_address(ENTRY,value_offset,indent,prefix);
                    print_makertagid(entry_ptr,23," : ",make,model);
                    chpr += printf(" length %-9lu", count);
                    if(Max_undefined == 0)
                    {
                        if(chpr)
                            printred(" (not dumped, use -U)");
                    }
                    else
                    {
                        if((Max_undefined == DUMPALL) || (Max_undefined > count))
                            dumplength = count;
                        else 
                            dumplength = Max_undefined;
                        chpr = newline(chpr);
                        hexdump(inptr,value_offset,count,dumplength,12,
                                    indent,SUBINDENT);
                        chpr = newline(1);
                    }
                }
                else if(!at_offset && (PRINT_VALUE))
                {
                    if(!(PRINT_OFFSET))
                        chpr += printf("@%lu:%lu",value_offset,count);
                    else
                        chpr += printf(":%lu", count);
                    if(!(PRINT_VALUE_AT_OFFSET))
                        chpr += printf(" # UNDEFINED");
                }
                /* make certain we're at the end                      */
                fseek(inptr,value_offset + count,SEEK_SET);
                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 0x311f1
movq %r9, %rbx
movq %rcx, %r12
movq %rdx, %r15
movl %esi, %r14d
movq %r8, 0x30(%rsp)
movq %rdi, 0x18(%rsp)
movl 0x90(%rsp), %eax
movq %rax, 0x20(%rsp)
movl 0x88(%rsp), %r13d
movl 0x80(%rsp), %ebp
movl 0x78(%rsp), %eax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x28(%rsp)
movzwl (%rdx), %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x1b2e4
leaq 0xe89d(%rip), %rsi      # 0x3f997
movq %rbx, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rdx
callq 0x16f1d
movq %rax, (%rsp)
movq 0x8(%r15), %r8
movq 0x10(%r15), %rdx
leaq (%rdx,%r12), %r9
movzwl (%r15), %eax
cmpl $0x1, %eax
je 0x3116c
cmpl $0xf00, %eax            # imm = 0xF00
je 0x3128b
cmpl $0x40, %eax
je 0x3157d
cmpl $0x81, %eax
je 0x31376
cmpl $0x88, %eax
je 0x311f9
cmpl $0x89, %eax
je 0x3126e
cmpl $0xe00, %eax            # imm = 0xE00
je 0x3124c
cmpl $0x3, %eax
jne 0x31342
leaq 0x2600d(%rip), %rdx     # 0x57180
movq (%rdx), %rax
cmpl $0x0, 0x20(%rsp)
je 0x313f1
btl $0x12, %eax
movq 0x10(%rsp), %rbp
jae 0x31428
movl $0x40000, %edi          # imm = 0x40000
movq %r9, %rsi
movl %ebp, %edx
movq 0x28(%rsp), %rcx
movq %r9, %rbp
movq %r8, %r14
callq 0x5100
leaq 0x18a3b(%rip), %rdi     # 0x49bec
movq 0x8(%rsp), %r12
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
shrq $0x2, %r14
leaq 0x16810(%rip), %rdi     # 0x479dd
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
leaq 0x25fa2(%rip), %rdx     # 0x57180
movq %rbp, %r9
movq 0x10(%rsp), %rbp
movl %eax, %r14d
addl %ebx, %r14d
jmp 0x31430
xorl %r15d, %r15d
jmp 0x317f5
movq %r9, 0x2b700(%rip)      # 0x5c900
cmpl $0x0, 0x20(%rsp)
jne 0x3157d
leaq 0x25f6e(%rip), %rax     # 0x57180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testw $0x300, %ax             # imm = 0x300
setne %al
orb %cl, %al
movq (%rsp), %r12
movl $0x0, %r15d
jne 0x317ed
leaq 0x155a2(%rip), %rdi     # 0x467dc
movq %r9, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
jmp 0x317ed
movl $0x0, 0x30(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x314f0
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
jmp 0x31541
movq 0x2b68b(%rip), %r9      # 0x5c900
testq %r9, %r9
je 0x31571
andq $0x0, 0x2b67a(%rip)     # 0x5c900
jmp 0x31379
leaq 0x25eee(%rip), %rbx     # 0x57180
movq (%rbx), %rax
cmpl $0x0, 0x20(%rsp)
je 0x31589
testl $0x4003333, %eax        # imm = 0x4003333
movq (%rsp), %r12
je 0x315bc
movl $0x4003333, %edi        # imm = 0x4003333
movq %r9, 0x8(%rsp)
movq %r9, %rsi
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %r8, %r14
callq 0x5100
leaq 0x1359b(%rip), %rdx     # 0x44870
pushq $0x17
popq %rsi
movq %r15, %rdi
movl %ebp, %ecx
movl %r13d, %r8d
callq 0x1850a
leaq 0x18946(%rip), %rdi     # 0x49c32
movq %r14, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
leaq 0x27108(%rip), %rax     # 0x58408
movq (%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r14, %rbx
cmpq %rcx, %rax
movq 0x18(%rsp), %r13
je 0x315d3
movq %r14, %r8
testq %rax, %rax
jne 0x315c9
testl %r15d, %r15d
je 0x317d5
leaq 0xe38a(%rip), %rdi      # 0x3f6bf
callq 0x56e2
movq %r14, %r8
jmp 0x317d8
movzwl %r14w, %esi
movq 0x18(%rsp), %rdi
movq %r15, %rdx
movq %r12, %rcx
movq (%rsp), %r12
movq %r12, %r8
movq 0x28(%rsp), %r9
pushq 0x20(%rsp)
pushq %r13
pushq %rbp
pushq 0x28(%rsp)
callq 0x185a8
addq $0x20, %rsp
jmp 0x31581
movq %r8, %rdx
movq (%rsp), %r12
leaq 0x25dfc(%rip), %r13     # 0x57180
movq (%r13), %rcx
cmpl $0x0, 0x20(%rsp)
movq %r9, 0x8(%rsp)
movq 0x10(%rsp), %rbp
movq %rdx, (%rsp)
je 0x314b5
btl $0x12, %ecx
jae 0x314e8
movl $0x1000000, %edi        # imm = 0x1000000
movq %r9, %rsi
movl %ebp, %edx
movq 0x28(%rsp), %rcx
callq 0x5100
leaq 0x16c4a(%rip), %rdi     # 0x48010
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x15334(%rip), %rdi     # 0x4670a
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movq 0x8(%rsp), %r9
movl %eax, %r14d
addl %ebx, %r14d
jmp 0x3164d
testb $0x30, %al
sete %cl
testw $0x300, %ax             # imm = 0x300
setne %al
orb %cl, %al
movq 0x10(%rsp), %rbp
jne 0x31428
leaq 0x153cf(%rip), %rdi     # 0x467dc
movq %r9, %rsi
xorl %eax, %eax
movq %r9, %rbx
movq %rdx, %r14
callq 0x3120
movq %r14, %rdx
movq %rbx, %r9
movl %eax, %r14d
jmp 0x3142b
xorl %r14d, %r14d
movq 0x8(%rsp), %r12
testb $0x40, (%rdx)
movq (%rsp), %rcx
cmoveq %r12, %rcx
leal 0x4(%rbp), %eax
subq $0x8, %rsp
movq 0x20(%rsp), %rdi
xorl %esi, %esi
movq %rdx, %r12
movl %r13d, %edx
movq %r15, %r8
pushq %rax
callq 0x3194e
addq $0x10, %rsp
testb $0x4, 0x2(%r12)
movl %r14d, %r15d
je 0x314a4
movq %rax, %rbx
xorl %edi, %edi
callq 0x160f7
movq %rbp, %rdx
movl %eax, %ebp
decq %rbx
movl $0x40000, %edi          # imm = 0x40000
movq %rbx, %rsi
movq 0x28(%rsp), %rcx
callq 0x5100
leaq 0x18760(%rip), %rdi     # 0x49bf2
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %ebp, %r15d
movl %r15d, %edi
callq 0x16a4f
movq (%rsp), %r12
jmp 0x317ed
testb $0x30, %cl
sete %dl
cmpw $0x81, %ax
setne %al
orb %dl, %al
jne 0x314e8
testw $0x300, %cx             # imm = 0x300
je 0x31618
leaq 0x11c8e(%rip), %rdi     # 0x43166
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x3162d
xorl %r14d, %r14d
jmp 0x3164d
leaq 0x25c89(%rip), %rax     # 0x57180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testw $0x300, %ax             # imm = 0x300
setne %al
orb %cl, %al
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
jne 0x31541
leaq 0x11c47(%rip), %rdi     # 0x43162
movq %r9, %rsi
movq %r8, %rdx
xorl %eax, %eax
movq %r8, 0x20(%rsp)
callq 0x3120
movl %eax, %edi
callq 0x160f7
movq 0x20(%rsp), %r8
movl %eax, 0x30(%rsp)
movq 0x10(%r15), %rdx
subq $0x8, %rsp
movzwl %r14w, %esi
movq %r13, %rdi
movq %r12, %rcx
movq 0x10(%rsp), %r9
pushq %rbp
pushq 0x38(%rsp)
pushq %rbx
callq 0x125a8
addq $0x20, %rsp
movq (%rsp), %r12
movl 0x30(%rsp), %r15d
jmp 0x317ed
leaq 0x18681(%rip), %rdi     # 0x49bf9
callq 0x56e2
movq (%rsp), %r12
xorl %r15d, %r15d
jmp 0x317ed
testb $0x30, %al
movq (%rsp), %r12
je 0x315bc
testw $0x300, %ax             # imm = 0x300
movq 0x18(%rsp), %r13
je 0x31798
movq %r9, %r15
leaq 0x11bbc(%rip), %rdi     # 0x43166
movq %r8, %r14
movq %r8, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x317b2
xorl %r15d, %r15d
movq 0x18(%rsp), %r13
jmp 0x317dd
cmpq %r8, %rax
cmovaeq %r8, %rax
movq %rax, %rbx
movl %r15d, %edi
callq 0x160f7
subq $0x8, %rsp
pushq $0xc
popq %r8
movq %r13, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq 0x18(%rsp), %r9
pushq $0x2
callq 0x6e93
popq %rax
popq %rcx
pushq $0x1
popq %rdi
callq 0x160f7
movq %r14, %r8
movq %r15, %r9
movl %eax, %r15d
jmp 0x317dd
leaq 0x11b43(%rip), %rdi     # 0x43162
movq %r9, %rsi
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
testb $0x1, 0x3(%r13)
jne 0x31648
leaq 0xe6c8(%rip), %rdi      # 0x3fd06
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movq 0x8(%rsp), %r9
testb $0xc, 0x2(%r13)
je 0x31664
movl %r14d, %edi
callq 0x160f7
movq 0x8(%rsp), %r9
movl %eax, %r14d
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r9, %rdx
movq %r9, %r15
callq 0x416a
movl %eax, %ebx
movq 0x10(%rsp), %rax
addl $0x2, %eax
movzwl %bx, %edx
movq %rbp, %rdi
movq %r15, %rsi
movq (%rsp), %rcx
movq 0x30(%rsp), %rbp
movq %rbp, %r8
movq %r12, %r9
pushq %rax
pushq 0x30(%rsp)
callq 0x105af
addq $0x10, %rsp
cmpl $0x0, 0x20(%rsp)
je 0x316ba
testb $0x4, 0x2(%r13)
jne 0x316c2
movl %r14d, %r15d
jmp 0x31747
xorl %edi, %edi
callq 0x1259b
xorl %ebp, %ebp
cmpl $0x1, %eax
sete %bpl
movl %r14d, %eax
jne 0x316de
movl %eax, %edi
callq 0x160f7
movl %eax, %r15d
movl %ebp, %edi
callq 0x1259b
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
leaq (%rax,%rcx), %rsi
decq %rsi
leaq 0xd9fa(%rip), %rcx      # 0x3f0f9
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x10(%rsp), %rdx
callq 0x5100
leaq 0x16924(%rip), %rdi     # 0x48039
xorl %eax, %eax
callq 0x3120
addl %r15d, %eax
movl %eax, %r15d
movq (%r13), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x31742
movl %r15d, %edi
callq 0x160f7
movl %eax, %r15d
movq 0x30(%rsp), %rbp
xorl %eax, %eax
callq 0x8fb2
testq %rbp, %rbp
je 0x3177d
testw %bx, %bx
je 0x3177d
movq %rbp, %rdi
callq 0xf111
testq %rax, %rax
je 0x3177d
orb $0x1, 0x19(%rax)
movl $0x5, 0x118(%rax)
movl $0x2, 0xc4(%rax)
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x31b0
movq 0x8(%rsp), %rsi
addq (%rsp), %rsi
movq %rbx, %rdi
jmp 0x317e6
leaq 0x119c3(%rip), %rdi     # 0x43162
movq %r9, %r15
movq %r9, %rsi
movq %r8, %r14
movq %r8, %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
testb $0x1, 0x3(%rbx)
jne 0x317ca
leaq 0xe545(%rip), %rdi      # 0x3fd06
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
movq %r15, %r9
movl %ebp, %r15d
movq %r14, %r8
jmp 0x317dd
xorl %r15d, %r15d
movq 0x8(%rsp), %r9
addq %r8, %r9
movq %r13, %rdi
movq %r9, %rsi
xorl %edx, %edx
callq 0x3210
movq %r12, %rdi
callq 0x3050
movl %r15d, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16a4f