// File: /workspace/github_c_makefile_star2_O1/martincameron[P]towntalk/towntalk.c
// Function: validate_syntax
struct element* validate_syntax( char *syntax, struct element *elem,
	struct element *prev, struct environment *env, char *message ) {
	int idx = 1, chr = syntax[ 0 ];
	struct element *next;
	while( message[ 0 ] == 0 ) {
		switch( chr ) {
			case 0:
				return elem;
			case '0': /* List end. */
				if( elem ) {
					sprintf( message, "Unexpected '%.64s' after '%.64s' on line %d.", elem->str.string, prev->str.string, elem->line );
				}
				break;
			case '"': case ',': case ';': case '=': case '{':
				/* Strings, separators or blocks. */
				if( elem && elem->str.string[ 0 ] == chr ) {
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected '%c' after '%.64s' on line %d.", chr, prev->str.string, prev->line );
				}
				break;
			case '(': /* Bracketed function parameter list. */
				if( elem && elem->str.string[ 0 ] == '(' ) {
					if( elem->child ) {
						validate_syntax( "P0", elem->child, elem, env, message );
					}
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected '(' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case '[': /* Index expression. */
				if( elem && elem->str.string[ 0 ] == '[' ) {
					if( elem->child ) {
						validate_syntax( "xx0", elem->child, elem, env, message );
						prev = elem;
						elem = elem->next;
					} else {
						sprintf( message, "Invalid index expression after '%.64s' on line %d.", prev->str.string, elem->line );
					}
				} else {
					sprintf( message, "Expected '[' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'c': /* Catch or finally. */
				if( elem && ( is_keyword( elem->str.string, "catch" ) || is_keyword( elem->str.string, "finally" ) ) ) {
					chr = elem->str.string[ 0 ];
					prev = elem;
					elem = elem->next;
					if( strchr( "Cc", chr ) ) {
						if( elem && elem->str.string[ 0 ] == '(' ) {
							validate_syntax( "n0", elem->child, elem, env, message );
							prev = elem->child;
							elem = elem->next;
						}
						if( message[ 0 ] == 0 ) {
							next = validate_syntax( "n", elem, prev, env, message );
							prev = elem;
							elem = next;
						}
					}
					if( message[ 0 ] == 0 ) {
						next = validate_syntax( "{", elem, prev, env, message );
						prev = elem;
						elem = next;
						if( message[ 0 ] == 0 && elem
						&& ( is_keyword( elem->str.string, "catch" ) || is_keyword( elem->str.string, "finally" ) ) ) {
							prev = elem;
							elem = validate_syntax( "c", elem, prev, env, message );
						}
					}
				} else {
					sprintf( message, "Expected 'catch' or 'finally' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'f': /* From. */
				if( elem && is_keyword( elem->str.string, "from" ) ) {
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected 'from' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'n': /* Name. */
				if( elem && elem->str.string[ 0 ] != ';' ) {
					validate_name( elem, message );
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected name after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'P': /* Function parameter list. */
				while( message[ 0 ] == 0 && elem ) {
					if( elem && elem->str.string[ 0 ] == '(' ) {
						validate_syntax( "n0", elem->child, elem, env, message );
						prev = elem->child;
						elem = elem->next;
					}
					if( message[ 0 ] == 0 ) {
						next = validate_syntax( "n", elem, prev, env, message );
						prev = elem;
						elem = next;
						if( elem && elem->str.string[ 0 ] == ',' && elem->next ) {
							prev = elem;
							elem = elem->next;
						}
					}
				}
				break;
			case 'x': /* Expression. */
				if( elem && strchr( ",;({", elem->str.string[ 0 ] ) == NULL ) {
					if( elem->str.string[ 0 ] == '[' ) {
						validate_syntax( "[", elem, prev, env, message );
					} else if( elem->str.string[ 0 ] == '\\' && elem->str.string[ 1 ] == 0 ) {
						prev = elem;
						elem = elem->next;
						validate_syntax( "\"", elem, prev, env, message );
					} else if( elem->str.string[ 0 ] == '$' && elem->str.string[ 1 ] == 0 ) {
						prev = elem;
						elem = elem->next;
						validate_syntax( "{", elem, prev, env, message );
					} else if( elem->next && elem->next->str.string[ 0 ] == '(' ) {
						prev = elem;
						elem = elem->next;
					}
					if( elem ) {
						prev = elem;
						elem = elem->next;
						if( syntax[ idx ] == 'x' && elem && elem->str.string[ 0 ] == ',' ) {
							prev = elem;
							elem = elem->next;
						}
					}
				} else {
					sprintf( message, "Expected expression after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'X': /* Expression list, terminated by '{' or NULL. */
				next = NULL;
				while( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] != '{' ) {
					if( next && elem->str.string[ 0 ] == ',' ) {
						prev = elem;
						elem = elem->next;
					}
					next = validate_syntax( "x", elem, prev, env, message );
					prev = elem;
					elem = next;
				}
				break;
			case 'v': /* Variable declaration. */
				if( elem && elem->str.string[ 0 ] == '(' ) {
					validate_syntax( "n0", elem->child, elem, env, message );
					prev = elem->child;
					elem = elem->next;
				}
				if( message[ 0 ] == 0 ) {
					if( elem && elem->str.string[ 0 ] == '[' ) {
						validate_syntax( "nx0", elem->child, elem, env, message );
						prev = elem->child;
						elem = elem->next;
					} else {
						next = validate_syntax( "n", elem, prev, env, message );
						prev = elem;
						elem = next;
						if( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] == '=' ) {
							prev = elem;
							elem = validate_syntax( "x", elem->next, prev, env, message );
						}
					}
				}
				break;
			case 'V': /* Variable declaration list, terminated by ';' or NULL. */
				next = NULL;
				while( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] != ';' ) {
					if( next && elem->str.string[ 0 ] == ',' ) {
						prev = elem;
						elem = elem->next;
					}
					next = validate_syntax( "v", elem, prev, env, message );
					prev = elem;
					elem = next;
				}
				break;
			case 'A': /* Variable assignment list, terminated by ';' or NULL. */
				next = NULL;
				while( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] != ';' ) {
					if( next && elem->str.string[ 0 ] == ',' ) {
						prev = elem;
						elem = elem->next;
					}
					next = validate_syntax( "x=x", elem, prev, env, message );
					prev = elem;
					elem = next;
				}
				break;
			default: /* Internal error. */
				sprintf( message, "Internal error. Unknown specifier '%c' while parsing line %d.", chr, ( elem ? elem : prev )->line );
		}
		chr = syntax[ idx++ ];
	}
	return elem;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
cmpb $0x0, (%r8)
je 0x671c
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r13
movq %rdi, %rbp
movl $0x1, %r15d
movq %rdi, %rax
movq %rdi, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movzbl (%rax), %eax
movsbl %al, %edx
cmpl $0x55, %eax
jle 0x6774
cmpl $0x65, %eax
jle 0x67c9
cmpl $0x75, %eax
jle 0x6a3d
cmpl $0x76, %eax
je 0x6b27
cmpl $0x78, %eax
je 0x6bd6
cmpl $0x7b, %eax
je 0x6a04
jmp 0x6d9d
cmpl $0x3a, %eax
jg 0x6853
cmpl $0x2b, %eax
jg 0x69c9
cmpl $0x22, %eax
je 0x6a04
cmpl $0x28, %eax
jne 0x6d95
testq %r12, %r12
je 0x6c6e
movq 0x8(%r12), %rax
cmpb $0x28, (%rax)
jne 0x6c6e
movq 0x18(%r12), %rsi
testq %rsi, %rsi
je 0x6a12
leaq 0xbb81(%rip), %rdi      # 0x12345
jmp 0x6b14
cmpl $0x5a, %eax
jg 0x6873
cmpl $0x56, %eax
je 0x6a79
cmpl $0x58, %eax
jne 0x6d9d
cmpb $0x0, (%rbx)
jne 0x6f26
testq %r12, %r12
je 0x6f26
xorl %eax, %eax
movq 0x8(%r12), %rcx
movb (%rcx), %cl
cmpb $0x7b, %cl
je 0x6f26
cmpb $0x2c, %cl
setne %cl
notb %al
orb %cl, %al
testb $0x1, %al
jne 0x6820
movq 0x20(%r12), %r13
movq %r12, %rdx
jmp 0x6826
movq %r13, %rdx
movq %r12, %r13
leaq 0xbc80(%rip), %rdi      # 0x124ad
movq %r13, %rsi
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rax, %r12
cmpb $0x0, (%rbx)
jne 0x6f26
movb $0x1, %al
testq %r12, %r12
jne 0x67f8
jmp 0x6f26
cmpl $0x40, %eax
jg 0x691c
cmpl $0x3b, %eax
je 0x6a04
cmpl $0x3d, %eax
je 0x6a04
jmp 0x6d9d
cmpl $0x5b, %eax
je 0x6ae8
cmpl $0x63, %eax
jne 0x6d9d
testq %r12, %r12
je 0x6c8c
movq 0x8(%r12), %rbp
movq %rbp, %rdi
leaq 0xbb30(%rip), %rsi      # 0x123cd
callq 0x66af
testl %eax, %eax
jne 0x68bd
movq %rbp, %rdi
leaq 0xbb23(%rip), %rsi      # 0x123d3
callq 0x66af
testl %eax, %eax
je 0x6c8c
movsbl (%rbp), %esi
movq 0x20(%r12), %rbp
movl $0x3, %edx
leaq 0xbb09(%rip), %rdi      # 0x123db
callq 0x3110
testq %rax, %rax
je 0x6de5
testq %rbp, %rbp
je 0x6dc0
movq 0x8(%rbp), %rax
cmpb $0x28, (%rax)
jne 0x6dc2
movq 0x18(%rbp), %rsi
leaq 0xbadd(%rip), %rdi      # 0x123de
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq 0x18(%rbp), %r12
movq 0x20(%rbp), %rbp
jmp 0x6dc2
cmpl $0x41, %eax
je 0x6b67
cmpl $0x50, %eax
jne 0x6d9d
cmpb $0x0, (%rbx)
jne 0x6f26
testq %r12, %r12
je 0x6f26
movq 0x8(%r12), %rax
cmpb $0x28, (%rax)
jne 0x696e
movq 0x18(%r12), %rsi
leaq 0xba88(%rip), %rdi      # 0x123de
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq 0x18(%r12), %r13
movq 0x20(%r12), %r12
cmpb $0x0, (%rbx)
jne 0x692e
leaq 0xc590(%rip), %rdi      # 0x12f0a
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
testq %rax, %rax
je 0x69b3
movq 0x8(%rax), %rcx
cmpb $0x2c, (%rcx)
jne 0x69be
movq 0x20(%rax), %rcx
testq %rcx, %rcx
cmovneq %rax, %r12
cmoveq %rax, %rcx
movq %r12, %r13
movq %rcx, %r12
jmp 0x692e
movq %r12, %r13
xorl %r12d, %r12d
jmp 0x692e
movq %r12, %r13
movq %rax, %r12
jmp 0x692e
cmpl $0x2c, %eax
je 0x6a04
cmpl $0x30, %eax
jne 0x6d9d
testq %r12, %r12
je 0x6f23
movq 0x8(%r12), %rdx
movq 0x8(%r13), %rcx
movl 0x28(%r12), %r8d
movq %rbx, %rdi
leaq 0xb8f8(%rip), %rsi      # 0x122f0
xorl %eax, %eax
callq 0x3200
jmp 0x6f26
testq %r12, %r12
je 0x6a1f
movq 0x8(%r12), %rcx
cmpb %al, (%rcx)
jne 0x6a1f
movq %r12, %r13
movq 0x20(%r12), %r12
jmp 0x6f26
movq 0x8(%r13), %rcx
movl 0x28(%r13), %r8d
movq %rbx, %rdi
leaq 0xb8ec(%rip), %rsi      # 0x1231d
xorl %eax, %eax
callq 0x3200
jmp 0x6f26
cmpl $0x66, %eax
je 0x6c28
cmpl $0x6e, %eax
jne 0x6d9d
testq %r12, %r12
je 0x6a62
movq 0x8(%r12), %rax
cmpb $0x3b, (%rax)
jne 0x6ce9
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb9d4(%rip), %rsi      # 0x12448
jmp 0x6c80
cmpb $0x0, (%rbx)
jne 0x6f26
testq %r12, %r12
je 0x6f26
xorl %eax, %eax
movq 0x8(%r12), %rcx
movb (%rcx), %cl
cmpb $0x3b, %cl
je 0x6f26
cmpb $0x2c, %cl
setne %cl
notb %al
orb %cl, %al
testb $0x1, %al
jne 0x6ab5
movq 0x20(%r12), %r13
movq %r12, %rdx
jmp 0x6abb
movq %r13, %rdx
movq %r12, %r13
leaq 0xc487(%rip), %rdi      # 0x12f49
movq %r13, %rsi
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rax, %r12
cmpb $0x0, (%rbx)
jne 0x6f26
movb $0x1, %al
testq %r12, %r12
jne 0x6a8d
jmp 0x6f26
testq %r12, %r12
je 0x6c5a
movq 0x8(%r12), %rax
cmpb $0x5b, (%rax)
jne 0x6c5a
movq 0x18(%r12), %rsi
testq %rsi, %rsi
je 0x6e6f
leaq 0xb85b(%rip), %rdi      # 0x1236f
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
jmp 0x6a12
testq %r12, %r12
je 0x6caa
movq 0x8(%r12), %rax
cmpb $0x28, (%rax)
jne 0x6cad
movq 0x18(%r12), %rsi
leaq 0xb894(%rip), %rdi      # 0x123de
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq 0x18(%r12), %r13
movq 0x20(%r12), %r12
jmp 0x6cad
cmpb $0x0, (%rbx)
jne 0x6f26
testq %r12, %r12
je 0x6f26
xorl %eax, %eax
movq 0x8(%r12), %rcx
movb (%rcx), %cl
cmpb $0x3b, %cl
je 0x6f26
cmpb $0x2c, %cl
setne %cl
notb %al
orb %cl, %al
testb $0x1, %al
jne 0x6ba3
movq 0x20(%r12), %r13
movq %r12, %rdx
jmp 0x6ba9
movq %r13, %rdx
movq %r12, %r13
leaq 0xb8fb(%rip), %rdi      # 0x124ab
movq %r13, %rsi
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rax, %r12
cmpb $0x0, (%rbx)
jne 0x6f26
movb $0x1, %al
testq %r12, %r12
jne 0x6b7b
jmp 0x6f26
testq %r12, %r12
je 0x6c00
movq 0x8(%r12), %r14
movsbl (%r14), %ebp
movl $0x5, %edx
leaq 0xb880(%rip), %rdi      # 0x12470
movl %ebp, %esi
callq 0x3110
testq %rax, %rax
je 0x6d54
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb867(%rip), %rsi      # 0x12479
xorl %eax, %eax
callq 0x3200
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %r14
jmp 0x6f26
testq %r12, %r12
je 0x6c46
movq 0x8(%r12), %rdi
leaq 0xb7e0(%rip), %rsi      # 0x12419
callq 0x66af
testl %eax, %eax
jne 0x6a12
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb7c6(%rip), %rsi      # 0x1241e
jmp 0x6c80
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb73a(%rip), %rsi      # 0x123a6
jmp 0x6c80
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb6c8(%rip), %rsi      # 0x12348
xorl %eax, %eax
callq 0x3200
jmp 0x6f26
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb743(%rip), %rsi      # 0x123e1
xorl %eax, %eax
callq 0x3200
jmp 0x6e65
xorl %r12d, %r12d
cmpb $0x0, (%rbx)
jne 0x6f26
testq %r12, %r12
je 0x6cf9
movq 0x8(%r12), %rax
cmpb $0x5b, (%rax)
jne 0x6cf9
movq 0x18(%r12), %rsi
leaq 0xb7d6(%rip), %rdi      # 0x124a7
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq 0x18(%r12), %r13
jmp 0x6a15
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6f43
jmp 0x6a12
leaq 0xc20a(%rip), %rdi      # 0x12f0a
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rax, %rbp
cmpb $0x0, (%rbx)
jne 0x6dea
testq %rbp, %rbp
je 0x6dea
movq 0x8(%rbp), %rax
cmpb $0x3d, (%rax)
jne 0x6dea
movq 0x20(%rbp), %rsi
leaq 0xb76f(%rip), %rdi      # 0x124ad
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rax, %r12
jmp 0x6e62
movzbl %bpl, %eax
cmpl $0x24, %eax
je 0x6e93
cmpl $0x5c, %eax
je 0x6e87
cmpl $0x5b, %eax
jne 0x6e9a
leaq 0xb6fb(%rip), %rdi      # 0x12475
movq %r12, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %r14
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
jmp 0x6ef5
testl %eax, %eax
je 0x670a
testq %r12, %r12
movq %r12, %rax
cmoveq %r13, %rax
movl 0x28(%rax), %ecx
movq %rbx, %rdi
leaq 0xb6fb(%rip), %rsi      # 0x124af
xorl %eax, %eax
callq 0x3200
jmp 0x6f26
xorl %ebp, %ebp
cmpb $0x0, (%rbx)
jne 0x6de5
leaq 0xc13c(%rip), %rdi      # 0x12f0a
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rbp, %r12
movq %rax, %rbp
cmpb $0x0, (%rbx)
je 0x6df2
movq %r12, %r13
movq %rbp, %r12
jmp 0x6e65
leaq 0xb67a(%rip), %rdi      # 0x12473
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %rax, %r12
cmpb $0x0, (%rbx)
jne 0x6e62
testq %r12, %r12
je 0x6e62
movq 0x8(%r12), %r13
movq %r13, %rdi
leaq 0xb5a7(%rip), %rsi      # 0x123cd
callq 0x66af
testl %eax, %eax
jne 0x6e42
movq %r13, %rdi
leaq 0xb59a(%rip), %rsi      # 0x123d3
callq 0x66af
testl %eax, %eax
je 0x6e62
leaq 0xb593(%rip), %rdi      # 0x123dc
movq %r12, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %r12, %r13
movq %rax, %r12
jmp 0x6e65
movq %rbp, %r13
movq 0x8(%rsp), %rbp
jmp 0x6f26
movq 0x8(%r13), %rdx
movl 0x28(%r12), %ecx
movq %rbx, %rdi
leaq 0xb4f1(%rip), %rsi      # 0x12373
jmp 0x6c80
cmpb $0x0, 0x1(%r14)
je 0x6ecd
cmpl $0x24, %eax
jne 0x6e9a
cmpb $0x0, 0x1(%r14)
je 0x6ebf
movq 0x20(%r12), %rax
testq %rax, %rax
je 0x6eb3
movq 0x8(%rax), %rcx
cmpb $0x28, (%rcx)
cmoveq %r12, %r13
cmoveq %rax, %r12
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %r14
jmp 0x6efa
movq 0x20(%r12), %rbp
leaq 0xb5a8(%rip), %rdi      # 0x12473
jmp 0x6ed9
movq 0x20(%r12), %rbp
leaq 0xb59e(%rip), %rdi      # 0x12477
movq %rbp, %rsi
movq %r12, %rdx
movq 0x10(%rsp), %r14
movq %r14, %rcx
movq %rbx, %r8
callq 0x66f3
movq %r12, %r13
movq %rbp, %r12
movq 0x8(%rsp), %rbp
testq %r12, %r12
je 0x6f23
movq 0x20(%r12), %rax
cmpb $0x78, (%rbp,%r15)
jne 0x6f3b
testq %rax, %rax
je 0x6f3b
movq 0x8(%rax), %rcx
cmpb $0x2c, (%rcx)
jne 0x6f3b
movq 0x20(%rax), %r12
movq %rax, %r13
jmp 0x6f26
xorl %r12d, %r12d
leaq (%r15,%rbp), %rax
incq %r15
cmpb $0x0, (%rbx)
je 0x673b
jmp 0x670a
movq %r12, %r13
movq %rax, %r12
jmp 0x6f26