// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/readfile.c
// Function: read_bytes
unsigned char *
read_bytes(FILE *inptr,unsigned long nbytes,unsigned long offset)
{
    static unsigned char rbuf[MAXBUFLEN];
    unsigned long curoffset;
    unsigned char *value = NULL;
    int chpr = 0;

    memset(rbuf,0,MAXBUFLEN);
    if(inptr)
    {
        if(nbytes > MAXBUFLEN)
        {
            chpr += printf(" read %lu bytes would overrun buffer; truncating to %d\n",
                                                                nbytes,MAXBUFLEN);
            nbytes = MAXBUFLEN;
        }
        if(nbytes)
        {
            if(inptr) /* ###%%% redundant; FIXME                      */
            {
                clearerr(inptr);
                curoffset = ftell(inptr);
                if((offset != HERE) && (fseek(inptr,offset,SEEK_SET) == -1))
                {
                    printred(" SEEK FAILED to read unsigned bytes at offset ");
                    chpr += printf("%lu",offset);
                }
                else
                {
                    if(fread(rbuf,1,nbytes,inptr) == nbytes)
                        value = rbuf;
                    else
                    {
                        if(offset == HERE)
                            offset = curoffset;
                        PUSHCOLOR(RED);
                        chpr += printf(" FAILED to read %lu unsigned bytes at offset ",nbytes);
                        chpr += printf("%lu",offset);
                        POPCOLOR();
                    }
                }
                if(ferror(inptr))
                {
                    chpr += printf(" (");
                    setcharsprinted(chpr);
                    chpr = 0;
                    printred(strerror(errno));
                    chpr += printf(")");
                    chpr = newline(chpr);
                }
                else if(feof(inptr))
                {
                    printred(" (EOF)");
                    chpr = newline(chpr);
                }
            }
        }
    }
    return(value);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
leaq 0x54c50(%rip), %rbx     # 0x594d0
movl $0x2000, %edx           # imm = 0x2000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3140
testq %r14, %r14
je 0x4953
cmpq $0x2001, %r13           # imm = 0x2001
jb 0x48c2
leaq 0x3ca5f(%rip), %rdi     # 0x41307
movq %r13, %rsi
movl $0x2000, %edx           # imm = 0x2000
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
movl $0x2000, %r13d          # imm = 0x2000
jmp 0x48ce
xorl %r15d, %r15d
testq %r13, %r13
je 0x4953
movq %r14, %rdi
callq 0x31b0
movq %r14, %rdi
callq 0x3190
movq %rax, %rbp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r12
je 0x48fd
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3210
cmpl $-0x1, %eax
je 0x495a
movl $0x1, %esi
movq %rbx, %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x30d0
cmpq %r13, %rax
je 0x497f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r12
cmovneq %r12, %rbp
leaq 0x3ca46(%rip), %rdi     # 0x4136e
xorl %ebx, %ebx
movq %r13, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %r15d, %r12d
leaq 0x43ff4(%rip), %rdi     # 0x48935
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
addl %r12d, %r15d
jmp 0x497f
xorl %ebx, %ebx
jmp 0x49eb
leaq 0x3c9de(%rip), %rdi     # 0x4133f
callq 0x5c26
leaq 0x43fc8(%rip), %rdi     # 0x48935
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
addl %r15d, %eax
movl %eax, %r15d
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x49cb
leaq 0x3c876(%rip), %rdi     # 0x41208
xorl %eax, %eax
callq 0x3120
addl %eax, %r15d
movl %r15d, %edi
callq 0x17a82
callq 0x3070
movl (%rax), %edi
callq 0x32c0
movq %rax, %rdi
callq 0x5c26
leaq 0x441f6(%rip), %rdi     # 0x48bb5
xorl %eax, %eax
callq 0x3120
movl %eax, %r15d
jmp 0x49e3
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
je 0x49eb
leaq 0x3c82d(%rip), %rdi     # 0x4120b
callq 0x5c26
movl %r15d, %edi
callq 0x1707a
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq