// File: /workspace/github_c_makefile_star2_O0/s3lase[P]v6shell/osh.c
// Function: syn3
static struct tnode *
syn3(char **p1, char **p2)
{
	struct tnode *t;
	enum tnflags flags;
	static int alcnt;
	int ac, ac1, c, n, subcnt;
	char **p, **pv, **lp, **rp;
	char **tav, **tavp;
	const char **av;
	char *fin, *fout;
	const char *as;

	pv    = xmalloc(((p2 - p1) + 1) * sizeof(char *));
	pv[0] = NULL;
	flags = 0;
	if (**p2 == RPARENTHESIS)
		flags |= FNOFORK;

	fin    = NULL;
	fout   = NULL;
	lp     = NULL;
	rp     = NULL;
	n      = 0;
	subcnt = 0;
	for (p = p1; p < p2; p++)
		switch (c = **p) {
		case LPARENTHESIS:
			if (subcnt == 0) {
				if (lp != NULL)
					goto synerr;
				lp = p + 1;
			}
			subcnt++;
			continue;

		case RPARENTHESIS:
			subcnt--;
			if (subcnt == 0)
				rp = p;
			continue;

		case GREATERTHAN:
			p++;
			if (p < p2 && **p == GREATERTHAN)
				flags |= FCAT;
			else
				p--;
			/*FALLTHROUGH*/

		case LESSTHAN:
			if (subcnt == 0) {
				p++;
				if (p == p2 || any(**p, REDIRERR))
					goto synerr;
				if (c == LESSTHAN) {
					if (fin != NULL)
						goto synerr;
					fin = xstrdup(*p);
				} else {
					if (fout != NULL)
						goto synerr;
					fout = xstrdup(*p);
				}
			}
			continue;

		default:
			if (subcnt == 0)
				pv[n++] = xstrdup(*p);
		}

	if (lp == NULL) {
		if (n == 0)
			goto synerr;
		if ((as = asget(pv[0])) != NULL && asp == NULL) {
			/*
			 * Substitute alias string pointed to by as
			 * for alias name pointed to by pv[0].
			 */

			/* Check for errors. */
			if (error)
				goto synerr;
			if (alcnt > 2) {
				error_message = ERR_ALIASLOOP;
				goto synerr;
			}
			/* Read and parse as into av. */
			if ((av = rp_alias(as)) == NULL)
				goto synerr;

			/* Create alias vector. */
			ac   = vacount(av);
			tav  = xmalloc((ac + n + 1) * sizeof(char *));
			tavp = tav;
			for (ac = 0; *av[ac] != EOL; ac++)
				*tavp++ = xstrdup(av[ac]);
			for (ac1 = 1; ac1 < n; ac1++)
				*tavp++ = xstrdup(pv[ac1]);
			*tavp++ = xstrdup("\n");
			*tavp   = NULL;

			/* Execute as TSUBSHELL w/o ( ) . */
			alcnt++;
			t = talloc();
			t->ntype = TSUBSHELL;
			t->nsub  = syn1(tav, tavp);
			vfree(tav);
			alcnt--;
		} else {
			/*
			 * Execute as TCOMMAND.
			 */
			t = talloc();
			t->ntype = TCOMMAND;
			t->nav   = xmalloc((n + 1) * sizeof(char *));
			for (ac = 0; ac < n; ac++)
				t->nav[ac] = xstrdup(pv[ac]);
			t->nav[ac] = NULL;
			t->nkey    = cmd_lookup(t->nav[0]);
		}
	} else {
		/*
		 * Execute as TSUBSHELL w/ ( ) .
		 */
		if (n != 0)
			goto synerr;
		t = talloc();
		t->ntype = TSUBSHELL;
		t->nsub  = syn1(lp, rp);
	}
	t->nfin   = fin;
	t->nfout  = fout;
	t->nflags = flags;
	pv[n] = NULL;
	vfree(pv);
	return t;

synerr:
	xfree(fin);
	xfree(fout);
	pv[n] = NULL;
	vfree(pv);
	error = true;
	if (error_message == NULL)
		error_message = ERR_SYNTAX;
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
subq %rax, %rdi
sarq $0x3, %rdi
addq $0x1, %rdi
shlq $0x3, %rdi
callq 0x4ae0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
jne 0x4bad
movl -0x24(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x24(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4d71
movq -0x40(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
addl $-0x28, %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x16, %eax
ja 0x4d31
movq -0x90(%rbp), %rax
leaq 0x695f(%rip), %rcx      # 0xb580
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, -0x38(%rbp)
jne 0x4c48
cmpq $0x0, -0x50(%rbp)
je 0x4c3c
jmp 0x504b
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x4d60
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jne 0x4c6d
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x4d60
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4ca2
movq -0x40(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x4ca2
movl -0x24(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x24(%rbp)
jmp 0x4cae
movq -0x40(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x40(%rbp)
jmp 0x4cb0
cmpl $0x0, -0x38(%rbp)
jne 0x4d2f
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x4ce8
movq -0x40(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %edi
leaq 0x6a69(%rip), %rsi      # 0xb746
callq 0x4460
testb $0x1, %al
jne 0x4ce8
jmp 0x4ced
jmp 0x504b
cmpl $0x3c, -0x30(%rbp)
jne 0x4d11
cmpq $0x0, -0x78(%rbp)
je 0x4cff
jmp 0x504b
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x50b0
movq %rax, -0x78(%rbp)
jmp 0x4d2d
cmpq $0x0, -0x80(%rbp)
je 0x4d1d
jmp 0x504b
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x50b0
movq %rax, -0x80(%rbp)
jmp 0x4d2f
jmp 0x4d60
cmpl $0x0, -0x38(%rbp)
jne 0x4d5c
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x50b0
movq %rax, %rdx
movq -0x48(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4d5e
jmp 0x4d60
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
jmp 0x4be3
cmpq $0x0, -0x50(%rbp)
jne 0x4fd2
cmpl $0x0, -0x34(%rbp)
jne 0x4d87
jmp 0x504b
movq -0x48(%rbp), %rax
movq (%rax), %rdi
callq 0x5100
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x4f34
cmpq $0x0, 0x94cc(%rip)      # 0xe278
jne 0x4f34
testb $0x1, 0xbce7(%rip)      # 0x10aa0
je 0x4dc0
jmp 0x504b
cmpl $0x2, 0xbd3d(%rip)      # 0x10b04
jle 0x4ddc
leaq 0x697a(%rip), %rax      # 0xb74a
movq %rax, 0xbcd1(%rip)      # 0x10aa8
jmp 0x504b
movq -0x88(%rbp), %rdi
callq 0x5180
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
jne 0x4df7
jmp 0x504b
movq -0x70(%rbp), %rdi
callq 0x53c0
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
addl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x4ae0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x70(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x4e70
movq -0x70(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x50b0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, (%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4e2b
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x4eb0
movq -0x48(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x50b0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, (%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4e77
leaq 0x687f(%rip), %rdi      # 0xb736
callq 0x50b0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
movq $0x0, (%rax)
movl 0xbc22(%rip), %eax      # 0x10b04
addl $0x1, %eax
movl %eax, 0xbc19(%rip)      # 0x10b04
callq 0x4940
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0x4, 0x38(%rax)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x47c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x60(%rbp), %rdi
callq 0x5400
movl 0xbbde(%rip), %eax      # 0x10b04
addl $-0x1, %eax
movl %eax, 0xbbd5(%rip)      # 0x10b04
jmp 0x4fd0
callq 0x4940
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0x3, 0x38(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x4ae0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x4fa3
movq -0x48(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x50b0
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4f6c
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rdi
callq 0x3540
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x30(%rax)
jmp 0x5006
cmpl $0x0, -0x34(%rbp)
je 0x4fda
jmp 0x504b
callq 0x4940
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0x4, 0x38(%rax)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x47c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x78(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x80(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x48(%rbp), %rdi
callq 0x5400
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x509d
movq -0x78(%rbp), %rdi
callq 0x33f0
movq -0x80(%rbp), %rdi
callq 0x33f0
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x48(%rbp), %rdi
callq 0x5400
movb $0x1, 0xba23(%rip)      # 0x10aa0
cmpq $0x0, 0xba23(%rip)      # 0x10aa8
jne 0x5095
leaq 0x663b(%rip), %rax      # 0xb6c9
movq %rax, 0xba13(%rip)      # 0x10aa8
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)