// File: /workspace/github_c_makefile_star2_O0/DeforaOS[P]libSystem/src/variable.c
// Function: get_as_convert_string
static VariableError _get_as_convert_string(Variable const * variable,
		String ** result)
{
	Variable const * v = variable;
	BufferData const * bufdata;
	size_t cnt;
	size_t i;

	switch(v->type)
	{
		case VT_NULL:
			*result = NULL;
			return 0;
		case VT_BOOL:
			return ((*result = string_new(v->u.b
							? "true" : "false"))
					!= NULL) ? 0 : -1;
		case VT_INT8:
			return ((*result = string_new_format("%" PRId8,
							v->u.int8)) != NULL)
				? 0 : -1;
		case VT_UINT8:
			return ((*result = string_new_format("%" PRIu8,
							v->u.uint8)) != NULL)
				? 0 : -1;
		case VT_INT16:
			return ((*result = string_new_format("%" PRId16,
							v->u.int16)) != NULL)
				? 0 : -1;
		case VT_UINT16:
			return ((*result = string_new_format("%" PRIu16,
							v->u.uint16)) != NULL)
				? 0 : -1;
		case VT_INT32:
			return ((*result = string_new_format("%" PRId32,
							v->u.int32)) != NULL)
				? 0 : -1;
		case VT_UINT32:
			return ((*result = string_new_format("%" PRIu32,
							v->u.uint32)) != NULL)
				? 0 : -1;
		case VT_INT64:
			return ((*result = string_new_format("%" PRId64,
							v->u.int64)) != NULL)
				? 0 : -1;
		case VT_UINT64:
			return ((*result = string_new_format("%" PRIu64,
							v->u.uint64)) != NULL)
				? 0 : -1;
		case VT_FLOAT:
			return ((*result = string_new_format("%f", v->u.f))
					!= NULL) ? 0 : -1;
		case VT_DOUBLE:
			return ((*result = string_new_format("%f", v->u.d))
					!= NULL) ? 0 : -1;
		case VT_STRING:
			/* cannot happen */
		case VT_COMPOUND:
			/* no possible conversion */
			break;
		case VT_BUFFER:
			if((*result = string_new("")) == NULL)
				return -1;
			bufdata = buffer_get_data(v->u.buffer);
			cnt = buffer_get_size(v->u.buffer);
			for(i = 0; i < cnt; i++)
				if(string_append_format(result, "\\x%02hhx",
							bufdata[i]) != 0)
				{
					string_delete(*result);
					return -1;
				}
			return 0;
#if 0
		case VT_ARRAY:
			/* FIXME implement */
			break;
#endif
		case VT_POINTER:
			return ((*result = string_new_format("%p",
							v->u.pointer)) != NULL)
				? 0 : -1;
	}
	return -error_set_code(1, "Unable to convert from type %u to %u",
			variable->type, VT_STRING);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x10, %rax
ja 0xf02a
movq -0x40(%rbp), %rax
leaq 0x1751(%rip), %rcx      # 0x10418
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movb 0x8(%rax), %cl
leaq 0x18f7(%rip), %rdi      # 0x105ec
leaq 0x18eb(%rip), %rax      # 0x105e7
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x41f0
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movsbl 0x8(%rax), %esi
leaq 0x18bb(%rip), %rdi      # 0x105f2
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movzbl 0x8(%rax), %esi
leaq 0x1852(%rip), %rdi      # 0x105bf
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movswl 0x8(%rax), %esi
leaq 0x184f(%rip), %rdi      # 0x105f2
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %esi
leaq 0x17e6(%rip), %rdi      # 0x105bf
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
leaq 0x17e4(%rip), %rdi      # 0x105f2
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
leaq 0x177c(%rip), %rdi      # 0x105bf
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x11f5(%rip), %rdi      # 0x1006e
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x1746(%rip), %rdi      # 0x105f5
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movss 0x8(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x170f(%rip), %rdi      # 0x105f9
movb $0x1, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movsd 0x8(%rax), %xmm0
leaq 0x16d8(%rip), %rdi      # 0x105f9
movb $0x1, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
jmp 0xf02a
leaq 0x1165(%rip), %rdi      # 0x100b9
callq 0x41f0
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xef72
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf051
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x4550
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x4270
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xefee
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq 0x163f(%rip), %rsi      # 0x105fc
movb $0x0, %al
callq 0x4570
cmpl $0x0, %eax
je 0xefde
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x4260
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf051
jmp 0xefe0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xef9c
movl $0x0, -0x4(%rbp)
jmp 0xf051
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x15ff(%rip), %rdi      # 0x10605
movb $0x0, %al
callq 0x4850
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xf051
movq -0x10(%rbp), %rax
movl (%rax), %edx
movl $0x1, %edi
leaq 0x1586(%rip), %rsi      # 0x105c2
movl $0xd, %ecx
movb $0x0, %al
callq 0x4630
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)