// File: /workspace/github_c_makefile_star2_O1/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, 0x56ad8(%rip)     # 0x5b4d0
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x4b7e
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 0x4a3c
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3210
cmpl $-0x1, %eax
je 0x4b3e
testq %r13, %r13
je 0x4b7e
cmpq $0x2001, %r13           # imm = 0x2001
movl $0x1ffe, %ebp           # imm = 0x1FFE
cmovbq %r13, %rbp
decq %rbp
leaq 0x56a71(%rip), %r13     # 0x5b4d0
movq %r14, %rdi
callq 0x3150
movb %al, (%r13)
testb %al, %al
je 0x4aa2
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x4aa2
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x4aa2
leaq 0x1(%r13), %rax
subq $0x1, %rbp
setb %cl
cmpb $0x0, (%r13)
js 0x4aa5
movq %rax, %r13
testb %cl, %cl
je 0x4a5f
jmp 0x4aa5
movq %r13, %rax
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x4ac4
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x4b7e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
cmovneq %r15, %r12
leaq 0x3c8f2(%rip), %rdi     # 0x413c9
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
leaq 0x43e0e(%rip), %rdi     # 0x488f5
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
addl %ebp, %ebx
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x4b5d
leaq 0x3c700(%rip), %rdi     # 0x41208
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x17530
callq 0x3070
movl (%rax), %edi
callq 0x32c0
movq %rax, %rdi
callq 0x5c33
leaq 0x44042(%rip), %rdi     # 0x48b75
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
jmp 0x4b77
leaq 0x3c857(%rip), %rdi     # 0x4139c
callq 0x5c33
leaq 0x43da4(%rip), %rdi     # 0x488f5
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x4b7c
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
je 0x4b7e
leaq 0x3c69b(%rip), %rdi     # 0x4120b
callq 0x5c33
movl %ebx, %edi
callq 0x16b56
movl %eax, %ebx
movl %ebx, %edi
callq 0x17530
leaq 0x56944(%rip), %rax     # 0x5b4d0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq