// File: /workspace/github_c_makefile_star2_O1/oridb[P]mc/parse/infer.c
// Function: typesub
static void
typesub(Node *n, int noerr)
{
	char *name;
	size_t i;
	Node *l;

	if (!n)
		return;
	switch (n->type) {
	case Ndecl:
		pushenv(n->decl.env);
		settype(n, tyfix(n, type(n), noerr));
		if (n->decl.init)
			typesub(n->decl.init, noerr);
		if (streq(declname(n), "main"))
			if (!maincompatible(tybase(decltype(n))))
				fatal(n, "main must be (->void) or (byte[:][:] -> void), got %s",
						tystr(decltype(n)));
		name = declname(n);
		if (streq(name, "__init__") || streq(name, "__fini__"))
			if (!initcompatible(tybase(decltype(n))))
				fatal(n, "%s must be (->void), got %s", name, tystr(decltype(n)));
		popenv(n->decl.env);
		break;
	case Nblock:
		pushstab(n->block.scope);
		for (i = 0; i < n->block.nstmts; i++)
			typesub(n->block.stmts[i], noerr);
		popstab();
		break;
	case Nifstmt:
		typesub(n->ifstmt.cond, noerr);
		typesub(n->ifstmt.iftrue, noerr);
		typesub(n->ifstmt.iffalse, noerr);
		break;
	case Nloopstmt:
		typesub(n->loopstmt.cond, noerr);
		typesub(n->loopstmt.init, noerr);
		typesub(n->loopstmt.step, noerr);
		typesub(n->loopstmt.body, noerr);
		break;
	case Niterstmt:
		typesub(n->iterstmt.elt, noerr);
		typesub(n->iterstmt.seq, noerr);
		typesub(n->iterstmt.body, noerr);
		if (!ingeneric)
			additerspecialization(n, curstab());
		break;
	case Nmatchstmt:
		typesub(n->matchstmt.val, noerr);
		for (i = 0; i < n->matchstmt.nmatches; i++) {
			typesub(n->matchstmt.matches[i], noerr);
		}
		break;
	case Nmatch:
		typesub(n->match.pat, noerr);
		typesub(n->match.block, noerr);
		break;
	case Nexpr:
		settype(n, tyfix(n, type(n), 0));
		if (n->expr.param)
			n->expr.param = tyfix(n, n->expr.param, 0);
		typesub(n->expr.idx, noerr);
		if (exprop(n) == Ocast && exprop(n->expr.args[0]) == Olit) {
			l = n->expr.args[0]->expr.args[0];
			if(l->lit.littype == Lint && istyint(exprtype(n))) {
				settype(n->expr.args[0], exprtype(n));
				settype(n->expr.args[0]->expr.args[0], exprtype(n));
			}
		}
		if (exprop(n) == Oauto)
			adddispspecialization(n, curstab());
		for (i = 0; i < n->expr.nargs; i++)
			typesub(n->expr.args[i], noerr);
		if (!noerr)
			verifyop(n);
		break;
	case Nfunc:
		pushstab(n->func.scope);
		settype(n, tyfix(n, n->func.type, 0));
		for (i = 0; i < n->func.nargs; i++)
			typesub(n->func.args[i], noerr);
		typesub(n->func.body, noerr);
		popstab();
		break;
	case Nlit:
		settype(n, tyfix(n, type(n), 0));
		switch (n->lit.littype) {
		case Lfunc:	typesub(n->lit.fnval, noerr);	break;
		case Lint:	checkrange(n);			break;
		default: 					break;
		}
		break;
	case Nimpl:
		pushenv(n->impl.env);
		putimpl(curstab(), n);
		popenv(n->impl.env);
	case Nname: case Nuse:
		break;
	case Nnone:
		die("Nnone should not be seen as node type!");
		break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x1c871(%rip), %r14     # 0x359e8
testq %rbx, %rbx
je 0x1962b
movl 0x8(%rbx), %eax
cmpq $0xd, %rax
ja 0x1962b
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movq 0x18(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x20(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x28(%rbx), %rbx
jmp 0x19177
movq 0x20(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x18(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x28(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
jmp 0x1920e
movq 0x18(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x20(%rbx), %rbx
jmp 0x19177
movq %rbx, %rdi
callq 0x1b6e6
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1a0c3
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c85b
movl 0x18(%rbx), %eax
cmpl $0x5, %eax
jne 0x19217
movq 0x30(%rbx), %rbx
jmp 0x19177
cmpl $0x2, %eax
jne 0x1962b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1d435
movq 0x18(%rbx), %rdi
callq 0x20070
cmpq $0x0, 0x20(%rbx)
je 0x1949c
xorl %r14d, %r14d
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x19164
incq %r14
cmpq 0x20(%rbx), %r14
jb 0x19249
jmp 0x1949c
movq 0x38(%rbx), %rdi
callq 0x20159
callq 0x20037
movq %rax, %rdi
movq %rbx, %rsi
callq 0x20e6c
jmp 0x193bc
movq 0x38(%rbx), %rdi
callq 0x20159
movq %rbx, %rdi
callq 0x1b6e6
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x1a0c3
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c85b
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x192bd
movl %ebp, %esi
callq 0x19164
movq %rbx, %rdi
callq 0x1e53d
leaq 0x18849(%rip), %rsi     # 0x31b15
movq %rax, %rdi
callq 0x2dfda
testl %eax, %eax
je 0x19352
movq %rbx, %rdi
callq 0x1e56c
movq %rax, %rdi
callq 0x22c44
cmpq $0x2, 0x70(%rax)
ja 0x1967d
movq %rax, %r14
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x22c44
cmpl $0x1, (%rax)
jne 0x1967d
cmpq $0x2, 0x70(%r14)
jne 0x19352
movq 0x68(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x22c44
cmpl $0x14, (%rax)
jne 0x1967d
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x22c44
cmpl $0x14, (%rax)
jne 0x1967d
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x22c44
cmpl $0x9, (%rax)
jne 0x1967d
movq %rbx, %rdi
callq 0x1e53d
movq %rax, %r14
leaq 0x18760(%rip), %rsi     # 0x31ac4
movq %rax, %rdi
callq 0x2dfda
testl %eax, %eax
jne 0x19383
leaq 0x18756(%rip), %rsi     # 0x31acd
movq %r14, %rdi
callq 0x2dfda
testl %eax, %eax
je 0x193bc
movq %rbx, %rdi
callq 0x1e56c
movq %rax, %rdi
callq 0x22c44
cmpl $0x13, (%rax)
jne 0x19656
cmpq $0x1, 0x70(%rax)
jne 0x19656
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x22c44
cmpl $0x1, (%rax)
jne 0x19656
movq 0x38(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x201a4
movq 0x18(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x20(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq 0x28(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
cmpl $0x0, 0x484f9(%rip)     # 0x618f0
jne 0x1962b
callq 0x20037
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1d23e
movq 0x18(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
cmpq $0x0, 0x20(%rbx)
je 0x1962b
xorl %r14d, %r14d
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x19164
incq %r14
cmpq 0x20(%rbx), %r14
jb 0x19430
jmp 0x1962b
movq 0x20(%rbx), %rdi
callq 0x20070
movq 0x28(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1a0c3
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c85b
cmpq $0x0, 0x30(%rbx)
je 0x19491
xorl %r14d, %r14d
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x19164
incq %r14
cmpq 0x30(%rbx), %r14
jb 0x19479
movq 0x40(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x200b6
movq %rbx, %rdi
callq 0x1b6e6
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1a0c3
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c85b
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x194e2
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1a0c3
movq %rax, 0x28(%rbx)
movq 0x48(%rbx), %rdi
movl %ebp, %esi
callq 0x19164
movq %rbx, %rdi
callq 0x1d672
cmpl $0x2e, %eax
jne 0x1956e
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1d672
cmpl $0x35, %eax
jne 0x1956e
movq 0x50(%rbx), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpl $0x2, 0x18(%rax)
jne 0x1956e
movq %rbx, %rdi
callq 0x1e5d4
movq %rax, %rdi
callq 0x23476
testl %eax, %eax
je 0x1956e
movq 0x50(%rbx), %rax
movq (%rax), %r14
movq %rbx, %rdi
callq 0x1e5d4
movq %r14, %rdi
movq %rax, %rsi
callq 0x1c85b
movq 0x50(%rbx), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq (%rax), %r14
movq %rbx, %rdi
callq 0x1e5d4
movq %r14, %rdi
movq %rax, %rsi
callq 0x1c85b
movq %rbx, %rdi
callq 0x1d672
cmpl $0x1, %eax
jne 0x19605
callq 0x20037
movq %rax, %r14
leaq 0x48c6a(%rip), %rax     # 0x621f8
movq (%rax), %rax
movq 0x38(%rax), %r15
movq %rbx, %rdi
callq 0x1e5d4
cmpq $0x1, 0x38(%r15)
jne 0x196a1
movq 0x30(%r15), %rcx
movq (%rcx), %rcx
movq 0x48(%rcx), %rdi
movq %rax, %rsi
callq 0x2decd
testl %eax, %eax
jne 0x19605
leaq 0x48332(%rip), %rdi     # 0x618f8
leaq 0x48333(%rip), %rsi     # 0x61900
movq %r14, %rdx
callq 0x2d3ff
leaq 0x4832c(%rip), %rdi     # 0x61908
leaq 0x4832d(%rip), %rsi     # 0x61910
movq %rbx, %rdx
callq 0x2d3ff
movq 0x30(%r15), %rax
movq (%rax), %rdx
leaq 0x4831f(%rip), %rdi     # 0x61918
leaq 0x48320(%rip), %rsi     # 0x61920
callq 0x2d3ff
cmpq $0x0, 0x40(%rbx)
je 0x19627
xorl %r14d, %r14d
movq 0x50(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x19164
incq %r14
cmpq 0x40(%rbx), %r14
jb 0x1960f
testl %ebp, %ebp
je 0x19636
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1d315
leaq 0x1cd22(%rip), %rdi     # 0x36371
xorl %eax, %eax
callq 0x13a00
movq %rbx, %rdi
callq 0x1e56c
movq %rax, %rdi
callq 0x23e44
leaq 0x1d314(%rip), %rsi     # 0x36981
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x13aa3
movq %rbx, %rdi
callq 0x1e56c
movq %rax, %rdi
callq 0x23e44
leaq 0x1d2b7(%rip), %rsi     # 0x3694b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x13aa3
leaq 0x1d2f5(%rip), %rdi     # 0x3699d
leaq 0x1cbf9(%rip), %rsi     # 0x362a8
leaq 0x1d2f7(%rip), %rcx     # 0x369ad
movl $0x113, %edx            # imm = 0x113
callq 0x4180