// File: /workspace/github_c_makefile_star2_O3/goodpaul6[P]generic/script.c
// Function: script_dissassemble
static void disassemble(script_t* script, FILE* out)
{
	int pc = 0;
	
	const char* file = "unknown";
	int line = 0;
	
	while(pc < script->code.length)
	{
		word code = vec_get_value(&script->code, pc, word);
		++pc;
		
		if(code != OP_FILE && code != OP_LINE)
			fprintf(out, "%d (%s:%i): ", pc, file, line);

		switch(code)
		{
			case OP_PUSH_NULL: fprintf(out, "push_null\n"); break;
			
			case OP_PUSH_TRUE: fprintf(out, "push_true\n"); break;
			case OP_PUSH_FALSE: fprintf(out, "push_false\n"); break;
			
			case OP_PUSH_CHAR:
			{
				int c = read_int_at(script, pc);
				fprintf(out, "push_char '%c'\n", c);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_PUSH_NUMBER:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "push_number %g\n", vec_get_value(&script->numbers, index, double));
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_PUSH_STRING:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "push_string '%s'\n", vec_get_value(&script->strings, index, script_string_t).data);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_PUSH_FUNC:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "push_func %d (pc = %d)\n", index, vec_get_value(&script->function_pcs, index, int));
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_PUSH_EXTERN_FUNC:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "push_extern_func %s (id=%d)\n", vec_get_value(&script->extern_names, index, char*), index);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_PUSH_ARRAY:
			{
				fprintf(out, "push_array\n");
			} break;
			
			case OP_PUSH_ARRAY_BLOCK:
			{
				int length = read_int_at(script, pc);
				fprintf(out, "push_array_block %d\n", length);
				pc += sizeof(int) / sizeof(word);
			} break;
		
			case OP_PUSH_RETVAL:
			{
				fprintf(out, "push_retval\n");
			} break;

			case OP_PUSH_STRUCT:
			{
				int nmem = read_int_at(script, pc);
				pc += sizeof(int) / sizeof(word);
				
				int ninit = read_int_at(script, pc);
				pc += sizeof(int) / sizeof(word);
				
				fprintf(out, "push_struct num_members=%d num_init=%d\n", nmem, ninit);
			} break;
			
			case OP_STRING_LEN:
			{
				fprintf(out, "string_len\n");
			} break;
			
			case OP_ARRAY_LEN:
			{
				fprintf(out, "array_len\n");
			} break;
			
			case OP_STRING_GET:
			{
				fprintf(out, "string_get\n");
			} break;
			
			case OP_ARRAY_GET:
			{
				fprintf(out, "array_get\n");
			} break;
			
			case OP_ARRAY_SET:
			{
				fprintf(out, "array_set\n");
			} break;
			
			case OP_STRUCT_GET:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "struct_get %d\n", index);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_STRUCT_SET:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "struct_set %d\n", index);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_ADD: fprintf(out, "add\n"); break;
			case OP_SUB: fprintf(out, "sub\n"); break;
			case OP_MUL: fprintf(out, "mul\n"); break;
			case OP_DIV: fprintf(out, "div\n"); break;
			case OP_MOD: fprintf(out, "mod\n"); break;

			case OP_LT: fprintf(out, "lt\n"); break;
			case OP_GT: fprintf(out, "gt\n"); break;
			case OP_LTE: fprintf(out, "lte\n"); break;
			case OP_GTE: fprintf(out, "gte\n"); break;
			
			case OP_LAND: fprintf(out, "land\n"); break;
			case OP_LOR: fprintf(out, "lor\n"); break;
			
			case OP_NEG: fprintf(out, "neg\n"); break;
			case OP_NOT: fprintf(out, "not\n"); break;
			
			case OP_EQU: fprintf(out, "equ\n"); break;
			
			case OP_READ: fprintf(out, "read\n"); break;
			case OP_WRITE: fprintf(out, "write\n"); break;
		
			case OP_SET:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "set %d\n", index);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_GET:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "get %d\n", index);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_SETLOCAL:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "setlocal %d\n", index);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_GETLOCAL:
			{
				int index = read_int_at(script, pc);
				fprintf(out, "getlocal %d\n", index);
				pc += sizeof(int) / sizeof(word);
			} break;
		
			case OP_GOTO:
			{
				int g = read_int_at(script, pc);
				fprintf(out, "goto %d\n", g);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_GOTOZ:
			{
				int g = read_int_at(script, pc);
				fprintf(out, "gotoz %d\n", g);
				pc += sizeof(int) / sizeof(word);
			} break;
			
			case OP_CALL:
			{
				word nargs = vec_get_value(&script->code, pc++, word);
				fprintf(out, "call nargs=%d\n", nargs);
			} break;
			
			case OP_RETURN:
			{
				fprintf(out, "return\n");
			} break;
			
			case OP_RETURN_VALUE:
			{
				fprintf(out, "return_value\n");
			} break;
			
			case OP_FILE:
			{
				int index = read_int_at(script, pc);
				const char* str = vec_get_value(&script->strings, index, script_string_t).data;
				pc += sizeof(int) / sizeof(word);
				
				file = str;
			} break;
			
			case OP_LINE:
			{
				int line_no = read_int_at(script, pc);
				pc += sizeof(int) / sizeof(word);
				line = line_no;
			} break;
			
			case OP_ATOMIC_ENABLE:
			{
				fprintf(out, "atomic_enable\n");
			} break;
			
			case OP_ATOMIC_DISABLE:
			{
				fprintf(out, "atomic_disable\n");
			} break;

			case OP_HALT:
			{
				fprintf(out, "halt\n");
			} break;
		}
	}
}

