// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %r8, %r14
movq %rcx, 0x20(%rsp)
movq %rdx, %rbx
movq %rsi, 0x10(%rsp)
movl $0x0, %ebp
testq %rdi, %rdi
je 0x1172d
movq %rdi, %r13
xorl %ebp, %ebp
movq %r14, (%rsp)
movq %rbx, 0x30(%rsp)
movq 0x8(%r13), %r15
movslq 0x10(%r13), %r12
cmpb $0x3a, -0x1(%r15,%r12)
jne 0x10d54
testq %rbx, %rbx
jne 0x11302
movl %ebp, %ebx
leaq -0x1(%r12), %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0x11e3d
testl %eax, %eax
je 0x10faa
addq $0x18, %r12
movq %r12, %rdi
callq 0x31b0
testq %rax, %rax
je 0x11043
movq %rax, %r12
movl %ebx, (%rax)
movq %rax, %rdi
addq $0x18, %rdi
movq %rdi, 0x8(%rax)
movq %r15, %rsi
movq %rbp, %rdx
callq 0x3050
movb $0x0, 0x18(%r12,%rbp)
movl %ebx, %ebp
movq $0x0, 0x10(%r12)
jmp 0x1105a
movq %r15, %rdi
leaq 0x1e0e(%rip), %rsi      # 0x12b6c
callq 0x3140
testl %eax, %eax
je 0x11302
movq %r15, %rdi
leaq 0x1f01(%rip), %rsi      # 0x12c76
callq 0x66af
testl %eax, %eax
je 0x10e4c
testq %rbx, %rbx
je 0x10f47
movl %ebp, %r12d
movslq %ebp, %rax
leaq (%rbx,%rax,8), %rbp
movq 0x20(%r13), %r13
movq 0x8(%r13), %rax
cmpb $0x5b, (%rax)
jne 0x10fc7
movq 0x18(%r13), %r15
testq %r15, %r15
je 0x11023
movq 0x20(%r15), %rax
testq %rax, %rax
je 0x11023
cmpq $0x0, 0x20(%rax)
jne 0x11023
movq 0x10(%rsp), %rdi
movq %r15, %rsi
leaq 0x127c(%rip), %rdx      # 0x12056
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x1(%rbp)
movq 0x20(%r15), %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 0x11335
leaq 0x4(%rbp), %rsi
callq 0x4d7d
testl %eax, %eax
je 0x113fa
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0x1223(%rip), %rdx      # 0x12056
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb $0xd, (%rbp)
jmp 0x115ea
movq 0x8(%r13), %rdi
leaq 0x25ad(%rip), %rsi      # 0x13404
callq 0x66af
testl %eax, %eax
je 0x1107b
testq %rbx, %rbx
je 0x11136
movl %ebp, %eax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rbp
movl %eax, 0x8(%rsp)
movslq %eax, %r12
movq 0x20(%r13), %r13
movq 0x8(%r13), %r15
leaq 0x202a(%rip), %rsi      # 0x12eb8
leaq 0x7e6b(%rip), %r14      # 0x18d00
movq %r15, %rdi
callq 0x3140
testl %eax, %eax
je 0x10eb1
movq 0x10(%r14), %rsi
addq $0x10, %r14
testq %rsi, %rsi
jne 0x10e95
xorl %r14d, %r14d
testq %r14, %r14
je 0x11178
movb 0x8(%r14), %al
movb %al, (%rbx,%r12,8)
movq 0x20(%r13), %r15
movq 0x18(%r15), %rsi
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r12, %r14
leaq 0x117a(%rip), %rdx      # 0x12056
movq (%rsp), %r12
movq %r12, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11191
movb %al, 0x2(%rbx,%r14,8)
movq 0x18(%r15), %rax
movq 0x20(%rax), %rsi
movq %r13, %rdi
leaq 0x114f(%rip), %rdx      # 0x12056
movq %r12, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11191
movb %al, 0x3(%rbx,%r14,8)
movq 0x20(%r15), %r13
movq 0x8(%r13), %r15
testq %rbp, %rbp
je 0x111f4
movq 0x8(%rbp), %rsi
movq %r15, %rdi
callq 0x3140
testl %eax, %eax
je 0x111f4
movq 0x10(%rbp), %rbp
jmp 0x10f24
movq 0x20(%r13), %r15
testq %r15, %r15
je 0x110af
movq 0x8(%r15), %rax
movzbl (%rax), %eax
movl %eax, %ecx
andb $-0x21, %cl
addb $-0x41, %cl
cmpb $0x1a, %cl
jb 0x10f75
cmpl $0x5b, %eax
je 0x10f75
testl %eax, %eax
jne 0x110af
movq 0x20(%r15), %r14
testq %r14, %r14
je 0x10f96
movq 0x8(%r14), %rsi
leaq 0x1f36(%rip), %rdi      # 0x12ebf
callq 0x3140
testl %eax, %eax
je 0x1121b
movl 0x28(%r15), %edx
movq (%rsp), %rdi
leaq 0x25be(%rip), %rsi      # 0x13563
jmp 0x112c1
movl 0x28(%r13), %ecx
movq %r14, %rdi
leaq 0x24a5(%rip), %rsi      # 0x1345d
movq %r15, %rdx
xorl %eax, %eax
callq 0x3200
jmp 0x11055
movq 0x20(%r13), %rax
movq 0x20(%rax), %rcx
movq 0x8(%rcx), %rax
movb (%rax), %al
cmpb $0x5b, %al
leaq 0x1078(%rip), %r15      # 0x12056
jne 0x110c2
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x1(%rbp)
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq 0x18(%r13), %r15
testq %r15, %r15
je 0x11023
movq 0x20(%r15), %rax
testq %rax, %rax
je 0x11023
cmpq $0x0, 0x20(%rax)
je 0x11396
movl 0x28(%r13), %edx
movq %r14, %rdi
leaq 0x155f(%rip), %rsi      # 0x12590
xorl %eax, %eax
callq 0x3200
xorl %r13d, %r13d
movl %r12d, %ebp
jmp 0x112cb
leaq 0x8126(%rip), %rax      # 0x19170
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3070
xorl %r12d, %r12d
movl %ebx, %ebp
movq 0x20(%rsp), %rax
movq %r12, 0x10(%rax)
movq %r12, 0x20(%rsp)
testq %r12, %r12
movq 0x30(%rsp), %rbx
jne 0x11302
jmp 0x1172d
movq 0x8(%r13), %rdi
leaq 0x2383(%rip), %rsi      # 0x13409
callq 0x66af
testl %eax, %eax
leaq 0x237a(%rip), %rsi      # 0x1340e
je 0x11715
testq %rbx, %rbx
je 0x112d4
movslq %ebp, %rax
movb $0x0, (%rbx,%rax,8)
jmp 0x112d4
movl 0x28(%r13), %edx
movq %r14, %rdi
leaq 0x24d1(%rip), %rsi      # 0x1358e
jmp 0x112c1
movq 0x20(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpb $0x28, (%rcx)
jne 0x1119d
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x1(%rbp)
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x1111f
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x1111f
movq 0x20(%rcx), %rax
testq %rax, %rax
je 0x1111f
cmpq $0x0, 0x20(%rax)
je 0x11471
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %r14, %rdi
leaq 0x23d0(%rip), %rsi      # 0x13501
jmp 0x1140f
movq 0x20(%r13), %r14
testq %r14, %r14
je 0x11207
movq 0x20(%r14), %r15
testq %r15, %r15
je 0x11164
movq 0x8(%r15), %rsi
leaq 0x1fd1(%rip), %rdi      # 0x13128
callq 0x3140
testl %eax, %eax
je 0x11295
movl 0x28(%r14), %edx
movq (%rsp), %rdi
leaq 0x2516(%rip), %rsi      # 0x13689
jmp 0x112c1
movl 0x28(%r13), %ecx
movq (%rsp), %rdi
leaq 0x245d(%rip), %rsi      # 0x135e4
movq %r15, %rdx
xorl %eax, %eax
callq 0x3200
xorl %r13d, %r13d
movl 0x8(%rsp), %ebp
jmp 0x112cb
cmpb $0x2d, %al
movq %r14, %rcx
setne %r14b
addb $-0x30, %al
cmpb $0xa, %al
movq %r15, %rdx
setae %r15b
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x11ecd
testb %r15b, %r14b
jne 0x11242
testl %eax, %eax
js 0x11038
movb %al, 0x1(%rbp)
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq 0x8(%r13), %rdi
leaq 0x4(%rbp), %rsi
callq 0x4d7d
testl %eax, %eax
je 0x113ec
movb $0x7, (%rbp)
jmp 0x1103b
testq %rbp, %rbp
je 0x11281
movl (%rbp), %eax
movl %eax, 0x4(%rbx,%r14,8)
jmp 0x11194
movl 0x28(%r13), %edx
movq (%rsp), %rdi
leaq 0x24a1(%rip), %rsi      # 0x136b7
jmp 0x112c1
movq 0x20(%r14), %r13
testq %r13, %r13
je 0x11231
movq 0x8(%r13), %rax
cmpb $0x3b, (%rax)
jne 0x11314
movl 0x28(%r14), %edx
movq (%rsp), %rdi
leaq 0x22fe(%rip), %rsi      # 0x1353e
jmp 0x112c1
testl %eax, %eax
js 0x11038
movb %al, 0x1(%rbp)
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0xdf2(%rip), %rdx       # 0x12056
movq (%rsp), %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x2(%rbp)
movb $0x8, (%rbp)
jmp 0x1103b
movl 0x28(%r13), %ecx
movq (%rsp), %rdi
leaq 0x232a(%rip), %rsi      # 0x135ba
jmp 0x11187
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x112b2
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x112b2
cmpq $0x0, 0x20(%rax)
je 0x11574
movl 0x28(%r15), %edx
movq (%rsp), %rdi
leaq 0x23a5(%rip), %rsi      # 0x13666
xorl %eax, %eax
callq 0x3200
xorl %r13d, %r13d
testq %r13, %r13
je 0x11729
movq 0x20(%r13), %r14
testq %r14, %r14
je 0x1170a
movq 0x8(%r14), %rsi
leaq 0x17d9(%rip), %rdi      # 0x12ac5
callq 0x3140
testl %eax, %eax
jne 0x1170a
incl %ebp
movq %r14, %r13
movq (%rsp), %r14
movq 0x20(%r13), %r13
testq %r13, %r13
jne 0x10cdc
jmp 0x1172d
movq 0x20(%r13), %r14
testq %r14, %r14
je 0x112cb
movq 0x8(%r14), %rsi
leaq 0x1e00(%rip), %rdi      # 0x13128
callq 0x3140
testl %eax, %eax
cmoveq %r14, %r13
jmp 0x112cb
movq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0xd12(%rip), %rdx       # 0x12056
xorl %ecx, %ecx
callq 0x11ecd
testl %eax, %eax
js 0x1141b
movb %al, 0x2(%rbp)
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq 0x8(%r13), %rdi
movb (%rdi), %al
cmpb $0x2d, %al
setne %cl
addb $-0x30, %al
cmpb $0xa, %al
setae %al
testb %al, %cl
jne 0x11528
leaq 0x4(%rbp), %rsi
callq 0x4d7d
testl %eax, %eax
movq (%rsp), %rdi
je 0x115ba
movb $0xc, (%rbp)
jmp 0x1103b
movq 0x10(%rsp), %rdi
movq %r15, %rsi
leaq 0xcb1(%rip), %rdx       # 0x12056
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x2(%rbp)
movq 0x20(%r15), %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 0x11554
leaq 0x4(%rbp), %rsi
callq 0x4d7d
testl %eax, %eax
je 0x113fa
movb $0x9, (%rbp)
jmp 0x1103b
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq (%rsp), %rdi
jmp 0x11408
movq 0x20(%r15), %rax
movq 0x8(%rax), %rdx
movl 0x28(%rax), %ecx
movq %r14, %rdi
leaq 0x207c(%rip), %rsi      # 0x1348b
xorl %eax, %eax
callq 0x3200
jmp 0x11038
movq 0x20(%r15), %rsi
movq %r14, %rdi
leaq 0x1339(%rip), %rdx      # 0x12762
movq (%rsp), %r15
movq %r15, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x2(%rbp)
movq 0x20(%r13), %rax
movq 0x20(%rax), %r13
movq %r14, %rdi
movq %r13, %rsi
leaq 0xc01(%rip), %rdx       # 0x12056
movq %r15, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x3(%rbp)
movb $0xf, (%rbp)
jmp 0x1103b
movq 0x10(%rsp), %rdi
movq %rcx, %rsi
movq %rcx, 0x18(%rsp)
movq %r15, %rdx
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x2(%rbp)
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x8(%rsi), %rdx
movb (%rdx), %al
cmpb $0x2d, %al
setne %cl
addb $-0x30, %al
cmpb $0xa, %al
setae %al
testb %al, %cl
jne 0x115f2
movq %rdx, 0x28(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x8(%rsp)
leaq 0x1297(%rip), %rsi      # 0x12763
leaq 0x759d(%rip), %r15      # 0x18a70
movq 0x8(%rsp), %rdi
callq 0x3140
testl %eax, %eax
je 0x114f1
movq 0x10(%r15), %rsi
addq $0x10, %r15
testq %rsi, %rsi
jne 0x114d3
xorl %r15d, %r15d
testq %r15, %r15
movq 0x28(%rsp), %rdi
je 0x116e8
movb 0x8(%r15), %al
movb %al, (%rbp)
addq $0x4, %rbp
movq %rbp, %rsi
callq 0x4d7d
testl %eax, %eax
jne 0x116df
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
jmp 0x113fe
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0xb1f(%rip), %rdx       # 0x12056
movq (%rsp), %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb %al, 0x3(%rbp)
movb $0xe, (%rbp)
jmp 0x1103b
movq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0xaf3(%rip), %rdx       # 0x12056
xorl %ecx, %ecx
callq 0x11ecd
testl %eax, %eax
js 0x115c7
movb $0xa, (%rbp)
jmp 0x115ea
movq 0x20(%r15), %r13
testq %r13, %r13
movq (%rsp), %r14
je 0x11659
movq 0x8(%r13), %r15
movl 0x10(%r13), %esi
movq %r15, %rdi
callq 0x11e3d
testl %eax, %eax
jne 0x112cb
movl 0x28(%r13), %ecx
movq %r14, %rdi
leaq 0x2064(%rip), %rsi      # 0x1360f
movq %r15, %rdx
xorl %eax, %eax
callq 0x3200
jmp 0x112c8
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
jmp 0x11408
movq 0x20(%r15), %rsi
movq %r14, %rdi
leaq 0x118d(%rip), %rdx      # 0x12762
movq (%rsp), %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movb $0xb, (%rbp)
movb %al, 0x3(%rbp)
jmp 0x1103b
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x11ecd
testl %eax, %eax
js 0x1166c
movl %eax, %r14d
movq 0x8(%r13), %rax
movq %rax, 0x8(%rsp)
leaq 0x1148(%rip), %rsi      # 0x12763
leaq 0x756e(%rip), %r15      # 0x18b90
movq 0x8(%rsp), %rdi
callq 0x3140
testl %eax, %eax
je 0x11640
movq 0x10(%r15), %rsi
addq $0x10, %r15
testq %rsi, %rsi
jne 0x11622
xorl %r15d, %r15d
testq %r15, %r15
je 0x116f1
movb 0x8(%r15), %al
movb %al, (%rbp)
movb %r14b, 0x3(%rbp)
jmp 0x116df
movl 0x28(%r15), %edx
movq %r14, %rdi
leaq 0x1fcf(%rip), %rsi      # 0x13636
jmp 0x112c1
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
movq %r14, %rdi
leaq 0x10e3(%rip), %rdx      # 0x12762
movq (%rsp), %r14
movq %r14, %rcx
callq 0x11ecd
testl %eax, %eax
js 0x11038
movl %eax, 0x18(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x8(%rsp)
leaq 0x1842(%rip), %rsi      # 0x12ee9
leaq 0x7602(%rip), %r15      # 0x18cb0
movq 0x8(%rsp), %rdi
callq 0x3140
testl %eax, %eax
je 0x116cc
movq 0x10(%r15), %rsi
addq $0x10, %r15
testq %rsi, %rsi
jne 0x116ae
xorl %r15d, %r15d
testq %r15, %r15
je 0x116e8
movb 0x8(%r15), %al
movb %al, (%rbp)
movl 0x18(%rsp), %eax
movb %al, 0x3(%rbp)
movq 0x20(%r13), %r13
jmp 0x1103b
movl 0x28(%r13), %ecx
movq %r14, %rdi
jmp 0x116f9
movl 0x28(%r13), %ecx
movq (%rsp), %rdi
leaq 0x1ddc(%rip), %rsi      # 0x134dc
movq 0x8(%rsp), %rdx
jmp 0x1140f
leaq 0x1d25(%rip), %rsi      # 0x13436
movq (%rsp), %r14
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %r14, %rdi
xorl %eax, %eax
callq 0x3200
jmp 0x1172d
movq (%rsp), %r14
cmpb $0x0, (%r14)
movl $0x0, %eax
jne 0x11748
testq %rbx, %rbx
je 0x11744
movslq %ebp, %rax
movb $0x0, (%rbx,%rax,8)
incl %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq