// File: /workspace/github_c_makefile_star2_O2/s3lase[P]v6shell/sh6.c
// Function: syn3
static struct tnode *
syn3(char **p1, char **p2)
{
	struct tnode *t;
	enum tnflags flags;
	int ac, c, n, subcnt;
	char **p, **lp, **rp;
	char *fin, *fout;

	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 = *p;
				} else {
					if (fout != NULL)
						goto synerr;
					fout = *p;
				}
			}
			continue;

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

	if (lp == NULL) {
		if (n == 0)
			goto synerr;
		t = talloc();
		t->ntype = TCOMMAND;
		t->nav   = xmalloc((n + 1) * sizeof(char *));
		for (ac = 0; ac < n; ac++)
			t->nav[ac] = p1[ac];
		t->nav[ac] = NULL;
	} else {
		if (n != 0)
			goto synerr;
		t = talloc();
		t->ntype = TSUBSHELL;
		t->nsub  = syn1(lp, rp);
	}
	t->nfin   = fin;
	t->nfout  = fout;
	t->nflags = flags;
	return t;

synerr:
	error = true;
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
xorl %ecx, %ecx
cmpb $0x29, (%rax)
sete %cl
shll $0x5, %ecx
movl %ecx, 0x4(%rsp)
xorl %r13d, %r13d
xorl %eax, %eax
movq %rdi, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movslq %r13d, %r12
cmpq %r14, %rbx
jae 0x36e5
movq (%rbx), %rcx
movzbl (%rcx), %ebp
cmpl $0x3e, %ebp
je 0x3653
cmpl $0x29, %ebp
je 0x3648
cmpl $0x3c, %ebp
je 0x366d
cmpl $0x28, %ebp
jne 0x36b5
testl %eax, %eax
jne 0x3641
cmpq $0x0, 0x18(%rsp)
jne 0x3779
leaq 0x8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
incl %eax
jmp 0x36dc
decl %eax
cmoveq %rbx, %r15
jmp 0x36dc
leaq 0x8(%rbx), %rcx
cmpq %r14, %rcx
jae 0x366d
movq 0x8(%rbx), %rdx
cmpb $0x3e, (%rdx)
jne 0x366d
orl $0x2, 0x4(%rsp)
movq %rcx, %rbx
testl %eax, %eax
jne 0x36dc
addq $0x8, %rbx
cmpq %r14, %rbx
je 0x3779
movq (%rbx), %r12
movsbl (%r12), %edi
leaq 0x1b13(%rip), %rsi      # 0x51a0
callq 0x3347
testb %al, %al
jne 0x3779
cmpb $0x3c, %bpl
jne 0x36c9
cmpq $0x0, 0x10(%rsp)
jne 0x3779
xorl %eax, %eax
movq %r12, 0x10(%rsp)
jmp 0x36dc
testl %eax, %eax
jne 0x36dc
incl %r13d
movq 0x20(%rsp), %rax
movq %rcx, (%rax,%r12,8)
xorl %eax, %eax
jmp 0x36dc
cmpq $0x0, 0x8(%rsp)
jne 0x3779
xorl %eax, %eax
movq %r12, 0x8(%rsp)
addq $0x8, %rbx
jmp 0x35fe
cmpq $0x0, 0x18(%rsp)
je 0x3726
testl %r13d, %r13d
jne 0x3779
callq 0x34ab
movq %rax, %r14
movl $0x4, 0x34(%rax)
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x33e5
movq %rax, 0x10(%r14)
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %r9
jmp 0x378a
testl %r13d, %r13d
je 0x3779
callq 0x34ab
movq %rax, %r14
movl $0x3, 0x34(%rax)
leaq 0x8(,%r12,8), %rdi
callq 0x356a
movq %rax, 0x28(%r14)
xorl %ecx, %ecx
testl %r13d, %r13d
cmovlel %ecx, %r13d
movl 0x4(%rsp), %esi
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %r9
cmpq %rcx, %r13
je 0x3785
movq (%rdi,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x3767
movb $0x1, 0x7258(%rip)      # 0xa9d8
xorl %r14d, %r14d
jmp 0x3796
andq $0x0, (%rax,%r13,8)
movq %r8, 0x18(%r14)
movq %r9, 0x20(%r14)
movl %esi, 0x30(%r14)
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq