// File: /workspace/github_c_makefile_star2_O0/DeforaOS[P]libSystem/src/variable.c
// Function: variable_get_as
VariableError variable_get_as(Variable const * variable, VariableType type,
		void * result, size_t * size)
{
	int ret;
	void const * p;
	size_t sz;
	Buffer ** b;
	String ** s;
	Array ** a;

	if(variable->type != type)
		return _get_as_convert(variable, type, result);
	switch(type)
	{
		case VT_NULL:
			return 0;
		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:
			sz = (type < sizeof(_variable_sizes)
					/ sizeof(*_variable_sizes))
				? _variable_sizes[type] : 0;
			if(size != NULL)
			{
				if(sz > *size)
					return error_set_code(-ENOSPC, "%s",
							strerror(ENOSPC));
				*size = sz;
			}
			p = variable_get_pointer(variable);
			memcpy(result, p, sz);
			return 0;
		case VT_BUFFER:
			if((ret = _get_as_pointer(size)) != 0)
				return ret;
			b = (Buffer **)result;
			return (*b = buffer_new_copy(variable->u.buffer))
				!= NULL ? 0 : -1;
		case VT_STRING:
			if((ret = _get_as_pointer(size)) != 0)
				return ret;
			s = (String **)result;
			return (*s = string_new(variable->u.string)) != NULL
				? 0 : -1;
		case VT_ARRAY:
			if((ret = _get_as_pointer(size)) != 0)
				return ret;
			a = (Array **)result;
			return (*a = array_new_copy(variable->u.array.array))
				!= NULL ? 0 : -1;
		case VT_COMPOUND:
			return _get_as_compound(variable, result, size);
	}
	return error_set_code(-ENOTSUP, "%s", strerror(ENOTSUP));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
je 0xd24a
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0xd450
movl %eax, -0x4(%rbp)
jmp 0xd441
movl -0x14(%rbp), %eax
movq %rax, -0x60(%rbp)
subq $0x10, %rax
ja 0xd41e
movq -0x60(%rbp), %rax
leaq 0x305e(%rip), %rcx      # 0x102c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0xd441
movl -0x14(%rbp), %eax
cmpq $0x11, %rax
jae 0xd29a
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x31d0(%rip), %rax      # 0x10460
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
jmp 0xd2a2
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0xd2a2
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xd2f1
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jbe 0xd2e6
movl $0x1c, %edi
callq 0x4840
movq %rax, %rdx
movl $0xffffffe4, %edi       # imm = 0xFFFFFFE4
leaq 0x2d87(%rip), %rsi      # 0x1005e
movb $0x0, %al
callq 0x4630
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x4720
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x44b0
movl $0x0, -0x4(%rbp)
jmp 0xd441
movq -0x28(%rbp), %rdi
callq 0xde50
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0xd337
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x47b0
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x28(%rbp), %rdi
callq 0xde50
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0xd388
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x41f0
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x28(%rbp), %rdi
callq 0xde50
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0xd3d6
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4760
movq %rax, %rdx
movq -0x58(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xd441
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xdec0
movl %eax, -0x4(%rbp)
jmp 0xd441
movl $0x5f, %edi
callq 0x4840
movq %rax, %rdx
movl $0xffffffa1, %edi       # imm = 0xFFFFFFA1
leaq 0x2c27(%rip), %rsi      # 0x1005e
movb $0x0, %al
callq 0x4630
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)