// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxUtil.c
// Function: Hax_SplitList
int
Hax_SplitList(
    Hax_Interp *interp,		/* Interpreter to use for error reporting. */
    char *list,			/* Pointer to string with list structure. */
    int *argcPtr,		/* Pointer to location to fill in with
				 * the number of elements in the list. */
    char ***argvPtr		/* Pointer to place to store pointer to array
				 * of pointers to list elements. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    char **argv;
    char *p;
    int result, brace;
    long int size, i, elSize;
    char *element;

    /*
     * Figure out how much space to allocate.  There must be enough
     * space for both the array of pointers and also for a copy of
     * the list.  To estimate the number of pointers needed, count
     * the number of space characters in the list.
     */

    for (size = 1, p = list; *p != 0; p++) {
	if (isspace(*p)) {
	    size++;
	}
    }
    size++;			/* Leave space for final NULL pointer. */
    argv = (char **) ckalloc(memoryp, (unsigned)
	    ((size * sizeof(char *)) + (p - list) + 1));
    for (i = 0, p = ((char *) argv) + size*sizeof(char *);
	    *list != 0; i++) {
	result = HaxFindElement(interp, list, &element, &list, &elSize, &brace);
	if (result != HAX_OK) {
	    ckfree(memoryp, (char *) argv);
	    return result;
	}
	if (*element == 0) {
	    break;
	}
	if (i >= size) {
	    ckfree(memoryp, (char *) argv);
	    Hax_SetResult(interp, (char *) "internal error in Hax_SplitList",
		    HAX_STATIC);
	    return HAX_ERROR;
	}
	argv[i] = p;
	if (brace) {
	    strncpy(p, element, elSize);
	    p += elSize;
	    *p = 0;
	    p++;
	} else {
	    HaxCopyAndCollapse(elSize, element, p);
	    p += elSize+1;
	}
    }

    argv[i] = NULL;
    *argvPtr = argv;
    *argcPtr = i;
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, 0x18(%rsp)
movq 0x280(%rdi), %r15
movb (%rsi), %bpl
testb %bpl, %bpl
je 0x10cf6
callq 0x4650
movq (%rax), %rcx
movl $0x1, %r12d
movq %rbx, %rax
movsbq %bpl, %rdx
movzwl (%rcx,%rdx,2), %edx
btl $0xd, %edx
adcq $0x0, %r12
movb 0x1(%rax), %bpl
incq %rax
testb %bpl, %bpl
jne 0x10cd8
jmp 0x10cff
movl $0x1, %r12d
movq %rbx, %rax
leaq 0x8(,%r12,8), %r13
subl %ebx, %eax
leal (%rax,%r13), %esi
incl %esi
leaq 0x5428(%rip), %rdx      # 0x1613e
movq %r15, 0x10(%rsp)
movq %r15, %rdi
movl $0x176, %ecx            # imm = 0x176
callq 0x44d0
movq %rax, %r15
cmpb $0x0, (%rbx)
je 0x10dcc
movq %r15, %rbp
addq %r13, %rbp
testq %r12, %r12
movq $-0x1, %r13
cmovnsq %r12, %r13
incq %r13
xorl %r12d, %r12d
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x30(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %rsp, %r8
leaq 0xc(%rsp), %r9
callq 0x4370
testl %eax, %eax
jne 0x10deb
movq 0x30(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x10dcf
cmpq %r12, %r13
je 0x10e06
movq %rbp, (%r15,%r12,8)
cmpl $0x0, 0xc(%rsp)
movq (%rsp), %rdx
je 0x10da9
movq %rbp, %rdi
callq 0x40a0
movq (%rsp), %rax
addq %rax, %rbp
incq %rbp
movb $0x0, -0x1(%rbp)
jmp 0x10dbd
movl %edx, %edi
movq %rbp, %rdx
callq 0x4160
movq (%rsp), %rax
addq %rax, %rbp
incq %rbp
incq %r12
movq 0x18(%rsp), %rbx
cmpb $0x0, (%rbx)
jne 0x10d4e
jmp 0x10dcf
xorl %r12d, %r12d
movq $0x0, (%r15,%r12,8)
movq 0x20(%rsp), %rax
movq %r15, (%rax)
movq 0x28(%rsp), %rax
movl %r12d, (%rax)
xorl %eax, %eax
jmp 0x10e35
leaq 0x534c(%rip), %rdx      # 0x1613e
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl $0x17b, %ecx            # imm = 0x17B
callq 0x4280
jmp 0x10e30
leaq 0x5331(%rip), %rdx      # 0x1613e
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl $0x182, %ecx            # imm = 0x182
callq 0x4280
leaq 0x5322(%rip), %rsi      # 0x16148
movq %r14, %rdi
xorl %edx, %edx
callq 0x44f0
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq