// File: rurban[P]dgnlib/cpl_string.cpp
// Function: CSLInsertStrings
char **CSLInsertStrings(char **papszStrList, int nInsertAtLineNo, 
                        char **papszNewLines)
{
    int     i, nSrcLines, nDstLines, nToInsert;
    char    **ppszSrc, **ppszDst;

    if (papszNewLines == NULL ||
        ( nToInsert = CSLCount(papszNewLines) ) == 0)
        return papszStrList;    /* Nothing to do!*/

    nSrcLines = CSLCount(papszStrList);
    nDstLines = nSrcLines + nToInsert;

    /* Allocate room for the new strings */
    papszStrList = (char**)CPLRealloc(papszStrList, 
                                      (nDstLines+1)*sizeof(char*));

    /* Make sure the array is NULL-terminated... it may not be if
     * papszStrList was NULL before Realloc()
     */
    papszStrList[nSrcLines] = NULL;

    /* Make some room in the original list at the specified location 
     * Note that we also have to move the NULL pointer at the end of
     * the source StringList.
     */
    if (nInsertAtLineNo == -1 || nInsertAtLineNo > nSrcLines)
        nInsertAtLineNo = nSrcLines;

    ppszSrc = papszStrList + nSrcLines;
    ppszDst = papszStrList + nDstLines;

    for (i=nSrcLines; i>=nInsertAtLineNo; i--)
    {
        *ppszDst = *ppszSrc;
        ppszDst--;
        ppszSrc--;
    }

    /* Copy the strings to the list */
    ppszSrc = papszNewLines;
    ppszDst = papszStrList + nInsertAtLineNo;

    for (; *ppszSrc != NULL; ppszSrc++, ppszDst++)
    {
        *ppszDst = CPLStrdup(*ppszSrc);
    }
    
    return papszStrList;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7bab
movq -0x20(%rbp), %rdi
callq 0x7390
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
jne 0x7bb8
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7ccd
movq -0x10(%rbp), %rdi
callq 0x7390
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x3120
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
cmpl $-0x1, -0x14(%rbp)
je 0x7c05
movl -0x14(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x7c0b
movl -0x28(%rbp), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x7c70
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x7c37
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0x7cc5
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x31e0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
jmp 0x7c8b
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)