// File: /workspace/github_c_makefile_star2_O1/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), %r12
movq 0x10(%r12), %r15
movq 0x18(%r12), %rax
leaq -0x6ca(%rip), %rcx      # 0x420d
cmpq %rcx, %rax
je 0x48f7
leaq 0x20(%rsp), %r13
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq *%rax
movq 0x8(%r13), %r13
testl %eax, %eax
sete %al
jmp 0x490b
movq 0x10(%rbx), %rax
movslq 0x4(%r12), %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %r13
xorl %eax, %eax
xorl %ebp, %ebp
testb %al, %al
jne 0x49b6
testq %r13, %r13
je 0x4991
cmpb $0x2, 0x14(%r13)
jne 0x4991
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4714
xorl %ebp, %ebp
testl %eax, %eax
je 0x49a7
movslq 0xc(%rsp), %r12
cmpl 0x40(%r13), %r12d
jae 0x49c7
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x18(%r14)
testl %eax, %eax
je 0x49a7
movl %eax, %r15d
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x49d9
movq (%rax,%r12,8), %rdi
testq %rdi, %rdi
je 0x4973
callq 0x3979
movl 0x10(%rsp), %eax
movq 0x18(%r13), %rcx
movl %eax, (%rcx,%r12,4)
movq 0x18(%rsp), %rax
movq 0x20(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movl %r15d, %ebp
jmp 0x49a7
leaq 0xd84a(%rip), %rcx      # 0x121e2
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3cc3
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x49b6
callq 0x3979
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd7f9(%rip), %rcx      # 0x121c7
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
jmp 0x49a2
cmpq $0x0, 0x18(%rsp)
je 0x4a11
shlq $0x2, %r12
addq 0x18(%r13), %r12
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x4585
movl %eax, %ebp
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x49a7
callq 0x3979
jmp 0x49a7
movl 0x10(%rsp), %eax
movq 0x18(%r13), %rcx
movl %eax, (%rcx,%r12,4)
jmp 0x498c