// File: /workspace/github_c_makefile_star2_O1/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
movl %esi, %r14d
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
leal -0x4a(%r14), %esi
cmpl $0x13, %esi
ja 0x7b58
movq %rcx, %r13
movq %rdx, %r12
movq %rdi, %rbx
movq 0x8(%rdx), %rcx
movl 0x4(%rcx), %edx
movq 0x8(%r13), %rax
movl 0x4(%rax), %ebp
leaq 0xb922(%rip), %rdi      # 0x13248
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
testb $0x4, %dl
je 0x793d
andl $0x4, %ebp
jne 0x79ed
cmpl $0xc, (%rcx)
jne 0x7a9a
cmpl $0xc, (%rax)
jne 0x7a9a
movq 0x20(%rcx), %rdi
movq 0x20(%rax), %rsi
callq 0xd8c4
testb %al, %al
je 0x7972
movq 0x8(%r12), %rax
movq 0x20(%rax), %rax
cmpl $0xe, (%rax)
jne 0x7cca
movl %r14d, %eax
leaq 0x13c94(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc84c(%rip), %rsi      # 0x141d3
jmp 0x7aaf
testb $0x2, %dl
je 0x7996
andl $0x2, %ebp
jne 0x79b5
movl %r14d, %eax
leaq 0x13c70(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc9a6(%rip), %rsi      # 0x14351
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq %r12, %rdi
callq 0x6b42
movq %rax, %rbx
movq %rax, 0x10(%rsp)
movq %r13, %rdi
callq 0x6b42
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %r15
jmp 0x7cd1
testb $0x8, %dl
je 0x7ae9
andl $0x8, %ebp
je 0x7ae9
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7429
jmp 0x7cca
testb $0x8, %dl
je 0x7a0b
andl $0x8, %ebp
jne 0x7a2a
movl %r14d, %eax
leaq 0x13bfb(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc904(%rip), %rsi      # 0x14324
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7429
movq %rax, %r15
jmp 0x7cd1
testb $0x10, %dl
jne 0x7a65
movl %r14d, %eax
leaq 0x13bc0(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc6bf(%rip), %rsi      # 0x1411a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
leaq 0x14194(%rip), %r15     # 0x1bc00
testb $0x10, %bpl
jne 0x7cd1
movl %r14d, %eax
leaq 0x13b90(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc6bc(%rip), %rsi      # 0x14147
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
jmp 0x7cd1
movl %r14d, %eax
leaq 0x13b6c(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc6c6(%rip), %rsi      # 0x14175
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
jmp 0x7cca
testb $0x8, %dl
je 0x7bd4
movl %ebp, %ecx
andl $0x8, %ecx
je 0x7bd4
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7429
movq %rax, %r15
jmp 0x7c98
cmpl $0xc, (%rcx)
je 0x7af8
movq %r13, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq 0x10(%rsp), %r15
movq 0x8(%r15), %rax
cmpl $0xc, (%rax)
je 0x7b25
movl %r14d, %eax
leaq 0x13b00(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc65a(%rip), %rsi      # 0x14175
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x61cc
movq %rax, %rdi
callq 0x6abb
testb %al, %al
je 0x7ca0
movq 0x8(%r15), %rsi
movq %r12, %rdi
callq 0x6af1
movq %rax, 0x8(%rsp)
jmp 0x7cca
leaq 0xc81c(%rip), %rdi      # 0x1437b
xorl %r15d, %r15d
movl %r14d, %esi
xorl %eax, %eax
callq 0xe054
jmp 0x7cd1
testb $0x8, %dl
je 0x7d26
movl %ebp, %edx
andl $0x8, %edx
je 0x7d26
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7429
movq %rax, %r15
jmp 0x7f3c
testb $0x2, %dl
je 0x7ba6
andl $0x2, %ebp
jne 0x7bb7
leaq 0xc74d(%rip), %rsi      # 0x142fa
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7429
movq %rax, %r15
movl $0x51, %r14d
jmp 0x7cd1
cmpl $0xc, (%rax)
jne 0x7be5
movq %r13, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movl %edx, %ebp
movq 0x10(%rsp), %r14
movq 0x8(%r14), %rax
cmpl $0xc, (%rax)
jne 0x7bf8
andl $0x2, %ebp
jne 0x7c09
leaq 0xc619(%rip), %rsi      # 0x14218
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq 0x8(%r14), %r15
movq 0x20(%r15), %rax
cmpb $0x0, 0x3c(%rax)
jne 0x7c1c
cmpl $0xe, (%rax)
jne 0x7c2d
leaq 0xc616(%rip), %rsi      # 0x14239
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq 0x8(%rsp), %rdi
leaq 0x140cf(%rip), %r14     # 0x1bd08
movq %r14, %rsi
callq 0x6af1
movq %rax, %r12
movq 0x20(%r15), %rax
movq 0x10(%rax), %r13
movl $0x40, %edi
callq 0xe13e
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 0x78e0
movq %rax, 0x8(%rsp)
movl $0x4c, %r14d
jmp 0x7cd1
movq %r15, %rdi
callq 0x61cc
movq %rax, %rdi
callq 0x6abb
movq 0x8(%r12), %rsi
testb %al, %al
je 0x7e35
movq %r15, %rdi
callq 0x6af1
movq %rax, 0x10(%rsp)
leaq 0x13f2f(%rip), %r15     # 0x1bc00
movl $0x40, %edi
callq 0xe13e
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, (%rcx)
jne 0x7d36
testb $0x2, %bpl
jne 0x7d47
cmpl $0xc, (%rax)
je 0x7d47
leaq 0xc533(%rip), %rsi      # 0x14270
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq 0x8(%r12), %rax
movq 0x20(%rax), %rax
cmpb $0x0, 0x3c(%rax)
jne 0x7d5b
cmpl $0xe, (%rax)
jne 0x7d6c
leaq 0xc52f(%rip), %rsi      # 0x14291
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq 0x8(%r12), %r15
testb $0x2, %bpl
jne 0x7ed3
movq 0x20(%r15), %rdi
movq 0x8(%r13), %rax
movq 0x20(%rax), %rsi
callq 0xd8c4
testb %al, %al
jne 0x7da9
leaq 0x14371(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xc526(%rip), %rsi      # 0x142c8
xorl %eax, %eax
callq 0xd56a
leaq 0x13f00(%rip), %r15     # 0x1bcb0
movq %r12, %rdi
movq %r15, %rsi
callq 0x6af1
movq %rax, %r14
movq %r13, %rdi
movq %r15, %rsi
callq 0x6af1
movq %rbx, %rdi
movl $0x4d, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0x78e0
movq %rax, %rbx
movq 0x8(%r12), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %r14
movl $0x40, %edi
callq 0xe13e
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 0x7cd1
cmpl $0xc, (%rsi)
je 0x7e59
movl %r14d, %eax
leaq 0x137cc(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc326(%rip), %rsi      # 0x14175
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd56a
movq 0x8(%r15), %rax
movq 0x20(%rax), %rax
cmpl $0x1, (%rax)
jne 0x7e70
movq %r12, 0x10(%rsp)
movq %r15, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rax
movq 0x20(%rax), %rsi
cmpl $0x1, (%rsi)
jne 0x7e98
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rcx
cmpl $0xe, (%rcx)
jne 0x7f47
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rdi
callq 0xd8c4
leaq 0x13d4f(%rip), %r15     # 0x1bc00
testb %al, %al
jne 0x7cd1
movl %r14d, %eax
leaq 0x1374d(%rip), %rcx     # 0x1b610
movq (%rcx,%rax,8), %rdx
leaq 0xc2c9(%rip), %rsi      # 0x14197
jmp 0x7a8b
leaq 0x13e2e(%rip), %r14     # 0x1bd08
movq %r13, %rdi
movq %r14, %rsi
callq 0x6af1
movq %rax, %r12
movq 0x20(%r15), %rax
movq 0x10(%rax), %r13
movl $0x40, %edi
callq 0xe13e
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 0x78e0
movq %rax, 0x8(%rsp)
movl $0x4d, %r14d
jmp 0x7cd1
movq %rax, %rsi
jmp 0x7b49