// File: /workspace/github_c_makefile_star2_O1/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 0x9df7
movq %rdi, %rbx
movl 0xc(%rdi), %eax
cmpq $0x8, %rax
ja 0x9fc3
movl %esi, %r14d
leaq 0x55e6(%rip), %rcx      # 0xf3d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6e1f(%rip), %rdi      # 0x10c1d
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 %r14b, %r14b
je 0x9ee3
leaq 0x6f6e(%rip), %rdi      # 0x10d95
jmp 0x9fae
movsbl 0x20(%rbx), %edi
jmp 0x9f90
movsd 0x20(%rbx), %xmm0
leaq 0x6f0e(%rip), %rdi      # 0x10d4f
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
leaq 0x6f63(%rip), %rdi      # 0x10dc0
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, 0x30(%rbx)
je 0x9ec1
leaq 0x20(%rbx), %r15
leaq 0x6f1c(%rip), %r13      # 0x10d92
movsbl %r14b, %r14d
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x9e9a
movl %r14d, %esi
callq 0x9dc1
jmp 0x9ea8
leaq 0x6f16(%rip), %rdi      # 0x10db7
xorl %eax, %eax
callq 0x20d0
incq %r12
cmpq %r12, 0x30(%rbx)
jbe 0x9ebb
movq %r13, %rdi
xorl %eax, %eax
callq 0x20d0
cmpq %r12, 0x30(%rbx)
ja 0x9e7d
leaq 0x6efb(%rip), %rdi      # 0x10dc3
jmp 0x9dfe
cmpb $0x0, 0x20(%rbx)
leaq 0x6d71(%rip), %rax      # 0x10c49
leaq 0x6d65(%rip), %rsi      # 0x10c44
cmoveq %rax, %rsi
leaq 0x7587(%rip), %rdi      # 0x11471
jmp 0x9fae
cmpb $0x0, 0x20(%rbx)
leaq 0x6d4f(%rip), %rax      # 0x10c49
leaq 0x6d43(%rip), %rsi      # 0x10c44
cmoveq %rax, %rsi
movl 0x24(%rbx), %edx
leaq 0x6e8b(%rip), %rdi      # 0x10d9a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
movl $0x5b, %edi
callq 0x2040
cmpq $0x0, 0x30(%rbx)
je 0x9f8b
leaq 0x20(%rbx), %r15
leaq 0x6e52(%rip), %r13      # 0x10d92
movsbl %r14b, %r14d
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x9f64
movl %r14d, %esi
callq 0x9dc1
jmp 0x9f72
leaq 0x6e4c(%rip), %rdi      # 0x10db7
xorl %eax, %eax
callq 0x20d0
incq %r12
cmpq %r12, 0x30(%rbx)
jbe 0x9f85
movq %r13, %rdi
xorl %eax, %eax
callq 0x20d0
cmpq %r12, 0x30(%rbx)
ja 0x9f47
movl $0x5d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040
movq 0x20(%rbx), %rsi
leaq 0x6e18(%rip), %rdi      # 0x10dc6
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