// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %rbp
movq %rdi, %r14
movq %rsi, %rax
subq %rdi, %rax
leaq 0x8(%rax), %rdi
callq 0x42ee
movq %rax, %r13
movq $0x0, (%rax)
movq (%rbp), %rax
xorl %ecx, %ecx
cmpb $0x29, (%rax)
sete %cl
shll $0x5, %ecx
movl %ecx, 0x24(%rsp)
cmpq %r14, %rbp
movq %r13, 0x28(%rsp)
jbe 0x4536
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
movq $0x0, (%rsp)
movq (%r14), %r15
movb (%r15), %cl
movzbl %cl, %edx
cmpl $0x3b, %edx
jg 0x43e3
cmpl $0x28, %edx
je 0x44d3
cmpl $0x29, %edx
jne 0x4489
decl %eax
cmoveq %r14, %r12
jmp 0x4527
cmpl $0x3c, %edx
je 0x4419
cmpl $0x3e, %edx
jne 0x4489
leaq 0x8(%r14), %rdx
cmpq %rbp, %rdx
jae 0x4419
movq 0x8(%r14), %rsi
movl 0x24(%rsp), %r8d
movl %r8d, %edi
orl $0x2, %edi
cmpb $0x3e, (%rsi)
cmoveq %rdx, %r14
cmovel %edi, %r8d
movl %r8d, 0x24(%rsp)
testl %eax, %eax
jne 0x4527
addq $0x8, %r14
cmpq %rbp, %r14
je 0x4607
movq (%r14), %r15
movb (%r15), %al
leaq 0x4ea7(%rip), %rdx      # 0x92e2
movb (%rdx), %sil
testb %sil, %sil
je 0x444b
incq %rdx
cmpb %al, %sil
jne 0x443b
testb %sil, %sil
jne 0x4607
cmpb $0x3c, %cl
jne 0x44f0
movq 0x8(%rsp), %rax
testq %rax, %rax
jne 0x48ba
movq %r15, %rdi
callq 0x2130
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
callq 0x42ee
movq %rax, 0x8(%rsp)
jmp 0x4517
testl %eax, %eax
jne 0x4527
movq %r15, %rdi
callq 0x2130
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
callq 0x42ee
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x22a0
movq (%rsp), %rcx
movslq %ecx, %rax
incl %ecx
movq %rcx, (%rsp)
movq 0x28(%rsp), %rcx
movq %r13, (%rcx,%rax,8)
movq 0x28(%rsp), %r13
jmp 0x4525
testl %eax, %eax
jne 0x44ec
cmpq $0x0, 0x18(%rsp)
jne 0x4607
leaq 0x8(%r14), %rcx
movq %rcx, 0x18(%rsp)
incl %eax
jmp 0x4527
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
jne 0x48b1
movq %r15, %rdi
callq 0x2130
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
callq 0x42ee
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x22a0
xorl %eax, %eax
addq $0x8, %r14
cmpq %rbp, %r14
jb 0x43b8
jmp 0x455c
movq $0x0, (%rsp)
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x45ac
movq (%rsp), %rbp
testl %ebp, %ebp
jne 0x460b
movl $0x40, %edi
callq 0x42ee
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x2c(%rax)
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movl $0x4, 0x38(%rax)
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x4131
movq %rax, 0x10(%r14)
jmp 0x4714
movq (%rsp), %rbp
testl %ebp, %ebp
je 0x460b
movl %ebp, %r12d
movq (%r13), %rdi
callq 0x48f8
testq %rax, %rax
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r15
je 0x466a
cmpq $0x0, 0x7c9d(%rip)      # 0xc278
jne 0x466a
cmpb $0x0, 0xa4b8(%rip)      # 0xeaa0
jne 0x4615
cmpl $0x3, 0xa513(%rip)      # 0xeb04
jl 0x4754
leaq 0x4ce8(%rip), %rax      # 0x92e6
movq %rax, 0xa4a3(%rip)      # 0xeaa8
jmp 0x4615
movq (%rsp), %rbp
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x4622
movq %r15, %rdi
callq 0x2050
testq %rbx, %rbx
je 0x462f
movq %rbx, %rdi
callq 0x2050
movslq %ebp, %rax
movq $0x0, (%r13,%rax,8)
movq %r13, %rdi
callq 0x4a9f
movb $0x1, 0xa456(%rip)      # 0xeaa0
cmpq $0x0, 0xa456(%rip)      # 0xeaa8
jne 0x4662
leaq 0x4c0a(%rip), %rax      # 0x9265
movq %rax, 0xa446(%rip)      # 0xeaa8
xorl %r14d, %r14d
jmp 0x4742
movl $0x40, %edi
callq 0x42ee
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x2c(%rax)
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movl $0x3, 0x38(%rax)
movslq %ebp, %rax
leaq 0x8(,%rax,8), %rdi
callq 0x42ee
movq %rax, %r15
movq %rbx, 0x18(%rsp)
movq %rax, 0x28(%rbx)
testl %ebp, %ebp
jle 0x46f5
xorl %ebp, %ebp
movq (%r13,%rbp,8), %rbx
movq %rbx, %rdi
callq 0x2130
movq %r12, %r14
leaq 0x1(%rax), %r12
movq %r12, %rdi
callq 0x42ee
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %r12
callq 0x22a0
movq %r13, (%r15,%rbp,8)
movq 0x28(%rsp), %r13
incq %rbp
cmpq %rbp, %r14
jne 0x46b2
jmp 0x46f7
xorl %ebp, %ebp
movq $0x0, (%r15,%rbp,8)
movq (%r15), %rdi
callq 0x3226
movq 0x18(%rsp), %r14
movl %eax, 0x30(%r14)
movq (%rsp), %rbp
movq 0x8(%rsp), %rax
movq %rax, 0x18(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x20(%r14)
movl 0x24(%rsp), %eax
movl %eax, 0x34(%r14)
movslq %ebp, %rax
movq $0x0, (%r13,%rax,8)
movq %r13, %rdi
callq 0x4a9f
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x4948
testq %rax, %rax
je 0x4615
movq %rax, %r14
movq %r12, 0x18(%rsp)
xorl %eax, %eax
cmpq $0x0, (%r14,%rax,8)
leaq 0x1(%rax), %rax
jne 0x476f
addl %ebp, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x42ee
movq %rax, %r12
movq (%r14), %r15
cmpb $0xa, (%r15)
movq %rax, 0x30(%rsp)
je 0x47dc
addq $0x8, %r14
movq 0x30(%rsp), %r12
movq %r15, %rdi
callq 0x2130
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
callq 0x42ee
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x22a0
movq %r13, (%r12)
addq $0x8, %r12
movq (%r14), %r15
addq $0x8, %r14
cmpb $0xa, (%r15)
jne 0x47a2
movq 0x18(%rsp), %rax
cmpl $0x2, %eax
jl 0x483b
leaq -0x8(,%rax,8), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movq 0x28(%rsp), %rbp
movq 0x8(%rbp,%r13), %rbx
movq %rbx, %rdi
callq 0x2130
leaq 0x1(%rax), %r14
movq %r14, %rdi
callq 0x42ee
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x22a0
movq %r15, (%r12,%r13)
addq $0x8, %r13
cmpq %r13, 0x18(%rsp)
jne 0x47fb
addq %r13, %r12
movq (%rsp), %rbp
leaq 0x4a90(%rip), %rdi      # 0x92d2
callq 0x48cb
leaq 0x8(%r12), %rbx
movq %rax, (%r12)
movq $0x0, 0x8(%r12)
incl 0xa2a5(%rip)            # 0xeb04
movl $0x40, %edi
callq 0x42ee
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x2c(%rax)
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movl $0x4, 0x38(%rax)
movq 0x30(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4131
movq %rax, 0x10(%r14)
movq %r15, %rdi
callq 0x4a9f
decl 0xa25d(%rip)            # 0xeb04
movq 0x28(%rsp), %r13
jmp 0x4714
movq (%rsp), %rbp
jmp 0x4610
movq (%rsp), %rbp
movq 0x10(%rsp), %rbx
movq %rax, %r15
jmp 0x461a