// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x68(%rbp)
movl $0xffffffff, -0x6c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x70(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x74(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x78(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x38(%rbp)
je 0x9a1d
movq -0x38(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, 0x10(%rbp)
je 0x9a2e
movq 0x10(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, 0x18(%rbp)
je 0x9a3f
movq 0x18(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
callq 0x3540
movq %rax, -0x40(%rbp)
movl $0x1, -0x50(%rbp)
movl $0xffffffff, -0x8c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x9ccd
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0x9b0a
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x9b0a
movl -0x9c(%rbp), %eax
movl -0x8c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x9ad6
movl -0x9c(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x9af0
movq -0x10(%rbp), %rax
leaq 0x27e6(%rip), %rcx      # 0xc2c7
movq %rcx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa5e2
movl -0x9c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x9cb9
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x3c, %eax
jne 0x9bb8
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x9b5e
movq -0x28(%rbp), %rax
movl -0x9c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x9bb6
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3c, %eax
jne 0x9baf
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x9baf
movq -0x28(%rbp), %rax
movl -0x9c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
jmp 0x9bb4
jmp 0x9cb9
jmp 0x9bb6
jmp 0x9c08
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x9c01
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x9c01
movq -0x28(%rbp), %rax
movl -0x9c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
jmp 0x9c06
jmp 0x9cb9
jmp 0x9c08
jmp 0x9c0a
movl -0x9c(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jl 0x9c53
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x26af(%rip), %rsi      # 0xc2e3
leaq 0x26b8(%rip), %rcx      # 0xc2f3
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x3510
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa5e2
movl -0x9c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x9ca1
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movl -0xa0(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x9c62
movl -0x1c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl -0x9c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x9a75
cmpl $0x0, -0x1c(%rbp)
jne 0x9ced
movq -0x10(%rbp), %rax
leaq 0x262f(%rip), %rcx      # 0xc30d
movq %rcx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa5e2
cmpq $0x0, -0x58(%rbp)
je 0x9e89
cmpl $0x0, -0x5c(%rbp)
jne 0x9e1e
leaq -0xc0(%rbp), %rdi
leaq 0x261f(%rip), %rsi      # 0xc32f
callq 0x30e0
leaq -0xc0(%rbp), %rdi
callq 0x3460
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x9d5f
movq -0x10(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x1c0(%rbp), %rdi
movq %rax, %rdx
leaq 0x25f3(%rip), %rsi      # 0xc342
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
movq -0x58(%rbp), %rdi
callq 0x3190
movl %eax, -0xc4(%rbp)
movl -0x6c(%rbp), %edi
movq -0x58(%rbp), %rsi
movslq -0xc4(%rbp), %rdx
callq 0x3150
movslq -0xc4(%rbp), %rcx
cmpq %rcx, %rax
je 0x9dc2
movq -0x10(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x1c8(%rbp), %rdi
movq %rax, %rdx
leaq 0x25b9(%rip), %rsi      # 0xc36b
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
movl -0x6c(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x3220
cmpq $-0x1, %rax
je 0x9de7
leaq -0xc0(%rbp), %rdi
callq 0x3090
cmpl $-0x1, %eax
jne 0x9e1c
movq -0x10(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x1d0(%rbp), %rdi
movq %rax, %rdx
leaq 0x2587(%rip), %rsi      # 0xc393
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
jmp 0x9e87
movq -0x58(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
movb $0x0, %al
callq 0x34e0
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x9e85
movq -0x10(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x1e0(%rbp), %rdi
movq -0x1d8(%rbp), %rdx
movq %rax, %r8
leaq 0x23b7(%rip), %rsi      # 0xc224
leaq 0x1377(%rip), %rcx      # 0xb1eb
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
jmp 0x9e87
jmp 0x9ef2
cmpq $0x0, -0x38(%rbp)
je 0x9ef0
leaq -0x80(%rbp), %rdi
callq 0x32a0
cmpl $0x0, %eax
je 0x9ed3
movq -0x10(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x1e8(%rbp), %rdi
movq %rax, %rdx
leaq 0x2502(%rip), %rsi      # 0xc3c5
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
movl -0x80(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x7c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ef2
cmpq $0x0, -0x68(%rbp)
je 0x9f68
movq -0x68(%rbp), %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x34e0
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x78(%rbp)
jge 0x9f66
movq -0x10(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x1f8(%rbp), %rdi
movq -0x1f0(%rbp), %rdx
movq %rax, %r8
leaq 0x24a0(%rip), %rsi      # 0xc3ee
leaq 0x1296(%rip), %rcx      # 0xb1eb
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
jmp 0x9fd1
cmpq $0x0, 0x10(%rbp)
je 0x9fcf
leaq -0x80(%rbp), %rdi
callq 0x32a0
cmpl $0x0, %eax
je 0x9fb2
movq -0x10(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x200(%rbp), %rdi
movq %rax, %rdx
leaq 0x2462(%rip), %rsi      # 0xc404
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
movl -0x7c(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x80(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
jmp 0x9fd1
cmpq $0x0, 0x18(%rbp)
je 0xa0d7
leaq -0xe0(%rbp), %rdi
leaq 0x2438(%rip), %rsi      # 0xc422
callq 0x30e0
leaq -0xe0(%rbp), %rdi
callq 0x3460
movl %eax, -0x74(%rbp)
cmpl $-0x1, %eax
je 0xa010
movl -0x74(%rbp), %edi
callq 0x3290
cmpl $0x0, %eax
je 0xa012
jmp 0xa035
leaq -0xe0(%rbp), %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x180, %edx            # imm = 0x180
movb $0x0, %al
callq 0x34e0
movl %eax, -0x74(%rbp)
cmpl $0x0, -0x74(%rbp)
jge 0xa06a
jmp 0xa035
movq -0x10(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x208(%rbp), %rdi
movq %rax, %rdx
leaq 0x23dc(%rip), %rsi      # 0xc436
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
leaq -0xe0(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
movb $0x0, %al
callq 0x34e0
movl %eax, %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
jge 0xa08f
jmp 0xa035
leaq -0xe0(%rbp), %rdi
callq 0x3090
cmpl $-0x1, %eax
jne 0xa0d5
movq -0x10(%rbp), %rax
movq %rax, -0x210(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x210(%rbp), %rdi
movq %rax, %rdx
leaq 0x239a(%rip), %rsi      # 0xc45f
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
jmp 0xa0d7
movq -0x40(%rbp), %rdi
movslq -0x50(%rbp), %rax
shlq $0x2, %rax
movl %eax, %eax
movl %eax, %esi
leaq 0x2160(%rip), %rdx      # 0xc24e
movl $0x2a8, %ecx            # imm = 0x2A8
callq 0x34c0
movq %rax, -0x48(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0xa134
movq -0x48(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0xa106
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0xa492
movl -0x84(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0xa1a8
movq -0x28(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0xa195
movq -0x28(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0xa195
jmp 0xa1a8
jmp 0xa197
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0xa159
movq -0x28(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x88(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0xa1ce
movl -0x78(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0xa217
leaq -0x80(%rbp), %rdi
callq 0x32a0
cmpl $0x0, %eax
je 0xa211
movq -0x10(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x218(%rbp), %rdi
movq %rax, %rdx
leaq 0x2287(%rip), %rsi      # 0xc488
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
movl -0x7c(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movslq -0x84(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3570
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3360
movl %eax, -0xa4(%rbp)
cmpl $-0x1, -0xa4(%rbp)
jne 0xa28b
movq -0x10(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31b0
movq -0x220(%rbp), %rdi
movq %rax, %rdx
leaq 0x2224(%rip), %rsi      # 0xc49f
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3510
jmp 0xa4d2
cmpl $0x0, -0xa4(%rbp)
jne 0xa434
cmpl $-0x1, -0x6c(%rbp)
je 0xa2ad
movl -0x6c(%rbp), %edi
xorl %esi, %esi
callq 0x31d0
cmpl $-0x1, %eax
je 0xa2e1
cmpl $-0x1, -0x70(%rbp)
je 0xa2c5
movl -0x70(%rbp), %edi
movl $0x1, %esi
callq 0x31d0
cmpl $-0x1, %eax
je 0xa2e1
cmpl $-0x1, -0x74(%rbp)
je 0xa350
movl -0x74(%rbp), %edi
movl $0x2, %esi
callq 0x31d0
cmpl $-0x1, %eax
jne 0xa350
leaq 0x21d5(%rip), %rax      # 0xc4bd
movq %rax, -0x1b8(%rbp)
cmpl $0x0, -0x74(%rbp)
jge 0xa302
movl $0x2, %eax
movl %eax, -0x224(%rbp)
jmp 0xa30b
movl -0x74(%rbp), %eax
movl %eax, -0x224(%rbp)
movl -0x224(%rbp), %eax
movl %eax, -0x234(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x1b8(%rbp), %rdi
callq 0x3190
movl -0x234(%rbp), %edi
movq -0x230(%rbp), %rsi
movq %rax, %rdx
callq 0x3150
movl $0x1, %edi
callq 0x30d0
movl $0x3, -0x9c(%rbp)
movl -0x9c(%rbp), %ecx
movb $0x1, %al
cmpl -0x70(%rbp), %ecx
movb %al, -0x235(%rbp)
jle 0xa392
movl -0x9c(%rbp), %ecx
movb $0x1, %al
cmpl -0x6c(%rbp), %ecx
movb %al, -0x235(%rbp)
jle 0xa392
movl -0x9c(%rbp), %eax
cmpl -0x74(%rbp), %eax
setle %al
movb %al, -0x235(%rbp)
movb -0x235(%rbp), %al
testb $0x1, %al
jne 0xa39e
jmp 0xa3ba
movl -0x9c(%rbp), %edi
callq 0x3290
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0xa35a
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x84(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x3560
leaq -0x1b0(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x84(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x20f5(%rip), %rsi      # 0xc4ea
movb $0x0, %al
callq 0x35a0
leaq -0x1b0(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x3190
movq -0x240(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x3150
movl $0x1, %edi
callq 0x30d0
movl -0xa4(%rbp), %edx
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $-0x1, -0x6c(%rbp)
je 0xa453
movl -0x6c(%rbp), %edi
callq 0x3290
cmpl $-0x1, -0x70(%rbp)
je 0xa461
movl -0x70(%rbp), %edi
callq 0x3290
movl -0x80(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0xa13e
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
cmpl $-0x1, -0x6c(%rbp)
je 0xa4ab
movl -0x6c(%rbp), %edi
callq 0x3290
cmpl $-0x1, -0x78(%rbp)
je 0xa4b9
movl -0x78(%rbp), %edi
callq 0x3290
cmpl $-0x1, -0x74(%rbp)
je 0xa4c7
movl -0x74(%rbp), %edi
callq 0x3290
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xa5e2
cmpq $0x0, -0x38(%rbp)
je 0xa4f7
movq -0x38(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xa4f7
movq -0x38(%rbp), %rax
movl (%rax), %edi
callq 0x3290
movq -0x38(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, 0x10(%rbp)
je 0xa51c
movq 0x10(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xa51c
movq 0x10(%rbp), %rax
movl (%rax), %edi
callq 0x3290
movq 0x10(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, 0x18(%rbp)
je 0xa541
movq 0x18(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xa541
movq 0x18(%rbp), %rax
movl (%rax), %edi
callq 0x3290
movq 0x18(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpl $-0x1, -0x80(%rbp)
je 0xa54f
movl -0x80(%rbp), %edi
callq 0x3290
cmpl $-0x1, -0x7c(%rbp)
je 0xa55d
movl -0x7c(%rbp), %edi
callq 0x3290
cmpq $0x0, -0x48(%rbp)
je 0xa5d6
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0xa5bd
movq -0x48(%rbp), %rax
movslq -0x9c(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
je 0xa5aa
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rdx
movslq -0x9c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movl $0x1, %esi
callq 0x32b0
jmp 0xa5ac
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0xa56e
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x1c82(%rip), %rdx      # 0xc24e
movl $0x31b, %ecx            # imm = 0x31B
callq 0x31f0
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
jmp 0xa49d
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nop