// File: /workspace/github_c_makefile_star2_O0/DeforaOS[P]libSystem/src/variable.c
// Function: variable_copy
VariableError variable_copy(Variable * variable, Variable const * from)
{
	Buffer * b;
	String * s;
	Array * a;

	switch(from->type)
	{
		case VT_NULL:
		case VT_BOOL:
		case VT_INT8:
		case VT_UINT8:
		case VT_INT16:
		case VT_UINT16:
		case VT_INT32:
		case VT_UINT32:
		case VT_INT64:
		case VT_UINT64:
		case VT_FLOAT:
		case VT_DOUBLE:
		case VT_POINTER:
			_variable_destroy(variable);
			memcpy(&variable->u, &from->u, sizeof(from->u));
			break;
		case VT_BUFFER:
			if((b = buffer_new_copy(from->u.buffer)) == NULL)
				return -1;
			_variable_destroy(variable);
			variable->u.buffer = b;
			break;
		case VT_STRING:
			if((s = string_new(from->u.string)) == NULL)
				return -1;
			_variable_destroy(variable);
			variable->u.string = s;
			break;
		case VT_ARRAY:
			if((a = array_new_copy(from->u.array.array)) == NULL)
				return -1;
			_variable_destroy(variable);
			variable->u.array.type = from->u.array.type;
			variable->u.array.array = a;
			break;
		case VT_COMPOUND:
			return _copy_compound(variable, from);
		default:
			/* TODO implement */
			return error_set_code(-ENOSYS, "%s", strerror(ENOSYS));
	}
	variable->type = from->type;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x38(%rbp)
subq $0x10, %rax
ja 0xe3f4
movq -0x38(%rbp), %rax
leaq 0x20a1(%rip), %rcx      # 0x10390
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0xd1a0
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0xe419
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x47b0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0xe349
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe42c
movq -0x10(%rbp), %rdi
callq 0xd1a0
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xe419
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x41f0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xe386
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe42c
movq -0x10(%rbp), %rdi
callq 0xd1a0
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xe419
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4760
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xe3bd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe42c
movq -0x10(%rbp), %rdi
callq 0xd1a0
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xe419
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe440
movl %eax, -0x4(%rbp)
jmp 0xe42c
movl $0x26, %edi
callq 0x4840
movq %rax, %rdx
movl $0xffffffda, %edi       # imm = 0xFFFFFFDA
leaq 0x1c51(%rip), %rsi      # 0x1005e
movb $0x0, %al
callq 0x4630
movl %eax, -0x4(%rbp)
jmp 0xe42c
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)