// File: /workspace/github_c_makefile_star2_O1/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 0x38430
testq %rax, %rax
je 0x3525d
movq %rax, %r14
movl 0x50(%rax), %r15d
testl %r15d, %r15d
jns 0x35207
cmpb $0x3, (%r14)
movq %r14, %rax
jne 0x351d6
movq 0x60(%r14), %rax
cmpq 0x2bd5b(%rip), %rax     # 0x60f38
jne 0x35207
leaq 0x32c3e(%rip), %rax     # 0x67e24
cmpl $0x0, (%rax)
je 0x351fd
movq 0x8(%rbx), %rdi
leaq 0x1629f(%rip), %rsi     # 0x4b495
xorl %eax, %eax
callq 0x118b4
leaq 0x304fc(%rip), %rax     # 0x65700
movl (%rax), %r15d
cmpb $0x3, (%r14)
movq %r14, %rax
jne 0x35214
movq 0x60(%r14), %rax
cmpq 0x2bdc5(%rip), %rax     # 0x60fe0
jne 0x35275
leaq 0x32c10(%rip), %rax     # 0x67e34
cmpl $0x0, (%rax)
je 0x3523b
movq 0x8(%rbx), %rdi
leaq 0x1627f(%rip), %rsi     # 0x4b4b3
xorl %eax, %eax
callq 0x118b4
leaq 0x304ba(%rip), %rax     # 0x656fc
movl (%rax), %eax
testl %eax, %eax
js 0x35264
leaq 0x304b1(%rip), %rcx     # 0x65700
movl (%rcx), %ecx
addl %ecx, %eax
decl %eax
cltd
idivl %ecx
movl %eax, %r15d
jmp 0x3526a
xorl %eax, %eax
jmp 0x35485
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0x3048f(%rip), %rax     # 0x65700
imull (%rax), %r15d
movq 0x60(%r14), %rax
testq %rax, %rax
je 0x352ab
cmpb $0x5, (%rax)
jne 0x352ab
leaq 0x32b9a(%rip), %rax     # 0x67e24
cmpl $0x0, (%rax)
je 0x352a1
movq 0x8(%rbx), %rdi
leaq 0x16237(%rip), %rsi     # 0x4b4d1
xorl %eax, %eax
callq 0x118b4
leaq 0x30458(%rip), %rax     # 0x65700
movl (%rax), %r15d
cmpb $0x3, (%r14)
movq %r14, %rax
jne 0x352b8
movq 0x60(%r14), %rax
testb $0x40, 0x55(%rax)
je 0x352dc
leaq 0x32b3f(%rip), %rax     # 0x67e04
cmpl $0x0, (%rax)
je 0x352dc
movq 0x8(%rbx), %rdi
leaq 0x16222(%rip), %rsi     # 0x4b4f7
xorl %eax, %eax
callq 0x118b4
movzbl (%r14), %eax
movq %r14, %rcx
cmpl $0x3, %eax
jne 0x352ec
movq 0x60(%r14), %rcx
cmpb $0x6, (%rcx)
jne 0x3541e
testl %r15d, %r15d
jns 0x3541e
cmpl $0x3, %eax
jne 0x35307
movq 0x60(%r14), %r14
movq 0x60(%r14), %rdi
callq 0x2b5f4
movb $0x1, %cl
testq %rax, %rax
je 0x3536d
movq %rax, %r13
movl 0x50(%rax), %ebp
movq 0x8(%rbx), %rax
movq %rax, (%rsp)
xorl %edi, %edi
callq 0x30029
movq %rax, %r12
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
andl (%r12), %eax
testl %ebp, %ebp
jle 0x35372
orl $0x1, %eax
movq (%rsp), %rcx
movq %rcx, 0x8(%r12)
andl $0xffff0001, %eax       # imm = 0xFFFF0001
movl %eax, (%r12)
movl 0x50(%r13), %eax
testl %eax, %eax
js 0x3539b
leaq 0x303a0(%rip), %rcx     # 0x65700
movl (%rcx), %ecx
addl %ecx, %eax
decl %eax
cltd
idivl %ecx
cltq
jmp 0x353a2
jmp 0x3541a
orl $0xe, %eax
movq (%rsp), %rcx
movq %rcx, 0x8(%r12)
andl $0xffff000e, %eax       # imm = 0xFFFF000E
movl %eax, (%r12)
movq %r13, 0x20(%r12)
movq %r12, %rdi
callq 0x351a1
testq %rax, %rax
jne 0x353b6
jmp 0x35418
movq $-0x1, %rax
movq %rax, 0x20(%r12)
leaq 0x30272(%rip), %rax     # 0x65620
movq (%rax), %rax
movq %rax, 0x10(%r12)
movq 0x8(%rbx), %rbp
xorl %edi, %edi
callq 0x30029
movq %rax, %r13
movl (%rax), %eax
orl $0xb, %eax
movq %rbp, 0x8(%r13)
andl $0xffff000b, %eax       # imm = 0xFFFF000B
movl %eax, (%r13)
leaq 0x30243(%rip), %rbp     # 0x65620
movq (%rbp), %rax
movq %rax, 0x20(%r13)
movq 0x58(%r14), %rax
movq %rax, 0x28(%r13)
movq %r13, %rdi
callq 0x32c63
testq %rax, %rax
je 0x35418
movq %r13, 0x20(%rbx)
movq %r12, 0x28(%rbx)
movb $0x5, (%rbx)
movl $0x2a, 0x4(%rbx)
movq (%rbp), %rax
movq %rax, 0x10(%rbx)
xorl %ecx, %ecx
jmp 0x3541a
movb $0x1, %cl
testb %cl, %cl
je 0x35485
testl %r15d, %r15d
js 0x35436
leaq 0x302d6(%rip), %rax     # 0x65700
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addl (%rax), %ecx
testl %r15d, %ecx
je 0x35447
leaq 0x160df(%rip), %rsi     # 0x4b51c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11abc
movb $0x1, (%rbx)
testl %r15d, %r15d
js 0x35465
leaq 0x302aa(%rip), %rax     # 0x65700
movl (%rax), %ecx
leal (%r15,%rcx), %eax
decl %eax
cltd
idivl %ecx
cltq
jmp 0x3546c
movq $-0x1, %rax
movq %rax, 0x20(%rbx)
movl $0x0, 0x28(%rbx)
leaq 0x301a2(%rip), %rax     # 0x65620
movq (%rax), %rax
movq %rax, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq