// File: /workspace/github_c_makefile_star2_O1/oridb[P]mc/mi/match.c
// Function: addrec
static void
addrec(Frontier *fs, Node *pat, Node *val, Path *path)
{
	size_t i, n;
	Type *ty, *mty;
	Node *memb, *name, *tagid, *p, *v, *lit, *dcl, *asn, *deref;
	Ucon *uc;
	char *s;
	Frontier *next;

	pat = fold(pat, 1);
	switch (exprop(pat)) {
	case Olor:
		next = frontierdup(fs);
		next->next = fs->next;
		next->hasorpat = 1;
		fs->next = next;
		fs->hasorpat = 1;
		addrec(fs, pat->expr.args[0], val, path);
		addrec(next, pat->expr.args[1], val, path);
		break;
	case Ogap:
		lappend(&fs->slot, &fs->nslot, mkslot(path, pat, val));
		break;
	case Ovar:
		dcl = decls[pat->expr.did];
		if (dcl->decl.isconst) {
			ty = decltype(dcl);
			if (ty->type == Tyfunc || ty->type == Tycode || ty->type == Tyvalist)
				fatal(dcl, "bad pattern %s:%s: unmatchable type", declname(dcl), tystr(ty));
			if (!dcl->decl.init)
				fatal(dcl, "bad pattern %s:%s: missing initializer", declname(dcl), tystr(ty));
			addrec(fs, dcl->decl.init, val, mkpath(path, 0));
		} else {
			asn = mkexpr(pat->loc, Oasn, pat, val, NULL);
			asn->expr.type = exprtype(pat);
			lappend(&fs->cap, &fs->ncap, asn);

			lappend(&fs->slot, &fs->nslot, mkslot(path, pat, val));
		}
		break;
	case Olit:
		if (pat->expr.args[0]->lit.littype == Lstr) {
			lit = pat->expr.args[0];
			n = lit->lit.strval.len;
			s = lit->lit.strval.buf;

			ty = mktype(pat->loc, Tyuint64);
			p = mkintlit(lit->loc, n);
			p ->expr.type = ty;
			v = structmemb(val, mkname(pat->loc, "len"), ty);

			addrec(fs, p, v, mkpath(path, 0));

			ty = mktype(pat->loc, Tybyte);
			for (i = 0; i < n; i++) {
				p = mkintlit(lit->loc, s[i]);
				p->expr.type = ty;
				v = arrayelt(val, i);
				addrec(fs, p, v, mkpath(path, 1+i));
			}
		} else {
			lappend(&fs->slot, &fs->nslot, mkslot(path, pat, val));
		}
		break;
	case Oaddr:
		deref = mkexpr(val->loc, Oderef, val, NULL);
		deref->expr.type = exprtype(pat->expr.args[0]);
		addrec(fs, pat->expr.args[0], deref, mkpath(path, 0));
		break;
	case Oucon:
		uc = finducon(tybase(exprtype(pat)), pat->expr.args[0]);
		tagid = mkintlit(pat->loc, uc->id);
		tagid->expr.type = mktype(pat->loc, Tyint32);
		addrec(fs, tagid, utag(val), mkpath(path, 0));
		if (uc->etype)
			addrec(fs, pat->expr.args[1], uvalue(val, uc->etype), mkpath(path, 1));
		break;
	case Otup:
		for (i = 0; i < pat->expr.nargs; i++) {
			addrec(fs, pat->expr.args[i], tupelt(val, i), mkpath(path, i));
		}
		break;
	case Oarr:
		for (i = 0; i < pat->expr.nargs; i++) {
			addrec(fs, pat->expr.args[i], arrayelt(val, i), mkpath(path, i));
		}
		break;
	case Ostruct:
		ty = tybase(exprtype(pat));
		for (i = 0; i < ty->nmemb; i++) {
			mty = decltype(ty->sdecls[i]);
			name = ty->sdecls[i]->decl.name;
			memb = findmemb(pat, name);
			if (!memb) {
				memb = mkexpr(ty->sdecls[i]->loc, Ogap, NULL);
				memb->expr.type = mty;
			}
			addrec(fs, memb, structmemb(val, name, mty), mkpath(path, i));
		}
		break;
	default:
		fatal(pat, "unsupported pattern %s of type %s", opstr[exprop(pat)], tystr(exprtype(pat)));
		break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r15
movq %r12, %rdi
movl $0x1, %esi
callq 0x14703
movq %rax, %r12
movq %rax, %rdi
callq 0x1d672
cmpl $0x33, %eax
jne 0x2c4ae
leaq 0x3550f(%rip), %rax     # 0x61968
movq (%rax), %rax
movq 0x38(%r12), %rcx
movq (%rax,%rcx,8), %rbx
cmpb $0x0, 0x72(%rbx)
je 0x2c9aa
movq %r14, %r13
movq %rbx, %rdi
callq 0x1e56c
movq %rax, %r14
movl (%rax), %eax
cmpl $0x1e, %eax
ja 0x2c492
movl $0x400a0000, %ecx       # imm = 0x400A0000
btl %eax, %ecx
jb 0x2ca29
movq 0x30(%rbx), %r12
testq %r12, %r12
je 0x2ca79
movq %r13, %rdi
xorl %esi, %esi
callq 0x2caa3
movq %rax, %r14
jmp 0x2c435
leal -0x34(%rax), %ecx
cmpl $0x5, %ecx
ja 0x2c5ad
leaq 0xc793(%rip), %rdx      # 0x38c54
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
movq %rbp, 0x18(%rsp)
jmpq *%rax
movq %r12, %rdi
callq 0x1e5d4
movq %rax, %rdi
callq 0x22c44
movq 0x50(%r12), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x233cc
movq %rax, 0x8(%rsp)
movq 0x8(%rax), %rsi
movq (%r12), %rdi
callq 0x1d7ca
movq %rax, %rbx
movq (%r12), %rdi
movl $0x7, %esi
callq 0x22d38
movq %rax, 0x20(%rbx)
movq (%rbp), %rdi
movl $0x43, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d832
movq %r15, %r13
movq %rax, %r15
movq (%rbp), %rdi
movl $0x7, %esi
callq 0x22d38
movq %rax, 0x20(%r15)
movq %r14, %rdi
xorl %esi, %esi
callq 0x2caa3
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2c41b
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rbx
testq %rbx, %rbx
je 0x2c99b
movq 0x50(%r12), %rax
movq 0x8(%rax), %r12
movq (%rbp), %rdi
movl $0x44, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d832
movq %rax, %rbp
movq %rbx, 0x20(%rax)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2caa3
movq %rax, %r14
movq %r13, %r15
jmp 0x2c435
cmpl $0x12, %eax
je 0x2c647
cmpl $0x14, %eax
jne 0x2ca45
movl (%r15), %edi
movq 0x8(%r15), %rsi
callq 0x2c3af
movq %rax, %rbx
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
shlq $0x3, %rsi
callq 0x2d60b
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rax
movq %rax, 0x18(%rbx)
movq 0x20(%r15), %rdi
movq 0x28(%r15), %rsi
shlq $0x3, %rsi
callq 0x2d60b
movq %rax, 0x20(%rbx)
movq 0x28(%r15), %rax
movq %rax, 0x28(%rbx)
movq 0x40(%r15), %rax
movq %rax, 0x40(%rbx)
movl $0x1, %eax
movl %eax, 0x38(%rbx)
movq %rbx, 0x40(%r15)
movl %eax, 0x38(%r15)
movq 0x50(%r12), %rax
movq (%rax), %rsi
movq %r15, %rdi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2c41b
movq 0x50(%r12), %rax
movq 0x8(%rax), %r12
movq %rbx, %r15
jmp 0x2c435
movq (%rbp), %rdi
movl $0x13, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d832
movq %rax, %rbp
movq 0x50(%r12), %rax
movq (%rax), %rdi
callq 0x1e5d4
movq %rax, 0x20(%rbp)
movq 0x50(%r12), %rax
movq (%rax), %r12
movq %r14, %rdi
jmp 0x2c4a2
movq %r12, %rdi
callq 0x1e5d4
movq %rax, %rdi
callq 0x22c44
cmpq $0x0, 0x78(%rax)
je 0x2c99b
movq %r14, %r13
movq %rax, %r14
xorl %ebp, %ebp
movq %r15, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq %r13, 0x20(%rsp)
movq 0x88(%r14), %rax
movq (%rax,%rbp,8), %rdi
callq 0x1e56c
movq %rax, %r13
movq 0x88(%r14), %rax
movq (%rax,%rbp,8), %rax
movq 0x20(%rax), %r15
cmpq $0x0, 0x40(%r12)
je 0x2c701
xorl %ebx, %ebx
movq 0x50(%r12), %rax
movq (%rax,%rbx,8), %r14
movq 0x48(%r14), %rdi
movq %r15, %rsi
callq 0x1e773
testl %eax, %eax
jne 0x2c704
incq %rbx
cmpq 0x40(%r12), %rbx
jb 0x2c6de
xorl %r14d, %r14d
testq %r14, %r14
jne 0x2c731
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
movq (%rax), %rdi
movl $0x34, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x1d832
movq %rax, %r14
movq %r13, 0x20(%rax)
movq 0x18(%rsp), %rdx
movq (%rdx), %rdi
movl $0x2a, %esi
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d832
movq %rax, %r15
movq %r13, 0x20(%rax)
movq 0x20(%rsp), %rdi
movl %ebp, %esi
callq 0x2caa3
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2c41b
incq %rbp
movq 0x8(%rsp), %r14
cmpq 0x78(%r14), %rbp
jb 0x2c6b2
jmp 0x2c99b
movq 0x50(%r12), %rax
movq (%rax), %rbx
cmpl $0x4, 0x18(%rbx)
jne 0x2c9f5
movq 0x30(%rbx), %r13
movq %r13, 0x28(%rsp)
movq 0x38(%rbx), %rax
movq %rax, 0x8(%rsp)
movq (%r12), %rdi
movl $0xe, %esi
callq 0x22d38
movq %r14, %rbp
movq %rax, %r14
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x1d7ca
movq %rbx, 0x30(%rsp)
movq %rax, %rbx
movq %r14, 0x20(%rax)
movq (%r12), %rdi
leaq 0xc2a6(%rip), %rsi      # 0x38a88
callq 0x1d945
movq 0x18(%rsp), %rdx
movq (%rdx), %rdi
movl $0x2a, %esi
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d832
movq %r15, %r13
movq %rax, %r15
movq %r14, 0x20(%rax)
movq %rbp, 0x20(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2caa3
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2c41b
movq (%r12), %rdi
movl $0x9, %esi
callq 0x22d38
movq 0x28(%rsp), %rbp
testq %rbp, %rbp
je 0x2c99b
movq %rax, %rbx
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movsbq (%rax,%r14), %rsi
movq 0x30(%rsp), %rax
movq (%rax), %rdi
callq 0x1d7ca
movq %rax, %r15
movq %rbx, 0x20(%rax)
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x2cb8c
movq %rax, %r12
incq %r14
movq 0x20(%rsp), %rdi
movl %r14d, %esi
callq 0x2caa3
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x2c41b
cmpq %r14, %rbp
jne 0x2c84d
jmp 0x2c99b
cmpq $0x0, 0x40(%r12)
movq %r15, 0x10(%rsp)
je 0x2c99b
movq %r14, %r13
xorl %ebx, %ebx
movq 0x50(%r12), %rax
movq (%rax,%rbx,8), %r14
movq (%rbp), %rdi
movq %rbx, %rsi
callq 0x1d7ca
movq %rax, %r15
movq (%rbp), %rdi
movl $0xe, %esi
callq 0x22d38
movq %rax, 0x20(%r15)
movq (%rbp), %rdi
movl $0x45, %esi
movq %rbp, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d832
movq %rax, %r15
movq %rbp, %rdi
callq 0x1e5d4
movq %rax, %rdi
callq 0x22c44
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rax
movq %rax, 0x20(%r15)
movq %r13, %rdi
movl %ebx, %esi
callq 0x2caa3
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2c41b
incq %rbx
cmpq 0x40(%r12), %rbx
jb 0x2c8bc
jmp 0x2c99b
cmpq $0x0, 0x40(%r12)
movq %r15, 0x10(%rsp)
je 0x2c99b
movq %r14, %r13
xorl %ebx, %ebx
movq 0x50(%r12), %rax
movq (%rax,%rbx,8), %r14
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2cb8c
movq %rax, %r15
movq %r13, %rdi
movl %ebx, %esi
callq 0x2caa3
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2c41b
incq %rbx
cmpq 0x40(%r12), %rbx
jb 0x2c95d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rdi
movl $0x1d, %esi
movq %r12, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d832
movq %rax, %rbx
movq %r12, %rdi
callq 0x1e5d4
movq %rax, 0x20(%rbx)
leaq 0x20(%r15), %rdi
leaq 0x28(%r15), %rsi
movq %rbx, %rdx
callq 0x2d3ff
leaq 0x10(%r15), %rbx
addq $0x18, %r15
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
jmp 0x2ca08
leaq 0x10(%r15), %rbx
addq $0x18, %r15
movq %r14, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
callq 0x2cb3e
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d3ff
movq %rbx, %rdi
callq 0x1e53d
movq %rax, %r15
movq %r14, %rdi
callq 0x23e44
leaq 0xc47e(%rip), %rsi      # 0x38ec1
jmp 0x2ca93
movq %r12, %rdi
callq 0x1d672
movl %eax, %eax
leaq 0x3394a(%rip), %rcx     # 0x603a0
movq (%rcx,%rax,8), %rbx
movq %r12, %rdi
callq 0x1e5d4
movq %rax, %rdi
callq 0x23e44
leaq 0xc49b(%rip), %rsi      # 0x38f0c
movq %r12, %rdi
movq %rbx, %rdx
jmp 0x2ca99
movq %rbx, %rdi
callq 0x1e53d
movq %rax, %r15
movq %r14, %rdi
callq 0x23e44
leaq 0xc452(%rip), %rsi      # 0x38ee5
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x13aa3