// File: /workspace/github_c_makefile_star2_O3/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 0x9c1d
movq %rdi, %rbx
movl 0xc(%rdi), %eax
cmpq $0x8, %rax
ja 0x9df5
movl %esi, %r13d
leaq 0x57c0(%rip), %rcx      # 0xf3d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6ff9(%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 %r13b, %r13b
je 0x9d0f
leaq 0x7148(%rip), %rdi      # 0x10d95
jmp 0x9de0
movsbl 0x20(%rbx), %edi
jmp 0x9dc2
movsd 0x20(%rbx), %xmm0
leaq 0x70e8(%rip), %rdi      # 0x10d4f
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20d0
leaq 0x713d(%rip), %rdi      # 0x10dc0
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, 0x30(%rbx)
je 0x9ced
leaq 0x20(%rbx), %r14
leaq 0x70f6(%rip), %r12      # 0x10d92
movsbl %r13b, %r13d
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0xdcf3
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x9cc0
movl %r13d, %esi
callq 0x9be7
jmp 0x9cce
leaq 0x70f0(%rip), %rdi      # 0x10db7
xorl %eax, %eax
callq 0x20d0
incq %r15
movq 0x30(%rbx), %rax
cmpq %r15, %rax
jbe 0x9ce8
movq %r12, %rdi
xorl %eax, %eax
callq 0x20d0
movq 0x30(%rbx), %rax
cmpq %r15, %rax
ja 0x9ca3
leaq 0x70cf(%rip), %rdi      # 0x10dc3
jmp 0x9c24
cmpb $0x0, 0x20(%rbx)
leaq 0x6f45(%rip), %rax      # 0x10c49
leaq 0x6f39(%rip), %rsi      # 0x10c44
cmoveq %rax, %rsi
leaq 0x775b(%rip), %rdi      # 0x11471
jmp 0x9de0
cmpb $0x0, 0x20(%rbx)
leaq 0x6f23(%rip), %rax      # 0x10c49
leaq 0x6f17(%rip), %rsi      # 0x10c44
cmoveq %rax, %rsi
movl 0x24(%rbx), %edx
leaq 0x705f(%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 0x9dbd
leaq 0x20(%rbx), %r14
leaq 0x7026(%rip), %r12      # 0x10d92
movsbl %r13b, %r13d
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0xdcf3
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x9d90
movl %r13d, %esi
callq 0x9be7
jmp 0x9d9e
leaq 0x7020(%rip), %rdi      # 0x10db7
xorl %eax, %eax
callq 0x20d0
incq %r15
movq 0x30(%rbx), %rax
cmpq %r15, %rax
jbe 0x9db8
movq %r12, %rdi
xorl %eax, %eax
callq 0x20d0
movq 0x30(%rbx), %rax
cmpq %r15, %rax
ja 0x9d73
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 0x6fe6(%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