// File: /workspace/github_c_makefile_star2_O3/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 0x144db
movq %rax, %r12
movq %rax, %rdi
callq 0x1d422
cmpl $0x33, %eax
jne 0x2bfb5
leaq 0x35a08(%rip), %rax     # 0x61968
movq (%rax), %rax
movq 0x38(%r12), %rcx
movq (%rax,%rcx,8), %rbx
cmpb $0x0, 0x72(%rbx)
je 0x2c4a9
movq %r14, %r13
movq %rbx, %rdi
callq 0x1e31c
movq %rax, %r14
movl (%rax), %eax
cmpl $0x1e, %eax
ja 0x2bf99
movl $0x400a0000, %ecx       # imm = 0x400A0000
btl %eax, %ecx
jb 0x2c528
movq 0x30(%rbx), %r12
testq %r12, %r12
je 0x2c578
movq %r13, %rdi
xorl %esi, %esi
callq 0x2c5a2
movq %rax, %r14
jmp 0x2bf3c
leal -0x34(%rax), %ecx
cmpl $0x5, %ecx
ja 0x2c0af
leaq 0xcc5c(%rip), %rdx      # 0x38c24
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
movq %rbp, 0x18(%rsp)
jmpq *%rax
movq %r12, %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x227ac
movq 0x50(%r12), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x22f1e
movq %rax, 0x8(%rsp)
movq 0x8(%rax), %rsi
movq (%r12), %rdi
callq 0x1d57a
movq %rax, %rbx
movq (%r12), %rdi
movl $0x7, %esi
callq 0x2289d
movq %rax, 0x20(%rbx)
movq (%rbp), %rdi
movl $0x43, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %r14, %r13
movq %r15, %r14
movq %rax, %r15
movq (%rbp), %rdi
movl $0x7, %esi
callq 0x2289d
movq %rax, 0x20(%r15)
movq %r13, %rdi
xorl %esi, %esi
callq 0x2c5a2
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2bf22
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rbx
testq %rbx, %rbx
je 0x2c49a
movq 0x50(%r12), %rax
movq 0x8(%rax), %r12
movq (%rbp), %rdi
movl $0x44, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %rbp
movq %rbx, 0x20(%rax)
movl $0x1, %ebx
movq %r14, %r15
movq %r13, %r14
jmp 0x2c17c
cmpl $0x12, %eax
je 0x2c149
cmpl $0x14, %eax
jne 0x2c544
movl (%r15), %edi
movq 0x8(%r15), %rsi
callq 0x2beb6
movq %rax, %rbx
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
shlq $0x3, %rsi
callq 0x2d10d
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rax
movq %rax, 0x18(%rbx)
movq 0x20(%r15), %rdi
movq 0x28(%r15), %rsi
shlq $0x3, %rsi
callq 0x2d10d
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 0x2bf22
movq 0x50(%r12), %rax
movq 0x8(%rax), %r12
movq %rbx, %r15
jmp 0x2bf3c
movq (%rbp), %rdi
xorl %ebx, %ebx
movl $0x13, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %rbp
movq 0x50(%r12), %rax
movq (%rax), %rdi
callq 0x1e384
movq %rax, 0x20(%rbp)
movq 0x50(%r12), %rax
movq (%rax), %r12
movq %r14, %rdi
movl %ebx, %esi
jmp 0x2bfab
movq %r12, %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x227ac
cmpq $0x0, 0x78(%rax)
je 0x2c49a
movq %r14, %r13
movq %rax, %r14
xorl %ebp, %ebp
movq %r15, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movq %rax, 0x8(%rsp)
movq 0x88(%r14), %rax
movq (%rax,%rbp,8), %rdi
callq 0x1e31c
movq %rax, %rbx
movq 0x88(%r14), %rax
movq (%rax,%rbp,8), %rax
movq 0x20(%rax), %r15
cmpq $0x0, 0x40(%r12)
je 0x2c218
xorl %r13d, %r13d
movq 0x50(%r12), %rax
movq (%rax,%r13,8), %r14
movq 0x48(%r14), %rdi
movq %r15, %rsi
callq 0x1e523
testl %eax, %eax
jne 0x2c230
incq %r13
cmpq 0x40(%r12), %r13
jb 0x2c1e5
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 0x1d5e2
movq %rax, %r14
movq %rbx, 0x20(%rax)
movq 0x18(%rsp), %rdx
movq (%rdx), %rdi
movl $0x2a, %esi
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r15
movq %rbx, 0x20(%rax)
movq 0x20(%rsp), %rdi
movl %ebp, %esi
callq 0x2c5a2
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2bf22
incq %rbp
movq 0x8(%rsp), %r14
cmpq 0x78(%r14), %rbp
jb 0x2c1b8
jmp 0x2c49a
movq 0x50(%r12), %rax
movq (%rax), %rbx
cmpl $0x4, 0x18(%rbx)
jne 0x2c4f4
movq 0x30(%rbx), %r13
movq %r13, 0x28(%rsp)
movq 0x38(%rbx), %rax
movq %rax, 0x8(%rsp)
movq (%r12), %rdi
movl $0xe, %esi
callq 0x2289d
movq %r14, %rbp
movq %rax, %r14
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x1d57a
movq %rbx, 0x30(%rsp)
movq %rax, %rbx
movq %r14, 0x20(%rax)
movq (%r12), %rdi
leaq 0xc777(%rip), %rsi      # 0x38a58
callq 0x1d6f5
movq 0x18(%rsp), %rdx
movq (%rdx), %rdi
movl $0x2a, %esi
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d5e2
movq %r15, %r13
movq %rax, %r15
movq %r14, 0x20(%rax)
movq %rbp, 0x20(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2c5a2
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2bf22
movq (%r12), %rdi
movl $0x9, %esi
callq 0x2289d
movq 0x28(%rsp), %rbp
testq %rbp, %rbp
je 0x2c49a
movq %rax, %rbx
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movsbq (%rax,%r15), %rsi
movq 0x30(%rsp), %rax
movq (%rax), %rdi
callq 0x1d57a
movq %rax, %r14
movq %rbx, 0x20(%rax)
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x2c665
movq %rax, %r12
incq %r15
movq 0x20(%rsp), %rdi
movl %r15d, %esi
callq 0x2c5a2
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x2bf22
cmpq %r15, %rbp
jne 0x2c34c
jmp 0x2c49a
cmpq $0x0, 0x40(%r12)
movq %r15, 0x10(%rsp)
je 0x2c49a
movq %r14, %r13
xorl %ebx, %ebx
movq 0x50(%r12), %rax
movq (%rax,%rbx,8), %r15
movq (%rbp), %rdi
movq %rbx, %rsi
callq 0x1d57a
movq %rax, %r14
movq (%rbp), %rdi
movl $0xe, %esi
callq 0x2289d
movq %rax, 0x20(%r14)
movq (%rbp), %rdi
movl $0x45, %esi
movq %rbp, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r14
movq %rbp, %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x227ac
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rax
movq %rax, 0x20(%r14)
movq %r13, %rdi
movl %ebx, %esi
callq 0x2c5a2
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x2bf22
incq %rbx
cmpq 0x40(%r12), %rbx
jb 0x2c3bb
jmp 0x2c49a
cmpq $0x0, 0x40(%r12)
movq %r15, 0x10(%rsp)
je 0x2c49a
movq %r14, %r13
xorl %ebx, %ebx
movq 0x50(%r12), %rax
movq (%rax,%rbx,8), %r14
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2c665
movq %rax, %r15
movq %r13, %rdi
movl %ebx, %esi
callq 0x2c5a2
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x2bf22
incq %rbx
cmpq 0x40(%r12), %rbx
jb 0x2c45c
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 0x1d5e2
movq %rax, %rbx
movq %r12, %rdi
callq 0x1e384
movq %rax, 0x20(%rbx)
leaq 0x20(%r15), %rdi
leaq 0x28(%r15), %rsi
movq %rbx, %rdx
callq 0x2ceff
leaq 0x10(%r15), %rbx
addq $0x18, %r15
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
jmp 0x2c507
leaq 0x10(%r15), %rbx
addq $0x18, %r15
movq %r14, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
callq 0x2c617
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 0x2ceff
movq %rbx, %rdi
callq 0x1e2ed
movq %rax, %r15
movq %r14, %rdi
callq 0x2398e
leaq 0xc94f(%rip), %rsi      # 0x38e91
jmp 0x2c592
movq %r12, %rdi
callq 0x1d422
movl %eax, %eax
leaq 0x33e4b(%rip), %rcx     # 0x603a0
movq (%rcx,%rax,8), %rbx
movq %r12, %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x2398e
leaq 0xc96c(%rip), %rsi      # 0x38edc
movq %r12, %rdi
movq %rbx, %rdx
jmp 0x2c598
movq %rbx, %rdi
callq 0x1e2ed
movq %rax, %r15
movq %r14, %rdi
callq 0x2398e
leaq 0xc923(%rip), %rsi      # 0x38eb5
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x138e7