// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x3d10
jmp 0x4116
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x3, %eax
ja 0x4116
movq -0x38(%rbp), %rax
leaq 0x75e1(%rip), %rcx      # 0xb314
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
andl $0x4c, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x3d67
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
orl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x3cf0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x3d96
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
orl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x3cf0
jmp 0x4116
leaq -0x30(%rbp), %rdi
callq 0x21e0
cmpl $-0x1, %eax
jne 0x3dfe
callq 0x8df0
movq %rax, %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x79d4(%rip), %rsi      # 0xb7a1
leaq 0x798a(%rip), %rcx      # 0xb75e
movb $0x0, %al
callq 0x8af0
cmpq $0x0, -0x10(%rbp)
je 0x3df9
movq -0x10(%rbp), %rax
movl (%rax), %edi
callq 0x21d0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x21d0
jmp 0x4116
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x3e2f
movl -0x24(%rbp), %ecx
andl $0xcc, %ecx
orl $0x10, %ecx
movq -0x20(%rbp), %rax
orl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x3cf0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x3e68
movl -0x24(%rbp), %ecx
andl $0xd1, %ecx
orl $0x8, %ecx
movq -0x20(%rbp), %rax
orl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3cf0
movl -0x30(%rbp), %edi
callq 0x21d0
movl -0x2c(%rbp), %edi
callq 0x21d0
jmp 0x4116
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x3ea7
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, (%rax)
jne 0x3ece
callq 0x8df0
movq %rax, %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x78e6(%rip), %rsi      # 0xb7a1
leaq 0x78b4(%rip), %rcx      # 0xb776
movb $0x0, %al
callq 0x8af0
jmp 0x4116
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x5470
testb $0x1, %al
jne 0x3ee1
jmp 0x3f0a
movq -0x8(%rbp), %rax
movl 0x30(%rax), %edi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x54d0
movq -0x8(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
jne 0x3f08
jmp 0x4116
jmp 0x3f2d
movq -0x8(%rbp), %rax
cmpl $0x2, 0x30(%rax)
je 0x3f2b
movq -0x8(%rbp), %rax
cmpl $0x3, 0x30(%rax)
je 0x3f2b
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x5600
jmp 0x3f2d
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
addl $-0x4, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x10, %eax
ja 0x402b
movq -0x40(%rbp), %rax
leaq 0x73d3(%rip), %rcx      # 0xb324
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x4039
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3fa0
callq 0x8df0
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x7810(%rip), %rsi      # 0xb79d
leaq 0x77fb(%rip), %r8       # 0xb78f
movb $0x0, %al
callq 0x8af0
jmp 0x4116
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x3540
movq -0x8(%rbp), %rcx
movl %eax, 0x30(%rcx)
cmpl $0x14, %eax
je 0x3ffb
callq 0x8df0
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %r8
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x77b1(%rip), %rsi      # 0xb799
leaq 0x77ba(%rip), %r9       # 0xb7a9
movb $0x0, %al
callq 0x8af0
jmp 0x4116
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x34(%rax)
movl $0x11, %edi
movl $0x1, %esi
callq 0xac70
jmp 0x4039
jmp 0x4039
movq -0x8(%rbp), %rdi
callq 0x5640
jmp 0x4116
jmp 0x403b
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x4057
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x405f
callq 0x23c0
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $-0x1, %eax
jne 0x4091
callq 0x8df0
movq %rax, %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x7723(%rip), %rsi      # 0xb7a1
leaq 0x7733(%rip), %rcx      # 0xb7b8
movb $0x0, %al
callq 0x8af0
jmp 0x4116
cmpl $0x0, -0x28(%rbp)
je 0x4105
cmpq $0x0, -0x10(%rbp)
je 0x40c0
movl -0x24(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x40c0
movq -0x10(%rbp), %rax
movl (%rax), %edi
callq 0x21d0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x21d0
movl -0x24(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x40e3
movl -0x28(%rbp), %edx
movl $0x2, %edi
leaq 0x76f4(%rip), %rsi      # 0xb7d0
movb $0x0, %al
callq 0x8d40
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x40f0
jmp 0x4116
movl -0x24(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x4103
movl -0x28(%rbp), %edi
callq 0x6060
jmp 0x4116
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x6140
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)