// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
leaq 0x73d06(%rip), %rdi     # 0x784d0
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x3130
cmpq $0x0, -0x8(%rbp)
je 0x4985
cmpq $0x2000, -0x10(%rbp)    # imm = 0x2000
jbe 0x4810
movq -0x10(%rbp), %rsi
leaq 0x5faf2(%rip), %rdi     # 0x642e8
movl $0x2000, %edx           # imm = 0x2000
movb $0x0, %al
callq 0x3110
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq $0x2000, -0x10(%rbp)    # imm = 0x2000
cmpq $0x0, -0x10(%rbp)
je 0x4983
cmpq $0x0, -0x8(%rbp)
je 0x4981
movq -0x8(%rbp), %rdi
callq 0x31a0
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x20(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x18(%rbp)
je 0x4881
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x3200
cmpl $-0x1, %eax
jne 0x4881
leaq 0x5fabe(%rip), %rdi     # 0x64320
callq 0x6860
movq -0x18(%rbp), %rsi
leaq 0x6662e(%rip), %rdi     # 0x6aea0
movb $0x0, %al
callq 0x3110
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x48f2
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rcx
leaq 0x73c40(%rip), %rdi     # 0x784d0
movl $0x1, %esi
callq 0x30c0
cmpq -0x10(%rbp), %rax
jne 0x48ad
leaq 0x73c29(%rip), %rax     # 0x784d0
movq %rax, -0x28(%rbp)
jmp 0x48f0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x18(%rbp)
jne 0x48c0
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x5fa84(%rip), %rdi     # 0x6434f
movb $0x0, %al
callq 0x3110
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x665bd(%rip), %rdi     # 0x6aea0
movb $0x0, %al
callq 0x3110
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x48f2
movq -0x8(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
je 0x4958
leaq 0x5f8e2(%rip), %rdi     # 0x641e9
movb $0x0, %al
callq 0x3110
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %edi
callq 0x1ff00
movl $0x0, -0x2c(%rbp)
callq 0x3060
movl (%rax), %edi
callq 0x32b0
movq %rax, %rdi
callq 0x6860
leaq 0x667e2(%rip), %rdi     # 0x6b120
movb $0x0, %al
callq 0x3110
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x2c(%rbp)
jmp 0x497f
movq -0x8(%rbp), %rdi
callq 0x3190
cmpl $0x0, %eax
je 0x497d
leaq 0x5f87f(%rip), %rdi     # 0x641ec
callq 0x6860
movl -0x2c(%rbp), %edi
callq 0x1ef50
movl %eax, -0x2c(%rbp)
jmp 0x497f
jmp 0x4981
jmp 0x4983
jmp 0x4985
movq -0x28(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop