// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movl %edi, %ebp
movq $0x0, (%rsp)
leaq 0x61702(%rip), %r12     # 0x73a80
leaq 0x3410b(%rip), %r13     # 0x46490
movq %r12, %r14
testq %rbx, %rbx
je 0x12a57
movzbl (%rbx), %edx
leal -0x9(%rdx), %eax
cmpl $0x2, %eax
jae 0x124eb
movq 0x20(%rbx), %r15
movl 0x4(%rbx), %eax
cmpl $0x29, %eax
jle 0x123e5
cmpl $0x103, %eax            # imm = 0x103
je 0x1240c
cmpl $0x101, %eax            # imm = 0x101
je 0x1240c
movq %r15, %rcx
cmpl $0x2a, %eax
jne 0x1240f
cmpb $0x9, (%rcx)
jne 0x12482
movl 0x4(%rcx), %eax
cmpl $0x28, %eax
jne 0x12477
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
jne 0x123c2
jmp 0x12482
movq %r15, %rcx
cmpl $0x26, %eax
je 0x123f4
cmpl $0x28, %eax
je 0x1241f
jmp 0x1240f
cmpb $0x9, (%rcx)
jne 0x1243e
movl 0x4(%rcx), %eax
cmpl $0x28, %eax
jne 0x12433
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
jne 0x123f4
jmp 0x1243e
orl $0xc, %ebp
xorl %eax, %eax
testl $0xd04, %ebp            # imm = 0xD04
setne %al
shll $0x2, %eax
orl %eax, %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x1235c
movq %rax, %r14
movb $0x1, %cl
jmp 0x124de
cmpl $0x2a, %eax
jne 0x1243e
movq 0x20(%rcx), %rbx
jmp 0x12440
xorl %ebx, %ebx
testq %rbx, %rbx
jne 0x12489
movq 0x8(%r15), %rdi
movl $0x4, %esi
callq 0x2038b
movq %rax, %r14
movl %ebp, %eax
andl $0xd, %eax
movl %ebp, %edi
andl $0x2, %edi
incl %edi
testl %eax, %eax
cmovel %eax, %edi
movq %r15, %rsi
callq 0x1235c
movq %rax, 0x60(%r14)
movb $0x1, %cl
jmp 0x124dc
cmpl $0x26, %eax
jne 0x12482
movq 0x20(%rcx), %rbx
jmp 0x12484
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x1248d
xorl %ecx, %ecx
jmp 0x124de
movl %ebp, %eax
orl $0x4, %eax
testl $0xd00, %ebp            # imm = 0xD00
cmovel %ebp, %eax
movl %eax, %ecx
shll $0x8, %ecx
movl %eax, %edx
andl $0x1, %edx
leal (%rcx,%rdx,4), %ecx
shrl $0x2, %eax
andl $0x2, %eax
movl %eax, %ebp
orl %ecx, %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x1235c
movl (%rax), %edx
movl $0xfd, %ecx
andl %ecx, %edx
movb $0x1, %cl
cmpl $0x4, %edx
jne 0x124d5
movq 0x60(%rax), %r14
testq %r14, %r14
jne 0x124dc
leaq 0x62724(%rip), %r14     # 0x74c00
xorl %ebx, %ebx
testb %cl, %cl
je 0x12388
jmp 0x12a57
leal -0x1(%rdx), %eax
cmpl $0x1e, %eax
ja 0x128fd
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x28(%rbx), %rbx
testb $0x1, (%rsp)
movq 0x8(%rsp), %rax
cmoveq %r14, %rax
movq %rax, 0x8(%rsp)
movb $0x1, %al
movq %rax, (%rsp)
xorl %ebp, %ebp
jmp 0x12385
xorl %r15d, %r15d
testl $0xd04, %ebp            # imm = 0xD04
setne %r15b
shll $0x2, %r15d
movq 0x20(%rbx), %rsi
movl %r15d, %edi
callq 0x1235c
movq 0x28(%rbx), %rbx
testb $0x1, (%rsp)
movq 0x8(%rsp), %rax
cmoveq %r14, %rax
movq %rax, 0x8(%rsp)
movb $0x1, %al
movq %rax, (%rsp)
movl %r15d, %ebp
jmp 0x12385
movl %ebp, %edi
orl $0x4, %edi
cmpq $0x0, 0x28(%rbx)
movl $0x4, %eax
cmovnel %eax, %edi
movq 0x20(%rbx), %rsi
callq 0x1235c
movq 0x28(%rbx), %rsi
movl %ebp, %edi
callq 0x1235c
movq 0x30(%rbx), %rbx
jmp 0x12385
movq 0x20(%rbx), %rsi
xorl %edi, %edi
callq 0x1235c
movq 0x28(%rbx), %rbx
jmp 0x12385
movq 0x20(%rbx), %rsi
xorl %edi, %edi
callq 0x1235c
movq 0x30(%rbx), %r15
testq %r15, %r15
je 0x125d3
movq 0x8(%r15), %rsi
movl %ebp, %edi
callq 0x1235c
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x125bc
movq %rax, %r14
movq 0x28(%rbx), %rbx
testq %rbx, %rbx
jne 0x12385
jmp 0x12a57
orl $0xc, %ebp
movl %ebp, %r15d
andl $-0x5, %r15d
cmpl $0x3d, 0x4(%rbx)
cmovnel %ebp, %r15d
movq 0x20(%rbx), %rsi
movl %r15d, %edi
callq 0x1235c
movq %rax, %r14
leaq 0x8(%rbx), %rsi
movl %r15d, %edi
movq %rax, %rdx
callq 0x12fd5
movl $0x4, %ebp
cmpl $0x3d, 0x4(%rbx)
jne 0x12651
movl (%r14), %eax
movl $0xfd, %ecx
andl %ecx, %eax
cmpl $0x4, %eax
jne 0x12639
testb $0x2, 0x69(%r14)
sete %al
jmp 0x1263b
xorl %eax, %eax
cmpq 0x5594e(%rip), %r14     # 0x67f90
movzbl %al, %eax
leal 0x4(%rax,%rax), %ebp
movl $0x6, %eax
cmovel %eax, %ebp
movq 0x28(%rbx), %rbx
testb $0x1, (%rsp)
movq 0x8(%rsp), %rax
cmoveq %r14, %rax
movq %rax, 0x8(%rsp)
movb $0x1, %al
movq %rax, (%rsp)
jmp 0x12385
movq 0x20(%rbx), %rdi
callq 0x12d88
movq %rax, %r14
movq 0x28(%rbx), %rsi
movq %rax, %rdi
callq 0x12dba
jmp 0x12a57
movq 0x20(%rbx), %rsi
movl %ebp, %edi
callq 0x12b06
jmp 0x1280b
movq 0x20(%rbx), %r15
testq %r15, %r15
jne 0x126f4
movq 0x28(%rbx), %rdi
movl $0x10, %esi
callq 0x20355
movq %rax, %r15
testq %rax, %rax
jne 0x126f4
movq 0x8(%rbx), %rdi
movl $0x10, %esi
callq 0x2038b
movq %rax, %r15
movq 0x28(%rbx), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x21221
movl 0x4(%rbx), %eax
testl %eax, %eax
movl $0x76, %ecx
cmovnel %eax, %ecx
movb %cl, 0xd0(%r15)
cmpq $0x0, 0x60(%r15)
jne 0x12706
leaq 0x624fe(%rip), %rax     # 0x74c00
movq %rax, 0x60(%r15)
movq %r15, %rdi
callq 0x12d88
movq %rax, %r14
movq 0x5c4b0(%rip), %rax     # 0x6ebc8
movq 0x10(%rax), %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x13127
addq $0x8, %rbx
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq *%r12
jmp 0x12a57
xorl %r12d, %r12d
testl $0xd04, %ebp            # imm = 0xD04
setne %r12b
shll $0x2, %r12d
orl %ebp, %r12d
movq 0x20(%rbx), %rsi
movl %r12d, %edi
callq 0x1235c
movq %rax, %r15
movq 0x28(%rbx), %rsi
movl %r12d, %edi
callq 0x1235c
movl 0x4(%rbx), %ecx
cmpl $0x2d, %ecx
je 0x1277a
cmpl $0x2b, %ecx
jne 0x12a57
cmpb $0x3, (%rax)
jne 0x1291d
movq 0x60(%rax), %rcx
jmp 0x12920
leaq 0x6200d(%rip), %r14     # 0x747a0
jmp 0x12a57
movzbl %bpl, %eax
testl $0xd00, %ebp            # imm = 0xD00
movl $0x4, %edi
cmovel %eax, %edi
testb $0xd, %al
cmovnel %eax, %edi
movq 0x20(%rbx), %rsi
callq 0x1235c
movq %rax, %r14
movq 0x28(%rbx), %r15
addq $0x8, %rbx
movq %rax, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x131a6
testq %rax, %rax
jne 0x127fb
cmpq $0x0, 0x98(%r14)
jne 0x127ed
leaq 0x59462(%rip), %rax     # 0x6bc48
movq (%rax), %rax
movq %rax, 0x30(%r14)
movq %r15, 0x55b14(%rip)     # 0x68308
leaq 0x55af5(%rip), %rax     # 0x682f0
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x13070
movq %rax, %r14
jmp 0x12a57
movq 0x20(%rbx), %rdi
callq 0x12d88
movq %rax, %r15
leaq 0x59422(%rip), %r13     # 0x6bc48
leaq 0x55ac3(%rip), %rbp     # 0x682f0
cmpl $0x2e, 0x4(%rbx)
jne 0x1287b
movq 0x30(%rbx), %r12
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x131a6
testq %rax, %rax
jne 0x12865
cmpq $0x0, 0x98(%r15)
jne 0x1285b
movq (%r13), %rax
movq %rax, 0x30(%r15)
movq %r12, 0x55aa6(%rip)     # 0x68308
movq %rbp, %rax
leaq 0x8(%rbx), %rsi
xorl %edi, %edi
movq %r15, %rdx
movq %rax, %rcx
callq 0x13070
movq %rax, %r15
jmp 0x1288d
movq 0x30(%rbx), %rsi
movl $0x4, %edi
callq 0x1235c
movq 0x60(%r15), %r15
movq 0x28(%rbx), %rbx
testq %rbx, %rbx
jne 0x1282d
jmp 0x12a57
leaq 0x6227e(%rip), %r14     # 0x74b20
jmp 0x12a57
movq 0x20(%rbx), %rax
cmpb $0x3, (%rax)
jne 0x128b7
movl $0x66, 0x4(%rax)
movq 0x20(%rbx), %rsi
movl $0x400, %edi            # imm = 0x400
callq 0x1235c
movl $0xfd, %ecx
andl (%rax), %ecx
cmpl $0x4, %ecx
jne 0x128d5
movq 0x60(%rax), %rax
movq 0x88(%rax), %r12
testq %r12, %r12
movq %rax, 0x20(%rsp)
je 0x12914
movq %r12, %r13
cmpb $0x0, (%r13)
jg 0x12959
movq 0x10(%r13), %r13
cmpq %r12, %r13
jne 0x128e9
xorl %ebp, %ebp
jmp 0x12919
movq 0x8(%rbx), %rdi
leaq 0x33c64(%rip), %rsi     # 0x4656c
xorl %eax, %eax
callq 0x133dc
jmp 0x12a57
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %edi, %edi
jmp 0x12966
movq %rax, %rcx
movzbl (%rcx), %ecx
movl %ecx, %edx
orl $0x2, %edx
cmpl $0x6, %edx
jne 0x12a73
cmpb $0x3, (%r15)
jne 0x1293b
movq 0x60(%r15), %r15
movzbl (%r15), %ecx
movl %ecx, %edx
orl $0x2, %edx
cmpl $0x6, %edx
je 0x12a57
cmpl $0x5, %ecx
cmovneq %rax, %r14
jmp 0x12a57
movq 0x18(%r13), %rdi
andq $-0x4, %rdi
movl $0x1, %ebp
movq 0x28(%rbx), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x12a3d
movq 0x10(%rsp), %rdx
movzwl (%rdx), %eax
testb %al, %al
jle 0x12a2e
xorl %r15d, %r15d
movq %rdx, 0x18(%rsp)
movq 0x18(%rdx,%r15,8), %rbx
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x129a4
testq %rbx, %rbx
je 0x12a1c
movq %rdi, %r14
callq 0x12d88
movl (%rax), %ecx
movl $0xfd, %edx
andl %edx, %ecx
cmpl $0x4, %ecx
jne 0x129c3
testb $0x2, 0x69(%rax)
sete %cl
jmp 0x129c5
xorl %ecx, %ecx
cmpq 0x555c4(%rip), %rax     # 0x67f90
movzbl %cl, %eax
leal 0x4(%rax,%rax), %edi
movl $0x6, %eax
cmovel %eax, %edi
movq %rbx, %rsi
callq 0x1235c
testq %r14, %r14
je 0x12a05
movq 0x18(%rsp), %rdx
movsbl (%r13), %eax
cmpl %eax, %ebp
jl 0x12a0e
movq 0x10(%r13), %r13
xorl %ebp, %ebp
cmpq %r12, %r13
jne 0x129ed
xorl %edi, %edi
jmp 0x12a1c
xorl %edi, %edi
movq 0x18(%rsp), %rdx
jmp 0x12a1c
movslq %ebp, %rax
movq 0x18(%r13,%rax,8), %rdi
andq $-0x4, %rdi
incl %ebp
incq %r15
movl (%rdx), %eax
movsbq %al, %rcx
cmpq %rcx, %r15
jl 0x12990
movq 0x10(%rdx), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x1297d
movq 0x20(%rsp), %rax
cmpb $0x5, (%rax)
jne 0x12a50
movq 0x60(%rax), %r14
testq %r14, %r14
jne 0x12a57
leaq 0x621a9(%rip), %r14     # 0x74c00
testb $0x1, (%rsp)
cmovneq 0x8(%rsp), %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x5, %ecx
je 0x12931
movq %r15, %r14
jmp 0x12a57