// File: /workspace/github_c_makefile_star2_O3/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 -0x6cc(%rip), %rcx      # 0x41dc
cmpq %rcx, %rax
je 0x48c9
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x497d
movq 0x28(%rsp), %r13
jmp 0x48da
movq 0x10(%rbx), %rax
movslq 0x4(%r15), %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %r13
testq %r13, %r13
je 0x4956
cmpb $0x2, 0x14(%r13)
jne 0x4956
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x46e7
xorl %ebp, %ebp
testl %eax, %eax
je 0x496c
movslq 0xc(%rsp), %r15
cmpl 0x40(%r13), %r15d
jae 0x4990
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x18(%r14)
testl %eax, %eax
je 0x496c
movl %eax, %r12d
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x49a2
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
je 0x493c
callq 0x394d
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 0x496c
leaq 0xd88d(%rip), %rcx      # 0x121ea
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3c96
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x497f
callq 0x394d
jmp 0x497f
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd838(%rip), %rcx      # 0x121cf
movq %rbx, %rdi
movq %r12, %rsi
movl %r15d, %edx
jmp 0x4967
cmpq $0x0, 0x18(%rsp)
je 0x49db
shlq $0x2, %r15
addq 0x18(%r13), %r15
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x4559
movl %eax, %ebp
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x496c
callq 0x394d
jmp 0x496c
movl 0x10(%rsp), %eax
movq 0x18(%r13), %rcx
movl %eax, (%rcx,%r15,4)
jmp 0x4951