// File: /workspace/github_c_makefile_star2_O3/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 0x32c43
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 0x1c518
leaq 0xee2e(%rip), %rsi      # 0x41997
movq %rbx, %rdi
movq %rax, (%rsp)
movq %rax, %rdx
callq 0x17f99
movq %rax, 0x10(%rsp)
movq 0x10(%r13), %rdx
leaq (%rdx,%r15), %r9
movq 0x8(%r13), %r8
movzwl (%r13), %eax
cmpl $0x87, %eax
jg 0x32c4b
cmpl $0x3f, %eax
jg 0x32c8c
cmpl $0x1, %eax
je 0x32bb0
cmpl $0x3, %eax
jne 0x32e61
leaq 0x255c9(%rip), %rdx     # 0x58180
movq (%rdx), %rax
cmpl $0x0, 0x20(%rsp)
je 0x32e96
btl $0x12, %eax
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rdi
movq (%rsp), %r15
jae 0x32edd
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 0x55eb
leaq 0x19036(%rip), %rdi     # 0x4bc3c
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, 0x20(%rsp)
shrq $0x2, %rbx
leaq 0x16e0e(%rip), %rdi     # 0x49a2d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3120
movq %rbp, %rdi
leaq 0x2554d(%rip), %rdx     # 0x58180
movq 0x28(%rsp), %r9
movl %eax, %ebp
addl 0x20(%rsp), %ebp
jmp 0x32edf
xorl %r13d, %r13d
jmp 0x332bf
cmpl $0xdff, %eax            # imm = 0xDFF
jg 0x32d1e
cmpl $0x88, %eax
je 0x32df0
cmpl $0x89, %eax
jne 0x32e61
movq 0x2ac8d(%rip), %r9      # 0x5d900
testq %r9, %r9
je 0x33030
movq $0x0, 0x2ac79(%rip) # 0x5d900
movq %rdx, %r8
jmp 0x32ca0
cmpl $0x40, %eax
je 0x3303c
cmpl $0x81, %eax
jne 0x32e61
leaq 0x254d9(%rip), %r13     # 0x58180
movq (%r13), %rcx
cmpl $0x0, 0x20(%rsp)
movq %r9, 0x28(%rsp)
movq %r8, (%rsp)
je 0x32f64
btl $0x12, %ecx
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rbp
jae 0x32fa7
movl $0x1000000, %edi        # imm = 0x1000000
movq %r9, %rsi
movl %ebp, %edx
movq 0x30(%rsp), %rcx
callq 0x55eb
leaq 0x1736d(%rip), %rdi     # 0x4a060
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
leaq 0x15a57(%rip), %rdi     # 0x4875a
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movq 0x28(%rsp), %r9
movl %eax, %r14d
addl %ebx, %r14d
jmp 0x33112
cmpl $0xe00, %eax            # imm = 0xE00
je 0x32e45
cmpl $0xf00, %eax            # imm = 0xF00
jne 0x32e61
leaq 0x25445(%rip), %rbx     # 0x58180
movq (%rbx), %rax
cmpl $0x0, 0x20(%rsp)
je 0x33049
testl $0x4003333, %eax        # imm = 0x4003333
movq 0x10(%rsp), %r12
je 0x3307e
movl $0x4003333, %edi        # imm = 0x4003333
movq %r9, %r15
movq %r9, %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r8, (%rsp)
callq 0x55eb
leaq 0x13b42(%rip), %rdx     # 0x468c0
movq %r13, %rdi
movl $0x17, %esi
movl %ebp, %ecx
movl %r14d, %r8d
callq 0x19668
leaq 0x18eeb(%rip), %rdi     # 0x4bc82
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movq (%rsp), %r8
movl %eax, %r13d
leaq 0x26658(%rip), %rax     # 0x59408
movq (%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r8, %rbx
cmpq %rcx, %rax
movq 0x8(%rsp), %r14
je 0x33095
testq %rax, %rax
jne 0x3308b
testl %r13d, %r13d
je 0x3329c
leaq 0xe8dd(%rip), %rdi      # 0x416bf
callq 0x5c26
movq (%rsp), %r8
jmp 0x3329f
movq %r9, 0x2ab09(%rip)      # 0x5d900
cmpl $0x0, 0x20(%rsp)
jne 0x3303c
leaq 0x25377(%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 0x332b2
leaq 0x159f9(%rip), %rdi     # 0x4882c
movq %r9, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
jmp 0x332b2
xorl %ebp, %ebp
cmpl $0x0, 0x20(%rsp)
je 0x32faf
movq 0x8(%rsp), %r14
movq 0x18(%rsp), %r10
jmp 0x33000
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 0x19706
addq $0x20, %rsp
jmp 0x33041
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 0x32edd
movq %rdi, %rbp
leaq 0x1596d(%rip), %rdi     # 0x4882c
movq %r9, %rsi
xorl %eax, %eax
movq %r9, %rbx
callq 0x3120
movq %rbp, %rdi
leaq 0x252aa(%rip), %rdx     # 0x58180
movq %rbx, %r9
movl %eax, %ebp
jmp 0x32edf
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 0x33418
addq $0x10, %rsp
testb $0x4, 0x2(%r12)
movl %ebp, %r13d
je 0x32f52
movq %rax, %rbx
xorl %edi, %edi
callq 0x1707a
movl %eax, %ebp
decq %rbx
movl $0x40000, %edi          # imm = 0x40000
movq %rbx, %rsi
movl %r15d, %edx
movq 0x30(%rsp), %rcx
callq 0x55eb
leaq 0x18d01(%rip), %rdi     # 0x4bc42
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r13d
addl %ebp, %r13d
movl %r13d, %edi
callq 0x17a82
movq 0x10(%rsp), %r12
jmp 0x332b2
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 0x32fa7
testl $0x300, %ecx            # imm = 0x300
je 0x330de
leaq 0x12212(%rip), %rdi     # 0x451aa
movq %r8, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x330f2
xorl %r14d, %r14d
jmp 0x33112
leaq 0x251ca(%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 0x33000
leaq 0x121cb(%rip), %rdi     # 0x451a6
movq %r9, %rsi
movq %r8, %rdx
xorl %eax, %eax
movq %r8, %rbp
callq 0x3120
movl %eax, %edi
callq 0x1707a
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 0x1337a
addq $0x20, %rsp
movq 0x10(%rsp), %r12
movl %ebp, %r13d
jmp 0x332b2
leaq 0x18c12(%rip), %rdi     # 0x4bc49
callq 0x5c26
movq 0x10(%rsp), %r12
xorl %r13d, %r13d
jmp 0x332b2
testb $0x30, %al
movq 0x10(%rsp), %r12
je 0x3307e
testl $0x300, %eax            # imm = 0x300
movq 0x8(%rsp), %r14
je 0x3325f
movq %r9, %r15
leaq 0x1213e(%rip), %rdi     # 0x451aa
movq %r8, %r13
movq %r8, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x33279
xorl %r13d, %r13d
movq 0x8(%rsp), %r14
jmp 0x332a2
cmpq %r8, %rax
cmovaeq %r8, %rax
movq %rax, %rbx
movl %r13d, %edi
callq 0x1707a
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 0x7480
addq $0x10, %rsp
movl $0x1, %edi
callq 0x1707a
movq (%rsp), %r8
movq %r15, %r9
movl %eax, %r13d
jmp 0x332a2
leaq 0x120c1(%rip), %rdi     # 0x451a6
movq %r9, %rsi
movq %r8, %rdx
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
testb $0x1, 0x3(%r13)
jne 0x3310d
leaq 0xec03(%rip), %rdi      # 0x41d06
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movq 0x28(%rsp), %r9
testb $0xc, 0x2(%r13)
je 0x3312e
movq %r13, %rbx
movl %r14d, %edi
callq 0x1707a
movq 0x28(%rsp), %r9
movl %eax, %r14d
jmp 0x33131
movq %r13, %rbx
movq %r15, %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movq %r9, %rdx
movq %r9, %r13
callq 0x45af
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 0x11455
addq $0x10, %rsp
cmpl $0x0, 0x20(%rsp)
je 0x33181
testb $0x4, 0x2(%rbx)
jne 0x33189
movl %r14d, %r13d
jmp 0x33210
xorl %edi, %edi
callq 0x1336d
xorl %ebp, %ebp
cmpl $0x1, %eax
sete %bpl
jne 0x331a6
movl %r14d, %edi
callq 0x1707a
movl %eax, %r14d
movl %ebp, %edi
callq 0x1336d
movq 0x28(%rsp), %rax
movq (%rsp), %rcx
leaq (%rax,%rcx), %rsi
decq %rsi
leaq 0xdf35(%rip), %rcx      # 0x410f9
movl $0x1000000, %edi        # imm = 0x1000000
movq 0x18(%rsp), %rdx
callq 0x55eb
leaq 0x16eaf(%rip), %rdi     # 0x4a089
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 0x33206
movl %r13d, %edi
callq 0x1707a
movl %eax, %r13d
movq 0x8(%rsp), %r15
movq 0x40(%rsp), %rbp
xorl %eax, %eax
callq 0x9734
testq %rbp, %rbp
je 0x33249
cmpw $0x0, 0x3e(%rsp)
je 0x33249
movq %rbp, %rdi
callq 0xfed1
testq %rax, %rax
je 0x33249
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 0x332ab
leaq 0x11f40(%rip), %rdi     # 0x451a6
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 0x33291
leaq 0xea7e(%rip), %rdi      # 0x41d06
xorl %eax, %eax
callq 0x3120
addl %eax, %ebp
movq %r15, %r9
movq %r13, %r8
movl %ebp, %r13d
jmp 0x332a2
xorl %r13d, %r13d
movq %r15, %r9
addq %r8, %r9
movq %r14, %rdi
movq %r9, %rsi
xorl %edx, %edx
callq 0x3210
testq %r12, %r12
je 0x332bf
movq %r12, %rdi
callq 0x3050
movl %r13d, %edi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17a82