// File: /workspace/github_c_makefile_star2_O1/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 $0x118, %rsp            # imm = 0x118
leaq 0xb62c(%rip), %rbp      # 0x21140
incw 0x7a(%rbp)
leaq 0x9cfc(%rip), %rbx      # 0x1f81b
leaq 0x1b61c(%rip), %r14     # 0x31142
movzwl 0x7a(%rbp), %r12d
decl %r12d
movw %r12w, 0x7a(%rbp)
movq %rbx, %rdi
callq 0x15a90
testl %eax, %eax
je 0x15b7f
callq 0x15e85
movl %eax, %r12d
callq 0x15ed2
callq 0x15e85
leal -0x51(%rax), %ecx
cmpb $-0x50, %cl
setb %cl
leal -0x1a(%r12), %edx
cmpb $-0x19, %dl
setb %dl
orb %cl, %dl
cmpb $0x1, %dl
je 0x15bc9
movzbl %r12b, %esi
movzbl %al, %edi
callq 0x15f82
movl $0x3, %ecx
jmp 0x15bd7
leaq 0x9c9c(%rip), %rdi      # 0x1f822
callq 0x15a90
testl %eax, %eax
je 0x15be5
callq 0x15e85
movl %eax, %r12d
callq 0x15ed2
callq 0x15e85
movl %eax, %r13d
callq 0x15ed2
callq 0x15e85
cmpb $0x9, %r12b
jae 0x15bc9
leal -0x26(%r13), %ecx
cmpb $-0x9, %cl
jbe 0x15bc9
leal -0x30(%rax), %ecx
cmpb $-0x9, %cl
ja 0x15e1b
movb $0xe, (%r14)
movw $0xa437, %r15w          # imm = 0xA437
movl $0x1, %ecx
cmpl $0x3, %ecx
je 0x15b26
jmp 0x15e65
leaq 0x9c4a(%rip), %rdi      # 0x1f836
callq 0x15a90
testl %eax, %eax
je 0x15c03
leaq 0x9c41(%rip), %rdi      # 0x1f83d
xorl %eax, %eax
callq 0x10c0
leaq 0x9c37(%rip), %rdi      # 0x1f841
callq 0x15a90
testl %eax, %eax
je 0x15c21
leaq 0x9c2e(%rip), %rdi      # 0x1f848
xorl %eax, %eax
callq 0x10c0
leaq 0x9c24(%rip), %rdi      # 0x1f84c
callq 0x15a90
testl %eax, %eax
je 0x15c3f
leaq 0x9c1b(%rip), %rdi      # 0x1f853
xorl %eax, %eax
callq 0x10c0
movl %r15d, 0xc(%rsp)
leaq 0x9c0c(%rip), %rdi      # 0x1f857
callq 0x15a90
testl %eax, %eax
je 0x15d0b
leaq 0x1b4e1(%rip), %r13     # 0x31140
movw $0xad8a, (%r13)         # imm = 0xAD8A
leaq 0xb4bb(%rip), %rbx      # 0x21128
movzbl (%rbx), %eax
leal -0x1(%rax), %ecx
movb $-0x1, %r14b
movb %r14b, 0x100(%rbp,%rax)
movb $-0x2, %r15b
addl %r15d, %eax
movb %al, (%rbx)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
movw $0xb7f7, (%r13)         # imm = 0xB7F7
movzbl (%rbx), %eax
leal -0x1(%rax), %ecx
movb %cl, (%rbx)
movb %r14b, 0x100(%rbp,%rax)
addl %r15d, %eax
movb %al, (%rbx)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
movzwl 0x14(%rbp), %r13d
callq 0x15ed2
callq 0x15e85
cmpw $0x1966, %r13w          # imm = 0x1966
jne 0x15df3
leaq 0x9b6d(%rip), %rdi      # 0x1f859
xorl %eax, %eax
callq 0x10c0
movl $0x3, %ecx
leaq 0x9b1c(%rip), %rbx      # 0x1f81b
leaq 0x1b43c(%rip), %r14     # 0x31142
jmp 0x15de9
leaq 0x9b52(%rip), %rdi      # 0x1f864
callq 0x15a90
testl %eax, %eax
je 0x15e39
leaq 0x1b41a(%rip), %r12     # 0x31140
movw $0xad9e, (%r12)         # imm = 0xAD9E
leaq 0xb3f4(%rip), %rbx      # 0x21128
movzbl (%rbx), %eax
leal -0x1(%rax), %ecx
movb $-0x1, %r14b
movb %r14b, 0x100(%rbp,%rax)
movb $-0x2, %r15b
addl %r15d, %eax
movb %al, (%rbx)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
movw $0xb6a3, (%r12)         # imm = 0xB6A3
movzbl (%rbx), %eax
leal -0x1(%rax), %ecx
movb %cl, (%rbx)
movb %r14b, 0x100(%rbp,%rax)
leaq 0x1b3c3(%rip), %r14     # 0x31142
addl %r15d, %eax
movb %al, (%rbx)
movzbl %cl, %eax
movb %r15b, 0x100(%rbp,%rax)
xorl %edi, %edi
xorl %esi, %esi
callq 0x132c
leaq 0x1b3a6(%rip), %rax     # 0x31145
movzbl (%rax), %r12d
testq %r12, %r12
leaq 0x10(%rsp), %rbx
je 0x15dcf
movzbl (%r14), %eax
leaq 0x1b390(%rip), %rcx     # 0x31148
movzbl (%rcx), %esi
shll $0x8, %esi
orq %rax, %rsi
addq %rbp, %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x1180
movb $0x0, 0x10(%rsp,%r12)
movq %rbx, %rdi
callq 0x10b0
movl $0x3, %ecx
leaq 0x9a32(%rip), %rbx      # 0x1f81b
movl 0xc(%rsp), %r15d
jmp 0x15bd7
movl %r12d, %eax
shrl $0x8, %eax
movb %r12b, 0x7a(%rbp)
movb %al, 0x7b(%rbp)
movl $0x1, %ecx
xorl %r15d, %r15d
leaq 0x9a0c(%rip), %rbx      # 0x1f81b
leaq 0x1b32c(%rip), %r14     # 0x31142
jmp 0x15bd7
movsbl %r12b, %esi
movsbl %r13b, %ecx
movzbl %al, %edx
leaq 0x99fd(%rip), %rdi      # 0x1f82a
xorl %eax, %eax
callq 0x10c0
jmp 0x15b78
leaq 0x9a29(%rip), %rdi      # 0x1f869
callq 0x15a90
movl $0x2, %ecx
testl %eax, %eax
leaq 0x99c8(%rip), %rbx      # 0x1f81b
movl 0xc(%rsp), %r15d
je 0x15bd7
xorl %edi, %edi
callq 0x1200
cmpl $0x1, %ecx
je 0x15e6d
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq