// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/evaluate.c
// Function: evaluate_sizeof
static struct symbol *evaluate_sizeof(struct expression *expr)
{
	struct symbol *type;
	int size;

	type = evaluate_type_information(expr);
	if (!type)
		return NULL;

	size = type->bit_size;

	if (size < 0 && is_void_type(type)) {
		if (Wpointer_arith)
			warning(expr->pos, "expression using sizeof(void)");
		size = bits_in_char;
	}

	if (is_bool_type(type)) {
		if (Wsizeof_bool)
			warning(expr->pos, "expression using sizeof _Bool");
		size = bits_to_bytes(bits_in_bool) * bits_in_char;
	}

	if (is_function(type->ctype.base_type)) {
		if (Wpointer_arith)
			warning(expr->pos, "expression using sizeof on a function");
		size = bits_in_char;
	}

	if (has_flexible_array(type) && Wflexible_array_sizeof)
		warning(expr->pos, "using sizeof on a flexible structure");

	if (is_array_type(type) && size < 0) {	// VLA, 1-dimension only
		struct expression *base, *size;
		struct symbol *base_type;

		if (type->type == SYM_NODE)
			type = type->ctype.base_type;	// strip the SYM_NODE
		base_type = get_base_type(type);
		if (!base_type)
			goto error;
		if (base_type->bit_size <= 0) {
			base = alloc_expression(expr->pos, EXPR_SIZEOF);
			base->cast_type = base_type;
			if (!evaluate_sizeof(base))
				goto error;
		} else {
			base = alloc_expression(expr->pos, EXPR_VALUE);
			base->value = bits_to_bytes(base_type->bit_size);
			base->ctype = size_t_ctype;
		}
		size = alloc_expression(expr->pos, EXPR_CAST);
		size->cast_type = size_t_ctype;
		size->cast_expression = type->array_size;
		if (!evaluate_expression(size))
			goto error;
		expr->left = size;
		expr->right = base;
		expr->type = EXPR_BINOP;
		expr->op = '*';
		return expr->ctype = size_t_ctype;
	}

error:
	if ((size < 0) || (size & (bits_in_char - 1)))
		expression_error(expr, "cannot size expression");

	expr->type = EXPR_VALUE;
	expr->value = bits_to_bytes(size);
	expr->taint = 0;
	expr->ctype = size_t_ctype;
	return size_t_ctype;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x37959
testq %rax, %rax
je 0x34878
movq %rax, %r14
movl 0x50(%rax), %r13d
movzbl (%rax), %eax
testl %r13d, %r13d
jns 0x34823
movq %r14, %rcx
cmpl $0x3, %eax
jne 0x347ee
movq 0x60(%r14), %rcx
cmpq 0x2b753(%rip), %rcx     # 0x5ff48
jne 0x34823
leaq 0x32626(%rip), %rcx     # 0x66e24
cmpl $0x0, (%rcx)
je 0x34819
movq 0x8(%rbx), %rdi
leaq 0x15bf7(%rip), %rsi     # 0x4a405
xorl %eax, %eax
callq 0x118fc
movzbl (%r14), %eax
leaq 0x2fee0(%rip), %rcx     # 0x64700
movl (%rcx), %r13d
movq %r14, %rcx
cmpl $0x3, %eax
jne 0x3482f
movq 0x60(%r14), %rcx
cmpq 0x2b7b2(%rip), %rcx     # 0x5ffe8
jne 0x34888
leaq 0x325f5(%rip), %rax     # 0x66e34
cmpl $0x0, (%rax)
je 0x34856
movq 0x8(%rbx), %rdi
leaq 0x15bd4(%rip), %rsi     # 0x4a423
xorl %eax, %eax
callq 0x118fc
leaq 0x2fe9f(%rip), %rax     # 0x646fc
movl (%rax), %eax
leaq 0x2fe9a(%rip), %rcx     # 0x64700
movl (%rcx), %r13d
testl %eax, %eax
js 0x3487f
addl %r13d, %eax
decl %eax
cltd
idivl %r13d
jmp 0x34884
xorl %eax, %eax
jmp 0x34a6e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
imull %eax, %r13d
movq 0x60(%r14), %rax
testq %rax, %rax
je 0x348be
cmpb $0x5, (%rax)
jne 0x348be
leaq 0x32587(%rip), %rax     # 0x66e24
cmpl $0x0, (%rax)
je 0x348b4
movq 0x8(%rbx), %rdi
leaq 0x15b94(%rip), %rsi     # 0x4a441
xorl %eax, %eax
callq 0x118fc
leaq 0x2fe45(%rip), %rax     # 0x64700
movl (%rax), %r13d
movzbl (%r14), %eax
movq %r14, %rcx
cmpl $0x3, %eax
jne 0x348ce
movq 0x60(%r14), %rcx
testb $0x40, 0x55(%rcx)
je 0x348f6
leaq 0x32529(%rip), %rcx     # 0x66e04
cmpl $0x0, (%rcx)
je 0x348f6
movq 0x8(%rbx), %rdi
leaq 0x15b7c(%rip), %rsi     # 0x4a467
xorl %eax, %eax
callq 0x118fc
movzbl (%r14), %eax
cmpl $0x3, %eax
jne 0x3490d
movq 0x60(%r14), %r14
movl %r13d, %ecx
shrl $0x1f, %ecx
cmpb $0x6, (%r14)
je 0x34918
jmp 0x3497c
movl %r13d, %ecx
shrl $0x1f, %ecx
cmpl $0x6, %eax
jne 0x3497c
testl %r13d, %r13d
jns 0x3497c
movq 0x60(%r14), %rdi
callq 0x2b0b8
testq %rax, %rax
je 0x34a1f
movq %rax, %r12
movl 0x50(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rbx), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r15
movzwl 0x2(%rax), %eax
shll $0x10, %eax
movq %rbp, 0x8(%r15)
cmpl $0x0, 0x4(%rsp)
jle 0x3499d
orl $0x1, %eax
movl %eax, (%r15)
movl 0x50(%r12), %eax
testl %eax, %eax
js 0x349b6
leaq 0x2fd91(%rip), %rcx     # 0x64700
movl (%rcx), %ecx
addl %ecx, %eax
decl %eax
cltd
idivl %ecx
cltq
jmp 0x349bd
testb %cl, %cl
jne 0x34a1f
leaq 0x2fd75(%rip), %rax     # 0x64700
movl (%rax), %eax
decl %eax
testl %r13d, %eax
jne 0x34a1f
jmp 0x34a30
orl $0xe, %eax
movl %eax, (%r15)
movq %r12, 0x20(%r15)
movq %r15, %rdi
callq 0x347b7
testq %rax, %rax
jne 0x349cf
jmp 0x34a1f
movq $-0x1, %rax
movq %rax, 0x20(%r15)
leaq 0x2fc58(%rip), %rax     # 0x64620
movq (%rax), %rax
movq %rax, 0x10(%r15)
movq 0x8(%rbx), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r12
movq %rbp, 0x8(%rax)
movw $0xb, (%rax)
leaq 0x2fc33(%rip), %rax     # 0x64620
movq (%rax), %rax
movq %rax, 0x20(%r12)
movq 0x58(%r14), %rax
movq %rax, 0x28(%r12)
movq %r12, %rdi
callq 0x32223
testq %rax, %rax
je 0x34a1f
movq %r12, 0x20(%rbx)
movq %r15, 0x28(%rbx)
movb $0x5, (%rbx)
movl $0x2a, 0x4(%rbx)
jmp 0x34a60
leaq 0x15a66(%rip), %rsi     # 0x4a48c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11b04
movb $0x1, (%rbx)
testl %r13d, %r13d
js 0x34a4e
leaq 0x2fcc1(%rip), %rax     # 0x64700
movl (%rax), %ecx
leal (%rcx,%r13), %eax
decl %eax
cltd
idivl %ecx
cltq
jmp 0x34a55
movq $-0x1, %rax
movq %rax, 0x20(%rbx)
movl $0x0, 0x28(%rbx)
leaq 0x2fbb9(%rip), %rax     # 0x64620
movq (%rax), %rax
movq %rax, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq