// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxProc.c
// Function: InterpProc
static int
InterpProc(
    ClientData clientData,	/* Record describing procedure to be
				 * interpreted. */
    Hax_Interp *interp,		/* Interpreter in which procedure was
				 * invoked. */
    int argc,			/* Count of number of arguments to this
				 * procedure. */
    char **argv			/* Argument values. */)
{
    Proc *procPtr = (Proc *) clientData;
    Arg *argPtr;
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    char **args;
    CallFrame frame;
    char *value, *end;
    int result;

    /*
     * Set up a call frame for the new procedure invocation.
     */

    iPtr = procPtr->iPtr;
    Hax_InitHashTable(&frame.varTable, HAX_STRING_KEYS);
    if (iPtr->varFramePtr != NULL) {
	frame.level = iPtr->varFramePtr->level + 1;
    } else {
	frame.level = 1;
    }
    frame.argc = argc;
    frame.argv = argv;
    frame.callerPtr = iPtr->framePtr;
    frame.callerVarPtr = iPtr->varFramePtr;
    iPtr->framePtr = &frame;
    iPtr->varFramePtr = &frame;

    /*
     * Match the actual arguments against the procedure's formal
     * parameters to compute local variables.
     */

    for (argPtr = procPtr->argPtr, args = argv+1, argc -= 1;
	    argPtr != NULL;
	    argPtr = argPtr->nextPtr, args++, argc--) {

	/*
	 * Handle the special case of the last formal being "args".  When
	 * it occurs, assign it a list consisting of all the remaining
	 * actual arguments.
	 */

	if ((argPtr->nextPtr == NULL)
		&& (strcmp(argPtr->name, "args") == 0)) {
	    if (argc < 0) {
		argc = 0;
	    }
	    value = Hax_Merge(interp, argc, args);
	    Hax_SetVar(interp, argPtr->name, value, 0);
	    ckfree(memoryp, value);
	    argc = 0;
	    break;
	} else if (argc > 0) {
	    value = *args;
	} else if (argPtr->defValue != NULL) {
	    value = argPtr->defValue;
	} else {
	    Hax_AppendResult(interp, "no value given for parameter \"",
		    argPtr->name, "\" to \"", argv[0], "\"",
		    (char *) NULL);
	    result = HAX_ERROR;
	    goto procDone;
	}
	Hax_SetVar(interp, argPtr->name, value, 0);
    }
    if (argc > 0) {
	Hax_AppendResult(interp, "called \"", argv[0],
		"\" with too many arguments", (char *) NULL);
	result = HAX_ERROR;
	goto procDone;
    }

    /*
     * Invoke the commands in the procedure's body.
     */

    result = Hax_Eval(interp, NULL, procPtr->command, 0, &end);
    if (result == HAX_RETURN) {
	result = HAX_OK;
    } else if (result == HAX_ERROR) {
	char msg[100];

	/*
	 * Record information telling where the error occurred.
	 */

	sprintf(msg, "\n    (procedure \"%.50s\" line %d)", argv[0],
		iPtr->errorLine);
	Hax_AddErrorInfo(interp, msg);
    } else if (result == HAX_BREAK) {
	iPtr->result = (char *) "invoked \"break\" outside of a loop";
	result = HAX_ERROR;
    } else if (result == HAX_CONTINUE) {
	iPtr->result = (char *) "invoked \"continue\" outside of a loop";
	result = HAX_ERROR;
    }

    /*
     * Delete the call frame for this procedure invocation (it's
     * important to remove the call frame from the interpreter
     * before deleting it, so that traces invoked during the
     * deletion don't see the partially-deleted frame).
     */

    procDone:
    iPtr->framePtr = frame.callerPtr;
    iPtr->varFramePtr = frame.callerVarPtr;
    HaxDeleteVars(iPtr, &frame.varTable);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
callq 0x4590
movq -0x38(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x16e66
movq -0x38(%rbp), %rax
movq 0xc8(%rax), %rax
movl 0x50(%rax), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x16e6d
movl $0x1, -0x68(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0xc8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
leaq -0xb8(%rbp), %rcx
movq %rcx, 0xc0(%rax)
movq -0x38(%rbp), %rax
leaq -0xb8(%rbp), %rcx
movq %rcx, 0xc8(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1702f
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x16f72
movq -0x30(%rbp), %rdi
addq $0x10, %rdi
leaq 0x6de8(%rip), %rsi      # 0x1dcea
callq 0x4300
cmpl $0x0, %eax
jne 0x16f72
cmpl $0x0, -0x14(%rbp)
jge 0x16f19
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x48(%rbp), %rdx
callq 0x4510
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x10, %rsi
movq -0xc0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4450
movq -0x40(%rbp), %rdi
movq -0xc0(%rbp), %rsi
leaq 0x837b(%rip), %rdx      # 0x1f2d7
movl $0x1dc, %ecx            # imm = 0x1DC
callq 0x4260
movl $0x0, -0x14(%rbp)
jmp 0x1702f
cmpl $0x0, -0x14(%rbp)
jle 0x16f88
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x16fee
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x16fa4
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x16fec
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x10, %rdx
movq -0x20(%rbp), %rax
movq (%rax), %r8
leaq 0x83b6(%rip), %rsi      # 0x1f374
leaq 0x83ce(%rip), %rcx      # 0x1f393
leaq 0x62a4(%rip), %r9       # 0x1d270
xorl %eax, %eax
movq $0x0, (%rsp)
movb $0x0, %al
callq 0x4500
movl $0x1, -0xcc(%rbp)
jmp 0x1712f
jmp 0x16fee
jmp 0x16ff0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x10, %rsi
movq -0xc0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4450
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x16ede
cmpl $0x0, -0x14(%rbp)
jle 0x17069
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
leaq 0x8353(%rip), %rsi      # 0x1f39a
leaq 0x8355(%rip), %rcx      # 0x1f3a3
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movl $0x1, -0xcc(%rbp)
jmp 0x1712f
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
leaq -0xc8(%rbp), %r8
callq 0x45b0
movl %eax, -0xcc(%rbp)
cmpl $0x2, -0xcc(%rbp)
jne 0x170a5
movl $0x0, -0xcc(%rbp)
jmp 0x1712d
cmpl $0x1, -0xcc(%rbp)
jne 0x170e3
leaq -0x130(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
movq -0x38(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x82f3(%rip), %rsi      # 0x1f3bd
movb $0x0, %al
callq 0x45d0
movq -0x10(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x43f0
jmp 0x1712b
cmpl $0x3, -0xcc(%rbp)
jne 0x17106
movq -0x38(%rbp), %rax
leaq 0x617b(%rip), %rcx      # 0x1d272
movq %rcx, (%rax)
movl $0x1, -0xcc(%rbp)
jmp 0x17129
cmpl $0x4, -0xcc(%rbp)
jne 0x17127
movq -0x38(%rbp), %rax
leaq 0x617a(%rip), %rcx      # 0x1d294
movq %rcx, (%rax)
movl $0x1, -0xcc(%rbp)
jmp 0x17129
jmp 0x1712b
jmp 0x1712d
jmp 0x1712f
movq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xc0(%rax)
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x38(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4330
movl -0xcc(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopl (%rax)