// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/dissect.c
// Function: do_expression
static struct symbol *do_expression(usage_t mode, struct expression *expr)
{
	struct symbol *ret = &int_ctype;

again:
	if (expr) switch (expr->type) {
	default:
		warning(expr->pos, "bad expr->type: %d", expr->type);

	case EXPR_TYPE:		// [struct T]; Why ???
	case EXPR_VALUE:
	case EXPR_FVALUE:

	break; case EXPR_LABEL:
		ret = &label_ctype;

	break; case EXPR_STRING:
		ret = &string_ctype;

	break; case EXPR_STATEMENT:
		ret = do_statement(mode, expr->statement);

	break; case EXPR_SIZEOF: case EXPR_ALIGNOF: case EXPR_PTRSIZEOF:
		do_expression(U_VOID, expr->cast_expression);

	break; case EXPR_COMMA:
		do_expression(U_VOID, expr->left);
		ret = do_expression(mode, expr->right);

	break; case EXPR_CAST: case EXPR_FORCE_CAST: //case EXPR_IMPLIED_CAST:
		ret = base_type(expr->cast_type);
		do_initializer(ret, expr->cast_expression);

	break; case EXPR_COMPARE: case EXPR_LOGICAL:
		mode = u_rval(mode);
		do_expression(mode, expr->left);
		do_expression(mode, expr->right);

	break; case EXPR_CONDITIONAL: //case EXPR_SELECT:
		do_expression(expr->cond_true
					? U_R_VAL : U_R_VAL | mode,
				expr->conditional);
		ret = do_expression(mode, expr->cond_true);
		ret = do_expression(mode, expr->cond_false);

	break; case EXPR_CALL:
		if (expr->fn->type == EXPR_SYMBOL)
			expr->fn->op = 'f'; /* for expr_symbol() */
		ret = do_expression(U_R_PTR, expr->fn);
		if (is_ptr(ret))
			ret = ret->ctype.base_type;
		DO_2_LIST(ret->arguments, expr->args, arg, val,
			do_expression(u_lval(base_type(arg)), val));
		ret = ret->type == SYM_FN ? base_type(ret)
			: &bad_ctype;

	break; case EXPR_ASSIGNMENT:
		mode |= U_W_VAL | U_R_VAL;
		if (expr->op == '=')
			mode &= ~U_R_VAL;
		ret = do_expression(mode, expr->left);
		report_implicit(mode, &expr->pos, ret);
		mode = expr->op == '='
			? u_lval(ret) : U_R_VAL;
		do_expression(mode, expr->right);

	break; case EXPR_BINOP: {
		struct symbol *l, *r;
		mode |= u_rval(mode);
		l = do_expression(mode, expr->left);
		r = do_expression(mode, expr->right);
		if (expr->op != '+' && expr->op != '-')
			;
		else if (!is_ptr_type(r))
			ret = l;
		else if (!is_ptr_type(l))
			ret = r;
	}

	break; case EXPR_PREOP: case EXPR_POSTOP: {
		struct expression *unop = expr->unop;

		switch (expr->op) {
		case SPECIAL_INCREMENT:
		case SPECIAL_DECREMENT:
			mode |= U_W_VAL | U_R_VAL;
		default:
			mode |= u_rval(mode);
		case '(':
			ret = do_expression(mode, unop);

		break; case '&':
			if ((expr = peek_preop(unop, '*')))
				goto again;
			ret = alloc_symbol(unop->pos, SYM_PTR);
			ret->ctype.base_type =
				do_expression(u_addr(mode), unop);

		break; case '*':
			if ((expr = peek_preop(unop, '&')))
				goto again;
			if (mode & (U_MASK << U_SHIFT))
				mode |= U_R_VAL;
			mode <<= U_SHIFT;
			if (mode & (U_R_AOF << U_SHIFT))
				mode |= U_R_VAL;
			if (mode & (U_W_VAL << U_SHIFT))
				mode |= U_W_AOF;
			ret = do_expression(mode, unop);
			ret = is_ptr(ret) ? base_type(ret)
				: &bad_ctype;
		}
	}

	break; case EXPR_DEREF: {
		struct symbol *p_type;
		usage_t p_mode;

		p_mode = mode & U_SELF;
		if (!(mode & U_MASK) && (mode & (U_MASK << U_SHIFT)))
			p_mode = U_R_VAL;
		p_type = do_expression(p_mode, expr->deref);

		ret = report_member(mode, &expr->pos, p_type,
			lookup_member(p_type, expr->member, NULL));
	}

	break; case EXPR_OFFSETOF: {
		struct symbol *in = base_type(expr->in);

		do {
			if (expr->op == '.') {
				in = report_member(U_VOID, &expr->pos, in,
					lookup_member(in, expr->ident, NULL));
			} else {
				do_expression(U_R_VAL, expr->index);
				in = in->ctype.base_type;
			}
		} while ((expr = expr->down));
	}

	break; case EXPR_GENERIC: {
		struct type_expression *map;

		do_expression(U_VOID, expr->control);

		for (map = expr->map; map; map = map->next)
			ret = do_expression(mode, map->expr);
		if (expr->def)
			ret = do_expression(mode, expr->def);
	}

	break; case EXPR_SYMBOL:
		ret = report_symbol(mode, expr);
	}

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %ebp
xorl %eax, %eax
leaq 0x2cd73(%rip), %r15     # 0x3e490
movl %eax, 0x4(%rsp)
movl %ebp, %r13d
orl $0x4, %r13d
movq %r14, %rbx
testq %rbx, %rbx
je 0x119d3
movzbl (%rbx), %edx
leal -0x1(%rdx), %eax
cmpl $0x1e, %eax
ja 0x118fc
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x20(%rbx), %r14
movl 0x4(%rbx), %eax
cmpl $0x26, %eax
je 0x117fe
cmpl $0x2a, %eax
jne 0x1181a
movq %r14, %rdi
pushq $0x26
popq %rsi
callq 0x1215e
movq %rax, %rbx
testq %rax, %rax
jne 0x1172b
jmp 0x11b81
movq 0x20(%rbx), %rsi
xorl %edi, %edi
callq 0x11701
leaq 0x30(%rbx), %r14
leaq 0x5a2fd(%rip), %r12     # 0x6ba90
movq (%r14), %r14
testq %r14, %r14
je 0x117af
movq 0x8(%r14), %rsi
movl %ebp, %edi
callq 0x11701
movq %rax, %r12
addq $0x10, %r14
jmp 0x11793
movq 0x28(%rbx), %rbx
testq %rbx, %rbx
jne 0x1172b
jmp 0x11c9a
cmpq $0x0, 0x28(%rbx)
pushq $0x4
popq %rdi
cmovel %r13d, %edi
movq 0x20(%rbx), %rsi
callq 0x11701
movq 0x28(%rbx), %rsi
movl %ebp, %edi
callq 0x11701
movq 0x30(%rbx), %rbx
jmp 0x1172b
movq 0x20(%rbx), %rsi
xorl %edi, %edi
callq 0x11701
movq 0x28(%rbx), %rbx
jmp 0x1172b
movq %r14, %rdi
pushq $0x2a
popq %rsi
callq 0x1215e
movq %rax, %rbx
testq %rax, %rax
jne 0x1172b
jmp 0x11b4f
cmpl $0x28, %eax
je 0x11728
cmpl $0x103, %eax            # imm = 0x103
je 0x11831
cmpl $0x101, %eax            # imm = 0x101
jne 0x11834
orl $0xc, %ebp
xorl %eax, %eax
testw $0xd04, %bp             # imm = 0xD04
setne %al
shll $0x2, %eax
orl %eax, %ebp
jmp 0x11721
xorl %ebp, %ebp
leaq 0x5a23f(%rip), %r14     # 0x6ba90
jmp 0x11879
xorl %r12d, %r12d
testw $0xd04, %bp             # imm = 0xD04
setne %r12b
shll $0x2, %r12d
movq 0x20(%rbx), %rsi
movl %r12d, %edi
callq 0x11701
leaq 0x5a21a(%rip), %r14     # 0x6ba90
movl %r12d, %ebp
movl 0x4(%rsp), %eax
testb $0x1, %al
movq 0x10(%rsp), %rax
cmoveq %r14, %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rbx), %r14
movb $0x1, %al
jmp 0x1171d
orl $0xc, %ebp
movl %ebp, %r12d
andl $-0x5, %r12d
cmpl $0x3d, 0x4(%rbx)
cmovnel %ebp, %r12d
movq 0x20(%rbx), %rsi
movl %r12d, %edi
callq 0x11701
movq %rax, %r14
leaq 0x8(%rbx), %rsi
movl %r12d, %edi
movq %rax, %rdx
callq 0x120a7
cmpl $0x3d, 0x4(%rbx)
jne 0x118da
movq %r14, %rdi
callq 0x1207b
movl %eax, %ebp
jmp 0x11879
pushq $0x4
popq %rbp
jmp 0x11879
movq 0x20(%rbx), %rdi
callq 0x11ed6
movq %rax, %r12
movq 0x28(%rbx), %rsi
movq %rax, %rdi
callq 0x11f08
jmp 0x11c9a
movq 0x8(%rbx), %rdi
leaq 0x2cc65(%rip), %rsi     # 0x3e56c
xorl %eax, %eax
callq 0x1263a
jmp 0x119d3
movq 0x20(%rbx), %rsi
movl %ebp, %edi
callq 0x11cb7
jmp 0x11c8e
movzbl %bpl, %eax
testw $0xd00, %bp             # imm = 0xD00
pushq $0x4
popq %rdi
cmovel %eax, %edi
testb $0xd, %al
cmovnel %eax, %edi
movq 0x20(%rbx), %rsi
callq 0x11701
movq %rax, %r14
movq 0x28(%rbx), %rsi
addq $0x8, %rbx
movq %rax, %rdi
xorl %edx, %edx
callq 0x121d3
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x12180
jmp 0x11c8e
xorl %r14d, %r14d
testw $0xd04, %bp             # imm = 0xD04
setne %r14b
shll $0x2, %r14d
orl %ebp, %r14d
movq 0x20(%rbx), %rsi
movl %r14d, %edi
callq 0x11701
movq %rax, %r12
movq 0x28(%rbx), %rsi
movl %r14d, %edi
callq 0x11701
movq %rax, %r14
movl 0x4(%rbx), %eax
cmpl $0x2d, %eax
je 0x119a8
cmpl $0x2b, %eax
jne 0x119d3
movq %r14, %rdi
callq 0x12138
testl %eax, %eax
je 0x11c9a
movq %r12, %rdi
callq 0x12138
testl %eax, %eax
je 0x119cb
leaq 0x5a0c5(%rip), %r14     # 0x6ba90
movq %r14, %r12
jmp 0x11c9a
leaq 0x5a0b6(%rip), %r12     # 0x6ba90
jmp 0x11c9a
leaq 0x5adca(%rip), %r12     # 0x6c7b0
jmp 0x11c9a
movq 0x20(%rbx), %r14
testq %r14, %r14
jne 0x11a3c
movq 0x28(%rbx), %rdi
pushq $0x10
popq %rsi
callq 0x1e761
movq %rax, %r14
testq %rax, %rax
jne 0x11a3c
movq 0x8(%rbx), %rdi
pushq $0x10
popq %r15
movl %r15d, %esi
callq 0x1e797
movq %rax, %r14
movq 0x28(%rbx), %rsi
movq %rax, %rdi
movl %r15d, %edx
callq 0x1f525
movl 0x4(%rbx), %eax
testl %eax, %eax
pushq $0x76
popq %rcx
cmovnel %eax, %ecx
movb %cl, 0xd0(%r14)
cmpq $0x0, 0x60(%r14)
jne 0x11a4e
leaq 0x5b1c6(%rip), %rax     # 0x6cc10
movq %rax, 0x60(%r14)
movq %r14, %rdi
callq 0x11ed6
movq %rax, %r12
movq 0x55178(%rip), %rax     # 0x66bd8
movq 0x10(%rax), %r15
movq %r12, %rdi
movl %ebp, %esi
callq 0x1226f
addq $0x8, %rbx
movl %eax, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq *%r15
jmp 0x11c9a
leaq 0x5b0a7(%rip), %r12     # 0x6cb30
jmp 0x11c9a
movq 0x20(%rbx), %rsi
cmpb $0x3, (%rsi)
jne 0x11aa2
movl $0x66, 0x4(%rsi)
movq 0x20(%rbx), %rsi
movl $0x400, %edi            # imm = 0x400
callq 0x11701
movl $0xfd, %ecx
andl (%rax), %ecx
cmpl $0x4, %ecx
jne 0x11abc
movq 0x60(%rax), %rax
movq 0x88(%rax), %r12
testq %r12, %r12
movq %rax, 0x20(%rsp)
je 0x11bc7
movq %r12, %r13
cmpb $0x0, (%r13)
jg 0x11bd1
movq 0x10(%r13), %r13
cmpq %r12, %r13
jne 0x11ad4
xorl %ebp, %ebp
jmp 0x11bcc
movq 0x20(%rbx), %rdi
callq 0x11ed6
movq %rax, %r14
leaq 0x59f8e(%rip), %r12     # 0x6ba90
pushq $0x4
popq %rbp
cmpl $0x2e, 0x4(%rbx)
jne 0x11b32
leaq 0x8(%rbx), %r15
movq 0x30(%rbx), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x121d3
xorl %edi, %edi
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x12180
movq %rax, %r14
jmp 0x11b41
movq 0x30(%rbx), %rsi
movl %ebp, %edi
callq 0x11701
movq 0x60(%r14), %r14
movq 0x28(%rbx), %rbx
testq %rbx, %rbx
jne 0x11b05
jmp 0x11c9a
movq 0x8(%r14), %rdi
pushq $0x4
popq %rsi
callq 0x1e797
movq %rax, %r12
movl %ebp, %eax
andl $0xd, %eax
andl $0x2, %ebp
incl %ebp
testl %eax, %eax
cmovel %eax, %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x11701
movq %rax, 0x60(%r12)
jmp 0x11c9a
testw $0xd00, %bp             # imm = 0xD00
cmovel %ebp, %r13d
movl %r13d, %eax
shll $0x8, %eax
movl %r13d, %ecx
andl $0x1, %ecx
leal (%rax,%rcx,4), %eax
shrl $0x2, %r13d
andl $0x2, %r13d
orl %eax, %r13d
movl %r13d, %edi
movq %r14, %rsi
callq 0x11701
movl $0xfd, %ecx
andl (%rax), %ecx
cmpl $0x4, %ecx
jne 0x11c93
movq %rax, %rdi
jmp 0x11c89
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r14d, %r14d
jmp 0x11bdc
movq 0x18(%r13), %r14
andq $-0x4, %r14
pushq $0x1
popq %rbp
movq 0x28(%rbx), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x11c7f
movq 0x8(%rsp), %rdx
xorl %r15d, %r15d
movq %rdx, 0x18(%rsp)
movl (%rdx), %eax
movsbq %al, %rcx
cmpq %rcx, %r15
jge 0x11c70
movq 0x18(%rdx,%r15,8), %rbx
cmpw $0x100, %ax             # imm = 0x100
jb 0x11c16
testq %rbx, %rbx
je 0x11c6b
movq %r14, %rdi
callq 0x11ed6
movq %rax, %rdi
callq 0x1207b
movl %eax, %edi
movq %rbx, %rsi
callq 0x11701
testq %r14, %r14
je 0x11c53
movq 0x18(%rsp), %rdx
movsbl (%r13), %eax
cmpl %eax, %ebp
jl 0x11c5d
movq 0x10(%r13), %r13
xorl %ebp, %ebp
cmpq %r12, %r13
jne 0x11c3a
xorl %r14d, %r14d
jmp 0x11c6b
xorl %r14d, %r14d
movq 0x18(%rsp), %rdx
jmp 0x11c6b
movslq %ebp, %rax
movq 0x18(%r13,%rax,8), %r14
andq $-0x4, %r14
incl %ebp
incq %r15
jmp 0x11bfb
movq 0x10(%rdx), %rdx
cmpq 0x8(%rsp), %rdx
jne 0x11bf3
movq 0x20(%rsp), %rdi
cmpb $0x5, (%rdi)
jne 0x11c93
callq 0x11ed6
movq %rax, %r12
jmp 0x11c9a
leaq 0x5af76(%rip), %r12     # 0x6cc10
testb $0x1, 0x4(%rsp)
cmovneq 0x10(%rsp), %r12
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq