// File: /workspace/github_c_makefile_star2_O2/martincameron[P]towntalk/towntalk.c
// Function: execute_array_assignment
enum result execute_array_assignment( struct statement *this,
	struct variables *vars, struct variable *result ) {
	int idx;
	struct array *arr;
	enum result ret = OKAY;
	struct variable dest = { 0, NULL }, src = { 0, NULL };
	struct expression *src_expr = this->source, *dest_expr = src_expr->next, *idx_expr = dest_expr->next;
	if( dest_expr->evaluate == evaluate_local ) {
		arr = ( struct array * ) vars->locals[ dest_expr->index ].string_value;
	} else {
		ret = dest_expr->evaluate( dest_expr, vars, &dest );
		arr = ( struct array * ) dest.string_value;
	}
	if( ret ) {
		if( arr && arr->str.type == ARRAY ) {
			ret = evaluate_integer( idx_expr, vars, &idx );
			if( ret ) {
				if( ( unsigned int ) idx < ( unsigned int ) arr->length ) {
					ret = src_expr->evaluate( src_expr, vars, &src );
					if( ret ) {
						if( arr->string_values ) {
							if( arr->string_values[ idx ] ) {
								unref_string( arr->string_values[ idx ] );
							}
							arr->number_values[ idx ] = src.number_value;
							arr->string_values[ idx ] = src.string_value;
						} else if( src.string_value ) {
							ret = to_num( &src, &arr->number_values[ idx ], vars, src_expr );
							dispose_temporary( &src );
						} else {
							arr->number_values[ idx ] = src.number_value;
						}
					}
				} else {
					ret = throw( vars, idx_expr, idx, "Array index out of bounds." );
				}
			}
		} else {
			ret = throw( vars, dest_expr, 0, "Not an array." );
		}
		dispose_temporary( &dest );
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq 0x8(%rdi), %r14
movq 0x10(%r14), %r15
movq 0x10(%r15), %r12
movq 0x18(%r15), %rax
leaq -0x637(%rip), %rcx      # 0x407b
cmpq %rcx, %rax
je 0x46d3
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x4782
movq 0x28(%rsp), %r13
jmp 0x46e4
movq 0x10(%rbx), %rax
movslq 0x4(%r15), %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %r13
testq %r13, %r13
je 0x4760
cmpb $0x2, 0x14(%r13)
jne 0x4760
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4514
xorl %ebp, %ebp
testl %eax, %eax
je 0x4776
movslq 0xc(%rsp), %r15
cmpl 0x40(%r13), %r15d
jae 0x4795
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x18(%r14)
testl %eax, %eax
je 0x4776
movl %eax, %r12d
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x47a7
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
je 0x4746
callq 0x38b2
movq 0x20(%r13), %rax
movl 0x10(%rsp), %ecx
movq 0x18(%r13), %rdx
movl %ecx, (%rdx,%r15,4)
movq 0x18(%rsp), %rcx
movq %rcx, (%rax,%r15,8)
movl %r12d, %ebp
jmp 0x4776
leaq 0xcac3(%rip), %rcx      # 0x1122a
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3bb2
leaq 0x20(%rsp), %rdi
callq 0x3988
jmp 0x4784
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xca73(%rip), %rcx      # 0x1120f
movq %rbx, %rdi
movq %r12, %rsi
movl %r15d, %edx
jmp 0x4771
cmpq $0x0, 0x18(%rsp)
je 0x47d9
shlq $0x2, %r15
addq 0x18(%r13), %r15
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x4399
movl %eax, %ebp
movq %r12, %rdi
callq 0x3988
jmp 0x4776
movl 0x10(%rsp), %eax
movq 0x18(%r13), %rcx
movl %eax, (%rcx,%r15,4)
jmp 0x475b