// File: /workspace/github_c_makefile_star2_O3/rakitzis[P]rc/walk.c
// Function: walk
extern bool walk(Node *n, bool parent) {
top:	sigchk();
	if (n == NULL) {
		if (!parent)
			exit(0);
		set(TRUE);
		return TRUE;
	}
	switch (n->type) {
	case nArgs: case nBackq: case nConcat: case nCount:
	case nFlat: case nLappend: case nRedir: case nVar:
	case nVarsub: case nWord:
		exec(glob(glom(n)), parent);	/* simple command */
		break;
	case nBody:
		walk(n->u[0].p, TRUE);
		WALK(n->u[1].p, parent);
		/* WALK doesn't fall through */
	case nNowait: {
		int pid;
		if ((pid = rc_fork()) == 0) {
#if defined(RC_JOB) && defined(SIGTTOU) && defined(SIGTTIN) && defined(SIGTSTP)
			setsigdefaults(FALSE);
			rc_signal(SIGTTOU, SIG_IGN);	/* Berkeleyized version: put it in a new pgroup. */
			rc_signal(SIGTTIN, SIG_IGN);
			rc_signal(SIGTSTP, SIG_IGN);
			setpgid(0, getpid());
#else
			setsigdefaults(TRUE);		/* ignore SIGINT, SIGQUIT, SIGTERM */
#endif
			mvfd(rc_open("/dev/null", rFrom), 0);
			walk(n->u[0].p, FALSE);
			exit(getstatus());
		}
		if (interactive)
			fprint(2, "%d\n", pid);
		varassign("apid", word(nprint("%d", pid), NULL), FALSE);
		redirq = NULL; /* kill pre-redir queue */
		break;
	}
	case nAndalso: {
		bool oldcond = cond;
		cond = TRUE;
		if (walk(n->u[0].p, TRUE)) {
			cond = oldcond;
			WALK(n->u[1].p, parent);
		} else
			cond = oldcond;
		break;
	}
	case nOrelse: {
		bool oldcond = cond;
		cond = TRUE;
		if (!walk(n->u[0].p, TRUE)) {
			cond = oldcond;
			WALK(n->u[1].p, parent);
		} else
			cond = oldcond;
		break;
	}
	case nBang:
		set(!walk(n->u[0].p, TRUE));
		break;
	case nIf: {
		bool oldcond = cond;
		Node *true_cmd = n->u[1].p, *false_cmd = NULL;
		if (true_cmd != NULL && true_cmd->type == nElse) {
			false_cmd = true_cmd->u[1].p;
			true_cmd = true_cmd->u[0].p;
		}
		cond = TRUE;
		if (!walk(n->u[0].p, TRUE))
			true_cmd = false_cmd; /* run the else clause */
		cond = oldcond;
		WALK(true_cmd, parent);
	}
	case nWhile: {
		Jbwrap break_jb;
		Edata  break_data;
		Estack break_stack;
		bool testtrue;
		const bool oldcond = cond;
		cond = TRUE;
		if (!walk(n->u[0].p, TRUE)) { /* prevent spurious breaks inside test */
			cond = oldcond;
			break;
		}
		cond = oldcond;
		if (sigsetjmp(break_jb.j, 1))
			break;
		break_data.jb = &break_jb;
		except(eBreak, break_data, &break_stack);

		cond = oldcond;
		do {
			Edata  iter_data;
			Estack iter_stack;
			iter_data.b = newblock();
			except(eArena, iter_data, &iter_stack);
			loop_body(n->u[1].p);
			cond = TRUE;
			testtrue = walk(n->u[0].p, TRUE);
			cond = oldcond;
			unexcept(eArena);
		} while (testtrue);
		cond = oldcond;
		unexcept(eBreak);
		break;
	}
	case nForin: {
		List *l, *var = glom(n->u[0].p);
		Jbwrap break_jb;
		Edata  break_data;
		Estack break_stack;
		if (sigsetjmp(break_jb.j, 1))
			break;
		break_data.jb = &break_jb;
		except(eBreak, break_data, &break_stack);

		for (l = listcpy(glob(glom(n->u[1].p)), nalloc); l != NULL; l = l->n) {
			Edata  iter_data;
			Estack iter_stack;
			assign(var, word(l->w, NULL), FALSE);
			iter_data.b = newblock();
			except(eArena, iter_data, &iter_stack);
			loop_body(n->u[2].p);
			unexcept(eArena);
		}
		unexcept(eBreak);
		break;
	}
	case nSubshell:
		if (dofork(TRUE)) {
			setsigdefaults(FALSE);
			walk(n->u[0].p, FALSE);
			rc_exit(getstatus());
		}
		break;
	case nAssign:
		if (n->u[0].p == NULL)
			rc_error("null variable name");
		assign(glom(n->u[0].p), glob(glom(n->u[1].p)), FALSE);
		break;
	case nPipe:
		dopipe(n);
		break;
	case nNewfn: {
		List *l = glom(n->u[0].p);
		if (l == NULL)
			rc_error("null function name");
		while (l != NULL) {
			if (dashex)
				prettyprint_fn(2, l->w, n->u[1].p);
			fnassign(l->w, n->u[1].p);
			l = l->n;
		}
		set(TRUE);
		break;
	}
	case nRmfn: {
		List *l = glom(n->u[0].p);
		while (l != NULL) {
			if (dashex)
				fprint(2, "fn %S\n", l->w);
			fnrm(l->w);
			l = l->n;
		}
		set(TRUE);
		break;
	}
	case nDup:
		redirq = NULL;
		break; /* Null command */
	case nMatch: {
		List *a = glob(glom(n->u[0].p)), *b = glom(n->u[1].p);
		if (dashex)
			fprint(2, (a != NULL && a->n != NULL) ? "~ (%L) %L\n" : "~ %L %L\n", a, " ", b, " ");
		set(lmatch(a, b));
		break;
	}
	case nSwitch: {
		List *v = glom(n->u[0].p);
		while (1) {
			do {
				n = n->u[1].p;
				if (n == NULL)
					return istrue();
			} while (n->u[0].p == NULL || n->u[0].p->type != nCase);
			if (lmatch(v, glom(n->u[0].p->u[0].p))) {
				for (n = n->u[1].p; n != NULL && (n->u[0].p == NULL || n->u[0].p->type != nCase); n = n->u[1].p)
					walk(n->u[0].p, TRUE);
				break;
			}
		}
		break;
	}
	case nPre: {
		List *v;
		if (n->u[0].p->type == nRedir || n->u[0].p->type == nDup) {
			if (redirq == NULL && !dofork(parent)) /* subshell on first preredir */
				break;
			setsigdefaults(FALSE);
			qredir(n->u[0].p);
			if (!haspreredir(n->u[1].p))
				doredirs(); /* no more preredirs, empty queue */
			walk(n->u[1].p, FALSE);
			rc_exit(getstatus());
			/* NOTREACHED */
		} else if (n->u[0].p->type == nAssign) {
			if (isallpre(n->u[1].p)) {
				walk(n->u[0].p, TRUE);
				WALK(n->u[1].p, parent);
			} else {
				Estack e;
				Edata var;
				v = glom(n->u[0].p->u[0].p);
				assign(v, glob(glom(n->u[0].p->u[1].p)), TRUE);
				var.name = v->w;
				except(eVarstack, var, &e);
				walk(n->u[1].p, parent);
				varrm(v->w, TRUE);
				unexcept(eVarstack);
			}
		} else
			panic("unexpected node in preredir section of walk");
		break;
	}
	case nBrace:
		if (n->u[1].p == NULL) {
			WALK(n->u[0].p, parent);
		} else if (dofork(parent)) {
			setsigdefaults(FALSE);
			walk(n->u[1].p, TRUE); /* Do redirections */
			redirq = NULL;   /* Reset redirection queue */
			walk(n->u[0].p, FALSE); /* Do commands */
			rc_exit(getstatus());
			/* NOTREACHED */
		}
		break;
	case nEpilog:
		qredir(n->u[0].p);
		if (n->u[1].p != NULL) {
			WALK(n->u[1].p, parent); /* Do more redirections. */
		} else {
			doredirs();	/* Okay, we hit the bottom. */
		}
		break;
	case nNmpipe:
		rc_error("named pipes cannot be executed as commands");
		/* NOTREACHED */
	default:
		panic("unknown node in walk");
		/* NOTREACHED */
	}
	return istrue();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %esi, %ebp
movq %rdi, %rbx
callq 0xb9f9
testq %rbx, %rbx
je 0xd43a
leaq 0x73cd(%rip), %r15      # 0x1467c
movl $0x1, %r12d
movl (%rbx), %eax
cmpq $0x20, %rax
ja 0xd896
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl 0xdd07(%rip), %r13d     # 0x1afd8
movl $0x1, 0xdcfd(%rip)      # 0x1afd8
movq 0x8(%rbx), %rdi
movl %r12d, %esi
callq 0xd284
movl %r13d, 0xdcea(%rip)     # 0x1afd8
testl %eax, %eax
jne 0xd3d5
jmp 0xda43
movq 0x8(%rbx), %rdi
movl (%rdi), %eax
cmpl $0x1, %eax
jne 0xd4e2
movq 0x10(%rbx), %rcx
testq %rcx, %rcx
je 0xd3cd
movl (%rcx), %eax
cmpl $0x13, %eax
jne 0xd3b6
movq 0x10(%rcx), %rax
movq %rax, %rcx
testq %rax, %rax
jne 0xd317
jmp 0xd3cd
cmpq $0x0, 0x10(%rbx)
jne 0xd992
movq 0x8(%rbx), %r13
jmp 0xd429
movq 0x8(%rbx), %rdi
callq 0x6b3c
movq 0x10(%rbx), %rcx
movq %rcx, %r13
testq %rcx, %rcx
jne 0xd429
jmp 0xd9ce
movq 0x8(%rbx), %rdi
jmp 0xd3cd
movl 0xdc66(%rip), %r13d     # 0x1afd8
movl $0x1, 0xdc5c(%rip)      # 0x1afd8
movq 0x8(%rbx), %rdi
movl %r12d, %esi
callq 0xd284
movl %r13d, 0xdc49(%rip)     # 0x1afd8
testl %eax, %eax
je 0xd3d5
jmp 0xda43
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0xd3db
cmpl $0xa, (%rax)
jne 0xd3e8
movl %ebp, %r14d
movq 0x8(%rax), %rdx
movq 0x10(%rax), %r12
movq %rdx, %rax
jmp 0xd3f0
cmpl $0x14, %eax
ja 0xd474
movl $0x101002, %ecx         # imm = 0x101002
btl %eax, %ecx
jae 0xd474
movl %r12d, %esi
callq 0xd284
movq 0x10(%rbx), %r13
jmp 0xd429
movl %ebp, %r14d
xorl %eax, %eax
movl %eax, %r12d
movq %r12, %rax
jmp 0xd3f0
movl %ebp, %r14d
xorl %ecx, %ecx
movl %ecx, %r12d
movq %rax, %r13
movl 0xdbdf(%rip), %ebp      # 0x1afd8
movl $0x1, 0xdbd5(%rip)      # 0x1afd8
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0xd284
testl %eax, %eax
cmovneq %r13, %r12
movl %ebp, 0xdbbb(%rip)      # 0x1afd8
movq %r12, %r13
movl $0x1, %r12d
movl %r14d, %ebp
callq 0xb9f9
movq %r13, %rbx
testq %r13, %r13
jne 0xd2b5
testl %ebp, %ebp
je 0xda5a
movl $0x1, %ebx
movl %ebx, %edi
callq 0xbbec
movl %ebx, %eax
jmp 0xda48
movq %rbx, %rdi
callq 0x6b88
movq %rax, %rdi
callq 0x603d
movq %rax, %rdi
movl %ebp, %esi
callq 0x4800
jmp 0xda43
movq 0x8(%rdi), %rdi
callq 0x6b88
movq %rax, %r14
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x6b88
movq %rax, %rdi
callq 0x603d
movl $0x1, %r15d
movq %r14, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x6a02
movq (%r14), %rsi
movl $0x3, %r12d
leaq 0x30(%rsp), %rdx
movl %r12d, %edi
callq 0x44b0
movq 0x10(%rbx), %rdi
movl %ebp, %esi
callq 0xd284
movq (%r14), %rdi
movl %r15d, %esi
callq 0xcb35
movl %r12d, %edi
callq 0x44e4
jmp 0xda43
cmpl $0x14, %eax
je 0xd4f0
cmpl $0xc, %eax
jne 0xd9d5
leaq 0xc5d1(%rip), %rax      # 0x19ac8
cmpq $0x0, (%rax)
jne 0xd50c
movl %ebp, %edi
callq 0xdb28
testl %eax, %eax
je 0xda43
xorl %edi, %edi
callq 0x4dba
movq 0x8(%rbx), %rdi
callq 0x6b3c
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0xd551
movq %rax, %rcx
cmpl $0x13, (%rcx)
jne 0xd551
movq 0x8(%rcx), %rdx
movl (%rdx), %edx
cmpl $0xc, %edx
je 0xd9e3
cmpl $0x14, %edx
je 0xd9e3
movq 0x10(%rcx), %rdx
movq %rdx, %rcx
testq %rdx, %rdx
jne 0xd528
callq 0xb7c0
movq 0x10(%rbx), %rdi
jmp 0xd9e6
movq 0x8(%rbx), %rdi
callq 0x6b88
testq %rax, %rax
je 0xda07
leaq 0xc678(%rip), %r14      # 0x19bf0
leaq 0x7198(%rip), %rbx      # 0x14717
xorl %r15d, %r15d
movl $0x2, %ebp
movq %rax, %r12
cmpl $0x0, (%r14)
je 0xd5a1
movq (%r12), %rdx
movl %r15d, %eax
movl %ebp, %edi
movq %rbx, %rsi
callq 0xaf8c
movq (%r12), %rdi
callq 0x4cf4
movq 0x10(%r12), %rax
movq %rax, %r12
testq %rax, %rax
jne 0xd58a
jmp 0xda07
movl 0xda15(%rip), %r13d     # 0x1afd8
movl $0x1, 0xda0b(%rip)      # 0x1afd8
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0xd284
movl %r13d, 0xd9f6(%rip)     # 0x1afd8
testl %eax, %eax
je 0xda43
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x3370
testl %eax, %eax
jne 0xda43
movl $0x1, %ebp
leaq 0x30(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movl %ebp, %edi
callq 0x44b0
movl %r13d, 0xd9ba(%rip)     # 0x1afd8
movl $0x4, %r14d
movq %rsp, %r15
callq 0x9fe8
movl %r14d, %edi
movq %rax, %rsi
movq %r15, %rdx
callq 0x44b0
movq 0x10(%rbx), %rdi
callq 0xdad3
movl $0x1, 0xd98b(%rip)      # 0x1afd8
movq 0x8(%rbx), %rdi
movl %ebp, %esi
callq 0xd284
movl %eax, %r12d
movl %r13d, 0xd976(%rip)     # 0x1afd8
movl %r14d, %edi
callq 0x44e4
testl %r12d, %r12d
jne 0xd627
movl %r13d, 0xd962(%rip)     # 0x1afd8
jmp 0xd80e
callq 0xce78
testl %eax, %eax
je 0xda61
movl %eax, %ebx
leaq 0xc543(%rip), %rax      # 0x19bd4
cmpl $0x0, (%rax)
je 0xd6ab
leaq 0x7063(%rip), %rsi      # 0x14700
xorl %eax, %eax
movl $0x2, %edi
movl %ebx, %edx
callq 0xaf8c
leaq 0x20e3(%rip), %rdi      # 0xf795
xorl %ebp, %ebp
movl %ebp, %eax
movl %ebx, %esi
callq 0xb191
movl %ebp, %esi
movq %rax, %rdi
callq 0x6644
leaq 0x20d9(%rip), %rdi      # 0xf7a7
movq %rax, %rsi
movl %ebp, %edx
callq 0xc808
leaq 0xc3e9(%rip), %rax      # 0x19ac8
movq $0x0, (%rax)
jmp 0xda43
movq 0x8(%rbx), %rax
movq %rax, %rdi
testq %rax, %rax
jne 0xd707
leaq 0x1fee(%rip), %rdi      # 0xf6ec
callq 0x46c0
movq 0x8(%rbx), %rdi
callq 0x6b88
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x6b88
movq %rax, %rdi
callq 0x603d
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x6a02
jmp 0xda43
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0xd284
xorl %edi, %edi
testl %eax, %eax
sete %al
movb %al, %dil
jmp 0xda3e
movq %rbx, %rdi
callq 0xdbc6
jmp 0xda43
movq 0x8(%rbx), %rdi
callq 0x6b88
movq %rax, %r14
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x3370
testl %eax, %eax
jne 0xda43
leaq 0x30(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movl $0x1, %edi
callq 0x44b0
movq 0x10(%rbx), %rdi
callq 0x6b88
movq %rax, %rdi
callq 0x603d
leaq -0x392b(%rip), %rsi     # 0x9e80
movq %rax, %rdi
callq 0x9694
testq %rax, %rax
je 0xd80e
xorl %ebp, %ebp
movl $0x4, %r15d
movq %rsp, %r12
movq %rax, %r13
movq (%r13), %rdi
movl %ebp, %esi
callq 0x6644
movq %r14, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x6a02
callq 0x9fe8
movl %r15d, %edi
movq %rax, %rsi
movq %r12, %rdx
callq 0x44b0
movq 0x18(%rbx), %rdi
callq 0xdad3
movl %r15d, %edi
callq 0x44e4
movq 0x10(%r13), %rax
movq %rax, %r13
testq %rax, %rax
jne 0xd7c6
movl $0x1, %edi
jmp 0xd4d8
movl $0x1, %edi
callq 0xdb28
testl %eax, %eax
je 0xda43
xorl %ebp, %ebp
movl %ebp, %edi
callq 0x4dba
jmp 0xd9c6
movq 0x8(%rbx), %rdi
callq 0x6b88
testq %rax, %rax
je 0xd9fb
leaq 0xc39f(%rip), %r14      # 0x19bf0
movl $0x2, %ebp
movq %rax, %r15
cmpl $0x0, (%r14)
je 0xd86d
movq (%r15), %rsi
movq 0x10(%rbx), %rdx
movl %ebp, %edi
callq 0x50fa
movq (%r15), %rdi
movq 0x10(%rbx), %rsi
callq 0x4bc5
movq 0x10(%r15), %rax
movq %rax, %r15
testq %rax, %rax
jne 0xd859
jmp 0xda07
leaq 0x6ecd(%rip), %rdi      # 0x1475e
callq 0x46c0
leaq 0x6eec(%rip), %rdi      # 0x14789
jmp 0xd9dc
movq 0x8(%rbx), %rdi
callq 0x6b88
movq %rax, %rdi
callq 0x603d
movq %rax, %r15
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x6b88
movq %rax, %rbx
leaq 0xc324(%rip), %rax      # 0x19bf0
cmpl $0x0, (%rax)
je 0xda31
testq %r15, %r15
je 0xda0e
cmpq $0x0, 0x10(%r14)
leaq 0x6e3f(%rip), %rax      # 0x14729
leaq 0x6e2d(%rip), %rcx      # 0x1471e
cmoveq %rax, %rcx
movq %rcx, %rsi
jmp 0xda15
movq 0x8(%rbx), %rdi
callq 0x6b88
movq %rax, %r14
movq %rbx, %rcx
movq 0x10(%rcx), %rbx
testq %rbx, %rbx
je 0xda43
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0xd927
cmpl $0x18, (%rax)
je 0xd938
movq 0x10(%rbx), %rax
movq %rax, %rbx
testq %rax, %rax
jne 0xd919
jmp 0xda43
movq 0x8(%rax), %rdi
callq 0x6b88
movq %r14, %rdi
movq %rax, %rsi
callq 0x5f9c
movq %rbx, %rcx
testl %eax, %eax
je 0xd90c
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0xda43
movl $0x1, %ebx
movq %rax, %r14
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0xd97a
cmpl $0x18, (%rdi)
je 0xda43
movl %ebx, %esi
callq 0xd284
movq 0x10(%r14), %rax
movq %rax, %r14
testq %rax, %rax
jne 0xd968
jmp 0xda43
movl %ebp, %edi
callq 0xdb28
testl %eax, %eax
je 0xda43
xorl %ebp, %ebp
movl %ebp, %edi
callq 0x4dba
movq 0x10(%rbx), %rdi
movl $0x1, %esi
callq 0xd284
leaq 0xc109(%rip), %rax      # 0x19ac8
movq $0x0, (%rax)
movq 0x8(%rbx), %rdi
movl %ebp, %esi
jmp 0xd9e8
callq 0xb7c0
jmp 0xda43
leaq 0x6d56(%rip), %rdi      # 0x14732
callq 0xc72e
jmp 0xda43
movq %rax, %rdi
xorl %esi, %esi
callq 0xd284
callq 0xbb95
movl %eax, %edi
callq 0x4eb5
jmp 0xda43
leaq 0x6d02(%rip), %rdi      # 0x14704
callq 0x46c0
movl $0x1, %edi
jmp 0xda3e
leaq 0x6d14(%rip), %rsi      # 0x14729
leaq 0x6bd9(%rip), %rcx      # 0x145f5
xorl %eax, %eax
movl $0x2, %edi
movq %r14, %rdx
movq %rbx, %r8
movq %rcx, %r9
callq 0xaf8c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5f9c
movl %eax, %edi
callq 0xbbec
callq 0xbb64
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x3330
xorl %ebp, %ebp
movl %ebp, %edi
callq 0x4dba
movl $0x1, %r14d
movl $0x16, %edi
movq %r14, %rsi
callq 0xbaa4
movl $0x15, %edi
movq %r14, %rsi
callq 0xbaa4
movl $0x14, %edi
movq %r14, %rsi
callq 0xbaa4
callq 0x30d0
movl %ebp, %edi
movl %eax, %esi
callq 0x3320
leaq 0x23b9(%rip), %rdi      # 0xfe65
movl %ebp, %esi
callq 0xa08c
movl %eax, %edi
movl %ebp, %esi
callq 0xc7e5
movq 0x8(%rbx), %rdi
movl %ebp, %esi
callq 0xd284
callq 0xbb95
movl %eax, %edi
callq 0x3330