// File: /workspace/github_cpp_makefile_star2_O2/rurban[P]dgnlib/cpl_string.cpp
// Function: CSLRemoveStrings
char **CSLRemoveStrings(char **papszStrList, int nFirstLineToDelete,
                        int nNumToRemove, char ***ppapszRetStrings)
{
    int     i, nSrcLines, nDstLines;
    char    **ppszSrc, **ppszDst;

    nSrcLines = CSLCount(papszStrList);
    nDstLines = nSrcLines - nNumToRemove;

    if (nNumToRemove < 1 || nSrcLines == 0)
        return papszStrList;    /* Nothing to do!*/

    /* If operation will result in an empty StringList then don't waste
     * time here!
     */
    if (nDstLines < 1)
    {
        CSLDestroy(papszStrList);
        return NULL;
    }

    
    /* Remove lines from the source StringList...
     * Either free() each line or store them to a new StringList depending on
     * the caller's choice.
     */
    ppszDst = papszStrList + nFirstLineToDelete;

    if (ppapszRetStrings == NULL)
    {
        /* free() all the strings that will be removed.
         */
        for (i=0; i < nNumToRemove; i++)
        {
            CPLFree(*ppszDst);
            *ppszDst = NULL;
        }
    }
    else
    {
        /* Store the strings to remove in a new StringList
         */
        *ppapszRetStrings = (char **)CPLCalloc(nNumToRemove+1, sizeof(char*));

        for (i=0; i < nNumToRemove; i++)
        {
            (*ppapszRetStrings)[i] = *ppszDst;
            *ppszDst = NULL;
            ppszDst++;
        }
    }


    /* Shift down all the lines that follow the lines to remove.
     */
    if (nFirstLineToDelete == -1 || nFirstLineToDelete > nSrcLines)
        nFirstLineToDelete = nDstLines;

    ppszSrc = papszStrList + nFirstLineToDelete + nNumToRemove;
    ppszDst = papszStrList + nFirstLineToDelete;

    for ( ; *ppszSrc != NULL; ppszSrc++, ppszDst++)
    {
        *ppszDst = *ppszSrc;
    }
    /* Move the NULL pointer at the end of the StringList     */
    *ppszDst = *ppszSrc; 

    /* At this point, we could realloc() papszStrList to a smaller size, but
     * since this array will likely grow again in further operations on the
     * StringList we'll leave it as it is.
     */

    return papszStrList;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
callq 0x553e
movl %eax, %r14d
testl %r12d, %r12d
setle %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x5b5a
movl %r14d, %r13d
subl %r12d, %r13d
testl %r13d, %r13d
jle 0x5b01
movl %ebp, 0x4(%rsp)
movslq %ebp, %rax
leaq (%rbx,%rax,8), %rbp
testq %r15, %r15
je 0x5b0d
leal 0x1(%r12), %edi
pushq $0x8
popq %rsi
callq 0x2c6c
movq %rax, (%r15)
movl %r12d, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x5b29
movq (%rbp,%rcx,8), %rdx
movq (%r15), %rsi
movq %rdx, (%rsi,%rcx,8)
andq $0x0, (%rbp,%rcx,8)
incq %rcx
jmp 0x5ae5
movq %rbx, %rdi
callq 0x5585
xorl %ebx, %ebx
jmp 0x5b5a
movl %r12d, %r15d
subl $0x1, %r15d
jb 0x5b26
movq (%rbp), %rdi
callq 0x6a49
andq $0x0, (%rbp)
jmp 0x5b10
movl %r12d, %eax
movl 0x4(%rsp), %edx
cmpl %edx, %r14d
movl %edx, %ecx
cmovll %r13d, %ecx
cmpl $-0x1, %edx
cmovel %r13d, %ecx
movslq %ecx, %rcx
leaq (%rbx,%rcx,8), %rcx
movq (%rcx,%rax,8), %rdx
testq %rdx, %rdx
je 0x5b56
movq %rdx, (%rcx)
addq $0x8, %rcx
jmp 0x5b44
andq $0x0, (%rcx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq