// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/evaluate.c
// Function: type_difference
const char *type_difference(struct ctype *c1, struct ctype *c2,
	unsigned long mod1, unsigned long mod2)
{
	struct ident *as1 = c1->as, *as2 = c2->as;
	struct symbol *t1 = c1->base_type;
	struct symbol *t2 = c2->base_type;
	int move1 = 1, move2 = 1;
	mod1 |= c1->modifiers;
	mod2 |= c2->modifiers;
	for (;;) {
		unsigned long diff;
		int type;
		struct symbol *base1 = t1->ctype.base_type;
		struct symbol *base2 = t2->ctype.base_type;

		/*
		 * FIXME! Collect alignment and context too here!
		 */
		if (move1) {
			if (t1 && t1->type != SYM_PTR) {
				mod1 |= t1->ctype.modifiers;
				combine_address_space(t1->pos, &as1, t1->ctype.as);
			}
			move1 = 0;
		}

		if (move2) {
			if (t2 && t2->type != SYM_PTR) {
				mod2 |= t2->ctype.modifiers;
				combine_address_space(t2->pos, &as2, t2->ctype.as);
			}
			move2 = 0;
		}

		if (t1 == t2)
			break;
		if (!t1 || !t2)
			return "different types";

		if (t1->type == SYM_NODE || t1->type == SYM_ENUM) {
			t1 = base1;
			move1 = 1;
			if (!t1)
				return "bad types";
			continue;
		}

		if (t2->type == SYM_NODE || t2->type == SYM_ENUM) {
			t2 = base2;
			move2 = 1;
			if (!t2)
				return "bad types";
			continue;
		}

		move1 = move2 = 1;
		type = t1->type;
		if (type != t2->type)
			return "different base types";

		switch (type) {
		default:
			sparse_error(t1->pos,
				     "internal error: bad type in derived(%d)",
				     type);
			return "bad types";
		case SYM_RESTRICT:
			return "different base types";
		case SYM_UNION:
		case SYM_STRUCT:
			/* allow definition of incomplete structs and unions */
			if (t1->ident == t2->ident)
			  return NULL;
			return "different base types";
		case SYM_ARRAY:
			/* XXX: we ought to compare sizes */
			break;
		case SYM_PTR:
			if (as1 != as2)
				return "different address spaces";
			/* MOD_SPECIFIER is due to idiocy in parse.c */
			if ((mod1 ^ mod2) & ~MOD_IGNORE & ~MOD_SPECIFIER)
				return "different modifiers";
			/* we could be lazier here */
			base1 = examine_pointer_target(t1);
			base2 = examine_pointer_target(t2);
			mod1 = t1->ctype.modifiers;
			as1 = t1->ctype.as;
			mod2 = t2->ctype.modifiers;
			as2 = t2->ctype.as;
			break;
		case SYM_FN: {
			struct symbol *arg1, *arg2;
			int i;

			if (as1 != as2)
				return "different address spaces";
			if ((mod1 ^ mod2) & ~MOD_IGNORE & ~MOD_SIGNEDNESS)
				return "different modifiers";
			mod1 = t1->ctype.modifiers;
			as1 = t1->ctype.as;
			mod2 = t2->ctype.modifiers;
			as2 = t2->ctype.as;

			if (t1->variadic != t2->variadic)
				return "incompatible variadic arguments";
			examine_fn_arguments(t1);
			examine_fn_arguments(t2);
			PREPARE_PTR_LIST(t1->arguments, arg1);
			PREPARE_PTR_LIST(t2->arguments, arg2);
			i = 1;
			for (;;) {
				const char *diffstr;
				if (!arg1 && !arg2)
					break;
				if (!arg1 || !arg2)
					return "different argument counts";
				diffstr = type_difference(&arg1->ctype,
							  &arg2->ctype,
							  MOD_IGN, MOD_IGN);
				if (diffstr) {
					static char argdiff[80];
					sprintf(argdiff, "incompatible argument %d (%s)", i, diffstr);
					return argdiff;
				}
				NEXT_PTR_LIST(arg1);
				NEXT_PTR_LIST(arg2);
				i++;
			}
			FINISH_PTR_LIST(arg2);
			FINISH_PTR_LIST(arg1);
			break;
		}
		case SYM_BASETYPE:
			if (as1 != as2)
				return "different address spaces";
			if (base1 != base2)
				return "different base types";
			if (t1->rank != t2->rank)
				return "different type sizes";
			diff = (mod1 ^ mod2) & ~MOD_IGNORE;
			if (!diff)
				return NULL;
			else if (diff & ~MOD_SIGNEDNESS)
				return "different modifiers";
			else
				return "different signedness";
		}
		t1 = base1;
		t2 = base2;
	}
	if (as1 != as2)
		return "different address spaces";
	if ((mod1 ^ mod2) & ~MOD_IGNORE & ~MOD_SIGNEDNESS)
		return "different modifiers";
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r10
movq (%rdi), %rbx
movq 0x20(%rdi), %r11
movq (%rsi), %r8
movq 0x20(%rsi), %r12
orq 0x8(%rdi), %r10
orq 0x8(%rsi), %rcx
xorl %eax, %eax
movq %r8, %rbp
xorl %r14d, %r14d
movq %rbx, %r13
movq 0x60(%r13), %rbx
movq 0x60(%rbp), %r8
testq %r13, %r13
sete %dl
orb %al, %dl
testb $0x1, %dl
jne 0x3193c
cmpb $0x4, (%r13)
je 0x3193c
orq 0x68(%r13), %r10
movq 0x80(%r13), %rax
testq %rax, %rax
je 0x3193c
testq %r11, %r11
je 0x31939
cmpq %rax, %r11
je 0x3193c
movq 0x4(%r13), %rdi
leaq 0x15131(%rip), %rsi     # 0x46a3c
xorl %eax, %eax
movq %rcx, (%rsp)
movq %r12, 0x8(%rsp)
movq %r10, %r12
movq %r8, %r15
callq 0x11a80
movq %r15, %r8
movq %r12, %r10
movq 0x8(%rsp), %r12
movq (%rsp), %rcx
leaq 0x33aa9(%rip), %r11     # 0x653e0
jmp 0x3193c
movq %rax, %r11
testb $0x1, %r14b
jne 0x3199a
cmpb $0x4, (%rbp)
je 0x3199a
orq 0x68(%rbp), %rcx
movq 0x80(%rbp), %rax
testq %rax, %rax
je 0x3199a
testq %r12, %r12
je 0x31997
cmpq %rax, %r12
je 0x3199a
movq 0x4(%rbp), %rdi
leaq 0x150cf(%rip), %rsi     # 0x46a3c
xorl %eax, %eax
movq %rcx, (%rsp)
movq %r10, %r15
movq %r11, %r12
movq %r8, %r14
callq 0x11a80
movq %r14, %r8
movq %r12, %r11
movq %r15, %r10
movq (%rsp), %rcx
leaq 0x33a4b(%rip), %r12     # 0x653e0
jmp 0x3199a
movq %rax, %r12
cmpq %rbp, %r13
je 0x31c51
movl (%r13), %eax
cmpb $0x9, %al
je 0x319b3
movzbl %al, %edx
cmpl $0x3, %edx
jne 0x319c9
movb $0x1, %r14b
xorl %eax, %eax
movq %rbx, %r13
testq %rbx, %rbx
jne 0x318ca
jmp 0x31d18
movl (%rbp), %eax
cmpb $0x9, %al
je 0x319d8
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x319eb
movb $0x1, %al
movq %r13, %rbx
testq %r8, %r8
jne 0x318c1
jmp 0x31d18
cmpl %eax, %edx
jne 0x31ca4
leal -0x2(%rdx), %esi
cmpl $0xb, %esi
ja 0x31d06
xorl %eax, %eax
leaq 0x17fc8(%rip), %rdi     # 0x499d0
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
cmpq %r12, %r11
jne 0x31cc5
xorq %r10, %rcx
testq $-0x2043e1e0, %rcx      # imm = 0xDFBC1E20
jne 0x31cce
movl 0x54(%rbp), %eax
xorl 0x54(%r13), %eax
btl $0x9, %eax
jb 0x31d31
movq %r8, 0x20(%rsp)
movq 0x68(%r13), %rax
movq %rax, 0x18(%rsp)
movq 0x80(%r13), %rax
movq %rax, 0x10(%rsp)
movq 0x68(%rbp), %rax
movq %rax, (%rsp)
movq 0x80(%rbp), %r12
movq %r13, %rdi
callq 0x31d66
movq %rbp, %rdi
callq 0x31d66
movq 0x88(%r13), %rax
xorl %r15d, %r15d
testq %rax, %rax
je 0x31aab
movq %rax, %r13
movq (%rsp), %rcx
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r11
cmpb $0x0, (%r13)
jg 0x31ac3
movq 0x10(%r13), %r13
cmpq %rax, %r13
jne 0x31a94
xorl %edi, %edi
xorl %r14d, %r14d
jmp 0x31ad1
xorl %edi, %edi
xorl %r13d, %r13d
xorl %r14d, %r14d
movq (%rsp), %rcx
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r11
jmp 0x31ad1
movq 0x18(%r13), %rdi
andq $-0x4, %rdi
movl $0x1, %r14d
movq 0x88(%rbp), %rdx
testq %rdx, %rdx
movq %rax, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
je 0x31b00
movq %rdx, %rbp
cmpb $0x0, (%rbp)
jg 0x31b06
movq 0x10(%rbp), %rbp
cmpq %rdx, %rbp
jne 0x31aea
xorl %esi, %esi
xorl %r15d, %r15d
jmp 0x31b14
xorl %esi, %esi
xorl %ebp, %ebp
jmp 0x31b14
movq 0x18(%rbp), %rsi
andq $-0x4, %rsi
movl $0x1, %r15d
testq %rdi, %rdi
setne %r9b
testq %rsi, %rsi
setne %dl
xorl %eax, %eax
movq %rdi, %r8
orq %rsi, %r8
movq 0x20(%rsp), %r8
je 0x318c1
movl $0x1, 0x8(%rsp)
testb $0x1, %r9b
je 0x31c7b
testb $0x1, %dl
je 0x31c7b
addq $0x60, %rdi
addq $0x60, %rsi
movl $0x11000e00, %edx       # imm = 0x11000E00
movl $0x11000e00, %ecx       # imm = 0x11000E00
callq 0x31898
testq %rax, %rax
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rsi
movl 0x8(%rsp), %edx
jne 0x31c87
movsbl (%r13), %eax
cmpl %eax, %r14d
jl 0x31b97
movq 0x10(%r13), %r13
xorl %r14d, %r14d
cmpq %rcx, %r13
jne 0x31b7d
xorl %edi, %edi
jmp 0x31ba6
movslq %r14d, %rax
movq 0x18(%r13,%rax,8), %rdi
andq $-0x4, %rdi
incl %r14d
movq (%rsp), %rcx
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r11
movsbl (%rbp), %eax
cmpl %eax, %r15d
jl 0x31bcd
movq 0x10(%rbp), %rbp
xorl %r15d, %r15d
cmpq %rsi, %rbp
jne 0x31bb4
xorl %esi, %esi
jmp 0x31bdc
movslq %r15d, %rax
movq 0x18(%rbp,%rax,8), %rsi
andq $-0x4, %rsi
incl %r15d
incl %edx
movl %edx, 0x8(%rsp)
testq %rdi, %rdi
setne %r9b
testq %rsi, %rsi
setne %dl
xorl %eax, %eax
movq %rdi, %r8
orq %rsi, %r8
movq 0x20(%rsp), %r8
jne 0x31b3c
jmp 0x318c1
cmpq %r12, %r11
jne 0x31cc5
xorq %r10, %rcx
testq $-0x2043e1e0, %rcx      # imm = 0xDFBC1E20
jne 0x31cce
movq %r13, %rdi
callq 0x2baa4
movq %rax, %rbx
movq %rbp, %rdi
callq 0x2baa4
movq %rax, %r8
movq 0x68(%r13), %r10
movq 0x80(%r13), %r11
movq 0x68(%rbp), %rcx
movq 0x80(%rbp), %r12
jmp 0x318bf
leaq 0x17ff3(%rip), %r14     # 0x49c4b
cmpq %r12, %r11
jne 0x31d1f
xorq %r10, %rcx
andq $-0x2043e1e0, %rcx      # imm = 0xDFBC1E20
leaq 0x17ff2(%rip), %r14     # 0x49c64
cmoveq %rcx, %r14
jmp 0x31d1f
leaq 0x18016(%rip), %r14     # 0x49c98
jmp 0x31d1f
leaq 0x5e272(%rip), %r14     # 0x8ff00
leaq 0x1801d(%rip), %rsi     # 0x49cb2
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0xe2c0
jmp 0x31d1f
leaq 0x17f63(%rip), %r14     # 0x49c0e
jmp 0x31d1f
movq 0x18(%r13), %rax
xorl %r14d, %r14d
cmpq 0x18(%rbp), %rax
leaq 0x17f4f(%rip), %rax     # 0x49c0e
cmovneq %rax, %r14
jmp 0x31d1f
leaq 0x17f7f(%rip), %r14     # 0x49c4b
jmp 0x31d1f
leaq 0x17f8f(%rip), %r14     # 0x49c64
jmp 0x31d1f
leaq 0x17f6d(%rip), %r14     # 0x49c4b
cmpq %r12, %r11
jne 0x31d1f
leaq 0x17f24(%rip), %r14     # 0x49c0e
cmpq %r8, %rbx
jne 0x31d1f
movl 0x54(%rbp), %eax
xorl 0x54(%r13), %eax
testl $0x3800000, %eax        # imm = 0x3800000
je 0x31d3a
leaq 0x17fcc(%rip), %r14     # 0x49cd0
jmp 0x31d1f
movq 0x4(%r13), %rdi
leaq 0x17f12(%rip), %rsi     # 0x49c23
xorl %eax, %eax
callq 0x11a80
leaq 0x17ee5(%rip), %r14     # 0x49c04
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17f40(%rip), %r14     # 0x49c78
jmp 0x31d1f
xorq %r10, %rcx
testq $-0x204381e0, %rcx      # imm = 0xDFBC7E20
je 0x31d61
testq $-0x2043e1e0, %rcx      # imm = 0xDFBC1E20
leaq 0x17f91(%rip), %rax     # 0x49ce5
leaq 0x17f09(%rip), %r14     # 0x49c64
cmoveq %rax, %r14
jmp 0x31d1f
xorl %r14d, %r14d
jmp 0x31d1f