// File: /workspace/github_c_makefile_star2_O2/martincameron[P]towntalk/ttasm.c
// Function: parse_instructions
static int parse_instructions( struct element *elem, struct function *func, struct instruction *output, struct label *labels, char *message ) {
	int count = 0;
	while( elem ) {
		if( elem->str.string[ elem->str.length - 1 ] == ':' ) {
			if( output == NULL ) {
				labels->next = new_label( elem, count, message );
				labels = labels->next;
				if( labels == NULL ) {
					break;
				}
			}
		} else if( strcmp( elem->str.string, "//" ) ) {
			if( is_keyword( elem->str.string, "let" ) ) {
				if( output ) {
					elem = parse_let( elem, func, &output[ count ], message );
				} else {
					elem = validate_let( elem, message );
				}
				if( elem == NULL ) {
					break;
				}
			} else if( is_keyword( elem->str.string, "jump" ) ) {
				if( output ) {
					elem = parse_jump( elem, func, labels->next, &output[ count ], message );
				} else {
					elem = validate_jump( elem, message );
				}
				if( elem == NULL ) {
					break;
				}
			} else if( is_keyword( elem->str.string, "halt" ) ) {
				if( output ) {
					output[ count ].opcode = HALT;
				}
			} else {
				sprintf( message, "Unrecognized opcode '%.64s' on line %d.", elem->str.string, elem->line );
				break;
			}
			if( elem->next && strcmp( ";", elem->next->str.string ) == 0 ) {
				elem = elem->next;
				count++;
			} else {
				sprintf( message, "Expected ';' after '%.64s' on line %d.", elem->str.string, elem->line );
				break;
			}
		}
		elem = elem->next;
	}
	if( message[ 0 ] ) {
		count = 0;
	} else {
		if( output ) {
			output[ count ].opcode = HALT;
		}
		count++;
	}
	return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, (%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %rbp
xorl %ebx, %ebx
movslq %ebx, %r15
testq %rbp, %rbp
je 0x103da
movq 0x8(%rbp), %r14
movslq 0x10(%rbp), %r13
cmpb $0x3a, -0x1(%r14,%r13)
jne 0xfadb
cmpq $0x0, 0x10(%rsp)
jne 0x1029a
leaq -0x1(%r13), %r12
movq %r14, %rdi
movl %r12d, %esi
callq 0x10a90
testl %eax, %eax
je 0x10302
addq $0x18, %r13
movq %r13, %rdi
callq 0x31b0
testq %rax, %rax
je 0x1032e
movq %rax, %r13
movl %ebx, (%rax)
movq %rax, %rdi
addq $0x18, %rdi
movq %rdi, 0x8(%rax)
movq %r14, %rsi
movq %r12, %rdx
callq 0x3050
movb $0x0, 0x18(%r13,%r12)
andq $0x0, 0x10(%r13)
movq 0x20(%rsp), %rax
movq %r13, 0x10(%rax)
movq %r13, 0x20(%rsp)
jmp 0x1029a
cmpb $0x2f, (%r14)
jne 0xfaf3
cmpb $0x2f, 0x1(%r14)
jne 0xfaf3
cmpb $0x0, 0x2(%r14)
je 0x1029a
movq %r14, %rdi
leaq 0x21b5(%rip), %rsi      # 0x11cb2
callq 0x6197
testl %eax, %eax
je 0xfbde
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0xfcc2
leaq (%rax,%r15,8), %r12
movq 0x20(%rbp), %rbp
movq 0x8(%rbp), %rax
cmpb $0x5b, (%rax)
movq 0x8(%rsp), %rdi
jne 0xfd5e
movq 0x18(%rbp), %r14
testq %r14, %r14
je 0x102d4
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x102d4
cmpq $0x0, 0x20(%rax)
jne 0x102d4
movq %r14, %rsi
leaq 0x14f5(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x1(%r12)
movq 0x20(%r14), %rsi
movq 0x8(%rsi), %rdi
movb (%rdi), %al
cmpb $0x2d, %al
setne %cl
addb $-0x30, %al
cmpb $0xa, %al
setae %al
testb %al, %cl
jne 0xffd7
leaq 0x4(%r12), %rsi
callq 0x4b5c
testl %eax, %eax
je 0x103ac
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rbp
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
leaq 0x1498(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb $0xd, (%r12)
movb %al, 0x3(%r12)
jmp 0x1026d
movq 0x8(%rbp), %rdi
leaq 0x2857(%rip), %rsi      # 0x12440
callq 0x6197
testl %eax, %eax
je 0xfe20
cmpq $0x0, 0x10(%rsp)
je 0xff4c
movq 0x20(%rsp), %rax
movq 0x10(%rax), %r12
movq 0x20(%rbp), %r13
movq 0x8(%r13), %r14
leaq 0x9726(%rip), %rdi      # 0x19340
movq %r14, %rsi
callq 0x10c05
testq %rax, %rax
je 0x10389
movb 0x8(%rax), %al
movq 0x10(%rsp), %rcx
movb %al, (%rcx,%r15,8)
movq 0x20(%r13), %r14
movq 0x18(%r14), %rsi
movq 0x8(%rsp), %rdi
leaq 0x140b(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movq 0x10(%rsp), %rcx
movb %al, 0x2(%rcx,%r15,8)
movq 0x18(%r14), %rax
movq 0x20(%rax), %rsi
movq 0x8(%rsp), %rdi
leaq 0x13dc(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movq 0x10(%rsp), %rcx
movb %al, 0x3(%rcx,%r15,8)
movq 0x20(%r14), %rbp
movq 0x8(%rbp), %r14
testq %r12, %r12
je 0x102a3
movq 0x8(%r12), %rsi
movq %r14, %rdi
callq 0x3140
testl %eax, %eax
je 0x10038
movq 0x10(%r12), %r12
jmp 0xfc9d
movq 0x20(%rbp), %r14
testq %r14, %r14
je 0x102e3
movq 0x8(%r14), %rax
movsbl (%rax), %edi
leaq 0x17dd(%rip), %rsi      # 0x114ba
callq 0x10afe
testl %eax, %eax
je 0x102e3
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x102f2
movq 0x8(%rax), %rdx
movzbl (%rdx), %ecx
subl $0x3d, %ecx
jne 0xfd07
movzbl 0x1(%rdx), %ecx
negl %ecx
testl %ecx, %ecx
jne 0x102f2
movq 0x20(%rax), %rbp
testq %rbp, %rbp
je 0x1031f
movq 0x8(%rbp), %rcx
cmpb $0x3b, (%rcx)
je 0x1031f
movq 0x20(%rbp), %rax
testq %rax, %rax
je 0x10276
movq 0x8(%rax), %rdx
movzbl (%rdx), %ecx
subl $0x28, %ecx
jne 0xfd51
movzbl 0x1(%rdx), %ecx
subl $0x29, %ecx
jne 0xfd51
movzbl 0x2(%rdx), %ecx
negl %ecx
testl %ecx, %ecx
cmoveq %rax, %rbp
jmp 0x10276
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rcx
movq 0x8(%rcx), %rax
movb (%rax), %al
cmpb $0x5b, %al
jne 0xfe50
movq %rbp, %rsi
leaq 0x12d8(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x1(%r12)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rbp
movq 0x18(%rbp), %r14
testq %r14, %r14
je 0x102d4
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x102d4
cmpq $0x0, 0x20(%rax)
jne 0x102d4
movq 0x8(%rsp), %rdi
movq %r14, %rsi
leaq 0x1286(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x2(%r12)
movq 0x20(%r14), %rsi
movq 0x8(%rsi), %rdi
movb (%rdi), %al
cmpb $0x2d, %al
setne %cl
addb $-0x30, %al
cmpb $0xa, %al
setae %al
testb %al, %cl
jne 0x100aa
leaq 0x4(%r12), %rsi
callq 0x4b5c
testl %eax, %eax
je 0x103ac
movb $0x9, (%r12)
jmp 0x10276
movq 0x8(%rbp), %rdi
leaq 0x261a(%rip), %rsi      # 0x12445
callq 0x6197
testl %eax, %eax
je 0x10399
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x10276
movb $0x0, (%rax,%r15,8)
jmp 0x10276
movq 0x20(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpb $0x28, (%rcx)
jne 0x1004b
movq %rbp, %rsi
leaq 0x11eb(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x1(%r12)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %r13
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x10369
movq 0x18(%rax), %rbp
testq %rbp, %rbp
je 0x10369
movq 0x20(%rbp), %rax
testq %rax, %rax
je 0x10369
cmpq $0x0, 0x20(%rax)
jne 0x10369
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
leaq 0x118c(%rip), %rdx      # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x2(%r12)
movq 0x20(%rbp), %rsi
movq 0x8(%rsi), %r14
movb (%r14), %al
cmpb $0x2d, %al
setne %cl
addb $-0x30, %al
cmpb $0xa, %al
setae %al
testb %al, %cl
movq %r13, 0x18(%rsp)
jne 0x101a0
movq 0x8(%r13), %r13
leaq 0x91a1(%rip), %rdi      # 0x190b0
movq %r13, %rsi
callq 0x10c05
testq %rax, %rax
je 0x1042b
movb 0x8(%rax), %al
movb %al, (%r12)
addq $0x4, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x4b5c
testl %eax, %eax
je 0x10435
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rbp
jmp 0x1026d
movq 0x20(%rbp), %rcx
testq %rcx, %rcx
je 0x103b9
movq 0x20(%rcx), %rax
testq %rax, %rax
je 0x1037d
movq 0x8(%rax), %rsi
movzbl (%rsi), %edx
subl $0x28, %edx
jne 0xff7f
movzbl 0x1(%rsi), %edx
subl $0x29, %edx
jne 0xff7f
movzbl 0x2(%rsi), %edx
negl %edx
testl %edx, %edx
jne 0x1037d
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x1035d
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
je 0x1035d
cmpq $0x0, 0x20(%rcx)
jne 0x1035d
movq 0x20(%rax), %rbp
testq %rbp, %rbp
je 0x103c5
movq 0x8(%rbp), %r14
movl 0x10(%rbp), %esi
movq %r14, %rdi
callq 0x10a90
testl %eax, %eax
jne 0x10276
jmp 0x10409
movq 0x8(%rsp), %r13
movq %r13, %rdi
leaq 0x1070(%rip), %rdx      # 0x11056
xorl %ecx, %ecx
callq 0x10b2b
testl %eax, %eax
js 0x100d2
movb %al, 0x2(%r12)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rbp
movq 0x8(%rbp), %rdi
movb (%rdi), %al
cmpb $0x2d, %al
setne %cl
addb $-0x30, %al
cmpb $0xa, %al
setae %al
testb %al, %cl
jne 0x1012d
leaq 0x4(%r12), %rsi
callq 0x4b5c
testl %eax, %eax
je 0x10418
movb $0xc, (%r12)
jmp 0x10276
movl (%r12), %eax
movq 0x10(%rsp), %rcx
movl %eax, 0x4(%rcx,%r15,8)
jmp 0x1026d
cmpb $0x2d, %al
setne %r14b
addb $-0x30, %al
cmpb $0xa, %al
setae %r13b
movq %rbp, %rsi
leaq 0xff3(%rip), %rdx       # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testb %r13b, %r14b
jne 0x1015c
testl %eax, %eax
js 0x103da
movb %al, 0x1(%r12)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rbp
movq 0x8(%rbp), %rdi
leaq 0x4(%r12), %rsi
callq 0x4b5c
testl %eax, %eax
je 0x10418
movb $0x7, (%r12)
jmp 0x10276
movq 0x8(%rsp), %r13
movq %r13, %rdi
leaq 0xf9d(%rip), %rdx       # 0x11056
xorl %ecx, %ecx
callq 0x10b2b
testl %eax, %eax
js 0x101f0
movb $0xa, (%r12)
jmp 0x10214
movq 0x20(%r14), %rsi
movq %r13, %rdi
leaq 0x240d(%rip), %rdx      # 0x124ed
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x2(%r12)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rbp
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
leaq 0xf49(%rip), %rdx       # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x3(%r12)
movb $0xf, (%r12)
jmp 0x1026d
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
leaq 0xf1a(%rip), %rdx       # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x3(%r12)
movb $0xe, (%r12)
jmp 0x10276
testl %eax, %eax
js 0x103da
movb %al, 0x1(%r12)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rbp
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
leaq 0xed6(%rip), %rdx       # 0x11056
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb %al, 0x2(%r12)
movb $0x8, (%r12)
jmp 0x1026d
movq 0x8(%rsp), %r13
movq %r13, %rdi
leaq 0xea7(%rip), %rdx       # 0x11056
xorl %ecx, %ecx
callq 0x10b2b
testl %eax, %eax
js 0x1021b
movl %eax, %r14d
movq 0x18(%rsp), %rbp
movq 0x8(%rbp), %r13
leaq 0x9003(%rip), %rdi      # 0x191d0
movq %r13, %rsi
callq 0x10c05
testq %rax, %rax
je 0x1043e
movb 0x8(%rax), %al
movb %al, (%r12)
movb %r14b, 0x3(%r12)
movq 0x20(%rbp), %rbp
jmp 0x1026d
movq 0x20(%r14), %rsi
movq %r13, %rdi
leaq 0x22ef(%rip), %rdx      # 0x124ed
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
js 0x103da
movb $0xb, (%r12)
movb %al, 0x3(%r12)
jmp 0x10276
movq 0x20(%rbp), %rsi
movq %r13, %rdi
leaq 0x22c4(%rip), %rdx      # 0x124ed
movq (%rsp), %rcx
callq 0x10b2b
testl %eax, %eax
movq 0x18(%rsp), %r13
js 0x103da
movl %eax, %ebp
movq 0x8(%r13), %r14
leaq 0x90a4(%rip), %rdi      # 0x192f0
movq %r14, %rsi
callq 0x10c05
testq %rax, %rax
je 0x10454
movb 0x8(%rax), %al
movb %al, (%r12)
movb %bpl, 0x3(%r12)
movq 0x20(%r13), %rbp
testq %rbp, %rbp
je 0x103da
movq 0x20(%rbp), %rax
testq %rax, %rax
je 0x102b6
movq 0x8(%rax), %rdx
movzbl (%rdx), %ecx
subl $0x3b, %ecx
jne 0x1028f
movzbl 0x1(%rdx), %ecx
negl %ecx
testl %ecx, %ecx
jne 0x102b6
incl %ebx
movq %rax, %rbp
movq 0x20(%rbp), %rbp
jmp 0xfa4e
movl 0x28(%rbp), %ecx
leaq 0x234c(%rip), %rsi      # 0x125f9
movq (%rsp), %rdi
movq %r14, %rdx
jmp 0x102c8
movq 0x8(%rbp), %rdx
movl 0x28(%rbp), %ecx
leaq 0x21ae(%rip), %rsi      # 0x12472
movq (%rsp), %rdi
xorl %eax, %eax
callq 0x3200
jmp 0x103da
movl 0x28(%rbp), %edx
leaq 0x12f7(%rip), %rsi      # 0x115d5
jmp 0x103cf
movl 0x28(%rbp), %edx
leaq 0x22e0(%rip), %rsi      # 0x125cd
jmp 0x103cf
movl 0x28(%r14), %edx
leaq 0x22a5(%rip), %rsi      # 0x125a2
jmp 0x103cf
movl 0x28(%rbp), %ecx
leaq 0x218d(%rip), %rsi      # 0x12499
movq (%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3200
jmp 0x10344
movl 0x28(%rax), %edx
leaq 0x2254(%rip), %rsi      # 0x1257d
jmp 0x103cf
leaq 0x7e3b(%rip), %rax      # 0x18170
movq (%rax), %rsi
movq (%rsp), %r15
movq %r15, %rdi
callq 0x3070
movq 0x20(%rsp), %rax
andq $0x0, 0x10(%rax)
cmpb $0x0, (%r15)
jne 0x103e3
jmp 0x103f6
movl 0x28(%rax), %edx
leaq 0x233e(%rip), %rsi      # 0x126a5
jmp 0x103cf
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
leaq 0x21c8(%rip), %rsi      # 0x12540
jmp 0x102c4
movl 0x28(%rcx), %edx
leaq 0x2341(%rip), %rsi      # 0x126c8
jmp 0x103cf
movl 0x28(%r13), %ecx
leaq 0x228f(%rip), %rsi      # 0x12623
jmp 0x102ad
movq 0x8(%rbp), %rdx
movl 0x28(%rbp), %ecx
leaq 0x20a3(%rip), %rsi      # 0x1244a
jmp 0x102c4
movq 0x20(%r14), %rax
movq 0x8(%rax), %rdx
movl 0x28(%rax), %ecx
jmp 0x1041f
movl 0x28(%rbp), %edx
leaq 0x2333(%rip), %rsi      # 0x126f6
jmp 0x103cf
movl 0x28(%rax), %edx
leaq 0x22a6(%rip), %rsi      # 0x12675
movq (%rsp), %rdi
xorl %eax, %eax
callq 0x3200
movq (%rsp), %rax
cmpb $0x0, (%rax)
je 0x103e7
xorl %ebx, %ebx
jmp 0x103f8
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x103f6
movb $0x0, (%rax,%r15,8)
incl %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x28(%rbp), %ecx
leaq 0x223b(%rip), %rsi      # 0x1264e
jmp 0x102ad
movq 0x8(%rbp), %rdx
movl 0x28(%rbp), %ecx
leaq 0x20a1(%rip), %rsi      # 0x124c7
jmp 0x102c4
movq 0x18(%rsp), %rax
movl 0x28(%rax), %ecx
jmp 0x10441
movq 0x20(%rbp), %rax
jmp 0x103b0
movl 0x28(%rbp), %ecx
leaq 0x20d3(%rip), %rsi      # 0x1251b
movq (%rsp), %rdi
movq %r13, %rdx
jmp 0x102c8
movl 0x28(%r13), %ecx
leaq 0x20bc(%rip), %rsi      # 0x1251b
jmp 0x102ad