// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxProc.c
// Function: Hax_ProcCmd
int
Hax_ProcCmd(
    ClientData dummy,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    Proc *procPtr;
    int result, argCount, i;
    char **argArray = NULL;
    Arg *lastArgPtr;
    Arg *argPtr = NULL;	/* Initialization not needed, but
					 * prevents compiler warning. */

    if (argc != 4) {
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" name args body\"", (char *) NULL);
	return HAX_ERROR;
    }

    procPtr = (Proc *) ckalloc(memoryp, sizeof(Proc));
    procPtr->iPtr = iPtr;
    procPtr->command =
	(char *) ckalloc(memoryp, (unsigned) strlen(argv[3]) + 1);
    strcpy(procPtr->command, argv[3]);
    procPtr->argPtr = NULL;

    /*
     * Break up the argument list into argument specifiers, then process
     * each argument specifier.
     */

    result = Hax_SplitList(interp, argv[2], &argCount, &argArray);
    if (result != HAX_OK) {
	goto procError;
    }
    lastArgPtr = NULL;
    for (i = 0; i < argCount; i++) {
	int fieldCount, nameLength, valueLength;
	char **fieldValues;

	/*
	 * Now divide the specifier up into name and default.
	 */

	result = Hax_SplitList(interp, argArray[i], &fieldCount,
		&fieldValues);
	if (result != HAX_OK) {
	    goto procError;
	}
	if (fieldCount > 2) {
	    ckfree(memoryp, (char *) fieldValues);
	    Hax_AppendResult(interp,
		    "too many fields in argument specifier \"",
		    argArray[i], "\"", (char *) NULL);
	    result = HAX_ERROR;
	    goto procError;
	}
	if ((fieldCount == 0) || (*fieldValues[0] == 0)) {
	    ckfree(memoryp, (char *) fieldValues);
	    Hax_AppendResult(interp, "procedure \"", argv[1],
		    "\" has argument with no name", (char *) NULL);
	    result = HAX_ERROR;
	    goto procError;
	}
	nameLength = strlen(fieldValues[0]) + 1;
	if (fieldCount == 2) {
	    valueLength = strlen(fieldValues[1]) + 1;
	} else {
	    valueLength = 0;
	}
	argPtr = (Arg *) ckalloc(memoryp, (unsigned)
		(sizeof(Arg) - sizeof(argPtr->name) + nameLength
		+ valueLength));
	if (lastArgPtr == NULL) {
	    procPtr->argPtr = argPtr;
	} else {
	    lastArgPtr->nextPtr = argPtr;
	}
	lastArgPtr = argPtr;
	argPtr->nextPtr = NULL;
	strcpy(argPtr->name, fieldValues[0]);
	if (fieldCount == 2) {
	    argPtr->defValue = argPtr->name + nameLength;
	    strcpy(argPtr->defValue, fieldValues[1]);
	} else {
	    argPtr->defValue = NULL;
	}
	ckfree(memoryp, (char *) fieldValues);
    }

    Hax_CreateCommand(interp, argv[1], InterpProc, (ClientData) procPtr,
	    ProcDeleteProc);
    ckfree(memoryp, (char *) argArray);
    return HAX_OK;

    procError:
    ckfree(memoryp, procPtr->command);
    while (procPtr->argPtr != NULL) {
	argPtr = procPtr->argPtr;
	procPtr->argPtr = argPtr->nextPtr;
	ckfree(memoryp, (char *) argPtr);
    }
    ckfree(memoryp, (char *) procPtr);
    if (argArray != NULL) {
	ckfree(memoryp, (char *) argArray);
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rsi, %r13
movq 0x280(%rsi), %rbx
andq $0x0, 0x8(%rsp)
cmpl $0x4, %edx
jne 0xf402
leaq 0x5ce8(%rip), %r14      # 0x14f2d
pushq $0x18
popq %rsi
pushq $0x47
popq %rcx
movq %rbx, %rdi
movq %r14, %rdx
callq 0x44e0
movq %rax, %r12
movq %r13, (%rax)
movq 0x18(%r15), %rdi
callq 0x41d0
leal 0x1(%rax), %esi
pushq $0x4a
popq %rcx
movq %rbx, %rdi
movq %r14, %rdx
callq 0x44e0
movq %rax, 0x8(%r12)
movq 0x18(%r15), %rsi
movq %rax, %rdi
callq 0x40f0
andq $0x0, 0x10(%r12)
movq %r15, %r14
movq %r12, %r15
addq $0x10, %r15
movq 0x10(%r14), %rsi
leaq 0x2c(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
callq 0x4540
movl %eax, %ebp
testl %eax, %eax
jne 0xf4e5
movq %r14, 0x30(%rsp)
movq %r13, 0x18(%rsp)
movq %r12, 0x38(%rsp)
xorl %r14d, %r14d
xorl %r13d, %r13d
movslq 0x2c(%rsp), %rax
cmpq %rax, %r14
jge 0xf456
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rsi
movq 0x18(%rsp), %rdi
leaq 0x14(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x4540
testl %eax, %eax
jne 0xf49c
movl 0x14(%rsp), %r12d
cmpl $0x3, %r12d
jge 0xf4a0
movq %r14, 0x40(%rsp)
movq 0x20(%rsp), %r14
testl %r12d, %r12d
je 0xf428
movq (%r14), %rdi
cmpb $0x0, (%rdi)
je 0xf428
callq 0x41d0
movq %rax, %rbp
cmpl $0x2, %r12d
jne 0xf35b
movq 0x8(%r14), %rdi
callq 0x41d0
shlq $0x20, %rax
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rcx, %rax
sarq $0x20, %rax
jmp 0xf367
xorl %eax, %eax
movabsq $0x100000000, %rcx      # imm = 0x100000000
shlq $0x20, %rbp
addq %rcx, %rbp
sarq $0x20, %rbp
leal (%rax,%rbp), %esi
addl $0x14, %esi
movq %rbx, %rdi
leaq 0x5bab(%rip), %rdx      # 0x14f2d
pushq $0x7c
popq %rcx
callq 0x44e0
movq %rax, %r12
testq %r13, %r13
cmoveq %r15, %r13
movq %rax, (%r13)
andq $0x0, (%rax)
movq %rax, %r13
addq $0x10, %r13
movq 0x20(%rsp), %r14
movq (%r14), %rsi
movq %r13, %rdi
callq 0x40f0
cmpl $0x2, 0x14(%rsp)
jne 0xf3d5
addq %rbp, %r13
movq %r13, 0x8(%r12)
movq 0x8(%r14), %rsi
movq %r13, %rdi
callq 0x40f0
movq 0x20(%rsp), %r14
jmp 0xf3db
andq $0x0, 0x8(%r12)
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x5b45(%rip), %rdx      # 0x14f2d
movl $0x8b, %ecx
callq 0x4280
movq 0x40(%rsp), %r14
incq %r14
movq %r12, %r13
jmp 0xf2cc
movq (%r15), %rdx
leaq 0x4454(%rip), %rsi      # 0x13860
leaq 0x5b09(%rip), %rcx      # 0x14f1c
movq %r13, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
pushq $0x1
popq %rbp
jmp 0xf551
leaq 0x5afe(%rip), %rdx      # 0x14f2d
pushq $0x6e
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4280
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x4889(%rip), %rsi      # 0x13cd6
leaq 0x5b0b(%rip), %rcx      # 0x14f5f
jmp 0xf4ce
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0xfc(%rip), %rdx        # 0xf562
leaq 0x359(%rip), %r8        # 0xf7c6
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rcx
callq 0x4030
movq 0x8(%rsp), %rsi
leaq 0x5aa5(%rip), %rdx      # 0x14f2d
movq %rbx, %rdi
movl $0x90, %ecx
callq 0x4280
xorl %ebp, %ebp
jmp 0xf551
movl %eax, %ebp
jmp 0xf4e0
movq 0x20(%rsp), %rsi
leaq 0x5a81(%rip), %rdx      # 0x14f2d
pushq $0x66
popq %rcx
movq %rbx, %rdi
callq 0x4280
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rdx
leaq 0x5a70(%rip), %rsi      # 0x14f37
leaq 0x3de1(%rip), %rcx      # 0x132af
movq 0x18(%rsp), %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
pushq $0x1
popq %rbp
movq 0x38(%rsp), %r12
movq 0x8(%r12), %rsi
leaq 0x5a3c(%rip), %r14      # 0x14f2d
movq %rbx, %rdi
movq %r14, %rdx
movl $0x94, %ecx
callq 0x4280
movq (%r15), %rsi
testq %rsi, %rsi
je 0xf51c
movq (%rsi), %rax
movq %rax, (%r15)
movq %rbx, %rdi
movq %r14, %rdx
movl $0x98, %ecx
jmp 0xf4fc
leaq 0x5a0a(%rip), %rdx      # 0x14f2d
movq %rbx, %rdi
movq %r12, %rsi
movl $0x9a, %ecx
callq 0x4280
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0xf551
leaq 0x59e9(%rip), %rdx      # 0x14f2d
movq %rbx, %rdi
movl $0x9c, %ecx
callq 0x4280
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq