// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/builtin.c
// Function: expand_object_size
static int expand_object_size(struct expression *expr, int cost)
{
	struct expression *arg = first_expression(expr->args);
	int type = get_expression_value_silent(ptr_list_nth(expr->args, 1));
	unsigned long val = -1, off = 0;

	while (arg) {
		switch (arg->type) {
		case EXPR_IMPLIED_CAST:
		case EXPR_CAST:
			// ignore those
			arg = arg->cast_expression;
			continue;
		case EXPR_BINOP:
			// a constant add is (maybe) an offset
			if (!arg->right || arg->op != '+' || arg->right->type != EXPR_VALUE)
				break;
			off += arg->right->value;
			arg = arg->left;
			continue;
		case EXPR_PREOP:
			// a deref is just intermediate variable
			// and so the offset needs to be zeroed.
			if (arg->op == '*') {
				struct expression *parent = arg;
				arg = arg->unop;
				off = 0;
				switch (arg->type) {
				case EXPR_SYMBOL:
					arg = arg->symbol->initializer;
					if (arg == parent) {
						// stop at self-initialized vars
						// and do not expand them.
						arg = NULL;
						val = -1;
						break;
					}
					continue;
				default:
					break;
				}
			}
			break;
		case EXPR_SYMBOL:
			// the symbol we're looking after
			val = bits_to_bytes(arg->symbol->bit_size);
			break;
		case EXPR_CALL:
			// use alloc_size() attribute but only after linearization.
			return UNSAFE;
		default:
			break;
		}
		break;
	}

	if (val == -1)
		val = (type & 2) ? 0 : val;
	else if (type & 1)
		return UNSAFE;
	else
		val -= off;

	expr->flags |= CEF_SET_ICE;
	expr->type = EXPR_VALUE;
	expr->value = val;
	expr->taint = 0;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x48980
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x31030
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x12190
movl %eax, -0x24(%rbp)
movq $-0x1, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x49017
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
addl $-0x3, %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x11, %eax
ja 0x49013
movq -0x58(%rbp), %rax
leaq 0x214db(%rip), %rcx     # 0x6a3f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x48eea
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x48f59
movq -0x20(%rbp), %rax
cmpl $0x2b, 0x4(%rax)
jne 0x48f59
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
je 0x48f5e
jmp 0x49015
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x48eea
movq -0x20(%rbp), %rax
cmpl $0x2a, 0x4(%rax)
jne 0x48fed
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movb (%rax), %al
subb $0x3, %al
jne 0x48fe9
jmp 0x48fb5
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x50(%rbp), %rax
jne 0x48fe4
movq $0x0, -0x20(%rbp)
movq $-0x1, -0x40(%rbp)
jmp 0x48feb
jmp 0x48eea
jmp 0x48feb
jmp 0x48fed
jmp 0x49015
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x50(%rax), %edi
callq 0x490d0
cltq
movq %rax, -0x40(%rbp)
jmp 0x49015
movl $0x64, -0x4(%rbp)
jmp 0x490be
jmp 0x49015
jmp 0x49017
cmpq $-0x1, -0x40(%rbp)
jne 0x49043
movl -0x24(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x49031
xorl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x49039
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x49068
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x49057
movl $0x64, -0x4(%rbp)
jmp 0x490be
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x49068
movq -0x10(%rbp), %rax
movl (%rax), %edx
shrl $0x8, %edx
andl $0xff, %edx
orl $0x30, %edx
movl (%rax), %ecx
andl $0xff, %edx
shll $0x8, %edx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)