// File: /workspace/github_c_makefile_star2_O1/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, %r15
leaq 0x54c83(%rip), %rbx     # 0x594d0
xorl %r14d, %r14d
movl $0x2000, %edx           # imm = 0x2000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3140
testq %r15, %r15
je 0x491e
cmpq $0x2001, %r13           # imm = 0x2001
jb 0x4890
leaq 0x3ca8f(%rip), %rdi     # 0x41307
movq %r13, %rsi
movl $0x2000, %edx           # imm = 0x2000
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
movl $0x2000, %r13d          # imm = 0x2000
testq %r13, %r13
je 0x491e
movq %r15, %rdi
callq 0x31b0
movq %r15, %rdi
callq 0x3190
movq %rax, %rbp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r12
je 0x48c8
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3210
cmpl $-0x1, %eax
je 0x4925
movl $0x1, %esi
movq %rbx, %rdi
movq %r13, %rdx
movq %r15, %rcx
callq 0x30d0
cmpq %r13, %rax
je 0x494a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r12
cmovneq %r12, %rbp
leaq 0x3ca7b(%rip), %rdi     # 0x4136e
xorl %ebx, %ebx
movq %r13, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r12d
addl %r14d, %r12d
leaq 0x43fe9(%rip), %rdi     # 0x488f5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
addl %r12d, %r14d
jmp 0x494a
xorl %ebx, %ebx
jmp 0x49b6
leaq 0x3ca13(%rip), %rdi     # 0x4133f
callq 0x5c33
leaq 0x43fbd(%rip), %rdi     # 0x488f5
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
addl %r14d, %eax
movl %eax, %r14d
movq %r15, %rdi
callq 0x30b0
testl %eax, %eax
je 0x4996
leaq 0x3c8ab(%rip), %rdi     # 0x41208
xorl %eax, %eax
callq 0x3120
addl %eax, %r14d
movl %r14d, %edi
callq 0x17530
callq 0x3070
movl (%rax), %edi
callq 0x32c0
movq %rax, %rdi
callq 0x5c33
leaq 0x441eb(%rip), %rdi     # 0x48b75
xorl %eax, %eax
callq 0x3120
movl %eax, %r14d
jmp 0x49ae
movq %r15, %rdi
callq 0x31a0
testl %eax, %eax
je 0x49b6
leaq 0x3c862(%rip), %rdi     # 0x4120b
callq 0x5c33
movl %r14d, %edi
callq 0x16b56
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq