// File: /workspace/github_c_makefile_star2_O1/haxlang[P]hax/haxUnixUtil.c
// Function: Hax_CreatePipeline
int
Hax_CreatePipeline(
    Hax_Interp *interp,		/* Interpreter to use for error reporting. */
    ClientData clientData,	/* Unix Client Data */
    int argc,			/* Number of entries in argv. */
    char **argv,		/* Array of strings describing commands in
				 * pipeline plus I/O redirection with <,
				 * <<, and >.  Argv[argc] must be NULL. */
    int **pidArrayPtr,		/* Word at *pidArrayPtr gets filled in with
				 * address of array of pids for processes
				 * in pipeline (first pid is first process
				 * in pipeline). */
    int *inPipePtr,		/* If non-NULL, input to the pipeline comes
				 * from a pipe (unless overridden by
				 * redirection in the command).  The file
				 * id with which to write to this pipe is
				 * stored at *inPipePtr.  -1 means command
				 * specified its own input source. */
    int *outPipePtr,		/* If non-NULL, output to the pipeline goes
				 * to a pipe, unless overriden by redirection
				 * in the command.  The file id with which to
				 * read frome this pipe is stored at
				 * *outPipePtr.  -1 means command specified
				 * its own output sink. */
    int *errFilePtr		/* If non-NULL, all stderr output from the
				 * pipeline will go to a temporary file
				 * created here, and a descriptor to read
				 * the file will be left at *errFilePtr.
				 * The file will be removed already, so
				 * closing this descriptor will be the end
				 * of the file.  If this is NULL, then
				 * all stderr output goes to our stderr. */)
{
    Hax_Memoryp *memoryp;
    int *pidPtr = NULL;		/* Points to malloc-ed array holding all
				 * the pids of child processes. */
    int numPids = 0;		/* Actual number of processes that exist
				 * at *pidPtr right now. */
    int cmdCount;		/* Count of number of distinct commands
				 * found in argc/argv. */
    char *input = NULL;		/* Describes input for pipeline, depending
				 * on "inputFile".  NULL means take input
				 * from stdin/pipe. */
    int inputFile = 0;		/* Non-zero means input is name of input
				 * file.  Zero means input holds actual
				 * text to be input to command. */
    char *output = NULL;	/* Holds name of output file to pipe to,
				 * or NULL if output goes to stdout/pipe. */
    int inputId = -1;		/* Readable file id input to current command in
				 * pipeline (could be file or pipe).  -1
				 * means use stdin. */
    int outputId = -1;		/* Writable file id for output from current
				 * command in pipeline (could be file or pipe).
				 * -1 means use stdout. */
    int errorId = -1;		/* Writable file id for all standard error
				 * output from all commands in pipeline.  -1
				 * means use stderr. */
    int lastOutputId = -1;	/* Write file id for output from last command
				 * in pipeline (could be file or pipe).
				 * -1 means use stdout. */
    int pipeIds[2];		/* File ids for pipe that's being created. */
    int firstArg, lastArg;	/* Indexes of first and last arguments in
				 * current command. */
    int lastBar;
    char *execName;
    int i, j, pid;

    if (inPipePtr != NULL) {
	*inPipePtr = -1;
    }
    if (outPipePtr != NULL) {
	*outPipePtr = -1;
    }
    if (errFilePtr != NULL) {
	*errFilePtr = -1;
    }
    pipeIds[0] = pipeIds[1] = -1;

    memoryp = Hax_GetMemoryp(interp);

    /*
     * First, scan through all the arguments to figure out the structure
     * of the pipeline.  Count the number of distinct processes (it's the
     * number of "|" arguments).  If there are "<", "<<", or ">" arguments
     * then make note of input and output redirection and remove these
     * arguments and the arguments that follow them.
     */

    cmdCount = 1;
    lastBar = -1;
    for (i = 0; i < argc; i++) {
	if ((argv[i][0] == '|') && ((argv[i][1] == 0))) {
	    if ((i == (lastBar+1)) || (i == (argc-1))) {
		interp->result = (char *) "illegal use of | in command";
		return -1;
	    }
	    lastBar = i;
	    cmdCount++;
	    continue;
	} else if (argv[i][0] == '<') {
	    if (argv[i][1] == 0) {
		input = argv[i+1];
		inputFile = 1;
	    } else if ((argv[i][1] == '<') && (argv[i][2] == 0)) {
		input = argv[i+1];
		inputFile = 0;
	    } else {
		continue;
	    }
	} else if ((argv[i][0] == '>') && (argv[i][1] == 0)) {
	    output = argv[i+1];
	} else {
	    continue;
	}
	if (i >= (argc-1)) {
	    Hax_AppendResult(interp, "can't specify \"", argv[i],
		    "\" as last word in command", (char *) NULL);
	    return -1;
	}
	for (j = i+2; j < argc; j++) {
	    argv[j-2] = argv[j];
	}
	argc -= 2;
	i--;			/* Process new arg from same position. */
    }
    if (argc == 0) {
	interp->result = (char *) "didn't specify command to execute";
	return -1;
    }

    /*
     * Set up the redirected input source for the pipeline, if
     * so requested.
     */

    if (input != NULL) {
	if (!inputFile) {
	    /*
	     * Immediate data in command.  Create temporary file and
	     * put data into file.
	     */

#	    define TMP_STDIN_NAME "/tmp/hax.in.XXXXXX"
	    char inName[sizeof(TMP_STDIN_NAME) + 1];
	    int length;

	    strcpy(inName, TMP_STDIN_NAME);
	    inputId = mkstemp(inName);
	    if (inputId < 0) {
		Hax_AppendResult(interp,
			"couldn't create input file for command: ",
			Hax_UnixError(interp), (char *) NULL);
		goto error;
	    }
	    length = strlen(input);
	    if (write(inputId, input, length) != length) {
		Hax_AppendResult(interp,
			"couldn't write file input for command: ",
			Hax_UnixError(interp), (char *) NULL);
		goto error;
	    }
	    if ((lseek(inputId, 0L, 0) == -1) || (unlink(inName) == -1)) {
		Hax_AppendResult(interp,
			"couldn't reset or remove input file for command: ",
			Hax_UnixError(interp), (char *) NULL);
		goto error;
	    }
	} else {
	    /*
	     * File redirection.  Just open the file.
	     */

	    inputId = open(input, O_RDONLY, 0);
	    if (inputId < 0) {
		Hax_AppendResult(interp,
			"couldn't read file \"", input, "\": ",
			Hax_UnixError(interp), (char *) NULL);
		goto error;
	    }
	}
    } else if (inPipePtr != NULL) {
	if (pipe(pipeIds) != 0) {
	    Hax_AppendResult(interp,
		    "couldn't create input pipe for command: ",
		    Hax_UnixError(interp), (char *) NULL);
	    goto error;
	}
	inputId = pipeIds[0];
	*inPipePtr = pipeIds[1];
	pipeIds[0] = pipeIds[1] = -1;
    }

    /*
     * Set up the redirected output sink for the pipeline from one
     * of two places, if requested.
     */

    if (output != NULL) {
	/*
	 * Output is to go to a file.
	 */

	lastOutputId = open(output, O_WRONLY|O_CREAT|O_TRUNC, 0666);
	if (lastOutputId < 0) {
	    Hax_AppendResult(interp,
		    "couldn't write file \"", output, "\": ",
		    Hax_UnixError(interp), (char *) NULL);
	    goto error;
	}
    } else if (outPipePtr != NULL) {
	/*
	 * Output is to go to a pipe.
	 */

	if (pipe(pipeIds) != 0) {
	    Hax_AppendResult(interp,
		    "couldn't create output pipe: ",
		    Hax_UnixError(interp), (char *) NULL);
	    goto error;
	}
	lastOutputId = pipeIds[1];
	*outPipePtr = pipeIds[0];
	pipeIds[0] = pipeIds[1] = -1;
    }

    /*
     * Set up the standard error output sink for the pipeline, if
     * requested.  Use a temporary file which is opened, then deleted.
     * Could potentially just use pipe, but if it filled up it could
     * cause the pipeline to deadlock:  we'd be waiting for processes
     * to complete before reading stderr, and processes couldn't complete
     * because stderr was backed up.
     */

    if (errFilePtr != NULL) {
#	define TMP_STDERR_NAME "/tmp/hax.err.XXXXXX"
	char errName[sizeof(TMP_STDERR_NAME) + 1];

	strcpy(errName, TMP_STDERR_NAME);

	/*
	 * mktemp() usage warns on NetBSD as it is an insecure function.
	 * Fake it with mkstemp()+close() to pacify the warning. The I/O
	 * mechanism should be certainly done in a better way.
	 */
	if ((errorId = mkstemp(errName)) == -1 || close(errorId)) {
	    goto errFileError;
	}
	errorId = open(errName, O_WRONLY|O_CREAT|O_TRUNC, 0600);
	if (errorId < 0) {
	    errFileError:
	    Hax_AppendResult(interp,
		    "couldn't create error file for command: ",
		    Hax_UnixError(interp), (char *) NULL);
	    goto error;
	}
	*errFilePtr = open(errName, O_RDONLY, 0);
	if (*errFilePtr < 0) {
	    goto errFileError;
	}
	if (unlink(errName) == -1) {
	    Hax_AppendResult(interp,
		    "couldn't remove error file for command: ",
		    Hax_UnixError(interp), (char *) NULL);
	    goto error;
	}
    }

    /*
     * Scan through the argc array, forking off a process for each
     * group of arguments between "|" arguments.
     */

    pidPtr = (int *) ckalloc(memoryp, (unsigned) (cmdCount * sizeof(int)));
    for (i = 0; i < numPids; i++) {
	pidPtr[i] = -1;
    }
    for (firstArg = 0; firstArg < argc; numPids++, firstArg = lastArg+1) {
	for (lastArg = firstArg; lastArg < argc; lastArg++) {
	    if ((argv[lastArg][0] == '|') && (argv[lastArg][1] == 0)) {
		break;
	    }
	}
	argv[lastArg] = NULL;
	if (lastArg == argc) {
	    outputId = lastOutputId;
	} else {
	    if (pipe(pipeIds) != 0) {
		Hax_AppendResult(interp, "couldn't create pipe: ",
			Hax_UnixError(interp), (char *) NULL);
		goto error;
	    }
	    outputId = pipeIds[1];
	}
	execName = Hax_TildeSubst(interp, clientData, argv[firstArg]);
	pid = Hax_Fork(interp, clientData);
	if (pid == -1) {
	    Hax_AppendResult(interp, "couldn't fork child process: ",
		    Hax_UnixError(interp), (char *) NULL);
	    goto error;
	}
	if (pid == 0) {
	    char errSpace[200];

	    if (((inputId != -1) && (dup2(inputId, 0) == -1))
		    || ((outputId != -1) && (dup2(outputId, 1) == -1))
		    || ((errorId != -1) && (dup2(errorId, 2) == -1))) {
		char *err;
		err = (char *) "forked process couldn't set up input/output\n";
		write(errorId < 0 ? 2 : errorId, err, strlen(err));
		_exit(1);
	    }
	    for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId);
		    i++) {
		close(i);
	    }
	    execvp(execName, &argv[firstArg]);
	    sprintf(errSpace, "couldn't find \"%.150s\" to execute\n",
		    argv[firstArg]);
	    write(2, errSpace, strlen(errSpace));
	    _exit(1);
	} else {
	    pidPtr[numPids] = pid;
	}

	/*
	 * Close off our copies of file descriptors that were set up for
	 * this child, then set up the input for the next child.
	 */

	if (inputId != -1) {
	    close(inputId);
	}
	if (outputId != -1) {
	    close(outputId);
	}
	inputId = pipeIds[0];
	pipeIds[0] = pipeIds[1] = -1;
    }
    *pidArrayPtr = pidPtr;

    /*
     * All done.  Cleanup open files lying around and then return.
     */

cleanup:
    if (inputId != -1) {
	close(inputId);
    }
    if (lastOutputId != -1) {
	close(lastOutputId);
    }
    if (errorId != -1) {
	close(errorId);
    }
    return numPids;

    /*
     * An error occurred.  There could have been extra files open, such
     * as pipes between children.  Clean them all up.  Detach any child
     * processes that have been created.
     */

    error:
    if ((inPipePtr != NULL) && (*inPipePtr != -1)) {
	close(*inPipePtr);
	*inPipePtr = -1;
    }
    if ((outPipePtr != NULL) && (*outPipePtr != -1)) {
	close(*outPipePtr);
	*outPipePtr = -1;
    }
    if ((errFilePtr != NULL) && (*errFilePtr != -1)) {
	close(*errFilePtr);
	*errFilePtr = -1;
    }
    if (pipeIds[0] != -1) {
	close(pipeIds[0]);
    }
    if (pipeIds[1] != -1) {
	close(pipeIds[1]);
    }
    if (pidPtr != NULL) {
	for (i = 0; i < numPids; i++) {
	    if (pidPtr[i] != -1) {
		Hax_DetachPids(clientData, 1, &pidPtr[i]);
	    }
	}
	ckfree(memoryp, (char *) pidPtr);
    }
    numPids = -1;
    goto cleanup;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r8, %rbx
