// File: /workspace/github_c_makefile_star2_O3/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 0x4d52
cmpb $0x0, 0x1(%rax)
je 0x4df3
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 0x4e52
movl %eax, %ebp
movl 0x1c(%rsp), %edi
cmpl $-0x1, %edi
je 0x4e94
leaq 0x30(%rsp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x32f0
testl %eax, %eax
je 0x4e5a
leaq 0x30(%rsp), %r15
testl %eax, %eax
js 0x4e5f
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, 0x30(%rsp,%rax)
xorl %r12d, %r12d
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3510
movl 0x1c(%rsp), %edi
movl $0x3e8, %edx            # imm = 0x3E8
movq %r15, %rsi
callq 0x32f0
testl %eax, %eax
jne 0x4db5
jmp 0x4e8b
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 0x4e52
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %eax, %esi
callq 0x32b0
movq 0x20(%rsp), %rsi
leaq 0x3455(%rip), %rdx      # 0x8298
movq %r12, %rdi
movl $0x132, %ecx            # imm = 0x132
callq 0x31f0
jmp 0x4eb7
movl $0x1, %r13d
jmp 0x4eb7
xorl %r12d, %r12d
jmp 0x4e8b
movq %r14, %rdi
callq 0x3270
movq %r14, %rdi
callq 0x31b0
leaq 0x3467(%rip), %rsi      # 0x82dd
movq %r14, %rdi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movl $0x1, %r12d
movl 0x1c(%rsp), %edi
callq 0x3290
movq 0x20(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x4a00
testl %eax, %eax
movl $0x1, %r13d
cmovel %r12d, %r13d
movl %r13d, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq