// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
testq %rdx, %rdx
je 0x323b7
movq %r9, %rbx
movq %rcx, %r15
movq %rdx, %r13
movl %esi, %r12d
movq %r8, 0x40(%rsp)
movq %rdi, 0x8(%rsp)
movl 0xa0(%rsp), %eax
movq %rax, 0x20(%rsp)
movl 0x98(%rsp), %r14d
movl 0x90(%rsp), %ebp
movl 0x88(%rsp), %eax
movq %rax, 0x18(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x30(%rsp)
movzwl (%rdx), %edi
movl %ebp, %esi
movl %r14d, %edx
callq 0x1c020
leaq 0xf6ba(%rip), %rsi      # 0x41997
movq %rbx, %rdi
movq %rax, (%rsp)
movq %rax, %rdx
callq 0x17a47
movq %rax, 0x10(%rsp)
movq 0x10(%r13), %rcx
leaq (%rcx,%r15), %r9
movq 0x8(%r13), %r8
movzwl (%r13), %eax
cmpl $0x87, %eax
jg 0x323bf
cmpl $0x3f, %eax
jg 0x32400
cmpl $0x1, %eax
je 0x32324
cmpl $0x3, %eax
jne 0x325d5
leaq 0x25e55(%rip), %rdx     # 0x58180
movq (%rdx), %rax
cmpl $0x0, 0x20(%rsp)
je 0x3260a
btl $0x12, %eax
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rdi
movq (%rsp), %r15
jae 0x32651
movq %rdi, %rbp
movl $0x40000, %edi          # imm = 0x40000
movq %r9, %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r9, 0x28(%rsp)
movq %r8, %rbx
callq 0x5605
leaq 0x19882(%rip), %rdi     # 0x4bbfc
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, 0x20(%rsp)
shrq $0x2, %rbx
leaq 0x1765a(%rip), %rdi     # 0x499ed
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
movq %rbp, %rdi
leaq 0x25dd9(%rip), %rdx     # 0x58180
movq 0x28(%rsp), %r9
movl %eax, %ebp
addl 0x20(%rsp), %ebp
jmp 0x32653
xorl %r13d, %r13d
jmp 0x32a33
cmpl $0xdff, %eax            # imm = 0xDFF
jg 0x32492
cmpl $0x88, %eax
je 0x32564
cmpl $0x89, %eax
jne 0x325d5
movq 0x2b519(%rip), %r9      # 0x5d900
testq %r9, %r9
je 0x327a4
movq $0x0, 0x2b505(%rip) # 0x5d900
movq %rcx, %r8
jmp 0x32414
cmpl $0x40, %eax
je 0x327b0
cmpl $0x81, %eax
jne 0x325d5
leaq 0x25d65(%rip), %r13     # 0x58180
movq (%r13), %rcx
cmpl $0x0, 0x20(%rsp)
movq %r9, 0x28(%rsp)
movq %r8, (%rsp)
je 0x326d8
btl $0x12, %ecx
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rbp
jae 0x3271b
movl $0x1000000, %edi        # imm = 0x1000000
movq %r9, %rsi
movl %ebp, %edx
movq 0x30(%rsp), %rcx
callq 0x5605
leaq 0x17bb9(%rip), %rdi     # 0x4a020
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x162a3(%rip), %rdi     # 0x4871a
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movq 0x28(%rsp), %r9
movl %eax, %r14d
addl %ebx, %r14d
jmp 0x32886
cmpl $0xe00, %eax            # imm = 0xE00
je 0x325b9
cmpl $0xf00, %eax            # imm = 0xF00
jne 0x325d5
leaq 0x25cd1(%rip), %rbx     # 0x58180
movq (%rbx), %rax
cmpl $0x0, 0x20(%rsp)
je 0x327bd
testl $0x4003333, %eax        # imm = 0x4003333
movq 0x10(%rsp), %r12
je 0x327f2
movl $0x4003333, %edi        # imm = 0x4003333
movq %r9, %r15
movq %r9, %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r8, (%rsp)
callq 0x5605
leaq 0x1438e(%rip), %rdx     # 0x46880
movq %r13, %rdi
movl $0x17, %esi
movl %ebp, %ecx
movl %r14d, %r8d
callq 0x1910e
leaq 0x19737(%rip), %rdi     # 0x4bc42
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movq (%rsp), %r8
movl %eax, %r13d
leaq 0x26ee4(%rip), %rax     # 0x59408
movq (%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r8, %rbx
cmpq %rcx, %rax
movq 0x8(%rsp), %r14
je 0x32809
testq %rax, %rax
jne 0x327ff
testl %r13d, %r13d
je 0x32a10
leaq 0xf169(%rip), %rdi      # 0x416bf
callq 0x5c33
movq (%rsp), %r8
jmp 0x32a13
movq %r9, 0x2b395(%rip)      # 0x5d900
cmpl $0x0, 0x20(%rsp)
jne 0x327b0
leaq 0x25c03(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testl $0x300, %eax            # imm = 0x300
setne %al
orb %cl, %al
movq 0x10(%rsp), %r12
movl $0x0, %r13d
jne 0x32a26
leaq 0x16245(%rip), %rdi     # 0x487ec
movq %r9, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
jmp 0x32a26
xorl %ebp, %ebp
cmpl $0x0, 0x20(%rsp)
je 0x32723
movq 0x8(%rsp), %r14
movq 0x18(%rsp), %r10
jmp 0x32770
movzwl %r12w, %esi
movq 0x8(%rsp), %rdi
movq %r13, %rdx
movq %r15, %rcx
movq 0x10(%rsp), %r12
movq %r12, %r8
movq 0x30(%rsp), %r9
pushq 0x20(%rsp)
pushq %r14
pushq %rbp
pushq 0x30(%rsp)
callq 0x191ac
addq $0x20, %rsp
jmp 0x327b5
testb $0x30, %al
sete %cl
testl $0x300, %eax            # imm = 0x300
setne %al
orb %cl, %al
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rdi
movq (%rsp), %r15
jne 0x32651
movq %rdi, %rbp
leaq 0x161b9(%rip), %rdi     # 0x487ec
movq %r9, %rsi
xorl %eax, %eax
movq %r9, %rbx
callq 0x3120
movq %rbp, %rdi
leaq 0x25b36(%rip), %rdx     # 0x58180
movq %rbx, %r9
movl %eax, %ebp
jmp 0x32653
xorl %ebp, %ebp
testb $0x40, (%rdx)
movq %r15, %rcx
cmovneq %r12, %rcx
movq 0x18(%rsp), %r15
leal 0x4(%r15), %eax
subq $0x8, %rsp
xorl %esi, %esi
movq %rdx, %r12
movl %r14d, %edx
movq %r13, %r8
pushq %rax
callq 0x32b8c
addq $0x10, %rsp
testb $0x4, 0x2(%r12)
movl %ebp, %r13d
je 0x326c6
movq %rax, %rbx
xorl %edi, %edi
callq 0x16b56
movl %eax, %ebp
decq %rbx
movl $0x40000, %edi          # imm = 0x40000
movq %rbx, %rsi
movl %r15d, %edx
movq 0x30(%rsp), %rcx
callq 0x5605
leaq 0x1954d(%rip), %rdi     # 0x4bc02
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %ebp, %r13d
movl %r13d, %edi
callq 0x17530
movq 0x10(%rsp), %r12
jmp 0x32a26
testb $0x30, %cl
sete %dl
cmpl $0x81, %eax
setne %al
orb %dl, %al
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rbp
jne 0x3271b
testl $0x300, %ecx            # imm = 0x300
je 0x32852
leaq 0x12a5a(%rip), %rdi     # 0x45166
movq %r8, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x32866
xorl %r14d, %r14d
jmp 0x32886
leaq 0x25a56(%rip), %rax     # 0x58180
movq (%rax), %rax
testb $0x30, %al
sete %cl
testl $0x300, %eax            # imm = 0x300
setne %al
orb %cl, %al
movq 0x8(%rsp), %r14
movq 0x18(%rsp), %r10
jne 0x32770
leaq 0x12a13(%rip), %rdi     # 0x45162
movq %r9, %rsi
movq %r8, %rdx
xorl %eax, %eax
movq %r8, %rbp
callq 0x3120
movl %eax, %edi
callq 0x16b56
movq %rbp, %r8
movq 0x18(%rsp), %r10
movl %eax, %ebp
movq 0x10(%r13), %rdx
subq $0x8, %rsp
movzwl %r12w, %esi
movq %r14, %rdi
movq %r15, %rcx
movq 0x8(%rsp), %r9
pushq %r10
pushq 0x40(%rsp)
pushq %rbx
callq 0x12f22
addq $0x20, %rsp
movq 0x10(%rsp), %r12
movl %ebp, %r13d
jmp 0x32a26
leaq 0x1945e(%rip), %rdi     # 0x4bc09
callq 0x5c33
movq 0x10(%rsp), %r12
xorl %r13d, %r13d
jmp 0x32a26
testb $0x30, %al
movq 0x10(%rsp), %r12
je 0x327f2
testl $0x300, %eax            # imm = 0x300
movq 0x8(%rsp), %r14
je 0x329d3
movq %r9, %r15
leaq 0x12986(%rip), %rdi     # 0x45166
movq %r8, %r13
movq %r8, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x329ed
xorl %r13d, %r13d
movq 0x8(%rsp), %r14
jmp 0x32a16
cmpq %r8, %rax
cmovaeq %r8, %rax
movq %rax, %rbx
movl %r13d, %edi
callq 0x16b56
subq $0x8, %rsp
movq %r14, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
movl $0xc, %r8d
movq 0x20(%rsp), %r9
pushq $0x2
callq 0x7446
addq $0x10, %rsp
movl $0x1, %edi
callq 0x16b56
movq (%rsp), %r8
movq %r15, %r9
movl %eax, %r13d
jmp 0x32a16
leaq 0x12909(%rip), %rdi     # 0x45162
movq %r9, %rsi
movq %r8, %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
testb $0x1, 0x3(%r13)
jne 0x32881
leaq 0xf48f(%rip), %rdi      # 0x41d06
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movq 0x28(%rsp), %r9
testb $0xc, 0x2(%r13)
je 0x328a2
movq %r13, %rbx
movl %r14d, %edi
callq 0x16b56
movq 0x28(%rsp), %r9
movl %eax, %r14d
jmp 0x328a5
movq %r13, %rbx
movq %r15, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r9, %rdx
movq %r9, %r13
callq 0x4574
leal 0x2(%rbp), %r10d
movw %ax, 0x3e(%rsp)
movzwl %ax, %edx
movq %r15, %rdi
movq %r13, %rsi
movq (%rsp), %rcx
movq 0x40(%rsp), %rbp
movq %rbp, %r8
movq %r12, %r9
pushq %r10
pushq 0x38(%rsp)
callq 0x112cd
addq $0x10, %rsp
cmpl $0x0, 0x20(%rsp)
je 0x328f5
testb $0x4, 0x2(%rbx)
jne 0x328fd
movl %r14d, %r13d
jmp 0x32984
xorl %edi, %edi
callq 0x12f15
xorl %ebp, %ebp
cmpl $0x1, %eax
sete %bpl
jne 0x3291a
movl %r14d, %edi
callq 0x16b56
movl %eax, %r14d
movl %ebp, %edi
callq 0x12f15
movq 0x28(%rsp), %rax
movq (%rsp), %rcx
leaq (%rax,%rcx), %rsi
decq %rsi
leaq 0xe7c1(%rip), %rcx      # 0x410f9
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x18(%rsp), %rdx
callq 0x5605
leaq 0x176fb(%rip), %rdi     # 0x4a049
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %r14d, %r13d
movq (%rbx), %rax
testl $0x4003333, %eax        # imm = 0x4003333
sete %cl
testb $0x30, %al
setne %al
orb %cl, %al
jne 0x3297a
movl %r13d, %edi
callq 0x16b56
movl %eax, %r13d
movq 0x8(%rsp), %r15
movq 0x40(%rsp), %rbp
xorl %eax, %eax
callq 0x9609
testq %rbp, %rbp
je 0x329bd
cmpw $0x0, 0x3e(%rsp)
je 0x329bd
movq %rbp, %rdi
callq 0xfdaa
testq %rax, %rax
je 0x329bd
orb $0x1, 0x19(%rax)
movl $0x5, 0x118(%rax)
movl $0x2, 0xc4(%rax)
movq %r15, %rdi
callq 0x31b0
movq 0x28(%rsp), %rsi
addq (%rsp), %rsi
movq %r15, %rdi
jmp 0x32a1f
leaq 0x12788(%rip), %rdi     # 0x45162
movq %r9, %r15
movq %r9, %rsi
movq %r8, %r13
movq %r8, %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
testb $0x1, 0x3(%rbx)
jne 0x32a05
leaq 0xf30a(%rip), %rdi      # 0x41d06
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
movq %r15, %r9
movq %r13, %r8
movl %ebp, %r13d
jmp 0x32a16
xorl %r13d, %r13d
movq %r15, %r9
addq %r8, %r9
movq %r14, %rdi
movq %r9, %rsi
xorl %edx, %edx
callq 0x3210
testq %r12, %r12
je 0x32a33
movq %r12, %rdi
callq 0x3050
movl %r13d, %edi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17530