// File: /workspace/github_c_makefile_star2_O1/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 0x3540
movq %rax, %r12
movslq %ebp, %rdx
movq -0x8(%r15,%rdx,8), %rax
decq %rdx
cmpb $0x26, (%rax)
jne 0x4d8e
cmpb $0x0, 0x1(%rax)
je 0x4e73
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 0x33d0
testl %eax, %eax
js 0x4ed2
movl %eax, %ebp
cmpl $-0x1, 0x1c(%rsp)
je 0x4e4e
leaq 0x30(%rsp), %r15
xorl %r12d, %r12d
movl 0x1c(%rsp), %edi
movl $0x3e8, %edx            # imm = 0x3E8
movq %r15, %rsi
callq 0x32f0
testl %eax, %eax
je 0x4e0c
js 0x4e11
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, 0x30(%rsp,%rax)
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3510
movb $0x1, %r13b
jmp 0x4e40
xorl %r13d, %r13d
jmp 0x4e40
movq %r14, %rdi
callq 0x3270
movq %r14, %rdi
callq 0x31b0
xorl %r13d, %r13d
movq %r14, %rdi
leaq 0x448b(%rip), %rsi      # 0x92b9
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movl $0x1, %r12d
testb %r13b, %r13b
jne 0x4dd7
movl 0x1c(%rsp), %edi
callq 0x3290
movq 0x20(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x4a3c
testl %eax, %eax
movl $0x1, %r13d
cmovel %r12d, %r13d
jmp 0x4ed8
movq $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 0x33d0
testl %eax, %eax
js 0x4ed2
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %eax, %esi
callq 0x32b0
movq 0x20(%rsp), %rsi
leaq 0x43b1(%rip), %rdx      # 0x9274
movq %r12, %rdi
movl $0x132, %ecx            # imm = 0x132
callq 0x31f0
jmp 0x4ed8
movl $0x1, %r13d
movl %r13d, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq