// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxUnixAZ.c
// Function: Hax_ExecCmd
int
Hax_ExecCmd(
    ClientData clientData,		/* Unix ClientData */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    Hax_Memoryp *memoryp;
    int outputId;			/* File id for output pipe.  -1
					 * means command overrode. */
    int errorId;			/* File id for temporary file
					 * containing error output. */
    int *pidPtr;
    int numPids, result;

    memoryp = Hax_GetMemoryp(interp);

    /*
     * See if the command is to be run in background;  if so, create
     * the command, detach it, and return.
     */

    if ((argv[argc-1][0] == '&') && (argv[argc-1][1] == 0)) {
	argc--;
	argv[argc] = NULL;
	numPids = Hax_CreatePipeline(interp, clientData, argc-1, argv+1,
		&pidPtr, (int *) NULL, (int *) NULL, (int *) NULL);
	if (numPids < 0) {
	    return HAX_ERROR;
	}
	Hax_DetachPids(clientData, numPids, pidPtr);
	ckfree(memoryp, (char *) pidPtr);
	return HAX_OK;
    }

    /*
     * Create the command's pipeline.
     */

    numPids = Hax_CreatePipeline(interp, clientData, argc-1, argv+1, &pidPtr,
	    (int *) NULL, &outputId, &errorId);
    if (numPids < 0) {
	return HAX_ERROR;
    }

    /*
     * Read the child's output (if any) and put it into the result.
     */

    result = HAX_OK;
    if (outputId != -1) {
	while (1) {
#	    define BUFFER_SIZE 1000
	    char buffer[BUFFER_SIZE+1];
	    int count;

	    count = read(outputId, buffer, BUFFER_SIZE);

	    if (count == 0) {
		break;
	    }
	    if (count < 0) {
		Hax_ResetResult(interp);
		Hax_AppendResult(interp,
			"error reading from output pipe: ",
			Hax_UnixError(interp), (char *) NULL);
		result = HAX_ERROR;
		break;
	    }
	    buffer[count] = 0;
	    Hax_AppendResult(interp, buffer, (char *) NULL);
	}
	close(outputId);
    }

    if (CleanupChildren(interp, clientData, numPids, pidPtr, errorId) != HAX_OK) {
	result = HAX_ERROR;
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x3530
movq %rax, %r12
movslq %ebp, %rdx
movq -0x8(%r15,%rdx,8), %rax
decq %rdx
cmpb $0x26, (%rax)
jne 0x4c9c
cmpb $0x0, 0x1(%rax)
je 0x4d25
addq $0x8, %r15
leaq 0x2c(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x1c(%rsp), %rax
movq %rax, (%rsp)
xorl %r12d, %r12d
leaq 0x20(%rsp), %r8
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
xorl %r9d, %r9d
callq 0x33c0
testl %eax, %eax
js 0x4d81
movl %eax, %ebp
movl 0x1c(%rsp), %edi
cmpl $-0x1, %edi
je 0x4dba
leaq 0x30(%rsp), %r15
xorl %r12d, %r12d
movl $0x3e8, %edx            # imm = 0x3E8
movq %r15, %rsi
callq 0x32e0
testl %eax, %eax
je 0x4db1
js 0x4d87
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, 0x30(%rsp,%rax)
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3500
movl 0x1c(%rsp), %edi
jmp 0x4ceb
andq $0x0, (%r15,%rdx,8)
addl $-0x2, %ebp
addq $0x8, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
xorl %r13d, %r13d
leaq 0x20(%rsp), %r8
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0x33c0
testl %eax, %eax
js 0x4d81
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %eax, %esi
callq 0x32a0
movq 0x20(%rsp), %rsi
leaq 0x3526(%rip), %rdx      # 0x8298
movq %r12, %rdi
movl $0x132, %ecx            # imm = 0x132
callq 0x31f0
jmp 0x4ddb
pushq $0x1
popq %r13
jmp 0x4ddb
movq %r14, %rdi
callq 0x3260
movq %r14, %rdi
callq 0x31b0
leaq 0x353f(%rip), %rsi      # 0x82dd
movq %r14, %rdi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3500
pushq $0x1
popq %r12
movl 0x1c(%rsp), %edi
callq 0x3280
movq 0x20(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x495d
testl %eax, %eax
pushq $0x1
popq %r13
cmovel %r12d, %r13d
movl %r13d, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq