// File: /workspace/github_cpp_makefile_star2_O3/rurban[P]dgnlib/cpl_conv.cpp
// Function: CPLReadLineL
const char *CPLReadLineL( FILE * fp )

{
/* -------------------------------------------------------------------- */
/*      Cleanup case.                                                   */
/* -------------------------------------------------------------------- */
    if( fp == NULL )
    {
        CPLReadLineBuffer( -1 );
        return NULL;
    }

/* -------------------------------------------------------------------- */
/*      Loop reading chunks of the line till we get to the end of       */
/*      the line.                                                       */
/* -------------------------------------------------------------------- */
    char *pszRLBuffer;
    const int nChunkSize = 40;
    char szChunk[nChunkSize];
    int nChunkBytesRead = 0;
    int nBufLength = 0;
    int nChunkBytesConsumed = 0;

    while( TRUE )
    {
/* -------------------------------------------------------------------- */
/*      Read a chunk from the input file.                               */
/* -------------------------------------------------------------------- */
        pszRLBuffer = CPLReadLineBuffer( nBufLength + nChunkSize + 1 );

        if( nChunkBytesRead == nChunkBytesConsumed + 1 )
        {
            // case where one character is left over from last read.
            szChunk[0] = szChunk[nChunkBytesConsumed];
            nChunkBytesRead = VSIFReadL( szChunk+1, 1, nChunkSize-1, fp ) + 1;
            if( nChunkBytesRead == 1 )
                break;
        }
        else
        {
            // fresh read.
            nChunkBytesRead = VSIFReadL( szChunk, 1, nChunkSize, fp );
            if( nChunkBytesRead == 0 )
                break;
        }
        
/* -------------------------------------------------------------------- */
/*      copy over characters watching for end-of-line.                  */
/* -------------------------------------------------------------------- */
        int bBreak = FALSE;
        nChunkBytesConsumed = 0;
        while( nChunkBytesConsumed < nChunkBytesRead-1 && !bBreak )
        {
            if( (szChunk[nChunkBytesConsumed] == 13
                 && szChunk[nChunkBytesConsumed+1] == 10)
                || (szChunk[nChunkBytesConsumed] == 10
                    && szChunk[nChunkBytesConsumed+1] == 13) )
            {
                nChunkBytesConsumed += 2;
                bBreak = TRUE;
            }
            else if( szChunk[nChunkBytesConsumed] == 10
                     || szChunk[nChunkBytesConsumed] == 13 )
            {
                nChunkBytesConsumed += 1;
                bBreak = TRUE;
            }
            else
                pszRLBuffer[nBufLength++] = szChunk[nChunkBytesConsumed++];
        }

        if( bBreak )
            break;

/* -------------------------------------------------------------------- */
/*      If there is a remaining character and it is not a newline       */
/*      consume it.  If it is a newline, but we are clearly at the      */
/*      end of the file then consume it.                                */
/* -------------------------------------------------------------------- */
        if( nChunkBytesConsumed == nChunkBytesRead-1 
            && nChunkBytesRead < nChunkSize )
        {
            if( szChunk[nChunkBytesConsumed] == 10
                || szChunk[nChunkBytesConsumed] == 13 )
            {
                nChunkBytesConsumed++;
                break;
            }

            pszRLBuffer[nBufLength++] = szChunk[nChunkBytesConsumed++];
            break;
        }
    }

/* -------------------------------------------------------------------- */
/*      If we have left over bytes after breaking out, seek back to     */
/*      ensure they remain to be read next time.                        */
/* -------------------------------------------------------------------- */
    if( nChunkBytesConsumed < nChunkBytesRead )
    {
        int nBytesToPush = nChunkBytesRead - nChunkBytesConsumed;
        
        VSIFSeekL( fp, VSIFTellL( fp ) - nBytesToPush, SEEK_SET );
    }

    pszRLBuffer[nBufLength] = '\0';

    return( pszRLBuffer );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x3255
movq %rdi, %r14
xorl %r15d, %r15d
movq %rsp, %r13
xorl %ebp, %ebp
xorl %r12d, %r12d
leal 0x29(%rbp), %edi
callq 0x30a8
movq %rax, %rbx
leal 0x1(%r12), %eax
cmpl %eax, %r15d
jne 0x31ce
movslq %r12d, %rax
movb (%rsp,%rax), %al
movb %al, (%rsp)
movl $0x1, %esi
movl $0x27, %edx
leaq 0x1(%rsp), %rdi
movq %r14, %rcx
callq 0x6df3
movq %rax, %r15
testl %r15d, %r15d
je 0x32bd
incl %r15d
jmp 0x31ef
movl $0x1, %esi
movl $0x28, %edx
movq %r13, %rdi
movq %r14, %rcx
callq 0x6df3
movq %rax, %r15
testl %r15d, %r15d
je 0x32a4
movslq %r15d, %rcx
leaq -0x1(%rcx), %rax
xorl %r12d, %r12d
cmpl $0x2, %ecx
jl 0x3228
movslq %ebp, %rdx
movq %rbx, %rcx
addq %rdx, %rcx
xorl %r12d, %r12d
movzbl (%rsp,%r12), %edx
cmpl $0xa, %edx
je 0x3274
cmpl $0xd, %edx
je 0x3263
movb %dl, (%rcx,%r12)
incq %r12
cmpl %eax, %r12d
jl 0x320a
addl %r12d, %ebp
cmpl %eax, %r12d
setne %cl
cmpl $0x28, %r15d
setge %dl
orb %cl, %dl
jne 0x3188
movzbl (%rsp,%rax), %eax
cmpl $0xa, %eax
je 0x32a4
cmpl $0xd, %eax
je 0x32a4
movslq %ebp, %rcx
incl %ebp
movb %al, (%rbx,%rcx)
jmp 0x32a4
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x30a8
xorl %ebx, %ebx
jmp 0x32ab
cmpb $0xa, 0x1(%rsp,%r12)
jne 0x327c
addl %r12d, %ebp
addl $0x2, %r12d
jmp 0x3284
cmpb $0xd, 0x1(%rsp,%r12)
je 0x326b
movl %ebp, %ebp
addq %r12, %rbp
incq %r12
subl %r12d, %r15d
jle 0x32a4
movq %r14, %rdi
callq 0x6ddb
movslq %r15d, %rcx
subq %rcx, %rax
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x6dd3
movslq %ebp, %rax
movb $0x0, (%rbx,%rax)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r15d
jmp 0x3284