// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/parse/infer.c
// Function: tymatchrank
int
tymatchrank(Type *pat, Type *to)
{
	int match, q;
	size_t i;
	Ucon *puc, *tuc;

	pat = tysearch(pat);
	to = tysearch(to);
	if (pat->type == Typaram) {
		if (!pat->trneed)
			return 0;
		for (i = 0; bsiter(pat->trneed, &i); i++)
			if (!tryconstrain(to, traittab[i], 0))
				return -1;
		return 0;
	} else if (pat->type == Tyvar) {
		return 1;
	} else if (pat->type != to->type) {
		return -1;
	}

	match = 0;
	switch (pat->type) {
	case Tystruct:
		if (pat->nmemb != to->nmemb)
			return -1;
		for (i = 0; i < pat->nmemb; i++) {
			if (!streq(declname(pat->sdecls[i]),declname( to->sdecls[i])))
				return -1;
			q = tymatchrank(decltype(pat->sdecls[i]), decltype(to->sdecls[i]));
			if (q < 0)
				return -1;
			match += q;
		}
		break;
	case Tyunion:
		if (pat->nmemb != to->nmemb)
			return -1;
		for (i = 0; i < pat->nmemb; i++) {
			if (!nameeq(pat->udecls[i], to->udecls[i]))
				return -1;
			puc = pat->udecls[i];
			tuc = to->udecls[i];
			if (puc->etype && tuc->etype) {
				q = tymatchrank(puc->etype, tuc->etype);
				if (q < 0)
					return -1;
				match += q;
			} else if (puc->etype != tuc->etype) {
				return -1;
			}
		}
		break;
	case Tyname:
		if (!nameeq(pat->name, to->name))
			return -1;
		if (pat->narg != to->narg)
			return -1;
		for (i = 0; i < pat->narg; i++) {
			q = tymatchrank(pat->arg[i], to->arg[i]);
			if (q < 0)
				return -1;
			match += q;
		}
		break;
	case Tyarray:
		/* unsized arrays are ok */
		if (pat->asize && to->asize) {
			if (!!litvaleq(pat->asize->expr.args[0], to->asize->expr.args[0]))
				return -1;
		} else if (pat->asize != to->asize) {
			return -1;
		}
		else return tymatchrank(pat->sub[0], to->sub[0]);
		break;
	default:
		if (pat->nsub != to->nsub)
			break;
		if (pat->type == to->type)
			match = 1;
		for (i = 0; i < pat->nsub; i++) {
			q = tymatchrank(pat->sub[i], to->sub[i]);
			if (q < 0)
				return -1;
			match += q;
		}
		break;
	}
	return match;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x25450
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
callq 0x25450
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1a, (%rax)
jne 0x2556c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0x25501
movl $0x0, -0x4(%rbp)
jmp 0x259e3
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x48860
cmpl $0x0, %eax
je 0x25560
movq -0x18(%rbp), %rdi
leaq 0x587e3(%rip), %rax     # 0x7dd10
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
xorl %edx, %edx
callq 0x259f0
cmpl $0x0, %eax
jne 0x25550
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
jmp 0x25552
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x25509
movl $0x0, -0x4(%rbp)
jmp 0x259e3
movq -0x10(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x25581
movl $0x1, -0x4(%rbp)
jmp 0x259e3
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0x2559b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
jmp 0x2559d
jmp 0x2559f
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $-0x15, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x7, %eax
ja 0x2594e
movq -0x40(%rbp), %rax
leaq 0x2c287(%rip), %rcx     # 0x51850
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x78(%rcx), %rax
je 0x255f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x78(%rcx), %rax
jae 0x256ca
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30200
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30200
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x499b0
cmpl $0x0, %eax
jne 0x2565b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30260
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30260
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x254b0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x256b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x255f8
jmp 0x259dd
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x78(%rcx), %rax
je 0x256ed
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x78(%rcx), %rax
jae 0x257ef
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x25743
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x257bc
movq -0x38(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x257bc
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x254b0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x257b1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x257dc
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x28(%rcx), %rax
je 0x257da
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
jmp 0x257dc
jmp 0x257de
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x256f5
jmp 0x259dd
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x25820
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x48(%rcx), %rax
je 0x2583e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x258a5
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x254b0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x2588e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x25846
jmp 0x259dd
movq -0x10(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x25902
movq -0x18(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x25902
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x50(%rax), %rax
movq (%rax), %rsi
callq 0x303f0
cmpl $0x0, %eax
je 0x25900
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
jmp 0x25949
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x88(%rcx), %rax
je 0x25926
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq (%rax), %rsi
callq 0x254b0
movl %eax, -0x4(%rbp)
jmp 0x259e3
jmp 0x259dd
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x70(%rcx), %rax
je 0x25962
jmp 0x259dd
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x25977
movl $0x1, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x70(%rcx), %rax
jae 0x259db
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x254b0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x259c4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x259e3
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x2597f
jmp 0x259dd
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)