// File: /workspace/github_c_makefile_star2_O0/michaelforney[P]cproc/type.c
// Function: typecompatible
bool
typecompatible(struct type *t1, struct type *t2)
{
	struct decl *p1, *p2;
	struct expr *e1, *e2;

	if (t1 == t2)
		return true;
	if (t1->kind != t2->kind) {
		/*
		enum types are compatible with their underlying
		type, but not with each other (unless they are the
		same type)
		*/
		return t1->kind == TYPEENUM && t2 == t1->base ||
		       t2->kind == TYPEENUM && t1 == t2->base;
	}
	switch (t1->kind) {
	case TYPEPOINTER:
		goto derived;
	case TYPEARRAY:
		if (t1->incomplete || t2->incomplete)
			goto derived;
		e1 = t1->u.array.length;
		e2 = t2->u.array.length;
		if (e1 && e2 && e1->kind == EXPRCONST && e2->kind == EXPRCONST && e1->u.constant.u != e2->u.constant.u)
			return false;
		goto derived;
	case TYPEFUNC:
		if (t1->u.func.isvararg != t2->u.func.isvararg)
			return false;
		for (p1 = t1->u.func.params, p2 = t2->u.func.params; p1 && p2; p1 = p1->next, p2 = p2->next) {
			if (!typecompatible(p1->type, p2->type))
				return false;
		}
		if (p1 || p2)
			return false;
		goto derived;
	derived:
		return t1->qual == t2->qual && typecompatible(t1->base, t2->base);
	}
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x118b3
movb $0x1, -0x1(%rbp)
jmp 0x11a97
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0x11910
movq -0x10(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x118dd
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
movb $0x1, %al
cmpq 0x20(%rdx), %rcx
movb %al, -0x39(%rbp)
je 0x11903
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x6, (%rcx)
movb %al, -0x3a(%rbp)
jne 0x118fd
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x20(%rcx), %rax
sete %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x11a97
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
subl $0xc, %eax
je 0x11937
jmp 0x11920
movl -0x40(%rbp), %eax
subl $0xd, %eax
je 0x1193c
jmp 0x1192a
movl -0x40(%rbp), %eax
subl $0xe, %eax
je 0x119ad
jmp 0x11a93
jmp 0x11a5c
movq -0x10(%rbp), %rax
testb $0x1, 0x3c(%rax)
jne 0x11950
movq -0x18(%rbp), %rax
testb $0x1, 0x3c(%rax)
je 0x11955
jmp 0x11a5c
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x119a8
cmpq $0x0, -0x38(%rbp)
je 0x119a8
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x119a8
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x119a8
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x30(%rcx), %rax
je 0x119a8
movb $0x0, -0x1(%rbp)
jmp 0x11a97
jmp 0x11a5c
movq -0x10(%rbp), %rax
movb 0x40(%rax), %al
andb $0x1, %al
movzbl %al, %eax
movq -0x18(%rbp), %rcx
movb 0x40(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x119d3
movb $0x0, -0x1(%rbp)
jmp 0x11a97
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x41(%rbp)
je 0x11a02
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x11a0b
jmp 0x11a46
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x11890
testb $0x1, %al
jne 0x11a2a
movb $0x0, -0x1(%rbp)
jmp 0x11a97
jmp 0x11a2c
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x119eb
cmpq $0x0, -0x20(%rbp)
jne 0x11a54
cmpq $0x0, -0x28(%rbp)
je 0x11a5a
movb $0x0, -0x1(%rbp)
jmp 0x11a97
jmp 0x11a5c
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x18(%rbp), %rdx
xorl %eax, %eax
cmpl 0x38(%rdx), %ecx
movb %al, -0x42(%rbp)
jne 0x11a89
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x11890
movb %al, -0x42(%rbp)
movb -0x42(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x11a97
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)