// File: /workspace/github_c_makefile_star2_O3/mist64[P]cbmbasic/plugin.c
// Function: plugin_gone
unsigned short
plugin_gone() {
	set_chrptr(get_chrptr()+1);
	for (;;) {
		unsigned short chrptr;
		set_chrptr(get_chrptr()-1);
		chrptr = get_chrptr();
		/*
		 * this example shows:
		 * - how to get a 16 bit integer
		 * - how to get an 8 bit integer
		 * - how to check for a comma delimiter
		 * - how to do error handling
		 */
		if (compare("LOCATE")) {
			unsigned char x,y;
			y = get_byte(); /* 'line' first */
			check_comma();
			x = get_byte(); /* then 'column' */
			/* XXX ignores terminal size */
			if (x>80 || y>25 || x==0 || y==0)
				return error(ERROR_ILLEGAL_QUANTITY);
			move_cursor(x, y);

			continue;
		}

                /* Implements the ANSI Set Graphics Mode
		   as appears on http://ascii-table.com/ansi-escape-sequences.php
	           Note that some attributes will be implemented differently depending on what
                   terminal program you are using.
                */
		if (compare("ANSISGM")) {
			char attr, fg, bg;
			attr = get_byte(); /* Attribute */
			check_comma();
			fg = get_byte(); /* Foreground color */
			check_comma();
			bg = get_byte(); /* Background color */

			if (attr < 0 || attr > 8) return error(ERROR_ILLEGAL_QUANTITY);
			if (fg < 30 || fg > 37) return error(ERROR_ILLEGAL_QUANTITY);
			if (bg < 40 || bg > 47) return error(ERROR_ILLEGAL_QUANTITY);

			printf("\033[%d;%d;%dm",attr,bg,fg);
	        	continue;
		}

                /* ANSI erase line */
		if (compare("ANSIEL")) {
			printf("\033[K");
                }

                /* ANSI save cursor pos */
		if (compare("ANSISC")) {
			printf("\033[s");
                }

                /* ANSI restore cursor pos */
		if (compare("ANSIRC")) {
			printf("\033[u");
                }

		/*
		 * this example shows:
		 * - how to override existing keywords
		 * - how to hand the instruction to the
		 *   original interpreter if we don't want
		 *   to handle it
		 */
		if (compare("\222")) { /* 0x92 - WAIT */
			unsigned short a;
			unsigned char b;
			a = get_word();
			check_comma();
			b = get_byte();
			if (a==6502) {
				printf("MICROSOFT!");
				continue;
			} else {
				set_chrptr(chrptr);
				return 0;
			}
		}

		/*
		 * this example shows:
		 * - how to deal with new keywords that contain
		 *   existing keywords
		 * - how to parse a string
		 */
		if (compare("\236TEM")) {
			char s[256];

			get_string(s);
			system(s);

			continue;
		}

		if (compare("QUIT")) {
			exit(0);
		}
		break;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0xc6c0(%rip), %rbp      # 0x20140
incw 0x7a(%rbp)
leaq 0x9e00(%rip), %r13      # 0x1d88b
leaq 0xc696(%rip), %r15      # 0x20128
movzwl 0x7a(%rbp), %r12d
decl %r12d
movw %r12w, 0x7a(%rbp)
movq %r13, %rdi
callq 0x13a0c
testl %eax, %eax
je 0x13b18
callq 0x13e68
movl %eax, %r12d
leaq 0x1c686(%rip), %rax     # 0x30140
movw $0xaefd, (%rax)         # imm = 0xAEFD
movzbl (%r15), %eax
leal -0x1(%rax), %ecx
movb $-0x1, 0x100(%rbp,%rax)
addl $-0x2, %eax
movb %al, (%r15)
movzbl %cl, %eax
movb $-0x2, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
callq 0x13e68
leal -0x51(%rax), %ecx
cmpb $-0x50, %cl
jb 0x13e23
leal -0x1a(%r12), %ecx
cmpb $-0x1a, %cl
jbe 0x13e23
movzbl %r12b, %esi
movzbl %al, %edi
callq 0x13f26
jmp 0x13a92
leaq 0x9d73(%rip), %rdi      # 0x1d892
callq 0x13a0c
testl %eax, %eax
je 0x13c09
callq 0x13e68
movl %eax, %r12d
leaq 0x1c605(%rip), %rbx     # 0x30140
movw $0xaefd, %ax            # imm = 0xAEFD
movw %ax, (%rbx)
movzbl (%r15), %eax
leal -0x1(%rax), %ecx
movb $-0x1, %r15b
movb %r15b, 0x100(%rbp,%rax)
movb $-0x2, %r14b
addl %r14d, %eax
leaq 0xc5c7(%rip), %rdx      # 0x20128
movb %al, (%rdx)
movzbl %cl, %eax
movb %r14b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
callq 0x13e68
movl %eax, %r13d
movw $0xaefd, %ax            # imm = 0xAEFD
movw %ax, (%rbx)
leaq 0xc59b(%rip), %rax      # 0x20128
movzbl (%rax), %eax
leal -0x1(%rax), %ecx
movb %r15b, 0x100(%rbp,%rax)
leaq 0xc586(%rip), %r15      # 0x20128
addl %r14d, %eax
movb %al, (%r15)
movzbl %cl, %eax
movb %r14b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
callq 0x13e68
cmpb $0x9, %r12b
jae 0x13e23
leal -0x26(%r13), %ecx
cmpb $-0x9, %cl
jbe 0x13e23
leal -0x30(%rax), %ecx
cmpb $-0x9, %cl
jbe 0x13e23
movsbl %r12b, %esi
movsbl %r13b, %ecx
movzbl %al, %edx
leaq 0x9ca4(%rip), %rdi      # 0x1d89a
xorl %eax, %eax
callq 0x10c0
leaq 0x9c87(%rip), %r13      # 0x1d88b
jmp 0x13a92
leaq 0x9c96(%rip), %rdi      # 0x1d8a6
callq 0x13a0c
testl %eax, %eax
je 0x13c27
leaq 0x9c8d(%rip), %rdi      # 0x1d8ad
xorl %eax, %eax
callq 0x10c0
leaq 0x9c83(%rip), %rdi      # 0x1d8b1
callq 0x13a0c
testl %eax, %eax
movq %rsp, %r13
je 0x13c48
leaq 0x9c77(%rip), %rdi      # 0x1d8b8
xorl %eax, %eax
callq 0x10c0
leaq 0x9c6d(%rip), %rdi      # 0x1d8bc
callq 0x13a0c
testl %eax, %eax
je 0x13c66
leaq 0x9c64(%rip), %rdi      # 0x1d8c3
xorl %eax, %eax
callq 0x10c0
leaq 0x9c5a(%rip), %rdi      # 0x1d8c7
callq 0x13a0c
testl %eax, %eax
jne 0x13d62
leaq 0x9c53(%rip), %rdi      # 0x1d8d4
callq 0x13a0c
testl %eax, %eax
je 0x13e4a
leaq 0x1c4ab(%rip), %rbx     # 0x30140
movw $0xad9e, (%rbx)         # imm = 0xAD9E
movzbl (%r15), %eax
leal -0x1(%rax), %ecx
movb $-0x1, %r15b
movb %r15b, 0x100(%rbp,%rax)
movb $-0x2, %r14b
addl %r14d, %eax
leaq 0xc46f(%rip), %rdx      # 0x20128
movb %al, (%rdx)
movzbl %cl, %eax
movb %r14b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
movw $0xb6a3, (%rbx)         # imm = 0xB6A3
leaq 0xc44d(%rip), %rax      # 0x20128
movzbl (%rax), %eax
leal -0x1(%rax), %ecx
movb %r15b, 0x100(%rbp,%rax)
leaq 0xc438(%rip), %r15      # 0x20128
addl %r14d, %eax
movb %al, (%r15)
movzbl %cl, %eax
movb %r14b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
leaq 0x1c434(%rip), %rax     # 0x30145
movzbl (%rax), %r12d
movl $0x0, %eax
testq %r12, %r12
je 0x13d4a
leaq 0x1c41c(%rip), %rax     # 0x30142
movzbl (%rax), %eax
leaq 0x1c418(%rip), %rcx     # 0x30148
movzbl (%rcx), %esi
shll $0x8, %esi
orq %rax, %rsi
addq %rbp, %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x1180
movq %r12, %rax
movb $0x0, (%rsp,%rax)
movq %r13, %rdi
callq 0x10b0
leaq 0x9b2e(%rip), %r13      # 0x1d88b
jmp 0x13a92
leaq 0x1c3d7(%rip), %rbx     # 0x30140
movw $0xad8a, (%rbx)         # imm = 0xAD8A
movzbl (%r15), %eax
leal -0x1(%rax), %ecx
movb $-0x1, %dl
movb %dl, 0x100(%rbp,%rax)
movb $-0x1, %r13b
movq %r15, %r14
movb $-0x2, %r15b
addl %r15d, %eax
movb %al, (%r14)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
movw $0xb7f7, (%rbx)         # imm = 0xB7F7
movzbl (%r14), %eax
leal -0x1(%rax), %ecx
movb %r13b, 0x100(%rbp,%rax)
addl %r15d, %eax
movb %al, (%r14)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
movzwl 0x14(%rbp), %r13d
movw $0xaefd, (%rbx)         # imm = 0xAEFD
movzbl (%r14), %eax
leal -0x1(%rax), %ecx
movb $-0x1, %dl
movb %dl, 0x100(%rbp,%rax)
addl %r15d, %eax
movb %al, (%r14)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
callq 0x13e68
cmpw $0x1966, %r13w          # imm = 0x1966
jne 0x13e43
leaq 0x9ab2(%rip), %rdi      # 0x1d8c9
xorl %eax, %eax
callq 0x10c0
jmp 0x13a84
leaq 0x1c318(%rip), %rax     # 0x30142
movb $0xe, (%rax)
movw $0xa437, %ax            # imm = 0xA437
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movw %r12w, 0x7a(%rbp)
jmp 0x13e5a
leaq 0x9a88(%rip), %rdi      # 0x1d8d9
callq 0x13a0c
testl %eax, %eax
jne 0x13e5e
xorl %eax, %eax
jmp 0x13e31
xorl %edi, %edi
callq 0x1200