// File: /workspace/github_c_makefile_star2_O3/s3lase[P]v6shell/osh.c
// Function: execute
static void
execute(struct tnode *t, int *pin, int *pout)
{
	struct tnode *t1;
	enum tnflags f;
	pid_t cpid;
	int pfd[2];

	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(-1, FMT2S, getmyname(), 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(-1, FMT2S, getmyname(), "execute: Invalid command");
			return;
		}
		if (vtglob(t->nav)) {
			if ((t->nav = (char **)glob(t->nkey, t->nav)) == NULL)
				return;
		} else if (DO_TRIM(t->nkey))
			vtrim(t->nav);
		switch (t->nkey) {
		case SBI_ECHO:
			break;
		case SBI_EXEC:
			/*
			 * Replace the current shell w/ an instance of
			 * the specified external command.
			 *
			 * usage: exec command [arg ...]
			 */
			if (t->nav[1] == NULL) {
				err(-1, FMT3S, getmyname(),
				    t->nav[0], ERR_ARGCOUNT);
				return;
			}
			if ((t->nkey = cmd_lookup(t->nav[1])) != SBI_UNKNOWN) {
				err(-1, FMT4S, getmyname(),
				    t->nav[0], t->nav[1], ERR_EXEC);
				return;
			}
			t->nav++;
			t->nflags |= FNOFORK;
			(void)sasignal(SIGCHLD, SIG_IGN);
			break;
		case SBI_FD2: case SBI_GOTO: case SBI_IF: case SBI_UNKNOWN:
			break;
		default:
			execute1(t);
			return;
		}
		/*FALLTHROUGH*/

	case TSUBSHELL:
		f = t->nflags;
		if ((cpid = ((f & FNOFORK) != 0) ? 0 : fork()) == -1) {
			err(-1, FMT2S, getmyname(), 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! ****/
		execute2(t, pin, pout);
		/*NOTREACHED*/
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x37bf
movq %rdi, %rbx
movl 0x38(%rdi), %eax
decl %eax
cmpl $0x3, %eax
ja 0x37bf
movq %rdx, %r14
movq %rsi, %r15
leaq 0x5ac2(%rip), %rcx      # 0x911c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x34(%rbx), %ebp
andl $0x4c, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x367d
orl %ebp, 0x34(%rdi)
xorl %esi, %esi
xorl %edx, %edx
callq 0x3628
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x37bf
orl %ebp, 0x34(%rdi)
xorl %esi, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3628
movq 0x28(%rbx), %r12
testq %r12, %r12
je 0x376f
movq (%r12), %r13
testq %r13, %r13
je 0x376f
leaq 0x8(%r12), %rbp
movq %r13, %rdi
callq 0x5bde
testq %rax, %rax
jne 0x37ce
movq (%rbp), %rdi
addq $0x8, %rbp
testq %rdi, %rdi
jne 0x36c3
movl 0x30(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
je 0x37e2
addq $0x8, %r12
movq %r13, %rdi
callq 0x5cf8
movq (%r12), %r13
addq $0x8, %r12
testq %r13, %r13
jne 0x36f1
jmp 0x37e2
movq %rsp, %rdi
callq 0x21e0
cmpl $-0x1, %eax
je 0x3787
movl 0x34(%rbx), %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x373e
movl %ebp, %eax
andl $0xcc, %eax
orl 0x34(%rdi), %eax
orl $0x10, %eax
movl %eax, 0x34(%rdi)
movq %rsp, %rdx
movq %r15, %rsi
callq 0x3628
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x3761
andl $0xd1, %ebp
orl 0x34(%rdi), %ebp
orl $0x8, %ebp
movl %ebp, 0x34(%rdi)
movq %rsp, %rsi
movq %r14, %rdx
callq 0x3628
movl (%rsp), %edi
callq 0x21d0
movl 0x4(%rsp), %edi
jmp 0x37ba
callq 0x6a87
leaq 0x5bbc(%rip), %rsi      # 0x9337
leaq 0x5b8a(%rip), %rcx      # 0x930c
jmp 0x3b9c
callq 0x6a87
leaq 0x5ba4(%rip), %rsi      # 0x9337
leaq 0x5b5a(%rip), %rcx      # 0x92f4
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
testq %r15, %r15
je 0x37bf
movl (%r15), %edi
callq 0x21d0
movl 0x4(%r15), %edi
callq 0x21d0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x30(%rbx), %edi
movq %r12, %rsi
callq 0x4aa8
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x37bf
movl 0x30(%rbx), %eax
cmpl $0x14, %eax
ja 0x3c64
movl $0x100390, %ecx         # imm = 0x100390
btl %eax, %ecx
jae 0x3c24
movl 0x34(%rbx), %r13d
testb $0x20, %r13b
jne 0x3822
callq 0x23c0
cmpl $-0x1, %eax
je 0x3b89
movl %eax, %ebp
testl %eax, %eax
jne 0x3bb9
movl 0x34(%rbx), %r13d
testq %r15, %r15
sete %al
testb $0x8, %r13b
sete %cl
orb %al, %cl
jne 0x3880
movl (%r15), %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x386f
callq 0x6a87
movq %rax, %r12
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x5ada(%rip), %rsi      # 0x9337
movl $0x7c, %edi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6840
movl (%r15), %edi
callq 0x21d0
movl 0x4(%r15), %edi
callq 0x21d0
testq %r14, %r14
sete %al
testb $0x10, %r13b
sete %cl
orb %al, %cl
jne 0x38e2
movl 0x4(%r14), %edi
movl $0x1, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x38d1
callq 0x6a87
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x5a78(%rip), %rsi      # 0x9337
movl $0x7c, %edi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6840
movl (%r14), %edi
callq 0x21d0
movl 0x4(%r14), %edi
callq 0x21d0
testb $0x8, %r13b
sete %al
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3991
cmpb $0x2d, (%rdi)
jne 0x390d
cmpb $0x0, 0x1(%rdi)
je 0x3c14
callq 0x5cf8
movq %rax, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2320
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x394b
callq 0x6a87
movq 0x18(%rbx), %rcx
leaq 0x59fe(%rip), %rsi      # 0x9333
leaq 0x58af(%rip), %r8       # 0x91eb
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
movl %ebp, %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x3986
callq 0x6a87
movq %rax, %r14
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x59c3(%rip), %rsi      # 0x9337
movl $0x7c, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6840
orl $0x4, %r13d
movl %ebp, %edi
callq 0x21d0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x3a41
movl %r13d, %eax
andl $0x10, %eax
jne 0x3a41
movl %r13d, %ebp
andl $0x2, %ebp
shll $0x8, %ebp
addl $0x241, %ebp            # imm = 0x241
callq 0x5cf8
movq %rax, %rdi
movl %ebp, %esi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x2320
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x39fc
callq 0x6a87
movq 0x20(%rbx), %rcx
leaq 0x594d(%rip), %rsi      # 0x9333
leaq 0x5b62(%rip), %r8       # 0x954f
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
movl %ebp, %edi
movl $0x1, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x3a3a
callq 0x6a87
movq %rax, %r14
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x590f(%rip), %rsi      # 0x9337
movl $0x7c, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6840
movl %ebp, %edi
callq 0x21d0
testb $0x40, %r13b
jne 0x3a8f
movl 0xd927(%rip), %eax      # 0x11374
testb $0x1, %al
jne 0x3a6c
testb $0x1, 0x87f4(%rip)      # 0xc24c
je 0x3a6c
movl $0x2, %edi
xorl %esi, %esi
callq 0x8034
movl 0xd908(%rip), %eax      # 0x11374
testb $0x2, %al
jne 0x3b07
testb $0x2, 0x87d1(%rip)      # 0xc24c
je 0x3b07
movl $0x3, %edi
xorl %esi, %esi
callq 0x8034
jmp 0x3b07
movl $0x1, %esi
movl $0x2, %edi
callq 0x8034
movl $0x1, %esi
movl $0x3, %edi
callq 0x8034
cmpq $0x0, 0x18(%rbx)
jne 0x3b07
movl %r13d, %eax
andl $0x8c, %eax
cmpl $0x80, %eax
jne 0x3b07
xorl %edi, %edi
callq 0x21d0
leaq 0x5a8c(%rip), %rdi      # 0x955d
xorl %esi, %esi
xorl %eax, %eax
callq 0x2320
testl %eax, %eax
je 0x3b07
callq 0x6a87
leaq 0x5849(%rip), %rsi      # 0x9333
leaq 0x5a6c(%rip), %rcx      # 0x955d
leaq 0x56f3(%rip), %r8       # 0x91eb
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
testb $0x4, 0xd866(%rip)      # 0x11374
jne 0x3b25
testb $0x4, 0x8735(%rip)      # 0xc24c
je 0x3b25
movl $0xf, %edi
xorl %esi, %esi
callq 0x8034
cmpl $0x4, 0x38(%rbx)
je 0x3cec
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x3b3e
cmpq $0x0, (%rax)
jne 0x3b60
callq 0x6a87
leaq 0x57ed(%rip), %rsi      # 0x9337
leaq 0x5a16(%rip), %rcx      # 0x9567
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
movl 0x30(%rbx), %edi
movq 0x28(%rbx), %rdx
cmpl $0x14, %edi
jne 0x3d11
movq (%rdx), %rdi
movq %rdx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7e21
callq 0x6a87
leaq 0x57a2(%rip), %rsi      # 0x9337
leaq 0x57b2(%rip), %rcx      # 0x934e
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6840
testq %r15, %r15
sete %al
testb $0x8, %r13b
sete %cl
orb %al, %cl
jne 0x3bdb
movl (%r15), %edi
callq 0x21d0
movl 0x4(%r15), %edi
callq 0x21d0
testb %r13b, %r13b
jns 0x3bf5
leaq 0x577f(%rip), %rsi      # 0x9366
movl $0x2, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x69fa
testb $0x11, %r13b
jne 0x37bf
movl %ebp, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5a8f
movl 0xd762(%rip), %edi      # 0x1137c
callq 0x2190
jmp 0x391e
cmpl $0x5, %eax
jne 0x3c64
movq 0x28(%rbx), %r12
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x3c7a
callq 0x326a
movl %eax, 0x30(%rbx)
cmpl $0x14, %eax
jne 0x3cb1
addq $0x8, %r12
movq %r12, 0x28(%rbx)
orb $0x20, 0x34(%rbx)
movl $0x1, %esi
movl $0x11, %edi
callq 0x8034
jmp 0x37fc
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f92
callq 0x6a87
movq 0x28(%rbx), %rcx
movq (%rcx), %rcx
leaq 0x56a6(%rip), %rsi      # 0x9333
leaq 0x5691(%rip), %r8       # 0x9325
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6840
callq 0x6a87
movq 0x28(%rbx), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %r8
leaq 0x5667(%rip), %rsi      # 0x932f
leaq 0x5670(%rip), %r9       # 0x933f
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6840
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x3d06
andl $0x4c, %r13d
orl %r13d, 0x34(%rdi)
xorl %esi, %esi
xorl %edx, %edx
callq 0x3628
movl 0x855c(%rip), %edi      # 0xc268
callq 0x2080
xorl %esi, %esi
cmpq $0x0, (%rdx,%rsi,8)
leaq 0x1(%rsi), %rsi
jne 0x3d13
decl %esi
callq 0x6b44
movl %eax, %edi
callq 0x2080