// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/ttasm.c
// Function: parse_letv_a
static struct element* parse_letv_a( struct element *elem, struct function *func, struct instruction *output, char *message ) {
	/*
		opcode      x y z imm : mnemonic
		letv_ai     x y 0 imm : let x = [ y imm ];
		letv_av     x y z   0 : let x = [ y z ];
		letv_ap     x y z   0 : let x = [ y z++ ];
	*/
	char *str;
	struct element *child, *next = elem->next;
	int idx = get_local_variable( func, next, "", message );
	if( idx >= 0 ) {
		output->x = idx;
		next = next->next->next;
		if( next->child && next->child->next && next->child->next->next == NULL ) {
			child = next->child;
			idx = get_local_variable( func, child, "", message );
			if( idx >= 0 ) {
				output->y = idx;
				str = child->next->str.string;
				if( str[ 0 ] == '-' || ( str[ 0 ] >= '0' && str[ 0 ] <= '9' ) ) {
					/* letv_ai */
					if( parse_number( str, &output->imm ) ) {
						output->opcode = LETV_AI;
					} else {
						sprintf( message, "Invalid immediate '%.64s' at line %d.", child->next->str.string, child->next->line );
						next = NULL;
					}
				} else {
					/* letv_av */
					idx = get_local_variable( func, child->next, "", NULL );
					if( idx >= 0 ) {
						output->opcode = LETV_AV;
						output->z = idx;
					} else {
						/* letv_ap*/
						idx = get_local_variable( func, child->next, "++", message );
						if( idx >= 0 ) {
							output->opcode = LETV_AP;
							output->z = idx;
						} else {
							next = NULL;
						}
					}
				}
			} else {
				next = NULL;
			}
		} else {
			sprintf( message, "Invalid index expression on line %d.", next->line );
			next = NULL;
		}
	} else {
		next = NULL;
	}
	return next;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq 0xdef(%rip), %rdx       # 0x1b056
callq 0x1a960
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x1a443
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1a420
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x20(%rax)
je 0x1a420
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1a420
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq 0xd69(%rip), %rdx       # 0x1b056
callq 0x1a960
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x1a416
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x1a33f
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x1a394
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jg 0x1a394
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
callq 0x5d90
cmpl $0x0, %eax
je 0x1a35e
movq -0x18(%rbp), %rax
movb $0x9, (%rax)
jmp 0x1a38f
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x28(%rax), %ecx
leaq 0x2607(%rip), %rsi      # 0x1c987
movb $0x0, %al
callq 0x31f0
movq $0x0, -0x38(%rbp)
jmp 0x1a414
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0xcaf(%rip), %rdx       # 0x1b056
xorl %eax, %eax
movl %eax, %ecx
callq 0x1a960
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x1a3ce
movq -0x18(%rbp), %rax
movb $0xa, (%rax)
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x3(%rax)
jmp 0x1a412
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rcx
leaq 0x1849(%rip), %rdx      # 0x1bc2e
callq 0x1a960
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x1a408
movq -0x18(%rbp), %rax
movb $0xb, (%rax)
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x3(%rax)
jmp 0x1a410
movq $0x0, -0x38(%rbp)
jmp 0x1a412
jmp 0x1a414
jmp 0x1a41e
movq $0x0, -0x38(%rbp)
jmp 0x1a441
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x28(%rax), %edx
leaq 0x162a(%rip), %rsi      # 0x1ba5c
movb $0x0, %al
callq 0x31f0
movq $0x0, -0x38(%rbp)
jmp 0x1a44b
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)