// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x536e0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4df4d
movq $0x0, -0x8(%rbp)
jmp 0x4e23a
movq -0x18(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x4df99
movq -0x18(%rbp), %rdi
callq 0x52630
cmpl $0x0, %eax
je 0x4df99
leaq 0x3f292(%rip), %rax     # 0x8d204
cmpl $0x0, (%rax)
je 0x4df8d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1e19f(%rip), %rsi     # 0x6c125
movb $0x0, %al
callq 0x16d80
leaq 0x3c73c(%rip), %rax     # 0x8a6d0
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x50bf0
cmpl $0x0, %eax
je 0x4dfe4
leaq 0x3f266(%rip), %rax     # 0x8d214
cmpl $0x0, (%rax)
je 0x4dfc9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1e181(%rip), %rsi     # 0x6c143
movb $0x0, %al
callq 0x16d80
leaq 0x3c6fc(%rip), %rax     # 0x8a6cc
movl (%rax), %edi
callq 0x513e0
leaq 0x3c6f2(%rip), %rcx     # 0x8a6d0
imull (%rcx), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x525f0
cmpl $0x0, %eax
je 0x4e024
leaq 0x3f207(%rip), %rax     # 0x8d204
cmpl $0x0, (%rax)
je 0x4e018
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1e150(%rip), %rsi     # 0x6c161
movb $0x0, %al
callq 0x16d80
leaq 0x3c6b1(%rip), %rax     # 0x8a6d0
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x537d0
cmpl $0x0, %eax
je 0x4e054
leaq 0x3f1ab(%rip), %rax     # 0x8d1e4
cmpl $0x0, (%rax)
je 0x4e054
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1e13a(%rip), %rsi     # 0x6c187
movb $0x0, %al
callq 0x16d80
movq -0x18(%rbp), %rdi
callq 0x528a0
cmpl $0x0, %eax
je 0x4e1bb
cmpl $0x0, -0x1c(%rbp)
jge 0x4e1bb
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x3, %eax
jne 0x4e08c
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x51e40
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4e0a5
jmp 0x4e1bd
movq -0x38(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jg 0x4e0e7
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0xe, %esi
callq 0x50ab0
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rdi
callq 0x4df20
cmpq $0x0, %rax
jne 0x4e0e5
jmp 0x4e1bd
jmp 0x4e126
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x50ab0
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movl 0x50(%rax), %edi
callq 0x513e0
movslq %eax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
leaq 0x3c4d5(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0xb, %esi
callq 0x50ab0
movq %rax, -0x30(%rbp)
leaq 0x3c4ad(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rdi
callq 0x4bb70
cmpq $0x0, %rax
jne 0x4e16f
jmp 0x4e1bd
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x5, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl $0x2a, 0x4(%rax)
leaq 0x3c446(%rip), %rax     # 0x8a5f0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq %rax, 0x10(%rcx)
movq %rax, -0x8(%rbp)
jmp 0x4e23a
jmp 0x4e1bd
cmpl $0x0, -0x1c(%rbp)
jl 0x4e1d9
movl -0x1c(%rbp), %eax
leaq 0x3c503(%rip), %rcx     # 0x8a6d0
movl (%rcx), %ecx
subl $0x1, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x4e1eb
movq -0x10(%rbp), %rdi
leaq 0x1dfc8(%rip), %rsi     # 0x6c1ac
movb $0x0, %al
callq 0x17030
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movl -0x1c(%rbp), %edi
callq 0x513e0
movslq %eax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
leaq 0x3c3cf(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0x3c3bd(%rip), %rax     # 0x8a5f0
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)