// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/expand.c
// Function: simplify_int_binop
static int simplify_int_binop(struct expression *expr, struct symbol *ctype)
{
	struct expression *left = expr->left, *right = expr->right;
	unsigned long long v, l, r, mask;
	signed long long sl, sr;
	int is_signed;

	if (right->type != EXPR_VALUE)
		return 0;
	r = right->value;
	if (expr->op == SPECIAL_LEFTSHIFT || expr->op == SPECIAL_RIGHTSHIFT) {
		if (!check_shift_count(expr, right))
			return 0;
	}
	if (left->type != EXPR_VALUE)
		return 0;
	l = left->value; r = right->value;
	is_signed = !(ctype->ctype.modifiers & MOD_UNSIGNED);
	mask = 1ULL << (ctype->bit_size-1);
	sl = l; sr = r;
	if (is_signed && (sl & mask))
		sl |= ~(mask-1);
	if (is_signed && (sr & mask))
		sr |= ~(mask-1);
	
	switch (CONVERT(expr->op,is_signed)) {
	case SIGNED('+'):
	case UNSIGNED('+'):
		v = l + r;
		break;

	case SIGNED('-'):
	case UNSIGNED('-'):
		v = l - r;
		break;

	case SIGNED('&'):
	case UNSIGNED('&'):
		v = l & r;
		break;

	case SIGNED('|'):
	case UNSIGNED('|'):
		v = l | r;
		break;

	case SIGNED('^'):
	case UNSIGNED('^'):
		v = l ^ r;
		break;

	case SIGNED('*'):
		v = sl * sr;
		break;

	case UNSIGNED('*'):
		v = l * r;
		break;

	case SIGNED('/'):
		if (!r)
			goto Div;
		if (l == mask && sr == -1)
			goto Overflow;
		v = sl / sr;
		break;

	case UNSIGNED('/'):
		if (!r) goto Div;
		v = l / r; 
		break;

	case SIGNED('%'):
		if (!r)
			goto Div;
		if (l == mask && sr == -1)
			goto Overflow;
		v = sl % sr;
		break;

	case UNSIGNED('%'):
		if (!r) goto Div;
		v = l % r;
		break;

	case SIGNED(SPECIAL_LEFTSHIFT):
	case UNSIGNED(SPECIAL_LEFTSHIFT):
		v = l << r;
		break; 

	case SIGNED(SPECIAL_RIGHTSHIFT):
		v = sl >> r;
		break;

	case UNSIGNED(SPECIAL_RIGHTSHIFT):
		v = l >> r;
		break;

	default:
		return 0;
	}
	mask = mask | (mask-1);
	expr->value = v & mask;
	expr->type = EXPR_VALUE;
	expr->taint = left->taint | right->taint;
	return 1;
Div:
	if (!conservative)
		warning(expr->pos, "division by zero");
	return 0;
Overflow:
	if (!conservative)
		warning(expr->pos, "constant integer operation overflow");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
je 0x130c4
movl $0x0, -0x4(%rbp)
jmp 0x134c4
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x112, 0x4(%rax)       # imm = 0x112
je 0x130ea
movq -0x10(%rbp), %rax
cmpl $0x113, 0x4(%rax)       # imm = 0x113
jne 0x13109
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x13890
testb $0x1, %al
jne 0x13107
movl $0x0, -0x4(%rbp)
jmp 0x134c4
jmp 0x13109
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
je 0x13125
movl $0x0, -0x4(%rbp)
jmp 0x134c4
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
andq $0x4000, %rax           # imm = 0x4000
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rax
movl 0x50(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x131ae
movq -0x50(%rbp), %rax
andq -0x48(%rbp), %rax
cmpq $0x0, %rax
je 0x131ae
movq -0x48(%rbp), %rax
subq $0x1, %rax
xorq $-0x1, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x131d6
movq -0x58(%rbp), %rax
andq -0x48(%rbp), %rax
cmpq $0x0, %rax
je 0x131d6
movq -0x48(%rbp), %rax
subq $0x1, %rax
xorq $-0x1, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x5c(%rbp), %ecx
movl %ecx, %eax
movl %edx, %ecx
leal (%rax,%rcx,2), %eax
movl %eax, -0x60(%rbp)
subl $0x4a, %eax
je 0x133c7
jmp 0x131f5
movl -0x60(%rbp), %eax
subl $0x4b, %eax
je 0x13395
jmp 0x13203
movl -0x60(%rbp), %eax
addl $-0x4c, %eax
subl $0x2, %eax
jb 0x132e8
jmp 0x13214
movl -0x60(%rbp), %eax
subl $0x54, %eax
je 0x1332d
jmp 0x13222
movl -0x60(%rbp), %eax
subl $0x55, %eax
je 0x1331b
jmp 0x13230
movl -0x60(%rbp), %eax
addl $-0x56, %eax
subl $0x2, %eax
jb 0x132c6
jmp 0x13241
movl -0x60(%rbp), %eax
addl $-0x5a, %eax
subl $0x2, %eax
jb 0x132d7
jmp 0x13252
movl -0x60(%rbp), %eax
subl $0x5e, %eax
je 0x13374
jmp 0x13260
movl -0x60(%rbp), %eax
subl $0x5f, %eax
je 0x1333f
jmp 0x1326e
movl -0x60(%rbp), %eax
addl $0xffffff44, %eax       # imm = 0xFFFFFF44
subl $0x2, %eax
jb 0x1330a
jmp 0x13281
movl -0x60(%rbp), %eax
addl $0xffffff08, %eax       # imm = 0xFFFFFF08
subl $0x2, %eax
jb 0x132f9
jmp 0x13290
movl -0x60(%rbp), %eax
addl $0xfffffddc, %eax       # imm = 0xFFFFFDDC
subl $0x2, %eax
jb 0x133e5
jmp 0x132a3
movl -0x60(%rbp), %eax
subl $0x226, %eax            # imm = 0x226
je 0x13407
jmp 0x132b3
movl -0x60(%rbp), %eax
subl $0x227, %eax            # imm = 0x227
je 0x133f6
jmp 0x13418
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
andq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
orq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
xorq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x50(%rbp), %rax
imulq -0x58(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
imulq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
cmpq $0x0, -0x40(%rbp)
jne 0x1334b
jmp 0x13476
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x13361
cmpq $-0x1, -0x58(%rbp)
jne 0x13361
jmp 0x1349e
movq -0x50(%rbp), %rax
cqto
idivq -0x58(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x13424
cmpq $0x0, -0x40(%rbp)
jne 0x13380
jmp 0x13476
movq -0x38(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x40(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x13424
cmpq $0x0, -0x40(%rbp)
jne 0x133a1
jmp 0x13476
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x133b7
cmpq $-0x1, -0x58(%rbp)
jne 0x133b7
jmp 0x1349e
movq -0x50(%rbp), %rax
cqto
idivq -0x58(%rbp)
movq %rdx, -0x30(%rbp)
jmp 0x13424
cmpq $0x0, -0x40(%rbp)
jne 0x133d3
jmp 0x13476
movq -0x38(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x40(%rbp)
movq %rdx, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %cl, %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
sarq %cl, %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
shrq %cl, %rax
movq %rax, -0x30(%rbp)
jmp 0x13424
movl $0x0, -0x4(%rbp)
jmp 0x134c4
movq -0x48(%rbp), %rax
movq -0x48(%rbp), %rcx
subq $0x1, %rcx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rcx
andq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x28(%rbp), %rax
orl 0x28(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x134c4
cmpl $0x0, 0x783f3(%rip)     # 0x8b870
jne 0x13495
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x4ed65(%rip), %rsi     # 0x621f3
movb $0x0, %al
callq 0x16d80
movl $0x0, -0x4(%rbp)
jmp 0x134c4
cmpl $0x0, 0x783cb(%rip)     # 0x8b870
jne 0x134bd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x4ed4e(%rip), %rsi     # 0x62204
movb $0x0, %al
callq 0x16d80
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)