// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movq %rdi, %r13
movq %rsi, %rdi
subq %r13, %rdi
addq $0x8, %rdi
callq 0x4f10
movq %rax, 0x8(%rsp)
andq $0x0, (%rax)
movq (%r12), %rax
xorl %ecx, %ecx
cmpb $0x29, (%rax)
sete %cl
shll $0x5, %ecx
movl %ecx, 0x14(%rsp)
xorl %ebx, %ebx
xorl %eax, %eax
movq $0x0, 0x20(%rsp)
xorl %ebp, %ebp
movq $0x0, (%rsp)
movq $0x0, 0x18(%rsp)
movslq %ebx, %r15
cmpq %r12, %r13
jae 0x50b8
movq (%r13), %rdi
movzbl (%rdi), %r14d
cmpl $0x3e, %r14d
je 0x501a
cmpl $0x29, %r14d
je 0x500f
cmpl $0x3c, %r14d
je 0x5034
cmpl $0x28, %r14d
jne 0x5082
testl %eax, %eax
jne 0x5008
cmpq $0x0, 0x20(%rsp)
jne 0x50f3
leaq 0x8(%r13), %rcx
movq %rcx, 0x20(%rsp)
incl %eax
jmp 0x50af
decl %eax
cmoveq %r13, %rbp
jmp 0x50af
leaq 0x8(%r13), %rcx
cmpq %r12, %rcx
jae 0x5034
movq 0x8(%r13), %rdx
cmpb $0x3e, (%rdx)
jne 0x5034
orl $0x2, 0x14(%rsp)
movq %rcx, %r13
testl %eax, %eax
jne 0x50af
addq $0x8, %r13
cmpq %r12, %r13
je 0x50f3
movq (%r13), %r15
movsbl (%r15), %edi
leaq 0x328e(%rip), %rsi      # 0x82e2
callq 0x4d6a
testb %al, %al
jne 0x50f3
cmpb $0x3c, %r14b
jne 0x5098
movq (%rsp), %r14
testq %r14, %r14
jne 0x5146
movq %r15, %rdi
callq 0x52ee
movq %rax, (%rsp)
jmp 0x50ad
testl %eax, %eax
jne 0x50af
callq 0x52ee
incl %ebx
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
jmp 0x50ad
cmpq $0x0, 0x18(%rsp)
jne 0x50f3
movq %r15, %rdi
callq 0x52ee
movq %rax, 0x18(%rsp)
xorl %eax, %eax
addq $0x8, %r13
jmp 0x4fbf
movq 0x20(%rsp), %r13
testq %r13, %r13
je 0x50f9
testl %ebx, %ebx
movq (%rsp), %r14
jne 0x5146
callq 0x4e52
movq %rax, %r12
movl $0x4, 0x38(%rax)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4d7e
movq %rax, 0x10(%r12)
movq 0x8(%rsp), %rbp
jmp 0x51ec
movq (%rsp), %r14
jmp 0x5146
testl %ebx, %ebx
movq (%rsp), %r14
je 0x5144
movq 0x8(%rsp), %rbp
movq (%rbp), %rdi
callq 0x531b
testq %rax, %rax
je 0x5191
cmpq $0x0, 0x715c(%rip)      # 0xc278
jne 0x5191
cmpb $0x0, 0x997b(%rip)      # 0xeaa0
jne 0x5146
cmpl $0x3, 0x99d6(%rip)      # 0xeb04
jl 0x5224
leaq 0x31ab(%rip), %rax      # 0x82e6
movq %rax, 0x9966(%rip)      # 0xeaa8
jmp 0x5146
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2050
movslq %ebx, %rax
movq 0x8(%rsp), %rdi
andq $0x0, (%rdi,%rax,8)
callq 0x54a6
movb $0x1, 0x992f(%rip)      # 0xeaa0
cmpq $0x0, 0x992f(%rip)      # 0xeaa8
jne 0x5189
leaq 0x30e3(%rip), %rax      # 0x8265
movq %rax, 0x991f(%rip)      # 0xeaa8
xorl %r12d, %r12d
jmp 0x5212
callq 0x4e52
movq %rax, %r12
movl $0x3, 0x38(%rax)
leaq 0x8(,%r15,8), %rdi
callq 0x4f10
movq %rax, %r14
movq %rax, 0x28(%r12)
xorl %r13d, %r13d
testl %ebx, %ebx
cmovlel %r13d, %ebx
cmpq %r13, %rbx
je 0x51d6
movq (%rbp,%r13,8), %rdi
callq 0x52ee
movq %rax, (%r14,%r13,8)
incq %r13
jmp 0x51be
andq $0x0, (%r14,%rbx,8)
movq (%r14), %rdi
callq 0x31a5
movl %eax, 0x30(%r12)
movq (%rsp), %r14
movq %r14, 0x18(%r12)
movq 0x18(%rsp), %rax
movq %rax, 0x20(%r12)
movl 0x14(%rsp), %eax
movl %eax, 0x34(%r12)
andq $0x0, (%rbp,%r15,8)
movq %rbp, %rdi
callq 0x54a6
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x5358
testq %rax, %rax
je 0x5146
movq %rax, %r12
movq %rax, %rdi
callq 0x5496
addl %ebx, %eax
incl %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x4f10
movq %rax, %r14
xorl %r13d, %r13d
movq %rax, %rbx
movq 0x8(%rsp), %rbp
movq (%r12,%r13,8), %rdi
cmpb $0xa, (%rdi)
je 0x5278
callq 0x52ee
movq %rax, (%rbx)
addq $0x8, %rbx
incq %r13
jmp 0x525e
pushq $0x1
popq %r12
pushq $0x8
popq %r13
cmpq %r15, %r12
jge 0x529d
movq (%rbp,%r12,8), %rdi
callq 0x52ee
movq %rax, -0x8(%rbx,%r12,8)
incq %r12
addq $0x8, %r13
jmp 0x5280
leaq 0x302e(%rip), %rdi      # 0x82d2
callq 0x52ee
movq %rax, -0x8(%rbx,%r12,8)
andq $0x0, (%rbx,%r12,8)
addq %rbx, %r13
incl 0x9848(%rip)            # 0xeb04
callq 0x4e52
movq %rax, %r12
movl $0x4, 0x38(%rax)
movq %r14, %rdi
movq %r13, %rsi
callq 0x4d7e
movq %rax, 0x10(%r12)
movq %r14, %rdi
callq 0x54a6
decl 0x981b(%rip)            # 0xeb04
jmp 0x51e8