// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/readfile.c
// Function: read_string
char *
read_string(FILE *inptr,unsigned long offset,unsigned long max_bytes)
{
    static char stringbuf[MAXBUFLEN];
    unsigned long curoffset;
    char *bufp;
    int nread = 0;
    int chpr = 0;

    bufp = stringbuf;
    *bufp = '\0';

    if(inptr)
    {
        clearerr(inptr);
        curoffset = ftell(inptr);
        if((offset != HERE) && (fseek(inptr,offset,SEEK_SET) == -1))
        {
            printred(" SEEK FAILED to read ascii string at offset ");
            chpr += printf("%lu",offset);
        }
        else if(max_bytes > 0)
        {
            if(max_bytes > MAXBUFLEN)
                max_bytes = MAXBUFLEN - 2;
            while((nread < max_bytes) &&
                    (*bufp = fgetc(inptr)) &&
                        !feof(inptr) && 
                            !ferror(inptr) &&
                                    isascii(*bufp++))
            {
                    ++nread;
            }
            *bufp = '\0';
            if(feof(inptr) || ferror(inptr))
            {
                if(offset == HERE)
                    offset = curoffset;
                PUSHCOLOR(RED);
                chpr += printf(" FAILED to read character at offset ");
                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);
                }
            }
        }
    }
    setcharsprinted(chpr);
    return(stringbuf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb $0x0, 0x56aa7(%rip)     # 0x5b4d0
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x4baf
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
callq 0x31b0
movq %r14, %rdi
callq 0x3190
movq %rax, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
je 0x4a6d
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3210
cmpl $-0x1, %eax
je 0x4b6f
testq %r13, %r13
je 0x4baf
cmpq $0x2001, %r13           # imm = 0x2001
movl $0x1ffe, %ebp           # imm = 0x1FFE
cmovbq %r13, %rbp
decq %rbp
leaq 0x56a40(%rip), %r13     # 0x5b4d0
movq %r14, %rdi
callq 0x3150
movb %al, (%r13)
testb %al, %al
je 0x4ad3
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x4ad3
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x4ad3
leaq 0x1(%r13), %rax
subq $0x1, %rbp
setb %cl
cmpb $0x0, (%r13)
js 0x4ad6
movq %rax, %r13
testb %cl, %cl
je 0x4a90
jmp 0x4ad6
movq %r13, %rax
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x4af5
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x4baf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
cmovneq %r15, %r12
leaq 0x3c8c1(%rip), %rdi     # 0x413c9
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
leaq 0x43e1d(%rip), %rdi     # 0x48935
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
addl %ebp, %ebx
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x4b8e
leaq 0x3c6cf(%rip), %rdi     # 0x41208
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x17a82
callq 0x3070
movl (%rax), %edi
callq 0x32c0
movq %rax, %rdi
callq 0x5c26
leaq 0x44051(%rip), %rdi     # 0x48bb5
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
jmp 0x4ba8
leaq 0x3c826(%rip), %rdi     # 0x4139c
callq 0x5c26
leaq 0x43db3(%rip), %rdi     # 0x48935
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x4bad
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
je 0x4baf
leaq 0x3c66a(%rip), %rdi     # 0x4120b
callq 0x5c26
movl %ebx, %edi
callq 0x1707a
movl %eax, %ebx
movl %ebx, %edi
callq 0x17a82
leaq 0x56913(%rip), %rax     # 0x5b4d0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq