// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/readfile.c
// Function: read_ifd_entry
struct ifd_entry *
read_ifd_entry(FILE *inptr,unsigned short byteorder,unsigned long offset)
{
    static struct ifd_entry entry;
    unsigned char *value;

    memset(&entry,0,sizeof(struct ifd_entry));
    if(inptr && !feof(inptr) && !ferror(inptr))
    {
        entry.tag = read_ushort(inptr,byteorder,offset);
        entry.value_type = read_ushort(inptr,byteorder,HERE);
        entry.count = read_ulong(inptr,byteorder,HERE);
        value = read_bytes(inptr,4,HERE);
        if(value)
        {
            if((value_type_size(entry.value_type) * entry.count) > 4)
                entry.value = to_ulong(value,byteorder);    /* offset */
            else    /* actual value(s)                                */
            {
                entry.value = 0L;
                switch(entry.value_type)
                {
                    case SSHORT: 
                    case SHORT:
                        if(entry.count == 1)
                            entry.value = to_ushort(value,byteorder);
                        else
                        {
                            entry.value = to_ushort(value,byteorder);
                            if(byteorder == TIFF_MOTOROLA)
                                entry.value |= (((unsigned long)to_ushort(value + 2,byteorder) & 0xffff) << 16);
                            else
                                entry.value = (to_ushort(value + 2,byteorder) & 0xffff) |
                                    ((entry.value & 0xffff) << 16);
                        }
                        break;
                    case BYTE:
                    case SBYTE:
                    case UNDEFINED:
                    case ASCII:
                        entry.value = *(unsigned long *)value;
                        break;
                    case LONG:
                    case SLONG:
                    default:
                        entry.value = to_ulong(value,byteorder);
                        break;
                }
            }
        }
        else
            entry.value = 0L;
    }
    return(&entry);
}

// Assembly:
xorps %xmm0, %xmm0
movups %xmm0, 0x548e2(%rip)    # 0x594b8
movq $0x0, 0x548e7(%rip) # 0x594c8
testq %rdi, %rdi
je 0x4cd7
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
callq 0x31a0
testl %eax, %eax
jne 0x4cd2
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x4cd2
movzwl %bx, %ebx
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x45af
movw %ax, 0x5488d(%rip)      # 0x594b8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r14, %rdi
movl %ebx, %esi
callq 0x45af
movw %ax, 0x54879(%rip)      # 0x594ba
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r14, %rdi
movl %ebx, %esi
callq 0x4707
movq %rax, 0x54869(%rip)     # 0x594c0
movl $0x4, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r14, %rdi
callq 0x4865
testq %rax, %rax
je 0x4ca3
movq %rax, %r14
movzwl 0x54842(%rip), %edi     # 0x594ba
callq 0x1646c
movslq %eax, %rcx
movq 0x54839(%rip), %rax     # 0x594c0
imulq %rax, %rcx
cmpq $0x5, %rcx
jb 0x4ca7
movl (%r14), %ecx
cmpl $0x4d4d, %ebx           # imm = 0x4D4D
movl %ecx, %eax
bswapl %eax
cmovnel %ecx, %eax
jmp 0x4ccb
xorl %eax, %eax
jmp 0x4ccb
movq $0x0, 0x54816(%rip) # 0x594c8
movzwl 0x54801(%rip), %ecx     # 0x594ba
cmpl $0x8, %ecx
ja 0x4c91
movl $0xc6, %edx
btl %ecx, %edx
jae 0x4cdf
movq (%r14), %rax
movq %rax, 0x547f6(%rip)     # 0x594c8
popq %rbx
popq %r14
popq %r15
leaq 0x547da(%rip), %rax     # 0x594b8
retq
movl $0x108, %edx            # imm = 0x108
btl %ecx, %edx
jae 0x4c91
movzwl (%r14), %ecx
movl %ecx, %edx
rolw $0x8, %dx
cmpl $0x4d4d, %ebx           # imm = 0x4D4D
cmovnel %ecx, %edx
movzwl %dx, %ecx
movq %rcx, 0x547c2(%rip)     # 0x594c8
cmpq $0x1, %rax
je 0x4cd2
movzwl 0x2(%r14), %eax
cmpl $0x4d4d, %ebx           # imm = 0x4D4D
jne 0x4d22
rolw $0x8, %ax
shll $0x10, %eax
jmp 0x4d25
shll $0x10, %ecx
orq %rcx, %rax
jmp 0x4ccb