// File: /workspace/github_c_makefile_star2_O3/Oric4ever[P]lcc65/6502/build/../src/types.c
// Function: composite
Type composite(ty1, ty2) Type ty1, ty2; {
	if (ty1 == ty2)
		return ty1;
	if (ty1->op != ty2->op)
		return 0;
	switch (ty1->op) {
	case CONST+VOLATILE:
		return qual(CONST, qual(VOLATILE, composite(ty1->type, ty2->type)));
	case CONST: case VOLATILE:
		return qual(ty1->op, composite(ty1->type, ty2->type));
	case POINTER:
		return ptr(composite(ty1->type, ty2->type));
	case ARRAY: {
		Type ty = composite(ty1->type, ty2->type);
		if (ty) {
			if (ty1->size && ty1->type->size && ty2->size == 0)
				return array(ty, ty1->size/ty1->type->size, ty1->align);
			if (ty2->size && ty2->type->size && ty1->size == 0)
				return array(ty, ty2->size/ty2->type->size, ty2->align);
			return array(ty, 0, 0);
		}
		break;
		}
	case FUNCTION: {
		List list = 0;
		Type ty = composite(ty1->type, ty2->type);
		if (ty) {
			Type *p1, *p2, proto = 0;
			if (ty1->u.proto && ty2->u.proto == 0)
				return func(ty, ty1->u.proto);
			if (ty2->u.proto && ty1->u.proto == 0)
				return func(ty, ty2->u.proto);
			for (p1 = ty1->u.proto, p2 = ty2->u.proto; *p1 && *p2; p1++, p2++) {
				Type ty;
				if ((ty = composite(unqual(*p1), unqual(*p2))) == 0)
					return 0;
				if (isconst(*p1) || isconst(*p2))
					ty = qual(CONST, ty);
				if (isvolatile(*p1) || isvolatile(*p2))
					ty = qual(VOLATILE, ty);
				list = append(ty, list);
			}
			if (*p1 || *p2)
				return 0;
			return funcl(ty, list);
		}
		break;
		}
	case CHAR:   case SHORT: case INT:     case DOUBLE:
	case VOID:   case FLOAT: case UNSIGNED:
	case STRUCT: case UNION: case ENUM:
		break;
	default:
		assert(0);
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
cmpq %rsi, %rdi
je 0x18bfc
movq %rsi, %r15
movl (%rbx), %r14d
cmpl (%rsi), %r14d
jne 0x18bfa
leal -0x1(%r14), %eax
cmpl $0x1e, %eax
ja 0x18e32
leaq 0x838f(%rip), %rcx      # 0x20f80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x10(%rbx), %rdi
movq 0x10(%r15), %rsi
callq 0x18bc1
movl %r14d, %edi
jmp 0x18d07
movq 0x10(%rbx), %rdi
movq 0x10(%r15), %rsi
callq 0x18bc1
testq %rax, %rax
je 0x18bfa
movq %rax, %r14
movq 0x18(%rbx), %r12
movq 0x18(%r15), %r15
testq %r12, %r12
je 0x18d18
testq %r15, %r15
jne 0x18d57
movq %r14, %rdi
movq %r12, %rsi
jmp 0x18d23
movq 0x10(%rbx), %rdi
movq 0x10(%r15), %rsi
callq 0x18bc1
testq %rax, %rax
je 0x18bfa
movq %rax, %rdi
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x18c8a
movq 0x10(%rbx), %rcx
movl 0x8(%rcx), %ecx
testl %ecx, %ecx
je 0x18c8a
cmpl $0x0, 0x8(%r15)
je 0x18d3d
movl 0x8(%r15), %ecx
testl %ecx, %ecx
je 0x18cab
testl %eax, %eax
setne %al
movq 0x10(%r15), %rdx
movl 0x8(%rdx), %esi
testl %esi, %esi
sete %dl
orb %al, %dl
je 0x18d31
xorl %esi, %esi
xorl %edx, %edx
jmp 0x18d46
movq 0x10(%rbx), %rdi
movq 0x10(%r15), %rsi
callq 0x18bc1
movq 0x1a320(%rip), %r8      # 0x32fe8
movl $0x7, %edi
movq %rax, %rsi
movl $0x2, %edx
movl $0x1, %ecx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x187eb
movq 0x10(%rbx), %rdi
movq 0x10(%r15), %rsi
callq 0x18bc1
movl $0x10, %edi
movq %rax, %rsi
callq 0x18e51
movl $0xf, %edi
movq %rax, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x18e51
testq %r15, %r15
je 0x18d54
movq %r14, %rdi
movq %r15, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x18f4f
movl %ecx, %eax
cltd
idivl %esi
movswl 0x4(%r15), %edx
jmp 0x18d44
cltd
idivl %ecx
movswl 0x4(%rbx), %edx
movl %eax, %esi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x188ea
xorl %r15d, %r15d
movq (%r12), %rdi
testq %rdi, %rdi
je 0x18e11
xorl %ebx, %ebx
xorl %r13d, %r13d
movq (%r15), %rsi
testq %rsi, %rsi
je 0x18bfc
cmpl $0xf, (%rdi)
jb 0x18d7e
movq 0x10(%rdi), %rdi
cmpl $0xf, (%rsi)
jb 0x18d87
movq 0x10(%rsi), %rsi
callq 0x18bc1
testq %rax, %rax
je 0x18bfc
movq (%r12), %rcx
movl (%rcx), %ecx
movl %ecx, %edx
orl $0x10, %edx
cmpl $0x1f, %edx
je 0x18db2
movq (%r15), %rdx
movl (%rdx), %edx
orl $0x10, %edx
cmpl $0x1f, %edx
jne 0x18dc5
movl $0xf, %edi
movq %rax, %rsi
callq 0x18e51
movq (%r12), %rcx
movl (%rcx), %ecx
cmpl $0x10, %ecx
je 0x18dde
cmpl $0x1f, %ecx
je 0x18dde
movq (%r15), %rcx
movl (%rcx), %ecx
cmpl $0x1f, %ecx
je 0x18dde
cmpl $0x10, %ecx
jne 0x18deb
movl $0x10, %edi
movq %rax, %rsi
callq 0x18e51
movq %rax, %rdi
movq %r13, %rsi
callq 0x16a18
movq %rax, %r13
addq $0x8, %r15
movq 0x8(%r12), %rdi
addq $0x8, %r12
testq %rdi, %rdi
jne 0x18d69
jmp 0x18e14
xorl %r13d, %r13d
cmpq $0x0, (%r15)
jne 0x18bfa
movq %r14, %rdi
movq %r13, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x18fa2
leaq 0x5362(%rip), %rdi      # 0x1e19b
leaq 0x83e8(%rip), %rsi      # 0x21228
leaq 0x886d(%rip), %rcx      # 0x216b4
movl $0xb1, %edx
callq 0x30d0