movq %rcx, %r13
movl %edx, %r14d
movq %rsi, 0x38(%rsp)
movq 0x170(%rsp), %rax
testq %r9, %r9
je 0x73d1
movl $0xffffffff, (%r9)      # imm = 0xFFFFFFFF
movq 0x178(%rsp), %rbp
testq %rax, %rax
je 0x73e4
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
testq %rbp, %rbp
je 0x73f0
movl $0xffffffff, (%rbp)     # imm = 0xFFFFFFFF
movq %r9, 0x50(%rsp)
movq $-0x1, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
callq 0x3540
movq %rax, 0x58(%rsp)
xorl %eax, %eax
testl %r14d, %r14d
jle 0x751a
movl $0x1, %r15d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
xorl %ecx, %ecx
xorl %r12d, %r12d
movslq %eax, %r9
movq (%r13,%r9,8), %rdx
movzbl (%rdx), %r8d
cmpl $0x3c, %r8d
je 0x7466
cmpl $0x3e, %r8d
je 0x7486
cmpl $0x7c, %r8d
jne 0x7504
cmpb $0x0, 0x1(%rdx)
je 0x74e9
cmpl $0x3e, %r8d
je 0x7486
cmpl $0x3c, %r8d
jne 0x7504
movzbl 0x1(%rdx), %r8d
cmpl $0x3c, %r8d
je 0x7493
testl %r8d, %r8d
jne 0x7504
movq 0x8(%r13,%r9,8), %r12
movl $0x1, %ecx
jmp 0x74a0
cmpb $0x0, 0x1(%rdx)
jne 0x7504
movq 0x8(%r13,%r9,8), %rdi
jmp 0x74a0
cmpb $0x0, 0x2(%rdx)
jne 0x7504
movq 0x8(%r13,%r9,8), %r12
xorl %ecx, %ecx
leal -0x1(%r14), %r8d
cmpl %r8d, %eax
jge 0x766a
leal 0x2(%rax), %edx
cmpl %r14d, %edx
jge 0x74e1
movslq %edx, %rdx
leaq (,%rdx,8), %rdx
addq %r13, %rdx
movl %r14d, %r10d
subl %eax, %r10d
addl $-0x2, %r10d
xorl %r8d, %r8d
movq (%rdx,%r8,8), %r9
movq %r9, -0x10(%rdx,%r8,8)
incq %r8
cmpl %r8d, %r10d
jne 0x74d0
addl $-0x2, %r14d
decl %eax
jmp 0x7504
incl %esi
cmpl %esi, %eax
je 0x7833
leal -0x1(%r14), %edx
cmpl %edx, %eax
je 0x7833
incl %r15d
movl %eax, %esi
incl %eax
cmpl %r14d, %eax
jl 0x742a
testl %ecx, %ecx
sete %al
shll $0x2, %r15d
jmp 0x7527
movb $0x1, %al
movl $0x4, %r15d
xorl %r12d, %r12d
xorl %edi, %edi
testl %r14d, %r14d
je 0x75d7
testq %r12, %r12
movq %rbx, 0x48(%rsp)
movq %rdi, 0x10(%rsp)
je 0x75eb
testb %al, %al
je 0x7643
movups 0x2e45(%rip), %xmm0     # 0xa397
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
movl $0x585858, 0xf(%rdi)    # imm = 0x585858
callq 0x3460
movl %eax, %ebx
testl %eax, %eax
movq %rbx, 0x30(%rsp)
js 0x769d
movq %r12, %rdi
callq 0x3190
movslq %eax, %rbp
movl %ebx, %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x3150
cmpq %rbp, %rax
jne 0x76fe
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3220
leaq 0x2e53(%rip), %r12      # 0xa3fb
cmpq $-0x1, %rax
je 0x7705
leaq 0x70(%rsp), %rdi
callq 0x3090
cmpl $-0x1, %eax
movq 0x178(%rsp), %rbp
je 0x770d
movq 0x30(%rsp), %r12
jmp 0x765b
leaq 0x2d97(%rip), %rax      # 0xa375
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
jmp 0x7687
cmpq $0x0, 0x50(%rsp)
je 0x7692
movq %rdi, %rbx
leaq 0x18(%rsp), %rdi
callq 0x32a0
testl %eax, %eax
je 0x774a
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x31b0
leaq 0x2e0d(%rip), %rsi      # 0xa42d
movq $0x0, 0x28(%rsp)
movq %r14, %rdi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x7815
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x34e0
movq %rax, %rbx
testl %eax, %eax
js 0x76a6
movq %rbx, %r12
movq 0x48(%rsp), %rbx
movq 0x10(%rsp), %rdi
jmp 0x776b
leaq 0x2cda(%rip), %rsi      # 0xa34b
leaq 0x2ce3(%rip), %rcx      # 0xa35b
movq 0x20(%rsp), %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3510
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x7ba4
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x776b
leaq 0x2d06(%rip), %r12      # 0xa3aa
jmp 0x770d
movq $0x0, 0x28(%rsp)
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x31b0
leaq 0x2bc9(%rip), %rsi      # 0xa28c
leaq 0x1b21(%rip), %rcx      # 0x91eb
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x3510
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq $0x0, 0x10(%rsp)
movq %rbx, %r12
jmp 0x7aa5
leaq 0x2cce(%rip), %r12      # 0xa3d3
movq 0x178(%rsp), %rbp
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x31b0
movq $0x0, 0x28(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
jmp 0x7a97
movl 0x18(%rsp), %r12d
movl 0x1c(%rsp), %eax
movq 0x50(%rsp), %rcx
movl %eax, (%rcx)
movq $-0x1, 0x18(%rsp)
movq %rbx, %rdi
movq 0x48(%rsp), %rbx
testq %rdi, %rdi
je 0x77d0
movl $0x241, %esi            # imm = 0x241
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x34e0
movl %eax, 0xc(%rsp)
testl %eax, %eax
jns 0x7868
movq $0x0, 0x28(%rsp)
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x31b0
leaq 0x2cac(%rip), %rsi      # 0xa456
leaq 0x1a3a(%rip), %rcx      # 0x91eb
movq %r14, %rdi
movq 0x10(%rsp), %rdx
movq %rax, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x3510
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
jmp 0x7825
cmpq $0x0, 0x170(%rsp)
je 0x783f
leaq 0x18(%rsp), %rdi
callq 0x32a0
testl %eax, %eax
je 0x7849
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x31b0
leaq 0x2c6f(%rip), %rsi      # 0xa46c
movq $0x0, 0x28(%rsp)
movq %r14, %rdi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq $0x0, 0x10(%rsp)
jmp 0x7aa5
leaq 0x2af5(%rip), %rax      # 0xa32f
jmp 0x75de
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
jmp 0x7868
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %ecx
movl %ecx, 0xc(%rsp)
movq 0x170(%rsp), %rcx
movl %eax, (%rcx)
movq $-0x1, 0x18(%rsp)
testq %rbp, %rbp
je 0x7905
movups 0x2c12(%rip), %xmm0     # 0xa48a
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
movl $0x585858, 0x10(%rdi)   # imm = 0x585858
callq 0x3460
movl %eax, %ebp
leaq 0x2c09(%rip), %rax      # 0xa49e
movq %rax, 0x28(%rsp)
cmpl $-0x1, %ebp
movq %r12, 0x30(%rsp)
je 0x790c
movl %ebp, %edi
callq 0x3290
testl %eax, %eax
jne 0x7911
leaq 0x70(%rsp), %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x34e0
movl %eax, %ebp
testl %eax, %eax
js 0x7911
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x34e0
movq 0x178(%rsp), %rcx
movl %eax, (%rcx)
testl %eax, %eax
js 0x7911
leaq 0x70(%rsp), %rdi
callq 0x3090
movb $0x1, %r12b
cmpl $-0x1, %eax
je 0x7c35
movl %ebp, 0x8(%rsp)
jmp 0x7939
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x7958
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, 0x8(%rsp)
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x31b0
xorl %r12d, %r12d
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
testb %r12b, %r12b
movq 0x178(%rsp), %rbp
je 0x7a8e
movq 0x30(%rsp), %r12
movq 0x48(%rsp), %rbx
movl 0x8(%rsp), %ebp
leaq 0x2957(%rip), %rdx      # 0xa2b6
movq 0x58(%rsp), %rdi
movq %r15, %rsi
movl $0x2a8, %ecx            # imm = 0x2A8
callq 0x34c0
movq %rax, 0x10(%rsp)
testl %r14d, %r14d
jle 0x7bb9
movl %ebp, 0x8(%rsp)
movl %r14d, %ebx
xorl %r15d, %r15d
xorl %ebp, %ebp
movslq %ebp, %rdx
leal 0x1(%rdx), %ebp
cmpl %ebp, %r14d
cmovgl %r14d, %ebp
movq %rdx, %rax
movq %r15, 0x28(%rsp)
movq (%r13,%rax,8), %rcx
cmpb $0x7c, (%rcx)
jne 0x79b0
cmpb $0x0, 0x1(%rcx)
je 0x79ba
incq %rax
cmpq %rbx, %rax
jl 0x79a0
jmp 0x79bc
movl %eax, %ebp
movslq %ebp, %rax
movq $0x0, (%r13,%rax,8)
movl 0xc(%rsp), %ecx
cmpl %r14d, %eax
je 0x79ed
movq %rdx, %r15
leaq 0x18(%rsp), %rdi
callq 0x32a0
testl %eax, %eax
jne 0x7c00
movl 0x1c(%rsp), %ecx
movq %r15, %rdx
movl %ecx, 0x44(%rsp)
movq %r12, 0x30(%rsp)
movq %rdx, 0x68(%rsp)
movq (%r13,%rdx,8), %rdx
movq 0x20(%rsp), %r15
movq %r15, %rdi
movq 0x38(%rsp), %r12
movq %r12, %rsi
callq 0x3570
movq %rax, 0x60(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x3360
cmpl $-0x1, %eax
je 0x7bc6
testl %eax, %eax
movq 0x30(%rsp), %rdi
je 0x7c46
movq 0x28(%rsp), %r15
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
cmpl $-0x1, %edi
je 0x7a53
callq 0x3290
movl 0x44(%rsp), %edi
cmpl $-0x1, %edi
je 0x7a61
callq 0x3290
movl 0x18(%rsp), %r12d
movq $-0x1, 0x18(%rsp)
incq %r15
incl %ebp
cmpl %r14d, %ebp
jl 0x798b
movl %r15d, %r14d
movq 0x48(%rsp), %rbx
movl 0x8(%rsp), %ebp
jmp 0x7bbc
movq $0x0, 0x28(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %r13
movq 0x50(%rsp), %r15
testq %r15, %r15
movq 0x170(%rsp), %r14
je 0x7ad0
movl (%r15), %edi
cmpl $-0x1, %edi
je 0x7ad0
callq 0x3290
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x7ae9
movl (%r14), %edi
cmpl $-0x1, %edi
je 0x7ae9
callq 0x3290
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
testq %rbp, %rbp
movq 0x28(%rsp), %rbx
je 0x7b07
movl (%rbp), %edi
cmpl $-0x1, %edi
je 0x7b07
callq 0x3290
movl $0xffffffff, (%rbp)     # imm = 0xFFFFFFFF
movl 0x18(%rsp), %edi
cmpl $-0x1, %edi
je 0x7b15
callq 0x3290
movl 0x1c(%rsp), %edi
cmpl $-0x1, %edi
movl 0x8(%rsp), %ebp
je 0x7b27
callq 0x3290
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpq $0x0, 0x10(%rsp)
je 0x7b7a
testl %ebx, %ebx
je 0x7b5f
movl %ebx, %ebx
movq 0x10(%rsp), %r15
cmpl $-0x1, (%r15)
je 0x7b56
movq %r13, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x32b0
addq $0x4, %r15
decq %rbx
jne 0x7b40
leaq 0x2750(%rip), %rdx      # 0xa2b6
movq 0x58(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x31b, %ecx            # imm = 0x31B
callq 0x31f0
movl 0xc(%rsp), %ebx
cmpl $-0x1, %r12d
je 0x7b8c
movl %r12d, %edi
callq 0x3290
cmpl $-0x1, %ebx
je 0x7b98
movl %ebx, %edi
callq 0x3290
cmpl $-0x1, %ebp
je 0x7ba4
movl %ebp, %edi
callq 0x3290
movl %r14d, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
jmp 0x7b7a
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x31b0
leaq 0x292d(%rip), %rsi      # 0xa507
movq %rbx, %rdi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movq 0x38(%rsp), %r13
movq 0x178(%rsp), %rbp
movq 0x30(%rsp), %r12
jmp 0x7aaa
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x31b0
leaq 0x28dc(%rip), %rsi      # 0xa4f0
movq %rbx, %rdi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3510
movq 0x38(%rsp), %r13
movq 0x178(%rsp), %rbp
jmp 0x7aaa
leaq 0x288b(%rip), %rax      # 0xa4c7
movq %rax, 0x28(%rsp)
jmp 0x7911
cmpl $-0x1, %edi
je 0x7c5c
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x31d0
cmpl $-0x1, %eax
je 0x7c90
cmpl $-0x1, 0x44(%rsp)
je 0x7c76
movl 0x44(%rsp), %edi
movl $0x1, %esi
callq 0x31d0
cmpl $-0x1, %eax
je 0x7c90
cmpl $-0x1, 0x8(%rsp)
je 0x7caf
movl 0x8(%rsp), %edi
movl $0x2, %esi
callq 0x31d0
cmpl $-0x1, %eax
jne 0x7caf
movl 0x8(%rsp), %eax
testl %eax, %eax
movl $0x2, %edi
cmovnsl %eax, %edi
leaq 0x2880(%rip), %rsi      # 0xa525
movl $0x2c, %edx
jmp 0x7d38
movq 0x30(%rsp), %r14
movl 0x44(%rsp), %eax
cmpl %r14d, %eax
cmovgl %eax, %r14d
movl 0x8(%rsp), %eax
cmpl %r14d, %eax
cmovgl %eax, %r14d
cmpl $0x3, %r14d
jl 0x7cf0
negl %r14d
movl $0x3, %ebx
movl %ebx, %edi
callq 0x3290
leal (%r14,%rbx), %eax
incl %eax
movl %ebx, %ecx
incl %ecx
movl %ecx, %ebx
cmpl $0x1, %eax
jne 0x7cd8
movq 0x68(%rsp), %rbx
leaq (,%rbx,8), %rsi
addq %r13, %rsi
movq 0x60(%rsp), %rdi
callq 0x3560
movq (%r13,%rbx,8), %rdx
leaq 0x283c(%rip), %rsi      # 0xa552
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x35a0
movq %rbx, %rdi
callq 0x3190
movl $0x2, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3150
movl $0x1, %edi
callq 0x30d0