// File: /workspace/github_c_makefile_star2_O1/s3lase[P]v6shell/sh6.c
// Function: execute
static void
execute(struct tnode *t, int *pin, int *pout)
{
	struct tnode *t1;
	enum tnflags f;
	pid_t cpid;
	int i, pfd[2];
	const char **gav;
	const char *cmd, *p;

	if (t == NULL)
		return;
	switch (t->ntype) {
	case TLIST:
		f = t->nflags & (FFIN | FPIN | FINTR);
		if ((t1 = t->nleft) != NULL)
			t1->nflags |= f;
		execute(t1, NULL, NULL);
		if ((t1 = t->nright) != NULL)
			t1->nflags |= f;
		execute(t1, NULL, NULL);
		return;

	case TPIPE:
		if (pipe(pfd) == -1) {
			err(SH_ERR, FMT1S, ERR_PIPE);
			if (pin != NULL) {
				(void)close(pin[0]);
				(void)close(pin[1]);
			}
			return;
		}
		f = t->nflags;
		if ((t1 = t->nleft) != NULL)
			t1->nflags |= FPOUT | (f & (FFIN|FPIN|FINTR|FPRS));
		execute(t1, pin, pfd);
		if ((t1 = t->nright) != NULL)
			t1->nflags |= FPIN | (f & (FAND|FPOUT|FINTR|FPRS));
		execute(t1, pfd, pout);
		(void)close(pfd[0]);
		(void)close(pfd[1]);
		return;

	case TCOMMAND:
		if (t->nav == NULL || t->nav[0] == NULL) {
			/* should never (but can) be true */
			err(SH_ERR, FMT1S, "execute: Invalid command");
			return;
		}
		cmd = t->nav[0];
		if (EQUAL(cmd, ":")) {
			status = SH_TRUE;
			return;
		}
		if (EQUAL(cmd, "chdir")) {
			ascan(t->nav[1], &trim);
			if (t->nav[1] == NULL)
				err(SH_ERR, FMT2S, cmd, ERR_ARGCOUNT);
			else if (chdir(t->nav[1]) == -1)
				err(SH_ERR, FMT2S, cmd, ERR_BADDIR);
			else
				status = SH_TRUE;
			return;
		}
		if (EQUAL(cmd, "exit")) {
			if (prompt == NULL) {
				(void)lseek(FD0, (off_t)0, SEEK_END);
				EXIT(status);
			}
			return;
		}
		if (EQUAL(cmd, "login") || EQUAL(cmd, "newgrp")) {
			if (prompt != NULL) {
				p = (*cmd == 'l') ? PATH_LOGIN : PATH_NEWGRP;
				vscan(t->nav, &trim);
				(void)sasignal(SIGINT, SIG_DFL);
				(void)sasignal(SIGQUIT, SIG_DFL);
				(void)pexec(p, (char *const *)t->nav);
				(void)sasignal(SIGINT, SIG_IGN);
				(void)sasignal(SIGQUIT, SIG_IGN);
			}
			err(SH_ERR, FMT2S, cmd, ERR_EXEC);
			return;
		}
		if (EQUAL(cmd, "shift")) {
			if (dolc > 1) {
				dolv = &dolv[1];
				dolc--;
				status = SH_TRUE;
				return;
			}
			err(SH_ERR, FMT2S, cmd, ERR_NOARGS);
			return;
		}
		if (EQUAL(cmd, "wait")) {
			pwait(-1);
			return;
		}
		/*FALLTHROUGH*/

	case TSUBSHELL:
		f = t->nflags;
		if ((cpid = ((f & FNOFORK) != 0) ? 0 : fork()) == -1) {
			err(SH_ERR, FMT1S, ERR_FORK);
			return;
		}
		/**** Parent! ****/
		if (cpid != 0) {
			if (pin != NULL && (f & FPIN) != 0) {
				(void)close(pin[0]);
				(void)close(pin[1]);
			}
			if ((f & FPRS) != 0)
				fd_print(FD2, "%u\n", (unsigned)cpid);
			if ((f & FAND) != 0)
				return;
			if ((f & FPOUT) == 0)
				pwait(cpid);
			return;
		}
		/**** Child! ****/
		/*
		 * Redirect (read) input from pipe.
		 */
		if (pin != NULL && (f & FPIN) != 0) {
			if (dup2(pin[0], FD0) == -1)
				err(FC_ERR, FMT1S, strerror(errno));
			(void)close(pin[0]);
			(void)close(pin[1]);
		}
		/*
		 * Redirect (write) output to pipe.
		 */
		if (pout != NULL && (f & FPOUT) != 0) {
			if (dup2(pout[1], FD1) == -1)
				err(FC_ERR, FMT1S, strerror(errno));
			(void)close(pout[0]);
			(void)close(pout[1]);
		}
		/*
		 * Redirect (read) input from file.
		 */
		if (t->nfin != NULL && (f & FPIN) == 0) {
			f |= FFIN;
			ascan(t->nfin, &trim);
			if ((i = open(t->nfin, O_RDONLY)) == -1)
				err(FC_ERR, FMT2S, t->nfin, ERR_OPEN);
			if (dup2(i, FD0) == -1)
				err(FC_ERR, FMT1S, strerror(errno));
			(void)close(i);
		}
		/*
		 * Redirect (write) output to file.
		 */
		if (t->nfout != NULL && (f & FPOUT) == 0) {
			if ((f & FCAT) != 0)
				i = O_WRONLY | O_APPEND | O_CREAT;
			else
				i = O_WRONLY | O_TRUNC | O_CREAT;
			ascan(t->nfout, &trim);
			if ((i = open(t->nfout, i, 0666)) == -1)
				err(FC_ERR, FMT2S, t->nfout, ERR_CREATE);
			if (dup2(i, FD1) == -1)
				err(FC_ERR, FMT1S, strerror(errno));
			(void)close(i);
		}
		/*
		 * Set the action for the SIGINT and SIGQUIT signals, and
		 * redirect input for `&' commands from `/dev/null' if needed.
		 */
		if ((f & FINTR) != 0) {
			(void)sasignal(SIGINT, SIG_IGN);
			(void)sasignal(SIGQUIT, SIG_IGN);
			if (t->nfin == NULL && (f & (FFIN|FPIN|FPRS)) == FPRS) {
				(void)close(FD0);
				if (open("/dev/null", O_RDONLY) != FD0)
					err(FC_ERR,FMT2S,"/dev/null",ERR_OPEN);
			}
		} else {
			if ((sig_child & S_SIGINT) != 0)
				(void)sasignal(SIGINT, SIG_DFL);
			if ((sig_child & S_SIGQUIT) != 0)
				(void)sasignal(SIGQUIT, SIG_DFL);
		}
		/* Set the SIGTERM signal to its default action if needed. */
		if ((sig_child & S_SIGTERM) != 0)
			(void)sasignal(SIGTERM, SIG_DFL);
		if (t->ntype == TSUBSHELL) {
			if ((t1 = t->nsub) != NULL)
				t1->nflags |= (f & (FFIN | FPIN | FINTR));
			execute(t1, NULL, NULL);
			_exit(status);
		}
		glob_flag = false;
		vscan(t->nav, &tglob);
		if (glob_flag) {
			for (i = 0; t->nav[i] != NULL; i++)
				;	/* nothing */
			gav = xmalloc((i + 2) * sizeof(char *));
			gav[0] = "glob6";
			cmd = gav[0];
			(void)memcpy(&gav[1], t->nav, (i + 1) * sizeof(char *));
			(void)err_pexec(cmd, (char *const *)gav);
		} else {
			vscan(t->nav, &trim);
			cmd = t->nav[0];
			(void)err_pexec(cmd, (char *const *)t->nav);
		}
		/*NOTREACHED*/
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2f68
movq %rdi, %rbx
movl 0x34(%rdi), %eax
decl %eax
cmpl $0x3, %eax
ja 0x2f68
movq %rdx, %r14
movq %rsi, %r15
leaq 0x2669(%rip), %rcx      # 0x5108
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x30(%rbx), %ebp
andl $0x4c, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2ab9
orl %ebp, 0x30(%rdi)
xorl %esi, %esi
xorl %edx, %edx
callq 0x2a6d
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x2ace
orl %ebp, 0x30(%rdi)
xorl %esi, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a6d
movq 0x28(%rbx), %r13
testq %r13, %r13
je 0x2c83
movq (%r13), %r12
testq %r12, %r12
je 0x2c83
movzbl (%r12), %ebp
cmpl $0x65, %ebp
je 0x2b4d
cmpl $0x63, %ebp
je 0x2b31
cmpl $0x3a, %ebp
jne 0x2b64
leaq 0x26be(%rip), %rsi      # 0x51d5
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x3246
cmpl $0x65, %ebp
je 0x2b4d
cmpl $0x63, %ebp
jne 0x2b64
leaq 0x269f(%rip), %rsi      # 0x51d7
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x31d9
cmpl $0x65, %ebp
jne 0x2b64
leaq 0x26a1(%rip), %rsi      # 0x51f5
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x319e
cmpl $0x6c, %ebp
jne 0x2b80
leaq 0x2693(%rip), %rsi      # 0x5203
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x3102
cmpl $0x77, %ebp
je 0x2bcc
cmpl $0x73, %ebp
je 0x2bb0
cmpl $0x6e, %ebp
jne 0x2be3
leaq 0x267c(%rip), %rsi      # 0x5212
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x3102
cmpl $0x77, %ebp
je 0x2bcc
cmpl $0x73, %ebp
jne 0x2be3
leaq 0x2671(%rip), %rsi      # 0x5228
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x322b
cmpl $0x77, %ebp
jne 0x2be3
leaq 0x2663(%rip), %rsi      # 0x5236
movq %r12, %rdi
callq 0x21c0
testl %eax, %eax
je 0x3221
movl 0x30(%rbx), %r12d
xorl %ebp, %ebp
testb $0x20, %r12b
jne 0x2bf6
callq 0x22a0
movl %eax, %ebp
testl %ebp, %ebp
je 0x2cab
cmpl $-0x1, %ebp
jne 0x2ee1
leaq 0x2804(%rip), %rsi      # 0x5412
leaq 0x2626(%rip), %rdx      # 0x523b
jmp 0x2c91
movq %rsp, %rdi
callq 0x2190
cmpl $-0x1, %eax
je 0x2f38
movl 0x30(%rbx), %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2c43
movl %ebp, %eax
andl $0xcc, %eax
orl 0x30(%rdi), %eax
orl $0x10, %eax
movl %eax, 0x30(%rdi)
movq %rsp, %rdx
movq %r15, %rsi
callq 0x2a6d
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x2c66
andl $0xd1, %ebp
orl 0x30(%rdi), %ebp
orl $0x8, %ebp
movl %ebp, 0x30(%rdi)
movq %rsp, %rbx
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2a6d
movl (%rbx), %edi
callq 0x2180
movl 0x4(%rbx), %edi
jmp 0x2f63
leaq 0x2788(%rip), %rsi      # 0x5412
leaq 0x252b(%rip), %rdx      # 0x51bc
movl $0x2, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b1c
testq %r15, %r15
sete %al
testb $0x8, %r12b
sete %cl
orb %al, %cl
jne 0x2cfe
movl (%r15), %edi
xorl %esi, %esi
callq 0x2120
cmpl $-0x1, %eax
jne 0x2ced
callq 0x2070
movl (%rax), %edi
callq 0x2260
leaq 0x2734(%rip), %rsi      # 0x5412
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3b1c
movl (%r15), %edi
callq 0x2180
movl 0x4(%r15), %edi
callq 0x2180
testq %r14, %r14
sete %al
testb $0x10, %r12b
sete %cl
orb %al, %cl
jne 0x2d55
movl 0x4(%r14), %edi
movl $0x1, %esi
callq 0x2120
cmpl $-0x1, %eax
jne 0x2d44
callq 0x2070
movl (%rax), %edi
callq 0x2260
leaq 0x26dd(%rip), %rsi      # 0x5412
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3b1c
movl (%r14), %edi
callq 0x2180
movl 0x4(%r14), %edi
callq 0x2180
movl %r12d, %ecx
andl $0x8, %ecx
shrl $0x3, %ecx
movq 0x18(%rbx), %rax
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x2df5
movb (%rax), %cl
testb %cl, %cl
je 0x2d88
incq %rax
andb $0x7f, %cl
movb %cl, -0x1(%rax)
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x2d79
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2230
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x2dba
movq 0x18(%rbx), %rdx
leaq 0x2667(%rip), %rsi      # 0x540e
leaq 0x2380(%rip), %rcx      # 0x512e
movl $0x7c, %edi
xorl %eax, %eax
callq 0x3b1c
movl %ebp, %edi
xorl %esi, %esi
callq 0x2120
cmpl $-0x1, %eax
jne 0x2dea
callq 0x2070
movl (%rax), %edi
callq 0x2260
leaq 0x2637(%rip), %rsi      # 0x5412
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3b1c
orl $0x4, %r12d
movl %ebp, %edi
callq 0x2180
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x2ea4
movl %r12d, %ecx
andl $0x10, %ecx
jne 0x2ea4
movl %r12d, %esi
andl $0x2, %esi
shll $0x8, %esi
addl $0x241, %esi            # imm = 0x241
movb (%rax), %cl
testb %cl, %cl
je 0x2e35
incq %rax
andb $0x7f, %cl
movb %cl, -0x1(%rax)
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x2e26
movq 0x20(%rbx), %rdi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x2230
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x2e6a
movq 0x20(%rbx), %rdx
leaq 0x25b7(%rip), %rsi      # 0x540e
leaq 0x23f9(%rip), %rcx      # 0x5257
movl $0x7c, %edi
xorl %eax, %eax
callq 0x3b1c
movl %ebp, %edi
movl $0x1, %esi
callq 0x2120
cmpl $-0x1, %eax
jne 0x2e9d
callq 0x2070
movl (%rax), %edi
callq 0x2260
leaq 0x2584(%rip), %rsi      # 0x5412
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3b1c
movl %ebp, %edi
callq 0x2180
testb $0x40, %r12b
jne 0x2f77
testb $0x1, 0x42fb(%rip)      # 0x71b0
je 0x2ec3
movl $0x2, %edi
xorl %esi, %esi
callq 0x42ec
testb $0x2, 0x42e6(%rip)      # 0x71b0
je 0x2fe7
movl $0x3, %edi
xorl %esi, %esi
callq 0x42ec
jmp 0x2fe7
testq %r15, %r15
sete %al
testb $0x8, %r12b
sete %cl
orb %al, %cl
jne 0x2f03
movl (%r15), %edi
callq 0x2180
movl 0x4(%r15), %edi
callq 0x2180
testb %r12b, %r12b
jns 0x2f1d
leaq 0x2344(%rip), %rsi      # 0x5253
movl $0x2, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x3cd6
testb $0x11, %r12b
jne 0x2f68
movl %ebp, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x395c
leaq 0x24d3(%rip), %rsi      # 0x5412
leaq 0x225e(%rip), %rdx      # 0x51a4
movl $0x2, %edi
xorl %eax, %eax
callq 0x3b1c
testq %r15, %r15
je 0x2f68
movl (%r15), %edi
callq 0x2180
movl 0x4(%r15), %edi
callq 0x2180
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %esi
movl $0x2, %edi
callq 0x42ec
movl $0x1, %esi
movl $0x3, %edi
callq 0x42ec
movl %r12d, %eax
andl $0x8c, %eax
cmpl $0x80, %eax
jne 0x2fe7
cmpq $0x0, 0x18(%rbx)
jne 0x2fe7
xorl %edi, %edi
callq 0x2180
leaq 0x22ac(%rip), %rdi      # 0x5265
xorl %esi, %esi
xorl %eax, %eax
callq 0x2230
testl %eax, %eax
je 0x2fe7
leaq 0x2441(%rip), %rsi      # 0x540e
leaq 0x2291(%rip), %rdx      # 0x5265
leaq 0x2153(%rip), %rcx      # 0x512e
movl $0x7c, %edi
xorl %eax, %eax
callq 0x3b1c
testb $0x4, 0x41c2(%rip)      # 0x71b0
je 0x2ffc
movl $0xf, %edi
xorl %esi, %esi
callq 0x42ec
cmpl $0x4, 0x34(%rbx)
je 0x3290
movb $0x0, 0x6a14(%rip)      # 0x9a21
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x3064
movq (%rax), %rdx
testq %rdx, %rdx
je 0x3064
leaq 0x2313(%rip), %rcx      # 0x5338
movb (%rdx), %sil
testb %sil, %sil
je 0x3058
movq %rcx, %rdi
movb (%rdi), %r8b
testb %r8b, %r8b
je 0x3040
incq %rdi
cmpb %sil, %r8b
jne 0x3030
testb %r8b, %r8b
je 0x304c
movb $0x1, 0x69d5(%rip)      # 0x9a21
movb %sil, (%rdx)
movb 0x1(%rdx), %sil
incq %rdx
jmp 0x3028
addq $0x8, %rax
movq (%rax), %rdx
testq %rdx, %rdx
jne 0x3025
movq 0x28(%rbx), %rax
cmpb $0x1, 0x69b2(%rip)      # 0x9a21
jne 0x30bd
xorl %r14d, %r14d
cmpq $0x0, (%rax,%r14)
leaq 0x8(%r14), %r14
jne 0x3074
leaq 0x8(%r14), %rdi
movabsq $0x7fffffff8, %r13      # imm = 0x7FFFFFFF8
andq %r13, %rdi
callq 0x36cf
movq %rax, %r15
leaq 0x21d0(%rip), %r12      # 0x526f
movq %r12, (%rax)
leaq 0x8(%rax), %rdi
movq 0x28(%rbx), %rsi
andq %r13, %r14
movq %r14, %rdx
callq 0x21f0
movq %r12, %rdi
movq %r15, %rsi
jmp 0x30ef
testq %rax, %rax
je 0x30e8
movq (%rax), %rcx
testq %rcx, %rcx
je 0x30e8
movb (%rcx), %dl
testb %dl, %dl
je 0x30e2
incq %rcx
andb $0x7f, %dl
movb %dl, -0x1(%rcx)
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x30d3
addq $0x8, %rax
jmp 0x30c2
movq 0x28(%rbx), %rsi
movq (%rsi), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40d5
cmpq $0x0, 0x409e(%rip)      # 0x71a8
je 0x318b
movq %r12, %rax
movb (%rax), %cl
testb %cl, %cl
je 0x3127
incq %rax
andb $0x7f, %cl
movb %cl, -0x1(%rax)
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3118
addq $0x8, %r13
movq (%r13), %rax
testq %rax, %rax
jne 0x310f
cmpl $0x6c, %ebp
leaq 0x20bc(%rip), %rax      # 0x51fa
leaq 0x20c4(%rip), %r14      # 0x5209
cmoveq %rax, %r14
movl $0x2, %edi
xorl %esi, %esi
callq 0x42ec
movl $0x3, %edi
xorl %esi, %esi
callq 0x42ec
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0x3e20
movl $0x1, %esi
movl $0x2, %edi
callq 0x42ec
movl $0x1, %esi
movl $0x3, %edi
callq 0x42ec
leaq 0x227c(%rip), %rsi      # 0x540e
leaq 0x2080(%rip), %rcx      # 0x5219
jmp 0x3273
cmpq $0x0, 0x4002(%rip)      # 0x71a8
jne 0x2f68
xorl %edi, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2150
callq 0x20e0
movl %eax, %ebx
callq 0x3d79
movl 0x3fe8(%rip), %edi      # 0x71b4
cmpl %eax, %ebx
jne 0x32b0
callq 0x2250
movq 0x8(%r13), %rax
testq %rax, %rax
je 0x31fa
movb (%rax), %cl
testb %cl, %cl
je 0x31fa
incq %rax
andb $0x7f, %cl
movb %cl, -0x1(%rax)
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x31eb
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x3255
callq 0x2100
cmpl $-0x1, %eax
jne 0x3246
leaq 0x21f6(%rip), %rsi      # 0x540e
leaq 0x1fc8(%rip), %rcx      # 0x51e7
jmp 0x3273
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
jmp 0x2f25
movl 0x3f5f(%rip), %eax      # 0x7190
cmpl $0x2, %eax
jl 0x3265
addq $0x8, 0x3f4a(%rip)      # 0x7188
decl %eax
movl %eax, 0x3f4a(%rip)      # 0x7190
movl $0x0, 0x3f64(%rip)      # 0x71b4
jmp 0x2f68
leaq 0x21b2(%rip), %rsi      # 0x540e
leaq 0x1f7a(%rip), %rcx      # 0x51dd
jmp 0x3273
leaq 0x21a2(%rip), %rsi      # 0x540e
leaq 0x1fbb(%rip), %rcx      # 0x522e
movl $0x2, %edi
movq %r12, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b1c
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x32a1
andl $0x4c, %r12d
orl %r12d, 0x30(%rdi)
xorl %esi, %esi
xorl %edx, %edx
callq 0x2a6d
movl 0x3f04(%rip), %edi      # 0x71b4
callq 0x2080