// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movl (%rdi), %edx
cmpl %esi, %edx
jne 0x98c4
cmpl $0x10, %r14d
ja 0x9b2f
movl %r14d, %eax
leaq 0x1b49(%rip), %rdx      # 0xb3d4
movslq (%rdx,%rax,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
leaq 0x1c15(%rip), %rdx      # 0xb4b0
movq (%rdx,%rax,8), %r14
testq %rcx, %rcx
je 0x990a
cmpq (%rcx), %r14
jbe 0x9907
movl $0x1c, %edi
callq 0x47a0
leaq 0x17a4(%rip), %rsi      # 0xb05e
movl $0xffffffe4, %edi       # imm = 0xFFFFFFE4
jmp 0x9b45
leal -0x1(%r14), %eax
cmpl $0xc, %eax
ja 0x9d43
leaq 0x19c8(%rip), %rcx      # 0xb2a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leal -0x2(%rdx), %eax
cmpl $0x7, %eax
ja 0x9d43
leaq 0x1a60(%rip), %rcx      # 0xb354
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x8(%r15), %eax
jmp 0x9b61
movq %r14, (%rcx)
movq %r15, %rdi
callq 0x46b0
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
jmp 0x9d2b
cmpl $0xa, %edx
jne 0x9d43
cvtss2sd 0x8(%r15), %xmm0
movsd %xmm0, (%rbx)
jmp 0x9d30
leal -0x3(%rdx), %eax
cmpl $0x6, %eax
ja 0x9d43
leaq 0x1a29(%rip), %rcx      # 0xb374
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x8(%r15), %al
testb %al, %al
js 0x9d43
leaq 0x8(%rsp), %r15
movb %al, (%r15)
jmp 0x9cd0
leal -0x2(%rdx), %eax
cmpl $0x7, %eax
ja 0x9d43
leaq 0x1974(%rip), %rcx      # 0xb2f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x8(%r15), %eax
jmp 0x9ce7
cmpl $0x10, %edx
ja 0x9eb7
movl %edx, %eax
leaq 0x19eb(%rip), %rcx      # 0xb390
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq $0x0, (%rbx)
jmp 0x9d30
leal -0x2(%rdx), %eax
cmpl $0x7, %eax
ja 0x9d43
leaq 0x1907(%rip), %rcx      # 0xb2d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%r15), %rax
movq %rax, %rcx
shrq $0x20, %rcx
je 0x9c89
jmp 0x9d43
cmpl $0x9, %edx
jne 0x9d43
movq 0x8(%r15), %rax
jmp 0x9a82
leal -0x2(%rdx), %eax
cmpl $0x7, %eax
ja 0x9d43
leaq 0x1923(%rip), %rcx      # 0xb334
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x8(%r15), %eax
jmp 0x9d17
leal -0x2(%rdx), %eax
cmpl $0x7, %eax
ja 0x9d43
leaq 0x18dd(%rip), %rcx      # 0xb314
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x8(%r15), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jbe 0x9d17
jmp 0x9d43
cmpl $0xb, %edx
jne 0x9d43
cvtsd2ss 0x8(%r15), %xmm0
movss %xmm0, (%rbx)
jmp 0x9d30
cmpl $0x8, %edx
jne 0x9d43
movq 0x8(%r15), %rax
testq %rax, %rax
js 0x9d43
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movl $0x8, %edx
jmp 0x9d25
movq %rcx, %rdi
callq 0x9f0a
testl %eax, %eax
jne 0x9bae
movq 0x8(%r15), %rdi
callq 0x4740
jmp 0x9e23
testq %rcx, %rcx
je 0x9b8e
leaq 0x8(%rsp), %r14
movq %rcx, (%r14)
movq $0x0, 0x10(%r14)
movq %rbx, 0x8(%r14)
movl $0x0, 0x18(%r14)
movq 0x18(%r15), %rdi
leaq 0xb44(%rip), %rsi       # 0xa626
movq %r14, %rdx
callq 0x4380
movl 0x18(%r14), %r14d
jmp 0x9ea5
movq %rcx, %rdi
callq 0x9f0a
testl %eax, %eax
jne 0x9bae
movq 0x8(%r15), %rdi
callq 0x41f0
jmp 0x9e23
movq %rcx, %rdi
callq 0x9f0a
testl %eax, %eax
jne 0x9bae
movq 0x10(%r15), %rdi
callq 0x46f0
jmp 0x9e23
movl $0x5f, %edi
callq 0x47a0
leaq 0x151e(%rip), %rsi      # 0xb05e
movl $0xffffffa1, %edi       # imm = 0xFFFFFFA1
movq %rax, %rdx
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x45d0
movl 0x8(%r15), %eax
cmpl $0xff, %eax
ja 0x9d43
leaq 0x8(%rsp), %r15
movb %al, (%r15)
jmp 0x9cd0
movq 0x8(%r15), %rax
cmpq $0xff, %rax
jbe 0x9cc8
jmp 0x9d43
movl $0x16, %edi
callq 0x47a0
leaq 0x14bf(%rip), %rsi      # 0xb05e
movl $0xffffffea, %edi       # imm = 0xFFFFFFEA
movq %rax, %rdx
xorl %eax, %eax
callq 0x45d0
movl %eax, %r14d
jmp 0x9ea5
movzbl 0x8(%r15), %eax
jmp 0x9ce7
movzwl 0x8(%r15), %eax
jmp 0x9ce7
movl 0x8(%r15), %eax
jmp 0x9ce3
movzbl 0x8(%r15), %eax
jmp 0x9d17
movzwl 0x8(%r15), %eax
testw %ax, %ax
js 0x9d43
leaq 0x8(%rsp), %r15
movw %ax, (%r15)
jmp 0x9d20
movq 0x8(%r15), %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
jbe 0x9d02
jmp 0x9d43
addq $0x8, %r15
jmp 0x9cd0
movl 0x8(%r15), %eax
cmpl $0x7f, %eax
jbe 0x9b6c
jmp 0x9d43
movq 0x8(%r15), %rax
movslq %eax, %rcx
cmpq %rax, %rcx
je 0x9c89
jmp 0x9d43
movzwl 0x8(%r15), %eax
cmpw $0x7f, %ax
jbe 0x9c6f
jmp 0x9d43
movl 0x8(%r15), %eax
movsbl %al, %ecx
cmpl %eax, %ecx
je 0x9b6c
jmp 0x9d43
movzwl 0x8(%r15), %eax
movsbl %al, %ecx
cmpw %ax, %cx
jne 0x9d43
leaq 0x8(%rsp), %r15
movb %al, (%r15)
jmp 0x9cd0
movq 0x8(%r15), %rax
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0x9d43
leaq 0x8(%rsp), %r15
movl %eax, (%r15)
jmp 0x9cef
movswl 0x8(%r15), %eax
jmp 0x9ce7
movq 0x8(%r15), %rax
movsbq %al, %rcx
cmpq %rax, %rcx
je 0x9cc8
jmp 0x9d43
movq 0x8(%r15), %rax
movswq %ax, %rcx
cmpq %rax, %rcx
je 0x9d02
jmp 0x9d43
movq 0x8(%r15), %rax
cmpq $0x7f, %rax
ja 0x9d43
leaq 0x8(%rsp), %r15
movb %al, (%r15)
movl $0x1, %edx
jmp 0x9d25
movsbl 0x8(%r15), %eax
jmp 0x9ce3
movswl 0x8(%r15), %eax
testl %eax, %eax
js 0x9d43
leaq 0x8(%rsp), %r15
movl %eax, (%r15)
movl $0x4, %edx
jmp 0x9d25
movq 0x8(%r15), %rax
cmpq $0x7fff, %rax           # imm = 0x7FFF
ja 0x9d43
leaq 0x8(%rsp), %r15
movw %ax, (%r15)
jmp 0x9d20
movsbl 0x8(%r15), %eax
testw %ax, %ax
js 0x9d43
leaq 0x8(%rsp), %r15
movw %ax, (%r15)
movl $0x2, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4470
xorl %r14d, %r14d
jmp 0x9ea5
movl 0x8(%r15), %eax
movswl %ax, %ecx
cmpl %eax, %ecx
je 0x9d17
leaq 0x18c8(%rip), %rsi      # 0xb612
movl $0x1, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x45d0
movl %eax, %r14d
negl %r14d
jmp 0x9ea5
movl 0x8(%r15), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jbe 0x9d17
jmp 0x9d43
movq 0x8(%r15), %rsi
leaq 0x18d9(%rip), %rdi      # 0xb655
jmp 0x9e91
cvtss2sd 0x8(%r15), %xmm0
jmp 0x9e15
movswl 0x8(%r15), %esi
jmp 0x9e59
leaq 0x131c(%rip), %rdi      # 0xb0b9
callq 0x41f0
movq %rax, (%rbx)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x9ea5
movq 0x8(%r15), %rdi
callq 0x4500
movq %rax, %r12
movq 0x8(%r15), %rdi
callq 0x4270
testq %rax, %rax
je 0x9d30
movq %rax, %r15
leaq 0x1870(%rip), %r13      # 0xb64c
xorl %ebp, %ebp
movsbl (%r12,%rbp), %edx
movq %rbx, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x4520
testl %eax, %eax
jne 0x9ecd
incq %rbp
xorl %r14d, %r14d
cmpq %rbp, %r15
jne 0x9dde
jmp 0x9ea5
movzwl 0x8(%r15), %esi
jmp 0x9e66
movsd 0x8(%r15), %xmm0
leaq 0x182d(%rip), %rdi      # 0xb649
movb $0x1, %al
callq 0x47b0
movq %rax, (%rbx)
xorl %r14d, %r14d
jmp 0x9e9e
movzbl 0x8(%r15), %esi
jmp 0x9e66
movsbl 0x8(%r15), %esi
jmp 0x9e59
leaq 0x17f7(%rip), %rax      # 0xb637
leaq 0x17f5(%rip), %rdi      # 0xb63c
cmpb $0x0, 0x8(%r15)
cmovneq %rax, %rdi
jmp 0x9b07
movl 0x8(%r15), %esi
leaq 0x17e2(%rip), %rdi      # 0xb642
jmp 0x9e6d
movl 0x8(%r15), %esi
leaq 0x17a2(%rip), %rdi      # 0xb60f
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x47b0
jmp 0x9e9b
movq 0x8(%r15), %rsi
leaq 0x17c1(%rip), %rdi      # 0xb645
jmp 0x9e91
movq 0x8(%r15), %rsi
leaq 0x11dd(%rip), %rdi      # 0xb06e
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x47b0
movq %rax, (%rbx)
cmpq $0x1, %rax
sbbl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1754(%rip), %rsi      # 0xb612
movl $0x1, %edi
movl $0xd, %ecx
jmp 0x9d52
movq (%rbx), %rdi
callq 0x4260
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x9ea5