// File: /workspace/github_c_makefile_star2_O3/michaelforney[P]cproc/expr.c
// Function: mkbinaryexpr
static struct expr *
mkbinaryexpr(struct location *loc, enum tokenkind op, struct expr *l, struct expr *r)
{
	struct expr *e;
	struct type *t = NULL;
	enum typeprop lp, rp;

	lp = l->type->prop;
	rp = r->type->prop;
	switch (op) {
	case TLOR:
	case TLAND:
		if (!(lp & PROPSCALAR))
			error(loc, "left operand of '%s' operator must be scalar", tokstr[op]);
		if (!(rp & PROPSCALAR))
			error(loc, "right operand of '%s' operator must be scalar", tokstr[op]);
		t = &typeint;
		break;
	case TEQL:
	case TNEQ:
		t = &typeint;
		if (lp & PROPARITH && rp & PROPARITH) {
			commonreal(&l, &r);
			break;
		}
		if (l->type->kind != TYPEPOINTER)
			e = l, l = r, r = e;
		if (l->type->kind != TYPEPOINTER)
			error(loc, "invalid operands to '%s' operator", tokstr[op]);
		if (nullpointer(eval(r))) {
			r = exprconvert(r, l->type);
			break;
		}
		if (nullpointer(eval(l))) {
			l = exprconvert(l, r->type);
			break;
		}
		if (r->type->kind != TYPEPOINTER)
			error(loc, "invalid operands to '%s' operator", tokstr[op]);
		if (l->type->base->kind == TYPEVOID)
			e = l, l = r, r = e;
		if (r->type->base->kind == TYPEVOID && l->type->base->kind != TYPEFUNC)
			r = exprconvert(r, l->type);
		else if (!typecompatible(l->type->base, r->type->base))
			error(loc, "pointer operands to '%s' operator are to incompatible types", tokstr[op]);
		break;
	case TLESS:
	case TGREATER:
	case TLEQ:
	case TGEQ:
		t = &typeint;
		if (lp & PROPREAL && rp & PROPREAL) {
			commonreal(&l, &r);
		} else if (l->type->kind == TYPEPOINTER && r->type->kind == TYPEPOINTER) {
			if (!typecompatible(l->type->base, r->type->base) || l->type->base->kind == TYPEFUNC)
				error(loc, "pointer operands to '%s' operator must be to compatible object types", tokstr[op]);
		} else {
			error(loc, "invalid operands to '%s' operator", tokstr[op]);
		}
		break;
	case TBOR:
	case TXOR:
	case TBAND:
		t = commonreal(&l, &r);
		break;
	case TADD:
		if (lp & PROPARITH && rp & PROPARITH) {
			t = commonreal(&l, &r);
			break;
		}
		if (r->type->kind == TYPEPOINTER)
			e = l, l = r, r = e, rp = lp;
		if (l->type->kind != TYPEPOINTER || !(rp & PROPINT))
			error(loc, "invalid operands to '+' operator");
		t = l->type;
		if (t->base->incomplete || t->base->kind == TYPEFUNC)
			error(loc, "pointer operand to '+' must be to complete object type");
		r = mkbinaryexpr(loc, TMUL, exprconvert(r, &typeulong), mkconstexpr(&typeulong, t->base->size));
		break;
	case TSUB:
		if (lp & PROPARITH && rp & PROPARITH) {
			t = commonreal(&l, &r);
			break;
		}
		if (l->type->kind != TYPEPOINTER || !(rp & PROPINT) && r->type->kind != TYPEPOINTER)
			error(loc, "invalid operands to '-' operator");
		if (l->type->base->incomplete || l->type->base->kind == TYPEFUNC)
			error(loc, "pointer operand to '-' must be to complete object type");
		if (rp & PROPINT) {
			t = l->type;
			r = mkbinaryexpr(loc, TMUL, exprconvert(r, &typeulong), mkconstexpr(&typeulong, t->base->size));
		} else {
			if (!typecompatible(l->type->base, r->type->base))
				error(&tok.loc, "pointer operands to '-' are to incompatible types");
			op = TDIV;
			t = &typelong;
			e = mkbinaryexpr(loc, TSUB, exprconvert(l, &typelong), exprconvert(r, &typelong));
			r = mkconstexpr(&typelong, l->type->base->size);
			l = e;
		}
		break;
	case TMOD:
		if (!(lp & PROPINT) || !(rp & PROPINT))
			error(loc, "operands to '%%' operator must be integer");
		t = commonreal(&l, &r);
		break;
	case TMUL:
	case TDIV:
		if (!(lp & PROPARITH) || !(rp & PROPARITH))
			error(loc, "operands to '%s' operator must be arithmetic", tokstr[op]);
		t = commonreal(&l, &r);
		break;
	case TSHL:
	case TSHR:
		if (!(lp & PROPINT) || !(rp & PROPINT))
			error(loc, "operands to '%s' operator must be integer", tokstr[op]);
		l = exprpromote(l);
		r = exprpromote(r);
		t = l->type;
		break;
	default:
		fatal("internal error: unknown binary operator %d", op);
	}
	e = mkexpr(EXPRBINARY, t, NULL);
	e->op = op;
	e->u.binary.l = l;
	e->u.binary.r = r;

	return e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r13
movl %esi, %r14d
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
leal -0x4a(%r14), %edx
cmpl $0x13, %edx
ja 0x79a7
movq %rcx, %r12
movq %rdi, %rbx
movq 0x8(%r13), %rax
movl 0x4(%rax), %ecx
movq 0x8(%r12), %r15
movl 0x4(%r15), %ebp
leaq 0xbad9(%rip), %rsi      # 0x132a8
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
testb $0x4, %cl
je 0x77e6
andl $0x4, %ebp
jne 0x7896
cmpl $0xc, (%rax)
jne 0x7943
cmpl $0xc, (%r15)
jne 0x7943
movq 0x20(%rax), %rdi
movq 0x20(%r15), %rsi
callq 0xd8b8
testb %al, %al
je 0x781b
movq 0x8(%r13), %rax
movq 0x20(%rax), %rax
cmpl $0xe, (%rax)
jne 0x7ac5
movl %r14d, %eax
leaq 0x13deb(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xca03(%rip), %rsi      # 0x14233
jmp 0x7958
testb $0x2, %cl
je 0x783f
andl $0x2, %ebp
jne 0x785e
movl %r14d, %eax
leaq 0x13dc7(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xcb5d(%rip), %rsi      # 0x143b1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
movq %r13, %rdi
callq 0x69b6
movq %rax, %rbx
movq %rax, 0x10(%rsp)
movq %r12, %rdi
callq 0x69b6
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %r15
jmp 0x7acc
testb $0x8, %cl
je 0x7992
andl $0x8, %ebp
je 0x7992
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72d9
jmp 0x7ac5
testb $0x8, %cl
je 0x78b4
andl $0x8, %ebp
jne 0x78d3
movl %r14d, %eax
leaq 0x13d52(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xcabb(%rip), %rsi      # 0x14384
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72d9
movq %rax, %r15
jmp 0x7acc
testb $0x10, %cl
jne 0x790e
movl %r14d, %eax
leaq 0x13d17(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc876(%rip), %rsi      # 0x1417a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
leaq 0x142eb(%rip), %r15     # 0x1bc00
testb $0x10, %bpl
jne 0x7acc
movl %r14d, %eax
leaq 0x13ce7(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc873(%rip), %rsi      # 0x141a7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
jmp 0x7acc
movl %r14d, %eax
leaq 0x13cc3(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc87d(%rip), %rsi      # 0x141d5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
jmp 0x7ac5
testb $0x8, %cl
je 0x7a23
movl %ebp, %edx
andl $0x8, %edx
je 0x7a23
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72d9
movq %rax, %r15
jmp 0x7ced
cmpl $0xc, (%rax)
jne 0x7a3a
leaq 0x8(%r13), %rbp
movq %r13, %r15
jmp 0x7a74
leaq 0xca2d(%rip), %rdi      # 0x143db
xorl %r15d, %r15d
movl %r14d, %esi
xorl %eax, %eax
callq 0xe058
jmp 0x7acc
testb $0x8, %cl
je 0x7b21
movl %ebp, %ecx
andl $0x8, %ecx
je 0x7b21
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72d9
movq %rax, %r15
jmp 0x7da5
testb $0x2, %cl
je 0x79f5
andl $0x2, %ebp
jne 0x7a06
leaq 0xc95e(%rip), %rsi      # 0x1435a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72d9
movq %rax, %r15
movl $0x51, %r14d
jmp 0x7acc
cmpl $0xc, (%r15)
jne 0x7c2f
movq %r12, 0x10(%rsp)
movq %r13, %r14
jmp 0x7c3a
movq %r12, 0x10(%rsp)
movq %r13, 0x8(%rsp)
leaq 0x8(%r12), %rbp
cmpl $0xc, (%r15)
je 0x7a6e
movl %r14d, %eax
leaq 0x13bb7(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc771(%rip), %rsi      # 0x141d5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
movq %r12, %r15
movq %r13, %r12
movq %r12, %rdi
callq 0x603c
movq %rax, %rdi
callq 0x692f
testb %al, %al
je 0x7a9b
movq (%rbp), %rsi
movq %r12, %rdi
callq 0x6965
movq %rax, 0x8(%rsp)
jmp 0x7ac5
movq %r15, %rdi
callq 0x603c
movq %rax, %rdi
callq 0x692f
movq 0x8(%r12), %rsi
testb %al, %al
je 0x7cf8
movq %r15, %rdi
callq 0x6965
movq %rax, 0x10(%rsp)
leaq 0x14134(%rip), %r15     # 0x1bc00
movl $0x40, %edi
callq 0xe142
movl $0x0, 0x10(%rax)
movq %r15, 0x8(%rax)
movw $0x0, 0x4(%rax)
movl $0x9, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movl %r14d, 0x14(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x38(%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0xc, (%rax)
jne 0x7b32
testb $0x2, %bpl
jne 0x7b47
cmpl $0xc, (%r15)
je 0x7b47
leaq 0xc797(%rip), %rsi      # 0x142d0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
movq 0x8(%r13), %rax
movq 0x20(%rax), %rax
cmpb $0x0, 0x3c(%rax)
jne 0x7b56
cmpl $0xe, (%rax)
jne 0x7b67
leaq 0xc794(%rip), %rsi      # 0x142f1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
movq 0x8(%r13), %r15
testb $0x2, %bpl
jne 0x7d3c
movq 0x20(%r15), %rdi
movq 0x8(%r12), %rax
movq 0x20(%rax), %rsi
callq 0xd8b8
testb %al, %al
jne 0x7ba4
leaq 0x14576(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xc78b(%rip), %rsi      # 0x14328
xorl %eax, %eax
callq 0xd55c
leaq 0x14105(%rip), %r15     # 0x1bcb0
movq %r13, %rdi
movq %r15, %rsi
callq 0x6965
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x6965
movq %rbx, %rdi
movl $0x4d, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0x7787
movq %rax, %rbx
movq 0x8(%r13), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %r14
movl $0x40, %edi
callq 0xe142
movl $0x0, 0x10(%rax)
movq %r15, 0x8(%rax)
movw $0x0, 0x4(%rax)
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq %r14, 0x30(%rax)
movq %rax, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movl $0x50, %r14d
jmp 0x7acc
movq %r12, %r14
movq %rax, %r15
movq %r13, %r12
movl %ebp, %ecx
cmpl $0xc, (%r15)
setne %al
testb $0x2, %cl
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x7c64
leaq 0xc623(%rip), %rsi      # 0x14278
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
movq 0x8(%r12), %r15
movq 0x20(%r15), %rax
cmpb $0x0, 0x3c(%rax)
jne 0x7c73
cmpl $0xe, (%rax)
jne 0x7c84
leaq 0xc61f(%rip), %rsi      # 0x14299
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
leaq 0x1407d(%rip), %r12     # 0x1bd08
movq %r14, %rdi
movq %r12, %rsi
callq 0x6965
movq %rax, %r14
movq 0x20(%r15), %rax
movq 0x10(%rax), %r13
movl $0x40, %edi
callq 0xe142
movl $0x0, 0x10(%rax)
movq %r12, 0x8(%rax)
movw $0x0, 0x4(%rax)
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq %r13, 0x30(%rax)
movq %rbx, %rdi
movl $0x4b, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0x7787
movq %rax, 0x8(%rsp)
movl $0x4c, %r14d
jmp 0x7acc
cmpl $0xc, (%rsi)
je 0x7d1c
movl %r14d, %eax
leaq 0x13909(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc4c3(%rip), %rsi      # 0x141d5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd55c
movq (%rbp), %rax
movq 0x20(%rax), %rax
cmpl $0x1, (%rax)
jne 0x7db0
movq %r12, 0x10(%rsp)
movq %r15, 0x8(%rsp)
movq %r12, %rax
jmp 0x7db6
leaq 0x13fc5(%rip), %r14     # 0x1bd08
movq %r12, %rdi
movq %r14, %rsi
callq 0x6965
movq %rax, %r12
movq 0x20(%r15), %rax
movq 0x10(%rax), %r13
movl $0x40, %edi
callq 0xe142
movl $0x0, 0x10(%rax)
movq %r14, 0x8(%rax)
movw $0x0, 0x4(%rax)
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq %r13, 0x30(%rax)
movq %rbx, %rdi
movl $0x4b, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0x7787
movq %rax, 0x8(%rsp)
movl $0x4d, %r14d
jmp 0x7acc
movq %r15, %rax
movq %r12, %r15
movq 0x8(%r15), %rcx
movq 0x20(%rcx), %rsi
cmpl $0x1, (%rsi)
movq 0x8(%rax), %rax
movq 0x20(%rax), %rdi
jne 0x7dd0
cmpl $0xe, (%rdi)
jne 0x7dfe
callq 0xd8b8
leaq 0x13e24(%rip), %r15     # 0x1bc00
testb %al, %al
jne 0x7acc
movl %r14d, %eax
leaq 0x13822(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc3fe(%rip), %rsi      # 0x141f7
jmp 0x7934
movq %r15, %rdi
movq %rax, %rsi
jmp 0x7a8f