// File: /workspace/github_c_makefile_star2_O0/hfiguiere[P]exifprobe/mrw.c
// Function: process_mrw
unsigned long
process_mrw(FILE *inptr,unsigned long offset,unsigned long data_offset,
            unsigned long data_length,struct image_summary *summary_entry,
            char *parent_name,int indent)
{
    char *blockname;
    char *fulldirname = CNULL;
    struct fileheader *header;
    unsigned long blocklength,blockid;
    unsigned long ifd_offset;
    unsigned long max_offset = 0UL;
    int chpr = 0;
    int status = 0;

    if(inptr && data_offset)
    {
        if((summary_entry == NULL) || summary_entry->entry_lock)
            summary_entry = new_summary_entry(summary_entry,0,IMGFMT_MRW);
        if(summary_entry)
        {
            /* This isn't strictly necessary, because we're going to  */
            /* do it again at the end, but allows the TIFF processor  */
            /* to avoid changing this stuff if it notices they're     */
            /* already set.                                           */
            if(summary_entry->length <= 0)
                summary_entry->length = data_length;
            if(summary_entry->offset <= 0)
                summary_entry->offset = data_offset;
            summary_entry->imageformat = IMGFMT_MRW;
            summary_entry->imagesubformat = IMGSUBFMT_CFA;
            /* Don't lock it here; the TIFF processor should use it   */
            /* (and lock it)                                          */
        }
        chpr = newline(chpr);
        while(offset < data_offset)
        {
            blockid = read_ulong(inptr,TIFF_MOTOROLA,offset);
            blockname = read_string(inptr,offset+1,3);
            blocklength = read_ulong(inptr,TIFF_MOTOROLA,HERE);
            print_tag_address(SECTION,offset,indent,"@");
            if(blockid != MRM_PAD)
                offset += 8;
            if((PRINT_SECTION))
            {
                chpr += printf("{%s} (%#lx) length %lu starting at offset %#lx/%lu",blockname,
                                                        blockid,blocklength,offset,offset);
                chpr = newline(chpr);
            }

            if(Debug)
            {
                chpr = newline(chpr);
                hexdump(inptr,offset,48,48,16,0,0);
                chpr = newline(1);
            }
            switch(blockid)
            {
                case MRM_PRD:
                    max_offset = process_prd(inptr,offset,blocklength,summary_entry,indent);
                    offset += blocklength;
                    break;
                case MRM_TTW:
                    header = read_imageheader(inptr,offset);
                    if(header && (header->probe_magic == PROBE_TIFFMAGIC))
                    {
                        ifd_offset = read_ulong(inptr,header->file_marker,HERE); 
                        if(PRINT_SECTION)
                        {
                            print_tag_address(SECTION,offset,indent + 4,"@");
                            status = print_header(header,SECTION);
                            chpr += printf(" ifd offset = %#lx/%lu)",ifd_offset,ifd_offset);
                            if(offset)
                            {
                                chpr += printf(" (+ %lu = %#lx/%lu)",offset,offset + ifd_offset,
                                                                            offset + ifd_offset);
                            }
                            chpr = newline(chpr);
                        }
                        fulldirname = splice(parent_name,".",blockname);
                        max_offset = process_tiff_ifd(inptr,header->file_marker,
                                            ifd_offset,offset,offset + blocklength,summary_entry,
                                            fulldirname,TIFF_IFD,0,-1,indent + 4);
                        if(max_offset > 0L)
                            status = 0;
                        max_offset = offset + blocklength;
                        fflush(stdout);
                        if(fulldirname)
                            free(fulldirname);
                        fulldirname = CNULL;
                    }
                    else
                        chpr += printf(" NOT A TIFF HEADER");
                    offset += blocklength;
                    break;
                case MRM_WBG:
                    max_offset = process_wbg(inptr,offset,blocklength,summary_entry,indent);
                    offset += blocklength;
                    break;
                case MRM_RIF:
                    max_offset = process_rif(inptr,offset,blocklength,summary_entry,indent);
                    offset += blocklength;
                    break;
                case MRM_PAD:
                    offset += blocklength;
                    max_offset = offset;
                    break;
                default:
                    offset += blocklength;
                    max_offset = offset - 8;
                    break;
            }
            chpr = newline(0);
            if((PRINT_SECTION))
            {
                print_tag_address(SECTION,max_offset - 1,indent,"@");
                chpr += printf("{/%s}",blockname ? blockname : "UNK");
            }
            chpr = newline(chpr);
        }
        if((PRINT_SECTION))
        {
            print_tag_address(SECTION,data_offset,indent,"@");
            chpr += printf("MRW (CFA) data length %lu",data_length);
            chpr = newline(chpr);
            dumpsection(inptr,data_offset,data_length,indent + SMALLINDENT);
            print_tag_address(SECTION,data_offset + data_length - 1,indent,"@");
            chpr += printf("End of MRW data");
        }
        chpr = newline(chpr);
        /* Fix up any damage done by the TIFF IFD...                  */
        /* This information supercedes anything the TIFF processor    */
        /* may have done...image processing software can trash the    */
        /* TIFF structure (and some do), but this is basic            */
        /* information from the MRW header.                           */
        if(summary_entry)
        {
            summary_entry->length = data_length;
            summary_entry->offset = data_offset;
            summary_entry->imageformat = IMGFMT_MRW;
            summary_entry->imagesubformat = IMGSUBFMT_CFA;
            /* The TIFF processor should have locked it, but make     */
            /* sure                                                   */
            summary_entry->entry_lock = lock_number(summary_entry);
        }
    }
    return(data_offset + data_length);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x35c35
cmpq $0x0, -0x18(%rbp)
je 0x35c35
cmpq $0x0, -0x28(%rbp)
je 0x3565b
movq -0x28(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x3566f
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x4d524d, %edx         # imm = 0x4D524D
callq 0x15420
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x356ce
movq -0x28(%rbp), %rax
cmpq $0x0, 0x98(%rax)
ja 0x35693
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x90(%rax)
ja 0x356b0
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x28(%rbp), %rax
movq $0x4d524d, 0x80(%rax) # imm = 0x4D524D
movq -0x28(%rbp), %rax
movq $0x18023, 0x88(%rax) # imm = 0x18023
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x35b33
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x4d4d, %esi           # imm = 0x4D4D
callq 0x4610
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x1, %rsi
movl $0x3, %edx
callq 0x4a00
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movl $0x4d4d, %esi           # imm = 0x4D4D
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4610
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rsi
movl 0x10(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x2e99b(%rip), %rcx     # 0x640dc
callq 0x5ed0
cmpq $0x504144, -0x58(%rbp)  # imm = 0x504144
je 0x3575c
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
leaq 0x41a1d(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x357a5
movq -0x38(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0x10(%rbp), %r9
leaq 0x36430(%rip), %rdi     # 0x6bbbd
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
leaq 0x46f04(%rip), %rax     # 0x7c6b0
cmpl $0x0, (%rax)
je 0x357ee
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x30, %ecx
movl $0x10, %r8d
xorl %r9d, %r9d
movq %rcx, %rdx
movl $0x0, (%rsp)
callq 0x8aa0
movl $0x1, %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
subq $0x504144, %rax         # imm = 0x504144
je 0x35a83
jmp 0x35804
movq -0x78(%rbp), %rax
subq $0x505244, %rax         # imm = 0x505244
je 0x35847
jmp 0x35812
movq -0x78(%rbp), %rax
subq $0x524946, %rax         # imm = 0x524946
je 0x35a58
jmp 0x35824
movq -0x78(%rbp), %rax
subq $0x545457, %rax         # imm = 0x545457
je 0x35875
jmp 0x35832
movq -0x78(%rbp), %rax
subq $0x574247, %rax         # imm = 0x574247
je 0x35a2d
jmp 0x35a99
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl 0x10(%rbp), %r8d
callq 0x35c50
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x35ab1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3f70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x35a08
movq -0x48(%rbp), %rax
cmpq $0x2a, 0x8(%rax)
jne 0x35a08
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movzwl (%rax), %esi
callq 0x4610
movq %rax, -0x60(%rbp)
leaq 0x418c0(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x35955
movq -0x10(%rbp), %rsi
movl 0x10(%rbp), %edx
addl $0x4, %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x2e7f3(%rip), %rcx     # 0x640dc
callq 0x5ed0
movq -0x48(%rbp), %rdi
movl $0x40000, %esi          # imm = 0x40000
callq 0x55c0
movl %eax, -0x70(%rbp)
movq -0x60(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq 0x362e2(%rip), %rdi     # 0x6bbf0
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3594a
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq -0x60(%rbp), %rdx
movq -0x10(%rbp), %rcx
addq -0x60(%rbp), %rcx
leaq 0x32018(%rip), %rdi     # 0x67955
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x2effe(%rip), %rsi     # 0x64962
callq 0x20960
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movw (%rax), %si
movq -0x60(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %r8
addq -0x50(%rbp), %r8
movq -0x28(%rbp), %r9
movq -0x40(%rbp), %r10
movl 0x10(%rbp), %eax
addl $0x4, %eax
xorl %r11d, %r11d
movzwl %si, %esi
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movl %eax, 0x20(%rsp)
callq 0x112e0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jbe 0x359d3
movl $0x0, -0x70(%rbp)
movq -0x10(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x415e2(%rip), %rax     # 0x76fc8
movq (%rax), %rdi
callq 0x31f0
cmpq $0x0, -0x40(%rbp)
je 0x359fe
movq -0x40(%rbp), %rdi
callq 0x3040
movq $0x0, -0x40(%rbp)
jmp 0x35a1c
leaq 0x361f9(%rip), %rdi     # 0x6bc08
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x35ab1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl 0x10(%rbp), %r8d
callq 0x368a0
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x35ab1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl 0x10(%rbp), %r8d
callq 0x377e0
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x35ab1
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x35ab1
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
subq $0x8, %rax
movq %rax, -0x68(%rbp)
xorl %edi, %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
leaq 0x416be(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x35b23
movq -0x68(%rbp), %rsi
subq $0x1, %rsi
movl 0x10(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x2e5f4(%rip), %rcx     # 0x640dc
callq 0x5ed0
cmpq $0x0, -0x38(%rbp)
je 0x35afe
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x35b0b
leaq 0x3611c(%rip), %rax     # 0x6bc21
movq %rax, -0x80(%rbp)
jmp 0x35b0b
movq -0x80(%rbp), %rsi
leaq 0x36105(%rip), %rdi     # 0x6bc1b
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
jmp 0x356d9
leaq 0x41646(%rip), %rax     # 0x77180
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0x35bd3
movq -0x18(%rbp), %rsi
movl 0x10(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x2e57c(%rip), %rcx     # 0x640dc
callq 0x5ed0
movq -0x20(%rbp), %rsi
leaq 0x360b5(%rip), %rdi     # 0x6bc25
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl 0x10(%rbp), %ecx
addl $0x2, %ecx
callq 0xbc60
movq -0x18(%rbp), %rsi
addq -0x20(%rbp), %rsi
subq $0x1, %rsi
movl 0x10(%rbp), %edx
movl $0x40000, %edi          # imm = 0x40000
leaq 0x2e522(%rip), %rcx     # 0x640dc
callq 0x5ed0
leaq 0x36079(%rip), %rdi     # 0x6bc3f
movb $0x0, %al
callq 0x3110
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x6c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x35c33
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x28(%rbp), %rax
movq $0x4d524d, 0x80(%rax) # imm = 0x4D524D
movq -0x28(%rbp), %rax
movq $0x18023, 0x88(%rax) # imm = 0x18023
movq -0x28(%rbp), %rdi
callq 0x157c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x35c35
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)