// File: /workspace/github_c_makefile_star2_O0/DeforaOS[P]libSystem/tests/variable.c
// Function: variable
static int _variable(char const * progname)
{
	int ret = 0;
	Variable * variable;
	const int samples[] = { 0, -1, 1, -127, -128, 126, 127 };
	const float fsamples[] = { 0.0, -1.0, 1.0 };
	size_t i;
	size_t size;
	int32_t j;
	int8_t i8;
	size_t s;
	double d;
	Buffer * buf;
	String * str;

	/* variable_new */
	for(i = 0; i < sizeof(samples) / sizeof(*samples); i++)
	{
		printf("%s: Testing variable_new_deserialize_type(): %d\n",
				progname, samples[i]);
		i8 = samples[i];
		s = sizeof(i8);
		if((variable = variable_new_deserialize_type(VT_INT8, &s,
						(void *)&i8)) == NULL)
		{
			error_print(progname);
			ret += 1;
			continue;
		}
		size = sizeof(j);
		if(variable_get_as(variable, VT_INT32, (void *)&j, &size) != 0
				|| j != samples[i])
		{
			error_print(progname);
			ret += 1;
		}
		variable_delete(variable);
	}
	for(i = 0; i < sizeof(fsamples) / sizeof(*fsamples); i++)
	{
		if((variable = variable_new(VT_FLOAT, fsamples[i])) == NULL)
		{
			error_print(progname);
			ret += 1;
			continue;
		}
		d = INFINITY;
		size = sizeof(d);
		if(variable_get_as(variable, VT_DOUBLE, &d, &size) != 0
				|| d != fsamples[i])
		{
			error_print(progname);
			ret += 1;
		}
		variable_delete(variable);
	}
	printf("%s: Testing variable_get_as(%u)\n", progname, VT_STRING);
	if((buf = buffer_new(4, "ABC")) == NULL)
		ret += 1;
	size = sizeof(buf);
	if((variable = variable_new(VT_BUFFER, buf)) == NULL)
	{
		error_print(progname);
		ret += 1;
	}
	else if(variable_get_as(variable, VT_STRING, &str, &size) != 0)
	{
		error_print(progname);
		ret += 1;
	}
	else if(string_compare(str, "\\x41\\x42\\x43\\x00") != 0)
	{
		error_print(progname);
		ret += 1;
	}
	buffer_delete(buf);
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq 0xdf3(%rip), %rax       # 0x2010
movq %rax, -0x40(%rbp)
movq 0xdf0(%rip), %rax       # 0x2018
movq %rax, -0x38(%rbp)
movq 0xded(%rip), %rax       # 0x2020
movq %rax, -0x30(%rbp)
movl 0xdeb(%rip), %eax       # 0x2028
movl %eax, -0x28(%rbp)
movq 0xde5(%rip), %rax       # 0x202c
movq %rax, -0x4c(%rbp)
movl 0xde3(%rip), %eax       # 0x2034
movl %eax, -0x44(%rbp)
movq $0x0, -0x58(%rbp)
cmpq $0x7, -0x58(%rbp)
jae 0x1320
movq -0x8(%rbp), %rsi
movq -0x58(%rbp), %rax
movl -0x40(%rbp,%rax,4), %edx
leaq 0xdbe(%rip), %rdi       # 0x2038
movb $0x0, %al
callq 0x1060
movq -0x58(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
movb %al, -0x65(%rbp)
movq $0x1, -0x70(%rbp)
movl $0x2, %edi
leaq -0x70(%rbp), %rsi
leaq -0x65(%rbp), %rdx
callq 0x1030
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x12c4
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x130f
movq $0x4, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movl $0x6, %esi
leaq -0x64(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x1090
cmpl $0x0, %eax
jne 0x12f4
movl -0x64(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl -0x40(%rbp,%rcx,4), %eax
je 0x1306
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1070
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x125c
movq $0x0, -0x58(%rbp)
cmpq $0x3, -0x58(%rbp)
jae 0x13e4
movq -0x58(%rbp), %rax
movss -0x4c(%rbp,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
movl $0xa, %edi
movb $0x1, %al
callq 0x10b0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x136b
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13d3
movsd 0xc95(%rip), %xmm0      # 0x2008
movsd %xmm0, -0x78(%rbp)
movq $0x8, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movl $0xb, %esi
leaq -0x78(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x1090
cmpl $0x0, %eax
jne 0x13b8
movsd -0x78(%rbp), %xmm0
movq -0x58(%rbp), %rax
movss -0x4c(%rbp,%rax,4), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13b8
jp 0x13b8
jmp 0x13ca
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1070
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x1328
movq -0x8(%rbp), %rsi
leaq 0xc7a(%rip), %rdi       # 0x2069
movl $0xd, %edx
movb $0x0, %al
callq 0x1060
movl $0x4, %edi
leaq 0xc83(%rip), %rsi       # 0x208a
callq 0x1040
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0x141f
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq $0x8, -0x60(%rbp)
movq -0x80(%rbp), %rsi
movl $0xc, %edi
movb $0x0, %al
callq 0x10b0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x1455
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x14b5
movq -0x18(%rbp), %rdi
movl $0xd, %esi
leaq -0x88(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x1090
cmpl $0x0, %eax
je 0x1487
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x14b3
movq -0x88(%rbp), %rdi
leaq 0xbf9(%rip), %rsi       # 0x208e
callq 0x1050
cmpl $0x0, %eax
je 0x14b1
movq -0x8(%rbp), %rdi
callq 0x1080
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x14b3
jmp 0x14b5
movq -0x80(%rbp), %rdi
callq 0x10a0
movl -0xc(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq