// File: /workspace/github_c_makefile_star2_O0/goodpaul6[P]generic/script.c
// Function: disassemble
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:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
leaq 0xf41c(%rip), %rax      # 0x1374d
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movslq -0x14(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x1e8(%rcx), %rax
jae 0x4af5
movq -0x8(%rbp), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
movslq -0x14(%rbp), %rsi
callq 0x11890
movb (%rax), %al
movb %al, -0x25(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x2c, %eax
je 0x43a2
movzbl -0x25(%rbp), %eax
cmpl $0x2d, %eax
je 0x43a2
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %r8d
leaq 0x11430(%rip), %rsi     # 0x157cb
movb $0x0, %al
callq 0x2150
movzbl -0x25(%rbp), %eax
movq %rax, -0x88(%rbp)
subq $0x30, %rax
ja 0x4af0
movq -0x88(%rbp), %rax
leaq 0xec6b(%rip), %rcx      # 0x13030
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
leaq 0x113ff(%rip), %rsi     # 0x157d8
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x113f3(%rip), %rsi     # 0x157e3
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x113e7(%rip), %rsi     # 0x157ee
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %edx
leaq 0x113ca(%rip), %rsi     # 0x157fa
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
movslq -0x30(%rbp), %rsi
callq 0x11890
movq -0x90(%rbp), %rdi
movsd (%rax), %xmm0
leaq 0x11383(%rip), %rsi     # 0x1580a
movb $0x1, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movslq -0x34(%rbp), %rsi
callq 0x11890
movq -0x98(%rbp), %rdi
movq 0x8(%rax), %rdx
leaq 0x1133c(%rip), %rsi     # 0x1581a
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x298, %rdi            # imm = 0x298
movslq -0x38(%rbp), %rsi
callq 0x11890
movq -0xa8(%rbp), %rdi
movl -0x9c(%rbp), %edx
movl (%rax), %ecx
leaq 0x112ea(%rip), %rsi     # 0x1582c
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
addq $0x238, %rdi            # imm = 0x238
movslq -0x3c(%rbp), %rsi
callq 0x11890
movq -0xb0(%rbp), %rdi
movq (%rax), %rdx
movl -0x3c(%rbp), %ecx
leaq 0x112a9(%rip), %rsi     # 0x15844
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x112a4(%rip), %rsi     # 0x15861
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %edx
leaq 0x11287(%rip), %rsi     # 0x1586d
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1127a(%rip), %rsi     # 0x15882
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x44(%rbp)
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x48(%rbp)
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
leaq 0x11236(%rip), %rsi     # 0x1588f
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x11247(%rip), %rsi     # 0x158b7
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1123c(%rip), %rsi     # 0x158c3
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x11230(%rip), %rsi     # 0x158ce
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x11225(%rip), %rsi     # 0x158da
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x11219(%rip), %rsi     # 0x158e5
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %edx
leaq 0x111fb(%rip), %rsi     # 0x158f0
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %edx
leaq 0x111d6(%rip), %rsi     # 0x158ff
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x111c3(%rip), %rsi     # 0x1590e
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x111b1(%rip), %rsi     # 0x15913
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1119f(%rip), %rsi     # 0x15918
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1118d(%rip), %rsi     # 0x1591d
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1117b(%rip), %rsi     # 0x15922
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x11211(%rip), %rsi     # 0x159cf
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x11152(%rip), %rsi     # 0x15927
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1113f(%rip), %rsi     # 0x1592b
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1112d(%rip), %rsi     # 0x15930
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1111b(%rip), %rsi     # 0x15935
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x1110a(%rip), %rsi     # 0x1593b
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x110f8(%rip), %rsi     # 0x15940
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x110e6(%rip), %rsi     # 0x15945
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x110d4(%rip), %rsi     # 0x1594a
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x110c2(%rip), %rsi     # 0x1594f
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x110b1(%rip), %rsi     # 0x15955
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %edx
leaq 0x11039(%rip), %rsi     # 0x15906
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %edx
leaq 0x10ff6(%rip), %rsi     # 0x158f7
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %edx
leaq 0x11027(%rip), %rsi     # 0x1595c
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %edx
leaq 0x11000(%rip), %rsi     # 0x15969
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %edx
leaq 0x10fd9(%rip), %rsi     # 0x15976
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %edx
leaq 0x10fae(%rip), %rsi     # 0x1597f
movb $0x0, %al
callq 0x2150
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %eax, %rsi
callq 0x11890
movb (%rax), %al
movb %al, -0x69(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x69(%rbp), %edx
leaq 0x10f6f(%rip), %rsi     # 0x15989
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x10f67(%rip), %rsi     # 0x15998
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x10f58(%rip), %rsi     # 0x159a0
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movslq -0x70(%rbp), %rsi
callq 0x11890
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x4af0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x10ce0
movl %eax, -0x7c(%rbp)
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x10eed(%rip), %rsi     # 0x159ae
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x10ee8(%rip), %rsi     # 0x159bd
movb $0x0, %al
callq 0x2150
jmp 0x4af0
movq -0x10(%rbp), %rdi
leaq 0x10ee4(%rip), %rsi     # 0x159cd
movb $0x0, %al
callq 0x2150
jmp 0x433c
addq $0xb0, %rsp
popq %rbp
retq
nop