// File: /workspace/github_c_makefile_star2_O2/goodpaul6[P]generic/script.c
// Function: get_token
static int get_token(char reset)
{
	static int last = ' ';
	
	if(reset)
	{
		last = ' ';
		return 0;
	}
	
	while(isspace(last))
	{
		if(last == '\n') ++g_line;
		last = get_char();
	}
	
	// TODO: check for buffer overflow	
	if(isalpha(last) || last == '_' || last == '#')
	{
		int i = 0;
		while(isalnum(last) || last == '_' || last == '#')
		{
			g_lexeme[i++] = last;
			last = get_char();
		}
		g_lexeme[i] = '\0';
		
		if(g_lexeme[0] == '#') return TOK_DIRECTIVE;
		
		if (strcmp(g_lexeme, "atomic") == 0) return TOK_ATOMIC;
		if(strcmp(g_lexeme, "using") == 0) return TOK_USING;
		if(strcmp(g_lexeme, "static") == 0) return TOK_STATIC;
		if(strcmp(g_lexeme, "null") == 0) return TOK_NULL;
		if(strcmp(g_lexeme, "new") == 0) return TOK_NEW;
		if(strcmp(g_lexeme, "union") == 0) return TOK_UNION;
		if(strcmp(g_lexeme, "struct") == 0) return TOK_STRUCT;
		if(strcmp(g_lexeme, "extern") == 0) return TOK_EXTERN;
		if(strcmp(g_lexeme, "true") == 0) return TOK_TRUE;
		if(strcmp(g_lexeme, "false") == 0) return TOK_FALSE;
		if(strcmp(g_lexeme, "while") == 0) return TOK_WHILE;
		if (strcmp(g_lexeme, "for") == 0) return TOK_FOR;
		if(strcmp(g_lexeme, "else") == 0) return TOK_ELSE;
		if(strcmp(g_lexeme, "if") == 0) return TOK_IF;
		if(strcmp(g_lexeme, "return") == 0) return TOK_RETURN;
		if(strcmp(g_lexeme, "func") == 0) return TOK_FUNC;
		if(strcmp(g_lexeme, "var") == 0) return TOK_VAR;
		if(strcmp(g_lexeme, "read") == 0) return TOK_READ;
		if(strcmp(g_lexeme, "write") == 0) return TOK_WRITE;
		if(strcmp(g_lexeme, "len") == 0) return TOK_LEN;
		
		return TOK_IDENT;
	}
	
	if(isdigit(last))
	{
		int i = 0;
		while(isdigit(last) || last == '-' || last == '.')
		{
			g_lexeme[i++] = last;
			last = get_char();
		}
		g_lexeme[i] = '\0';
		
		return TOK_NUMBER;
	}
	
	if(last == '"')
	{
		last = get_char();
		
		int i = 0;
		while(last != '"')
		{
			if (last == '\\')
			{
				last = get_char();
				switch (last)
				{
					case 'n': last = '\n'; break;
					case 't': last = '\t'; break;
					case '0': last = '\0'; break;
					case 'b': last = '\b'; break;
					case 'r': last = '\r'; break;
					case '\'': last = '\''; break;
					case '"': last = '"'; break;
					case '\\': last = '\\'; break;
					case '\n':
					case '\r':
					{
						while (isspace(last)) 
						{
							if (last == '\n') 
								++g_line;

							last = get_char();
						}
					} break;
					default:
						error_exit("invalid escape sequence char %c\n", last);
						break;
				}
			}

			g_lexeme[i++] = last;
			last = get_char();
		}
		last = get_char();
		
		g_lexeme[i] = '\0';
		
		return TOK_STRING;
	}
	
	if(last == '\'')
	{
		last = get_char();
		if (last == '\\')
		{
			last = get_char();
			switch (last)
			{
				case 'n': last = '\n'; break;
				case 't': last = '\t'; break;
				case '0': last = '\0'; break;
				case 'b': last = '\b'; break;
				case 'r': last = '\r'; break;
				case '\'': last = '\''; break;
				case '"': last = '"'; break;
				case '\\': last = '\\'; break;
				case '\n':
				case '\r':
				{
					while (isspace(last))
					{
						if (last == '\n')
							++g_line;

						last = get_char();
					}
				} break;
			}
		}
		g_lexeme[0] = last;
		g_lexeme[1] = '\0';
		last = get_char();
		if(last != '\'') error_exit_p("Expected ' after %c\n", g_lexeme[0]);
		last = get_char();
		
		return TOK_CHAR; 
	}
	
	if(last == EOF)
		return TOK_EOF;
	
	int last_char = last;
	last = get_char();
	
	if(last_char == '!')
	{
		if(last == '=')
		{
			last = get_char();
			return TOK_NOTEQUAL;
		}
		
		return TOK_NOT;
	}
	
	if(last_char == '&' && last == '&')
	{
		last = get_char();
		return TOK_LAND;
	}
	
	if(last_char == '|' && last == '|')
	{
		last = get_char();
		return TOK_LOR;
	}
	
	if(last_char == '/' && last == '/')
	{
		last = get_char();
		while(last != '\n' || last == EOF) last = get_char();
		return get_token(0);
	}
	
	if(last_char == '.') return TOK_DOT;
	
	if(last_char == ';') return TOK_SEMICOLON;
	
	if(last_char == '[') return TOK_OPENSQUARE;
	if(last_char == ']') return TOK_CLOSESQUARE;
	
	if(last_char == '(') return TOK_OPENPAREN;
	if(last_char == ')') return TOK_CLOSEPAREN;
	
	if(last_char == '{') return TOK_OPENCURLY;
	if(last_char == '}') return TOK_CLOSECURLY;
	
	if(last_char == ':') return TOK_COLON;
	
	if(last_char == ',') return TOK_COMMA;
	
	if(last_char == '+') return TOK_PLUS;
	if(last_char == '-') return TOK_MINUS;
	if(last_char == '*') return TOK_MUL;
	if(last_char == '/') return TOK_DIV;
	if (last_char == '%') return TOK_MOD;
	
	// NOTE: order of checking these is important
	if(last_char == '=' && last == '=')
	{
		last = get_char();
		return TOK_EQUALS;
	}
	
	if(last_char == '<' && last == '=')
	{
		last = get_char();
		return TOK_LTE;
	}
	if(last_char == '>' && last == '=')
	{
		last = get_char();
		return TOK_GTE;
	}
	
	if(last_char == '=') return TOK_ASSIGN;
	if(last_char == '<') return TOK_LT;
	if(last_char == '>') return TOK_GT;
	
	error_exit_p("Unexpected character '%c'\n", last_char);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0xb0d3(%rip), %r14d     # 0x14160
movl 0xb0bc(%rip), %r15d     # 0x14150
testb %dil, %dil
sete %al
pushq $0xa
popq %r12
testb $0x1, %al
je 0x9273
callq 0x2270
movq %rax, %rbx
movq (%rbx), %rax
movslq %r14d, %rcx
movzwl (%rax,%rcx,2), %eax
movzwl %ax, %eax
btl $0xd, %eax
jae 0x90e1
cmpl $0xa, %r14d
jne 0x90d1
incl %r15d
movl %r15d, 0xb07f(%rip)     # 0x14150
callq 0x97fa
movl %eax, %r14d
movl %eax, 0xb081(%rip)      # 0x14160
jmp 0x90ae
btl $0xa, %eax
jb 0x9193
cmpl $0x5f, %r14d
je 0x9193
cmpl $0x23, %r14d
je 0x9193
btl $0xb, %eax
jb 0x9284
cmpl $-0x1, %r14d
je 0x92ce
cmpl $0x27, %r14d
je 0x9376
cmpl $0x22, %r14d
je 0x92d5
callq 0x97fa
movl %eax, 0xb02e(%rip)      # 0x14160
cmpl $0x21, %r14d
je 0x940b
movl %r14d, %ecx
xorl $0x26, %ecx
movl %eax, %edx
xorl $0x26, %edx
orl %ecx, %edx
je 0x9422
movl %r14d, %ecx
xorl $0x7c, %ecx
movl %eax, %edx
xorl $0x7c, %edx
orl %ecx, %edx
je 0x9434
cmpl $0x2f, %r14d
jne 0x9446
cmpl $0x2f, %eax
jne 0x9446
callq 0x97fa
cmpl $0xa, %eax
jne 0x9175
movl $0xa, 0xafd7(%rip)      # 0x14160
movb $0x1, %al
movl %r12d, %r14d
jmp 0x909e
xorl %r12d, %r12d
leaq 0xb1d3(%rip), %r15      # 0x14370
testb $0x8, %al
jne 0x91ad
cmpl $0x5f, %r14d
je 0x91ad
cmpl $0x23, %r14d
jne 0x91ce
movb %r14b, (%r12,%r15)
incq %r12
callq 0x97fa
movl %eax, %r14d
movl %eax, 0xaf9e(%rip)      # 0x14160
movq (%rbx), %rax
movslq %r14d, %rcx
movzwl (%rax,%rcx,2), %eax
jmp 0x919d
movl %r12d, %eax
movb $0x0, (%rax,%r15)
cmpb $0x23, 0xb193(%rip)     # 0x14370
jne 0x91e6
pushq $0x1
jmp 0x95e4
leaq 0xb183(%rip), %rdi      # 0x14370
leaq 0x5a1b(%rip), %rsi      # 0xec0f
pushq $0x7
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x927d
leaq 0xb169(%rip), %rdi      # 0x14370
leaq 0x5a0a(%rip), %rsi      # 0xec18
pushq $0x6
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x946d
leaq 0xb14b(%rip), %rdi      # 0x14370
leaq 0x59f2(%rip), %rsi      # 0xec1e
pushq $0x7
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x94a3
leaq 0xb12d(%rip), %rdi      # 0x14370
leaq 0x59db(%rip), %rsi      # 0xec25
pushq $0x5
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x94aa
movl 0xb110(%rip), %ebx      # 0x14370
cmpl $0x77656e, %ebx         # imm = 0x77656E
jne 0x94b1
pushq $0x5
jmp 0x95e4
movl $0x20, 0xaee3(%rip)     # 0x14160
xorl %eax, %eax
jmp 0x95e5
xorl %r12d, %r12d
leaq 0xb0e2(%rip), %r15      # 0x14370
leal -0x2d(%r14), %ecx
cmpl $0x2, %ecx
jb 0x929e
andl $0x800, %eax            # imm = 0x800
je 0x92bf
movb %r14b, (%r12,%r15)
incq %r12
callq 0x97fa
movl %eax, %r14d
movl %eax, 0xaead(%rip)      # 0x14160
movq (%rbx), %rax
movslq %r14d, %rcx
movzwl (%rax,%rcx,2), %eax
jmp 0x928e
movl %r12d, %eax
movb $0x0, (%rax,%r15)
pushq $0x21
jmp 0x95e4
pushq $0x32
jmp 0x95e4
xorl %r14d, %r14d
pushq $0xd
popq %r13
leaq 0xb08d(%rip), %r12      # 0x14370
callq 0x97fa
cmpl $0x5c, %eax
je 0x92f7
cmpl $0x22, %eax
jne 0x936a
jmp 0x93f1
callq 0x97fa
cmpl $0xa, %eax
je 0x9347
cmpl $0x74, %eax
je 0x935f
cmpl $0x22, %eax
je 0x936a
cmpl $0x27, %eax
je 0x936a
cmpl $0x30, %eax
je 0x9368
cmpl $0x5c, %eax
je 0x936a
cmpl $0x62, %eax
je 0x935b
cmpl $0x6e, %eax
je 0x9363
cmpl $0x72, %eax
je 0x9356
cmpl $0xd, %eax
je 0x9347
jmp 0x97a2
cmpl $0xa, %eax
jne 0x9342
incl %r15d
movl %r15d, 0xae0e(%rip)     # 0x14150
callq 0x97fa
movq (%rbx), %rcx
movslq %eax, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x9333
jmp 0x936a
movl %r13d, %eax
jmp 0x936a
pushq $0x8
jmp 0x9365
pushq $0x9
jmp 0x9365
pushq $0xa
popq %rax
jmp 0x936a
xorl %eax, %eax
movb %al, (%r14,%r12)
incq %r14
jmp 0x92e3
callq 0x97fa
cmpl $0x5c, %eax
jne 0x95b6
callq 0x97fa
cmpl $0xa, %eax
je 0x93df
cmpl $0x74, %eax
je 0x95b3
cmpl $0x30, %eax
je 0x95af
cmpl $0x62, %eax
je 0x95a3
cmpl $0x6e, %eax
je 0x95ab
cmpl $0x72, %eax
je 0x95a7
cmpl $0xd, %eax
je 0x93df
jmp 0x95b6
cmpl $0xa, %eax
jne 0x93d4
incl %r15d
movl %r15d, 0xad7c(%rip)     # 0x14150
callq 0x97fa
movl %eax, 0xad81(%rip)      # 0x14160
movq (%rbx), %rcx
movslq %eax, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x93c5
jmp 0x95b6
callq 0x97fa
movl %eax, 0xad64(%rip)      # 0x14160
movl %r14d, %eax
movb $0x0, (%rax,%r12)
pushq $0x22
jmp 0x95e4
cmpl $0x3d, %eax
jne 0x9466
callq 0x97fa
movl %eax, 0xad45(%rip)      # 0x14160
pushq $0x31
jmp 0x95e4
callq 0x97fa
movl %eax, 0xad33(%rip)      # 0x14160
pushq $0x2e
jmp 0x95e4
callq 0x97fa
movl %eax, 0xad21(%rip)      # 0x14160
pushq $0x2f
jmp 0x95e4
leal -0x28(%r14), %ecx
cmpl $0x13, %ecx
ja 0x9474
leaq 0x3f62(%rip), %rdx      # 0xd3b8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
pushq $0x19
jmp 0x95e4
pushq $0x23
jmp 0x95e4
pushq $0x2
jmp 0x95e4
cmpl $0x5b, %r14d
je 0x95f4
cmpl $0x5d, %r14d
je 0x95fc
cmpl $0x7b, %r14d
je 0x95f8
cmpl $0x7d, %r14d
jne 0x9575
pushq $0x1c
jmp 0x95e4
pushq $0x3
jmp 0x95e4
pushq $0x4
jmp 0x95e4
leaq 0xaeb8(%rip), %rdi      # 0x14370
leaq 0x5776(%rip), %rsi      # 0xec35
pushq $0x6
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9600
leaq 0xae9a(%rip), %rdi      # 0x14370
leaq 0x5751(%rip), %rsi      # 0xec2e
pushq $0x7
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x960e
leaq 0xae7c(%rip), %rdi      # 0x14370
leaq 0x5740(%rip), %rsi      # 0xec3b
pushq $0x7
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x962e
leaq 0xae5e(%rip), %rdi      # 0x14370
leaq 0x5733(%rip), %rsi      # 0xec4c
pushq $0x5
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9632
leaq 0xae40(%rip), %rdi      # 0x14370
leaq 0x571a(%rip), %rsi      # 0xec51
pushq $0x6
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x964f
leaq 0xae22(%rip), %rdi      # 0x14370
leaq 0x5702(%rip), %rsi      # 0xec57
pushq $0x6
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9673
cmpl $0x726f66, %ebx         # imm = 0x726F66
jne 0x967a
pushq $0xd
jmp 0x95e4
cmpl $0x2f, %r14d
jne 0x9604
pushq $0x28
jmp 0x95e4
pushq $0x1f
jmp 0x95e4
pushq $0x26
jmp 0x95e4
pushq $0x25
jmp 0x95e4
pushq $0x27
jmp 0x95e4
pushq $0x1a
jmp 0x95e4
pushq $0x20
jmp 0x95e4
pushq $0x1e
jmp 0x95e4
pushq $0x1d
jmp 0x95e4
pushq $0x8
jmp 0x95b5
pushq $0xd
jmp 0x95b5
pushq $0xa
jmp 0x95b5
xorl %eax, %eax
jmp 0x95b6
pushq $0x9
popq %rax
movb %al, 0xadb4(%rip)       # 0x14370
movb $0x0, 0xadae(%rip)      # 0x14371
callq 0x97fa
movl %eax, 0xab92(%rip)      # 0x14160
cmpl $0x27, %eax
jne 0x97b8
callq 0x97fa
movl %eax, 0xab7e(%rip)      # 0x14160
pushq $0x9
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x17
jmp 0x95e4
pushq $0x1b
jmp 0x95e4
pushq $0x18
jmp 0x95e4
pushq $0x7
jmp 0x95e4
cmpl $0x25, %r14d
jne 0x9612
pushq $0x29
jmp 0x95e4
pushq $0x6
jmp 0x95e4
movl %r14d, %ecx
xorl $0x3d, %ecx
xorl $0x3d, %eax
orl %eax, %ecx
jne 0x9636
callq 0x97fa
movl %eax, 0xab36(%rip)      # 0x14160
pushq $0x30
jmp 0x95e4
pushq $0x8
jmp 0x95e4
pushq $0xa
jmp 0x95e4
movl %r14d, %ecx
xorl $0x3c, %ecx
orl %eax, %ecx
jne 0x9653
callq 0x97fa
movl %eax, 0xab15(%rip)      # 0x14160
pushq $0x2c
jmp 0x95e4
pushq $0xb
jmp 0x95e4
movl %r14d, %ecx
xorl $0x3e, %ecx
orl %eax, %ecx
jne 0x96f9
callq 0x97fa
movl %eax, 0xaaf4(%rip)      # 0x14160
pushq $0x2d
jmp 0x95e4
pushq $0xc
jmp 0x95e4
leaq 0xacef(%rip), %rdi      # 0x14370
leaq 0x55d9(%rip), %rsi      # 0xec61
pushq $0x5
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9731
leaq 0xacd1(%rip), %rdi      # 0x14370
leaq 0x55c0(%rip), %rsi      # 0xec66
pushq $0x3
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9738
leaq 0xacb3(%rip), %rdi      # 0x14370
leaq 0x55a5(%rip), %rsi      # 0xec69
pushq $0x7
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x973f
leaq 0xac99(%rip), %rdi      # 0x14370
leaq 0x506a(%rip), %rsi      # 0xe748
pushq $0x5
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9746
cmpl $0x726176, %ebx         # imm = 0x726176
jne 0x974d
pushq $0x12
jmp 0x95e4
movl %r14d, %eax
andl $-0x2, %eax
cmpl $0x3d, %r14d
pushq $0x24
popq %rcx
pushq $0x2a
popq %rdx
cmovel %ecx, %edx
cmpl $0x3c, %eax
pushq $0x2b
popq %rax
cmovel %edx, %eax
leal -0x3c(%r14), %ecx
cmpl $0x3, %ecx
jb 0x95e5
leaq 0x5701(%rip), %rdi      # 0xee2a
movl %r14d, %esi
jmp 0x97c6
pushq $0xe
jmp 0x95e4
pushq $0xf
jmp 0x95e4
pushq $0x10
jmp 0x95e4
pushq $0x11
jmp 0x95e4
leaq 0xac1c(%rip), %rdi      # 0x14370
leaq 0x5519(%rip), %rsi      # 0xec74
pushq $0x5
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x9794
leaq 0xac02(%rip), %rdi      # 0x14370
leaq 0x5504(%rip), %rsi      # 0xec79
pushq $0x6
popq %rdx
callq 0x21c0
testl %eax, %eax
je 0x979b
xorl %eax, %eax
cmpl $0x6e656c, %ebx         # imm = 0x6E656C
setne %al
addl $0x15, %eax
jmp 0x95e5
pushq $0x13
jmp 0x95e4
pushq $0x14
jmp 0x95e4
movl %eax, 0xa9b8(%rip)      # 0x14160
leaq 0x5645(%rip), %rdi      # 0xedf4
movl %eax, %esi
xorl %eax, %eax
callq 0x34e8
movsbl 0xabb1(%rip), %esi      # 0x14370
leaq 0x564f(%rip), %rdi      # 0xee15
xorl %eax, %eax
callq 0x78e4