// Assembly:
cmpq $0x0, 0x1e8(%rdi)
je 0x4538
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1d8(%rdi), %rax
movq %rax, -0x48(%rbp)
leaq 0x218(%rdi), %rax
movq %rax, -0x38(%rbp)
leaq 0x238(%rdi), %rax
movq %rax, -0x60(%rbp)
leaq 0x298(%rdi), %rax
movq %rax, -0x58(%rbp)
leaq 0x1f8(%rdi), %rax
movq %rax, -0x50(%rbp)
leaq 0xb5f3(%rip), %rax      # 0xf6b5
movq %rax, -0x40(%rbp)
xorl %esi, %esi
xorl %r13d, %r13d
movl $0x0, -0x2c(%rbp)
movq -0x48(%rbp), %rdi
callq 0xdcf3
movzbl (%rax), %r15d
leal 0x1(%r13), %r12d
leal -0x2e(%r15), %eax
cmpb $-0x3, %al
ja 0x4107
movq %rbx, %rdi
leaq 0xd5bf(%rip), %rsi      # 0x116b4
movl %r12d, %edx
movq -0x40(%rbp), %rcx
movl -0x2c(%rbp), %r8d
xorl %eax, %eax
callq 0x2180
cmpl $0x30, %r15d
ja 0x4507
movl %r15d, %eax
leaq 0xaf69(%rip), %rcx      # 0xf084
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd596(%rip), %rdi      # 0x116c1
jmp 0x43d3
leaq 0xd752(%rip), %rdi      # 0x11889
movl $0xd, %esi
jmp 0x44fa
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd69c(%rip), %rsi      # 0x117ef
jmp 0x44d9
leaq 0xd747(%rip), %rdi      # 0x118a6
movl $0xf, %esi
jmp 0x44fa
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd6e4(%rip), %rsi      # 0x1185f
jmp 0x44d9
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd6d6(%rip), %rsi      # 0x11868
jmp 0x44d9
leaq 0xd67b(%rip), %rdi      # 0x11819
jmp 0x44f5
leaq 0xd694(%rip), %rdi      # 0x1183e
movl $0x6, %esi
jmp 0x44fa
leaq 0xd613(%rip), %rdi      # 0x117ce
jmp 0x43d3
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movslq %eax, %rsi
movq -0x38(%rbp), %rdi
callq 0xdcf3
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x44e5
leaq 0xd5cc(%rip), %rdi      # 0x117b7
jmp 0x4441
leaq 0xd641(%rip), %rdi      # 0x11838
jmp 0x44b7
leaq 0xd6b3(%rip), %rdi      # 0x118b6
jmp 0x44b7
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movl %eax, %r12d
leal 0x5(%r13), %esi
movq %r14, %rdi
callq 0xd662
addl $0x9, %r13d
leaq 0xd54b(%rip), %rsi      # 0x11778
movq %rbx, %rdi
movl %r12d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x2180
jmp 0x44e9
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movslq %eax, %rsi
movq -0x50(%rbp), %rdi
callq 0xdcf3
movsd (%rax), %xmm0
leaq 0xd490(%rip), %rsi      # 0x116f3
movq %rbx, %rdi
movb $0x1, %al
callq 0x2180
jmp 0x44e5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd5ce(%rip), %rsi      # 0x11852
jmp 0x44d9
leaq 0xd510(%rip), %rdi      # 0x117a0
jmp 0x4441
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd4af(%rip), %rsi      # 0x11756
jmp 0x44d9
leaq 0xd55d(%rip), %rdi      # 0x11810
jmp 0x42bc
leaq 0xd5fc(%rip), %rdi      # 0x118b8
movl $0x3, %esi
jmp 0x44fa
leaq 0xd40a(%rip), %rdi      # 0x116d7
jmp 0x4441
leaq 0xd4ea(%rip), %rdi      # 0x117c3
jmp 0x43d3
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd3f3(%rip), %rsi      # 0x116e3
jmp 0x44d9
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movslq %eax, %r12
movq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0xdcf3
movq (%rax), %rdx
leaq 0xd414(%rip), %rsi      # 0x1172d
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2180
jmp 0x44e5
leaq 0xd39a(%rip), %rdi      # 0x116cc
jmp 0x43d3
leaq 0xd4f0(%rip), %rdi      # 0x1182e
jmp 0x44f5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd484(%rip), %rsi      # 0x117d9
jmp 0x44d9
addl $0x2, %r13d
movslq %r12d, %rsi
movq -0x48(%rbp), %rdi
callq 0xdcf3
movzbl (%rax), %edx
leaq 0xd4fe(%rip), %rsi      # 0x11872
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2180
jmp 0x44e9
leaq 0xd472(%rip), %rdi      # 0x117fc
jmp 0x44f5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movslq %eax, %rsi
movq -0x38(%rbp), %rdi
callq 0xdcf3
movq 0x8(%rax), %rdx
leaq 0xd352(%rip), %rsi      # 0x11703
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2180
jmp 0x44e5
leaq 0xd43a(%rip), %rdi      # 0x11801
jmp 0x44f5
leaq 0xd3d9(%rip), %rdi      # 0x117ac
movl $0xa, %esi
jmp 0x44fa
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movslq %eax, %r12
movq -0x58(%rbp), %rdi
movq %r12, %rsi
callq 0xdcf3
movl (%rax), %ecx
leaq 0xd315(%rip), %rsi      # 0x11715
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2180
jmp 0x44e5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd3c4(%rip), %rsi      # 0x117e8
jmp 0x44d9
leaq 0xd33b(%rip), %rdi      # 0x1176b
movl $0xc, %esi
jmp 0x44fa
leaq 0xd309(%rip), %rdi      # 0x1174a
movl $0xb, %esi
jmp 0x44fa
leaq 0xd3d7(%rip), %rdi      # 0x11829
jmp 0x44f5
leaq 0xd3d5(%rip), %rdi      # 0x11833
jmp 0x44f5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
movl %eax, -0x2c(%rbp)
jmp 0x44e5
leaq 0xd38c(%rip), %rdi      # 0x11806
jmp 0x44f5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd3b7(%rip), %rsi      # 0x11845
jmp 0x44d9
leaq 0xd360(%rip), %rdi      # 0x117f7
jmp 0x44f5
leaq 0xd3e1(%rip), %rdi      # 0x11881
movl $0x7, %esi
jmp 0x44fa
leaq 0xd35d(%rip), %rdi      # 0x1180b
jmp 0x44f5
leaq 0xd367(%rip), %rdi      # 0x1181e
movl $0x5, %esi
jmp 0x44fa
leaq 0xd35f(%rip), %rdi      # 0x11824
jmp 0x44f5
movq %r14, %rdi
movl %r12d, %esi
callq 0xd662
leaq 0xd307(%rip), %rsi      # 0x117e0
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2180
addl $0x5, %r13d
movl %r13d, %r12d
jmp 0x4507
leaq 0xd31f(%rip), %rdi      # 0x11814
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2250
movslq %r12d, %rsi
movl %r12d, %r13d
cmpq %rsi, 0x1e8(%r14)
ja 0x40d2
jmp 0x452a
leaq 0xd374(%rip), %rdi      # 0x11897
movl $0xe, %esi
jmp 0x44fa
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq