// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, 0x8(%rsp)
movq %rdi, %rbx
pushq $0x20
popq %rbp
leaq 0x1a3b8(%rip), %r13     # 0x319f8
testq %rbx, %rbx
je 0x17cd8
movl 0x8(%rbx), %eax
cmpq $0xd, %rax
ja 0x17cd8
movslq (%r13,%rax,4), %rcx
addq %r13, %rcx
movq %rbp, %r14
pushq $0x28
popq %r15
pushq $0x18
popq %rax
movq %rbp, %r12
jmpq *%rcx
movq 0x20(%rbx), %rdi
movl 0x8(%rsp), %esi
callq 0x17621
pushq $0x28
popq %r14
pushq $0x30
popq %r15
movq 0x18(%rbx), %rdi
movl 0x8(%rsp), %esi
callq 0x17621
movq %r14, %rax
movq %r15, %r12
movq (%rbx,%rax), %rdi
movl 0x8(%rsp), %esi
callq 0x17621
jmp 0x176d0
movq %rbx, %rdi
callq 0x19ae5
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x185d2
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1aea7
movl 0x18(%rbx), %eax
pushq $0x30
popq %r12
cmpl $0x5, %eax
jne 0x176d9
movq (%rbx,%r12), %rbx
jmp 0x17640
cmpl $0x2, %eax
jne 0x17cd8
movq %rbx, %rdi
callq 0x19ae5
movl (%rax), %ecx
leal -0x4(%rcx), %edx
cmpl $0x4, %edx
ja 0x17c98
movq 0x30(%rbx), %r14
shlq $0x4, %rcx
leaq 0x1a5d9(%rip), %rdx     # 0x31ce0
cmpq (%rcx,%rdx), %r14
jl 0x1771a
addq %rcx, %rdx
cmpq 0x8(%rdx), %r14
jle 0x17cd8
movq %rax, %rdi
callq 0x21009
leaq 0x1b2cb(%rip), %rsi     # 0x329f4
jmp 0x17d0c
movq 0x18(%rbx), %rdi
movl 0x8(%rsp), %ebp
movl %ebp, %esi
callq 0x17621
movq 0x20(%rbx), %rdi
movl %ebp, %esi
callq 0x17621
movq 0x28(%rbx), %rdi
movl %ebp, %esi
callq 0x17621
cmpl $0x0, 0x47196(%rip)     # 0x5e8f0
jne 0x17cd8
callq 0x1d859
movq %rax, %r14
leaq 0x47a89(%rip), %rax     # 0x5f1f8
movq (%rax), %rax
movq 0x30(%rax), %r13
movq 0x20(%rbx), %rdi
callq 0x1bf90
movl (%rax), %ecx
cmpl $0x15, %ecx
ja 0x17794
movl $0x340000, %edx         # imm = 0x340000
btl %ecx, %edx
jb 0x17cd8
xorl %ebp, %ebp
xorl %edi, %edi
movq %rax, %rsi
callq 0x19ca0
leaq 0x47171(%rip), %r15     # 0x5e918
leaq 0x47172(%rip), %r12     # 0x5e920
cmpq 0x38(%r13), %rbp
jae 0x17cd8
movq 0x20(%rbx), %rdi
callq 0x1bf90
movq 0x30(%r13), %rcx
movq (%rcx,%rbp,8), %rcx
movq 0x48(%rcx), %rdi
movq %rax, %rsi
callq 0x2a517
testl %eax, %eax
jne 0x17818
leaq 0x47118(%rip), %rdi     # 0x5e8f8
leaq 0x47119(%rip), %rsi     # 0x5e900
movq %r14, %rdx
callq 0x29b2d
leaq 0x47112(%rip), %rdi     # 0x5e908
leaq 0x47113(%rip), %rsi     # 0x5e910
movq %rbx, %rdx
callq 0x29b2d
movq 0x30(%r13), %rax
movq (%rax,%rbp,8), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x29b2d
incq %rbp
jmp 0x177ae
movq 0x18(%rbx), %rdi
callq 0x1d890
xorl %r14d, %r14d
movl 0x8(%rsp), %ebp
cmpq 0x20(%rbx), %r14
jae 0x17a0a
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x17621
incq %r14
jmp 0x1782d
movq 0x38(%rbx), %rdi
callq 0x1d970
callq 0x1d859
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1e589
jmp 0x179a5
movq 0x38(%rbx), %rdi
callq 0x1d970
movq %rbx, %rdi
callq 0x19ae5
movq %rbx, %rdi
movq %rax, %rsi
movl 0x8(%rsp), %ebp
movl %ebp, %edx
callq 0x185d2
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1aea7
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x178a6
movl %ebp, %esi
callq 0x17621
movq %rbx, %rdi
callq 0x1befe
leaq 0x16270(%rip), %rsi     # 0x2db25
movq %rax, %rdi
callq 0x2a626
testl %eax, %eax
je 0x1793b
movq %rbx, %rdi
callq 0x1bf2d
movq %rax, %rdi
callq 0x1fcd8
cmpq $0x2, 0x70(%rax)
ja 0x17d1c
movq %rax, %r14
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x1fcd8
cmpl $0x1, (%rax)
jne 0x17d1c
cmpq $0x2, 0x70(%r14)
jne 0x1793b
movq 0x68(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x1fcd8
cmpl $0x14, (%rax)
jne 0x17d1c
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x1fcd8
cmpl $0x14, (%rax)
jne 0x17d1c
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x1fcd8
cmpl $0x9, (%rax)
jne 0x17d1c
movq %rbx, %rdi
callq 0x1befe
movq %rax, %r14
leaq 0x16187(%rip), %rsi     # 0x2dad4
movq %rax, %rdi
callq 0x2a626
testl %eax, %eax
jne 0x1796c
leaq 0x1617d(%rip), %rsi     # 0x2dadd
movq %r14, %rdi
callq 0x2a626
testl %eax, %eax
je 0x179a5
movq %rbx, %rdi
callq 0x1bf2d
movq %rax, %rdi
callq 0x1fcd8
cmpl $0x13, (%rax)
jne 0x17cf5
cmpq $0x1, 0x70(%rax)
jne 0x17cf5
movq 0x68(%rax), %rax
movq (%rax), %rdi
callq 0x1fcd8
cmpl $0x1, (%rax)
jne 0x17cf5
movq 0x38(%rbx), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d9bb
movq 0x20(%rbx), %rdi
callq 0x1d890
movq 0x28(%rbx), %rsi
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %edx, %edx
callq 0x185d2
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1aea7
movl 0x8(%rsp), %ebp
cmpq 0x30(%rbx), %r14
jae 0x179ff
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x17621
incq %r14
jmp 0x179e5
movq 0x40(%rbx), %rdi
movl %ebp, %esi
callq 0x17621
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d8d4
movq %rbx, %rdi
callq 0x19ae5
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x185d2
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1aea7
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x17a54
movq %rbx, %rdi
xorl %edx, %edx
callq 0x185d2
movq %rax, 0x28(%rbx)
movq 0x48(%rbx), %rdi
movl 0x8(%rsp), %ebp
movl %ebp, %esi
callq 0x17621
movq %rbx, %rdi
callq 0x1b5e6
cmpl $0x2e, %eax
jne 0x17ae4
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1b5e6
cmpl $0x35, %eax
jne 0x17ae4
movq 0x50(%rbx), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpl $0x2, 0x18(%rax)
jne 0x17ae4
movq %rbx, %rdi
callq 0x1bf90
movq %rax, %rdi
callq 0x2049e
testl %eax, %eax
je 0x17ae4
movq 0x50(%rbx), %rax
movq (%rax), %r14
movq %rbx, %rdi
callq 0x1bf90
movq %r14, %rdi
movq %rax, %rsi
callq 0x1aea7
movq 0x50(%rbx), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq (%rax), %r14
movq %rbx, %rdi
callq 0x1bf90
movq %r14, %rdi
movq %rax, %rsi
callq 0x1aea7
movq %rbx, %rdi
callq 0x1b5e6
cmpl $0x1, %eax
jne 0x17b7b
callq 0x1d859
movq %rax, %r14
leaq 0x476f4(%rip), %rax     # 0x5f1f8
movq (%rax), %rax
movq 0x38(%rax), %r15
movq %rbx, %rdi
callq 0x1bf90
cmpq $0x1, 0x38(%r15)
jne 0x17d40
movq 0x30(%r15), %rcx
movq (%rcx), %rcx
movq 0x48(%rcx), %rdi
movq %rax, %rsi
callq 0x2a517
testl %eax, %eax
jne 0x17b7b
leaq 0x46dbc(%rip), %rdi     # 0x5e8f8
leaq 0x46dbd(%rip), %rsi     # 0x5e900
movq %r14, %rdx
callq 0x29b2d
leaq 0x46db6(%rip), %rdi     # 0x5e908
leaq 0x46db7(%rip), %rsi     # 0x5e910
movq %rbx, %rdx
callq 0x29b2d
movq 0x30(%r15), %rax
movq (%rax), %rdx
leaq 0x46da9(%rip), %rdi     # 0x5e918
leaq 0x46daa(%rip), %rsi     # 0x5e920
callq 0x29b2d
xorl %r14d, %r14d
cmpq 0x40(%rbx), %r14
jae 0x17bc8
movq 0x50(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x17621
incq %r14
jmp 0x17b7e
movq 0x18(%rbx), %rdi
movl 0x8(%rsp), %esi
callq 0x17621
xorl %r14d, %r14d
cmpq 0x20(%rbx), %r14
jae 0x17cd8
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl 0x8(%rsp), %esi
callq 0x17621
incq %r14
jmp 0x17ba8
testl %ebp, %ebp
jne 0x17cd8
movq %rbx, %rdi
callq 0x1bf90
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x1fcd8
movq %rax, %r15
movq %rbx, %rdi
callq 0x1b5e6
cmpl $0x39, %eax
je 0x17cce
cmpl $0x38, %eax
jne 0x17cd8
cmpl $0x17, (%r15)
jne 0x17d5f
xorl %ecx, %ecx
cmpq 0x40(%rbx), %rcx
jae 0x17cd8
movq 0x50(%rbx), %rax
movq %rcx, 0x8(%rsp)
movq (%rax,%rcx,8), %r14
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq 0x78(%r15), %r13
jae 0x17c67
movq 0x48(%r14), %rdi
callq 0x1c0c8
movq %rax, %r12
movq 0x88(%r15), %rax
movq (%rax,%r13,8), %rdi
callq 0x1befe
movq %r12, %rdi
movq %rax, %rsi
callq 0x4230
pushq $0x1
popq %rcx
testl %eax, %eax
je 0x17c60
movl %ebp, %ecx
incq %r13
movl %ecx, %ebp
jmp 0x17c2a
movq 0x8(%rsp), %rcx
incq %rcx
testl %ebp, %ebp
jne 0x17c0e
movq 0x10(%rsp), %rdi
callq 0x21009
movq %rax, %r15
movq 0x48(%r14), %rdi
callq 0x1c0c8
leaq 0x1ad4b(%rip), %rsi     # 0x329db
movq %rbx, %rdi
movq %r15, %rdx
jmp 0x17d12
cmpl $0xe, %ecx
ja 0x17cd8
movl $0x7e08, %edx           # imm = 0x7E08
btl %ecx, %edx
jae 0x17cd8
movq 0x30(%rbx), %r14
shlq $0x4, %rcx
leaq 0x1a0ba(%rip), %rdx     # 0x31d70
cmpq 0x8(%rcx,%rdx), %r14
jbe 0x17cd8
movq %rax, %rdi
callq 0x21009
leaq 0x1ad56(%rip), %rsi     # 0x32a22
jmp 0x17d0c
cmpl $0x15, (%r15)
jne 0x17d5f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a663(%rip), %rdi     # 0x32351
xorl %eax, %eax
callq 0x1205c
movq %rbx, %rdi
callq 0x1bf2d
movq %rax, %rdi
callq 0x21009
leaq 0x1ac55(%rip), %rsi     # 0x32961
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x120fd
movq %rbx, %rdi
callq 0x1bf2d
movq %rax, %rdi
callq 0x21009
leaq 0x1abf8(%rip), %rsi     # 0x3292b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x120fd
leaq 0x1ac36(%rip), %rdi     # 0x3297d
leaq 0x1a53a(%rip), %rsi     # 0x32288
leaq 0x1ac38(%rip), %rcx     # 0x3298d
movl $0x113, %edx            # imm = 0x113
callq 0x4180
movq 0x10(%rsp), %rdi
callq 0x21009
leaq 0x1ac48(%rip), %rsi     # 0x329b8
jmp 0x17d33