// File: /workspace/github_c_makefile_star2_O2/goodpaul6[P]generic/script.c
// Function: write_value
static void write_value(script_value_t* val, char quote)
{
	if(!val)
	{
		printf("null");
		return;
	}
	
	switch(val->type)
	{
		case VAL_NULL: printf("null"); break;
		case VAL_BOOL: printf("%s", val->boolean ? "true" : "false"); break;
		case VAL_CHAR: printf("%c", val->code); break;
		case VAL_NUMBER: printf("%g", val->number); break;
		case VAL_STRING: quote ? printf("\"%s\"", val->string.data) : printf("%s", val->string.data); break;
		case VAL_FUNC: printf("func (extern: %s, index: %d)", val->function.is_extern ? "true" : "false", val->function.index); break;
		case VAL_ARRAY:
		{
			printf("[");
			for(int i = 0; i < val->array.length; ++i)
			{
				script_value_t* mem = vec_get_value(&val->array, i, script_value_t*);
				if (val == mem)
					printf("__self__");
				else
					write_value(mem, quote);
				if(i + 1 < val->array.length) printf(", ");
			}
			printf("]");
		} break;
		case VAL_STRUCT_INSTANCE:
		{
			printf("{ ");
			for(int i = 0; i < val->ds.members.length; ++i)
			{
				script_value_t* mem = vec_get_value(&val->ds.members, i, script_value_t*);
				if (val == mem)
					printf("__self__");
				else
					write_value(mem, quote);
				if(i + 1 < val->ds.members.length) printf(", ");
			}
			printf(" }");
		} break;
		case VAL_NATIVE:
		{
			printf("native 0x%lX", (unsigned long)val->nat.value);
		} break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x8e0f
movq %rdi, %rbx
movl 0xc(%rdi), %eax
cmpq $0x8, %rax
ja 0x8fcd
movl %esi, %r15d
leaq 0x458e(%rip), %rcx      # 0xd394
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5e0f(%rip), %rdi      # 0xec25
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
movq 0x28(%rbx), %rsi
testb %r15b, %r15b
je 0x8ef6
leaq 0x5f5e(%rip), %rdi      # 0xed9d
jmp 0x8fb8
movsbl 0x20(%rbx), %edi
jmp 0x8f9a
movsd 0x20(%rbx), %xmm0
leaq 0x5efe(%rip), %rdi      # 0xed57
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
leaq 0x5f53(%rip), %rdi      # 0xedc8
xorl %eax, %eax
callq 0x20d0
leaq 0x20(%rbx), %r14
leaq 0x5f13(%rip), %r12      # 0xed9a
movsbl %r15b, %r13d
xorl %r15d, %r15d
cmpq %r15, 0x30(%rbx)
jbe 0x8ed4
movq %r14, %rdi
movq %r15, %rsi
callq 0xc15c
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x8eb1
movl %r13d, %esi
callq 0x8dd9
jmp 0x8ebf
leaq 0x5f07(%rip), %rdi      # 0xedbf
xorl %eax, %eax
callq 0x20d0
incq %r15
cmpq %r15, 0x30(%rbx)
jbe 0x8e8e
movq %r12, %rdi
xorl %eax, %eax
callq 0x20d0
jmp 0x8e8e
leaq 0x5ef0(%rip), %rdi      # 0xedcb
jmp 0x8e16
cmpb $0x0, 0x20(%rbx)
leaq 0x5d66(%rip), %rax      # 0xec51
leaq 0x5d5a(%rip), %rsi      # 0xec4c
cmoveq %rax, %rsi
leaq 0x657c(%rip), %rdi      # 0xf479
jmp 0x8fb8
cmpb $0x0, 0x20(%rbx)
leaq 0x5d44(%rip), %rax      # 0xec51
leaq 0x5d38(%rip), %rsi      # 0xec4c
cmoveq %rax, %rsi
movl 0x24(%rbx), %edx
leaq 0x5e80(%rip), %rdi      # 0xeda2
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
pushq $0x5b
popq %rdi
callq 0x2040
leaq 0x20(%rbx), %r14
leaq 0x5e50(%rip), %r12      # 0xed9a
movsbl %r15b, %r13d
xorl %r15d, %r15d
cmpq %r15, 0x30(%rbx)
jbe 0x8f97
movq %r14, %rdi
movq %r15, %rsi
callq 0xc15c
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x8f74
movl %r13d, %esi
callq 0x8dd9
jmp 0x8f82
leaq 0x5e44(%rip), %rdi      # 0xedbf
xorl %eax, %eax
callq 0x20d0
incq %r15
cmpq %r15, 0x30(%rbx)
jbe 0x8f51
movq %r12, %rdi
xorl %eax, %eax
callq 0x20d0
jmp 0x8f51
pushq $0x5d
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040
movq 0x20(%rbx), %rsi
leaq 0x5e16(%rip), %rdi      # 0xedce
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq