// File: /workspace/github_c_makefile_star2_O2/DeforaOS[P]libSystem/src/variable.c
// Function: variable_set_typev
VariableError variable_set_typev(Variable * variable, VariableType type,
		va_list ap)
{
	int32_t i32;
	uint32_t u32;
	int64_t i64;
	uint64_t u64;
	double d;
	Buffer * b;
	String * s;
	Mutator * m;

	switch(type)
	{
		case VT_NULL:
			_variable_destroy(variable);
			break;
		case VT_BOOL:
			_variable_destroy(variable);
			u32 = va_arg(ap, uint32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%s)\n", __func__,
					u32 ? "true" : "false");
#endif
			variable->u.b = u32 ? true : false;
			break;
		case VT_INT8:
			_variable_destroy(variable);
			i32 = va_arg(ap, int32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%d)\n", __func__, i32);
#endif
			variable->u.int8 = i32;
			break;
		case VT_UINT8:
			_variable_destroy(variable);
			u32 = va_arg(ap, uint32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%u)\n", __func__, u32);
#endif
			variable->u.uint8 = u32;
			break;
		case VT_INT16:
			_variable_destroy(variable);
			i32 = va_arg(ap, int32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%d)\n", __func__, i32);
#endif
			variable->u.int16 = i32;
			break;
		case VT_UINT16:
			_variable_destroy(variable);
			u32 = va_arg(ap, uint32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%u)\n", __func__, u32);
#endif
			variable->u.uint16 = u32;
			break;
		case VT_INT32:
			_variable_destroy(variable);
			i32 = va_arg(ap, int32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%d)\n", __func__, i32);
#endif
			variable->u.int32 = i32;
			break;
		case VT_UINT32:
			_variable_destroy(variable);
			u32 = va_arg(ap, uint32_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%u)\n", __func__, u32);
#endif
			variable->u.uint32 = u32;
			break;
		case VT_INT64:
			_variable_destroy(variable);
			i64 = va_arg(ap, int64_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%ld)\n", __func__, i64);
#endif
			variable->u.int64 = i64;
			break;
		case VT_UINT64:
			_variable_destroy(variable);
			u64 = va_arg(ap, uint64_t);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%lu)\n", __func__, u64);
#endif
			variable->u.uint64 = u64;
			break;
		case VT_FLOAT:
			_variable_destroy(variable);
			d = va_arg(ap, double);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%f)\n", __func__, d);
#endif
			variable->u.f = d;
			break;
		case VT_DOUBLE:
			_variable_destroy(variable);
			d = va_arg(ap, double);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%lf)\n", __func__, d);
#endif
			variable->u.d = d;
			break;
		case VT_BUFFER:
			b = va_arg(ap, Buffer *);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(%p)\n", __func__, (void *)b);
#endif
			b = (b != NULL)
				? buffer_new_copy(b) : buffer_new(0, NULL);
			if(b  == NULL)
				return -1;
			_variable_destroy(variable);
			variable->u.buffer = b;
			break;
		case VT_STRING:
			s = va_arg(ap, String *);
#ifdef DEBUG
			fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, s);
#endif
			if((s = string_new(s)) == NULL)
				return -1;
			_variable_destroy(variable);
			variable->u.string = s;
			break;
		case VT_COMPOUND:
			s = va_arg(ap, String *);
			if(s != NULL && (s = string_new(s)) == NULL)
				return -1;
			if((m = mutator_new()) == NULL)
			{
				string_delete(s);
				return -1;
			}
			_variable_destroy(variable);
			variable->u.compound.name = s;
			variable->u.compound.members = m;
			break;
		case VT_POINTER:
			_variable_destroy(variable);
			variable->u.pointer = va_arg(ap, void *);
			break;
		default:
			return error_set_code(-ENOSYS, "%s", strerror(ENOSYS));
	}
	variable->type = type;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpl $0x10, %esi
ja 0x895e
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %eax
leaq 0x2a5f(%rip), %rcx      # 0xb1d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x9256
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x8816
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x8822
movq %r14, %rdi
callq 0x9256
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x88a5
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x88b1
movq %r14, %rdi
callq 0x9256
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x88f0
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x88fc
movq %r14, %rdi
callq 0x9256
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x8945
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x8951
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rax
movq %rax, 0x8(%r14)
jmp 0x8a7b
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x8982
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x898e
movq %r14, %rdi
callq 0x9256
movl 0x4(%r15), %ecx
cmpq $0xa0, %rcx
ja 0x89a4
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x10, %ecx
movl %ecx, 0x4(%r15)
jmp 0x89b0
movq %r14, %rdi
callq 0x9256
movl 0x4(%r15), %ecx
cmpq $0xa0, %rcx
ja 0x89bf
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x10, %ecx
movl %ecx, 0x4(%r15)
jmp 0x89cb
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movb (%rax), %al
movb %al, 0x8(%r14)
jmp 0x8a7b
movq %r14, %rdi
callq 0x9256
jmp 0x8a7b
movq %r14, %rdi
callq 0x9256
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x89da
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x89e6
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movl (%rax), %eax
movl %eax, 0x8(%r14)
jmp 0x8a7b
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x89f3
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x89ff
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x8a11
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x8a1d
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movzwl (%rax), %eax
movw %ax, 0x8(%r14)
jmp 0x8a7b
pushq $0x26
popq %rdi
callq 0x47f0
leaq 0x26f1(%rip), %rsi      # 0xb05e
pushq $-0x26
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4610
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rdi
testq %rdi, %rdi
je 0x8a37
callq 0x4790
jmp 0x8a40
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%r14)
jmp 0x8a7b
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
cvtsd2ss (%rax), %xmm0
movss %xmm0, 0x8(%r14)
jmp 0x8a7b
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
cmpl $0x0, (%rax)
setne 0x8(%r14)
jmp 0x8a7b
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rdi
callq 0x41f0
testq %rax, %rax
je 0x8a56
movq %rax, %r15
jmp 0x8a48
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rdi
pushq $-0x1
popq %rbp
testq %rdi, %rdi
je 0x8a5b
callq 0x41f0
movq %rax, %r15
testq %rax, %rax
jne 0x8a5e
jmp 0x8a80
xorl %edi, %edi
xorl %esi, %esi
callq 0x4110
movq %rax, %r15
testq %rax, %rax
je 0x8a56
movq %r14, %rdi
callq 0x9256
movq %r15, 0x8(%r14)
jmp 0x8a7b
pushq $-0x1
popq %rbp
jmp 0x8a80
xorl %r15d, %r15d
callq 0x4390
testq %rax, %rax
je 0x8a8b
movq %rax, %r12
movq %r14, %rdi
callq 0x9256
movq %r15, 0x10(%r14)
movq %r12, 0x18(%r14)
movl %ebx, (%r14)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x4260
jmp 0x8a80