// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
callq 0x3e480
movzwl %ax, %eax
addl $0x1, %eax
movzwl %ax, %edi
callq 0x3e0c0
callq 0x3e480
movzwl %ax, %eax
subl $0x1, %eax
movzwl %ax, %edi
callq 0x3e0c0
callq 0x3e480
movw %ax, -0x4(%rbp)
leaq 0x19cf(%rip), %rdi      # 0x3fb50
callq 0x3e040
cmpl $0x0, %eax
je 0x3e1e9
callq 0x3e4b0
movb %al, -0x6(%rbp)
callq 0x3e560
callq 0x3e4b0
movb %al, -0x5(%rbp)
movzbl -0x5(%rbp), %eax
cmpl $0x50, %eax
jg 0x3e1c4
movzbl -0x6(%rbp), %eax
cmpl $0x19, %eax
jg 0x3e1c4
movzbl -0x5(%rbp), %eax
cmpl $0x0, %eax
je 0x3e1c4
movzbl -0x6(%rbp), %eax
cmpl $0x0, %eax
jne 0x3e1d7
movl $0xe, %edi
callq 0x3e3c0
movw %ax, -0x2(%rbp)
jmp 0x3e3af
movzbl -0x5(%rbp), %edi
movzbl -0x6(%rbp), %esi
callq 0x3e650
jmp 0x3e15e
leaq 0x1967(%rip), %rdi      # 0x3fb57
callq 0x3e040
cmpl $0x0, %eax
je 0x3e2ae
callq 0x3e4b0
movb %al, -0x7(%rbp)
callq 0x3e560
callq 0x3e4b0
movb %al, -0x8(%rbp)
callq 0x3e560
callq 0x3e4b0
movb %al, -0x9(%rbp)
movsbl -0x7(%rbp), %eax
cmpl $0x0, %eax
jl 0x3e232
movsbl -0x7(%rbp), %eax
cmpl $0x8, %eax
jle 0x3e245
movl $0xe, %edi
callq 0x3e3c0
movw %ax, -0x2(%rbp)
jmp 0x3e3af
movsbl -0x8(%rbp), %eax
cmpl $0x1e, %eax
jl 0x3e257
movsbl -0x8(%rbp), %eax
cmpl $0x25, %eax
jle 0x3e26a
movl $0xe, %edi
callq 0x3e3c0
movw %ax, -0x2(%rbp)
jmp 0x3e3af
movsbl -0x9(%rbp), %eax
cmpl $0x28, %eax
jl 0x3e27c
movsbl -0x9(%rbp), %eax
cmpl $0x2f, %eax
jle 0x3e28f
movl $0xe, %edi
callq 0x3e3c0
movw %ax, -0x2(%rbp)
jmp 0x3e3af
movsbl -0x7(%rbp), %esi
movsbl -0x9(%rbp), %edx
movsbl -0x8(%rbp), %ecx
leaq 0x18bd(%rip), %rdi      # 0x3fb5f
movb $0x0, %al
callq 0x10b0
jmp 0x3e15e
leaq 0x18b6(%rip), %rdi      # 0x3fb6b
callq 0x3e040
cmpl $0x0, %eax
je 0x3e2cd
leaq 0x18ac(%rip), %rdi      # 0x3fb72
movb $0x0, %al
callq 0x10b0
leaq 0x18a2(%rip), %rdi      # 0x3fb76
callq 0x3e040
cmpl $0x0, %eax
je 0x3e2ec
leaq 0x1898(%rip), %rdi      # 0x3fb7d
movb $0x0, %al
callq 0x10b0
leaq 0x188e(%rip), %rdi      # 0x3fb81
callq 0x3e040
cmpl $0x0, %eax
je 0x3e30b
leaq 0x1884(%rip), %rdi      # 0x3fb88
movb $0x0, %al
callq 0x10b0
leaq 0x187a(%rip), %rdi      # 0x3fb8c
callq 0x3e040
cmpl $0x0, %eax
je 0x3e361
callq 0x3e570
movw %ax, -0xc(%rbp)
callq 0x3e560
callq 0x3e4b0
movb %al, -0xd(%rbp)
movzwl -0xc(%rbp), %eax
cmpl $0x1966, %eax           # imm = 0x1966
jne 0x3e350
leaq 0x184a(%rip), %rdi      # 0x3fb8e
movb $0x0, %al
callq 0x10b0
jmp 0x3e15e
movzwl -0x4(%rbp), %edi
callq 0x3e0c0
movw $0x0, -0x2(%rbp)
jmp 0x3e3af
leaq 0x1831(%rip), %rdi      # 0x3fb99
callq 0x3e040
cmpl $0x0, %eax
je 0x3e38f
leaq -0x110(%rbp), %rdi
callq 0x3e3e0
leaq -0x110(%rbp), %rdi
callq 0x10a0
jmp 0x3e15e
leaq 0x1808(%rip), %rdi      # 0x3fb9e
callq 0x3e040
cmpl $0x0, %eax
je 0x3e3a7
xorl %edi, %edi
callq 0x11f0
jmp 0x3e3a9
movw $0x0, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax)