// File: /workspace/github_c_makefile_star2_O2/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, 0x55f01(%rip)     # 0x5a4d0
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x474d
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 0x4613
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3210
cmpl $-0x1, %eax
je 0x470d
testq %r13, %r13
je 0x474d
cmpq $0x2001, %r13           # imm = 0x2001
movl $0x1ffe, %ebp           # imm = 0x1FFE
cmovbq %r13, %rbp
leaq 0x55e9d(%rip), %r13     # 0x5a4d0
subq $0x1, %rbp
jb 0x4671
movq %r14, %rdi
callq 0x3150
movb %al, (%r13)
testb %al, %al
je 0x4671
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x4671
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x4671
leaq 0x1(%r13), %rax
cmpb $0x0, (%r13)
movq %rax, %r13
jns 0x4633
jmp 0x4674
movq %r13, %rax
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
jne 0x4693
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x474d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
cmovneq %r15, %r12
leaq 0x3ad23(%rip), %rdi     # 0x3f3c9
xorl %eax, %eax
callq 0x3120
movl %eax, %ebp
leaq 0x4222f(%rip), %rdi     # 0x468e5
movq %r12, %rsi
xorl %eax, %eax
callq 0x3120
movl %eax, %ebx
addl %ebp, %ebx
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x472c
leaq 0x3ab31(%rip), %rdi     # 0x3f208
xorl %eax, %eax
callq 0x3120
addl %eax, %ebx
movl %ebx, %edi
callq 0x16a4f
callq 0x3070
movl (%rax), %edi
callq 0x32c0
movq %rax, %rdi
callq 0x56e2
leaq 0x42463(%rip), %rdi     # 0x46b65
xorl %eax, %eax
callq 0x3120
movl %eax, %edi
jmp 0x4746
leaq 0x3ac88(%rip), %rdi     # 0x3f39c
callq 0x56e2
leaq 0x421c5(%rip), %rdi     # 0x468e5
movq %r15, %rsi
xorl %eax, %eax
callq 0x3120
jmp 0x474b
movq %r14, %rdi
callq 0x31a0
testl %eax, %eax
je 0x474d
leaq 0x3aacc(%rip), %rdi     # 0x3f20b
callq 0x56e2
movl %ebx, %edi
callq 0x160f7
movl %eax, %ebx
movl %ebx, %edi
callq 0x16a4f
leaq 0x55d75(%rip), %rax     # 0x5a4d0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq