// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3540
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x26, %eax
jne 0x580a
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x580a
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
leaq -0x40(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x33d0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x57d5
movl $0x1, -0x4(%rbp)
jmp 0x5933
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
movq -0x40(%rbp), %rdx
callq 0x32b0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x5a17(%rip), %rdx      # 0xb20b
movl $0x132, %ecx            # imm = 0x132
callq 0x31f0
movl $0x0, -0x4(%rbp)
jmp 0x5933
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
leaq -0x40(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
leaq -0x34(%rbp), %r10
leaq -0x38(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x33d0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x5854
movl $0x1, -0x4(%rbp)
jmp 0x5933
movl $0x0, -0x48(%rbp)
cmpl $-0x1, -0x34(%rbp)
je 0x5909
jmp 0x5867
movl -0x34(%rbp), %edi
leaq -0x440(%rbp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x32f0
movl %eax, -0x444(%rbp)
cmpl $0x0, -0x444(%rbp)
jne 0x588c
jmp 0x5901
cmpl $0x0, -0x444(%rbp)
jge 0x58d7
movq -0x18(%rbp), %rdi
callq 0x3270
movq -0x18(%rbp), %rax
movq %rax, -0x450(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31b0
movq -0x450(%rbp), %rdi
movq %rax, %rdx
leaq 0x598d(%rip), %rsi      # 0xb250
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
movl $0x1, -0x48(%rbp)
jmp 0x5901
movslq -0x444(%rbp), %rax
movb $0x0, -0x440(%rbp,%rax)
movq -0x18(%rbp), %rdi
leaq -0x440(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x3510
jmp 0x5867
movl -0x34(%rbp), %edi
callq 0x3290
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x44(%rbp), %edx
movq -0x40(%rbp), %rcx
movl -0x38(%rbp), %r8d
callq 0x52b0
cmpl $0x0, %eax
je 0x592d
movl $0x1, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nop