// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
leaq 0x75aa7(%rip), %rax     # 0x7a4d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
cmpq $0x0, -0x8(%rbp)
je 0x4c41
movq -0x8(%rbp), %rdi
callq 0x31a0
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x20(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x10(%rbp)
je 0x4a9d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x3200
cmpl $-0x1, %eax
jne 0x4a9d
leaq 0x5f902(%rip), %rdi     # 0x6437d
callq 0x6860
movq -0x10(%rbp), %rsi
leaq 0x66415(%rip), %rdi     # 0x6aea0
movb $0x0, %al
callq 0x3110
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x4c3f
cmpq $0x0, -0x18(%rbp)
jbe 0x4c3d
cmpq $0x2000, -0x18(%rbp)    # imm = 0x2000
jbe 0x4aba
movq $0x1ffe, -0x18(%rbp)    # imm = 0x1FFE
jmp 0x4abc
movslq -0x2c(%rbp), %rcx
xorl %eax, %eax
cmpq -0x18(%rbp), %rcx
movb %al, -0x31(%rbp)
jae 0x4b2f
movq -0x8(%rbp), %rdi
callq 0x3140
movq -0x28(%rbp), %rcx
movb %al, (%rcx)
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
je 0x4b2f
movq -0x8(%rbp), %rdi
callq 0x3190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
jne 0x4b2f
movq -0x8(%rbp), %rdi
callq 0x30a0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
jne 0x4b2f
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movsbl (%rax), %eax
andl $-0x80, %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x4b38
jmp 0x4b46
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4abc
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rdi
callq 0x3190
cmpl $0x0, %eax
jne 0x4b6d
movq -0x8(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
je 0x4c3b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x10(%rbp)
jne 0x4b80
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x5f823(%rip), %rdi     # 0x643aa
movb $0x0, %al
callq 0x3110
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x66301(%rip), %rdi     # 0x6aea0
movb $0x0, %al
callq 0x3110
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x30a0
cmpl $0x0, %eax
je 0x4c12
leaq 0x5f628(%rip), %rdi     # 0x641e9
movb $0x0, %al
callq 0x3110
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %edi
callq 0x1ff00
movl $0x0, -0x30(%rbp)
callq 0x3060
movl (%rax), %edi
callq 0x32b0
movq %rax, %rdi
callq 0x6860
leaq 0x66528(%rip), %rdi     # 0x6b120
movb $0x0, %al
callq 0x3110
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %edi
callq 0x1ef50
movl %eax, -0x30(%rbp)
jmp 0x4c39
movq -0x8(%rbp), %rdi
callq 0x3190
cmpl $0x0, %eax
je 0x4c37
leaq 0x5f5c5(%rip), %rdi     # 0x641ec
callq 0x6860
movl -0x30(%rbp), %edi
callq 0x1ef50
movl %eax, -0x30(%rbp)
jmp 0x4c39
jmp 0x4c3b
jmp 0x4c3d
jmp 0x4c3f
jmp 0x4c41
movl -0x30(%rbp), %edi
callq 0x1ff00
leaq 0x75880(%rip), %rax     # 0x7a4d0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)