// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/towntalk.c
// Function: evaluate_array_expression
static enum result evaluate_array_expression( struct expression *this,
	struct variables *vars, struct variable *result ) {
	struct expression prev, *param = this->parameters, *expr = param->next;
	int idx, len, buf = this->index == 'B';
	struct variable var = { 0, NULL };
	struct structure *struc = NULL;
	char msg[ 128 ] = "";
	struct array *arr;
	enum result ret = param->evaluate( param, vars, &var );
	prev.next = NULL;
	if( ret ) {
		if( var.string_value ) {
			if( var.string_value->type == ELEMENT ) {
				if( expr == NULL ) {
					parse_expressions( ( struct element * ) var.string_value, vars->func, NULL, 0, &prev, &len, msg );
					if( msg[ 0 ] == 0 ) {
						expr = prev.next;
						if( param->evaluate != evaluate_string_literal_expression ) {
							expr_set_line( expr, this->line );
						}
					} else {
						ret = throw( vars, this, 0, msg );
					}
				} else {
					ret = throw( vars, expr, 0, "Unexpected expression." );
				}
			} else if( var.string_value->type == STRUCT && !buf ) {
				struc = ( struct structure * ) var.string_value;
				len = struc->length;
			} else {
				ret = to_int( &var, &len, vars, param );
			}
		} else {
			len = var.number_value;
		}
	}
	if( ret ) {
		if( len >= 0 ) {
			if( buf ) {
				arr = new_buffer( len );
			} else {
				arr = new_array( vars->func->env, len, 0 );
				if( arr ) {
					arr->str.string = "[Array]";
					arr->str.length = 7;
				}
			}
			if( arr ) {
				idx = 0;
				while( expr && ret ) {
					if( idx < len ) {
						dispose_variable( &var );
						ret = expr->evaluate( expr, vars, &var );
						if( ret ) {
							ret = assign_array_variable( &var, arr, idx++, vars, expr );
						}
					} else {
						ret = throw( vars, this, idx, "Array index out of bounds." );
					}
					expr = expr->next;
				}
				if( ret ) {
					arr->structure = struc;
					result->string_value = &arr->str;
				} else {
					unref_string( &arr->str );
				}
			} else {
				ret = throw_out_of_memory( vars, this );
			}
		} else {
			ret = throw( vars, this, var.number_value, "Invalid array length." );
		}
	}
	dispose_temporary( &var );
	if( prev.next ) {
		dispose_expressions( prev.next );
	}
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x42, 0x4(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x54(%rbp)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x30f0
movq $0x0, -0x70(%rbp)
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x30f0
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq *%rax
movl %eax, -0xfc(%rbp)
movq $0x0, -0x28(%rbp)
cmpl $0x0, -0xfc(%rbp)
je 0xd2db
cmpq $0x0, -0x60(%rbp)
je 0xd2d3
movq -0x60(%rbp), %rax
movsbl 0x14(%rax), %eax
cmpl $0x1, %eax
jne 0xd28d
cmpq $0x0, -0x48(%rbp)
jne 0xd26f
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0xf0(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
leaq -0x38(%rbp), %r8
leaq -0x50(%rbp), %r9
movq %rax, (%rsp)
callq 0xac40
movsbl -0xf0(%rbp), %eax
cmpl $0x0, %eax
jne 0xd251
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
leaq -0x948a(%rip), %rcx     # 0x3db0
cmpq %rcx, 0x18(%rax)
je 0xd24f
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %esi
callq 0xd4c0
jmp 0xd26d
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
leaq -0xf0(%rbp), %rcx
xorl %edx, %edx
callq 0x4330
movl %eax, -0xfc(%rbp)
jmp 0xd28b
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
xorl %edx, %edx
leaq 0xee32(%rip), %rcx      # 0x1c0b2
callq 0x4330
movl %eax, -0xfc(%rbp)
jmp 0xd2d1
movq -0x60(%rbp), %rax
movsbl 0x14(%rax), %eax
cmpl $0x3, %eax
jne 0xd2b4
cmpl $0x0, -0x54(%rbp)
jne 0xd2b4
movq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x50(%rbp)
jmp 0xd2cf
movq -0x10(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5100
movl %eax, -0xfc(%rbp)
jmp 0xd2d1
jmp 0xd2d9
movl -0x68(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0xd2db
cmpl $0x0, -0xfc(%rbp)
je 0xd48f
cmpl $0x0, -0x50(%rbp)
jl 0xd470
cmpl $0x0, -0x54(%rbp)
je 0xd309
movl -0x50(%rbp), %edi
callq 0xd510
movq %rax, -0xf8(%rbp)
jmp 0xd352
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x40(%rax), %rdi
movl -0x50(%rbp), %esi
xorl %edx, %edx
callq 0x3810
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
je 0xd350
movq -0xf8(%rbp), %rax
leaq 0xed8b(%rip), %rcx      # 0x1c0c9
movq %rcx, 0x8(%rax)
movq -0xf8(%rbp), %rax
movl $0x7, 0x10(%rax)
jmp 0xd352
cmpq $0x0, -0xf8(%rbp)
je 0xd45b
movl $0x0, -0x4c(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x48(%rbp)
movb %al, -0xfd(%rbp)
je 0xd386
cmpl $0x0, -0xfc(%rbp)
setne %al
movb %al, -0xfd(%rbp)
movb -0xfd(%rbp), %al
testb $0x1, %al
jne 0xd395
jmp 0xd424
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0xd3f6
leaq -0x68(%rbp), %rdi
callq 0x3be0
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq *%rax
movl %eax, -0xfc(%rbp)
cmpl $0x0, -0xfc(%rbp)
je 0xd3f4
movq -0xf8(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rcx
movq -0x48(%rbp), %r8
leaq -0x68(%rbp), %rdi
callq 0x5270
movl %eax, -0xfc(%rbp)
jmp 0xd413
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl -0x4c(%rbp), %edx
leaq 0xe28b(%rip), %rcx      # 0x1b693
callq 0x4330
movl %eax, -0xfc(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xd367
cmpl $0x0, -0xfc(%rbp)
je 0xd44d
movq -0x70(%rbp), %rcx
movq -0xf8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0xf8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xd459
movq -0xf8(%rbp), %rdi
callq 0x3c20
jmp 0xd46e
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x5f20
movl %eax, -0xfc(%rbp)
jmp 0xd48d
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl -0x68(%rbp), %edx
leaq 0xec4f(%rip), %rcx      # 0x1c0d1
callq 0x4330
movl %eax, -0xfc(%rbp)
jmp 0xd48f
leaq -0x68(%rbp), %rdi
callq 0x3ce0
cmpq $0x0, -0x28(%rbp)
je 0xd4a8
movq -0x28(%rbp), %rdi
callq 0x3e60
movl -0xfc(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw (%rax,%rax)