#!/usr/bin/env python
# coding: utf-8

# # Pointer Aliasing

# In[20]:


get_ipython().system('rm -Rf tmp')
get_ipython().system('mkdir -p tmp')


# In[21]:


get_ipython().run_cell_magic('writefile', 'tmp/alias.c', 'void copy_twice(float * a, float * b, int n)\n{\n  for (int i = 0; i < n; ++i)\n  {\n    b[2*i] = 2*a[i];\n    b[2*i+1] = 2*a[i];\n  }\n\n}\n')


# In[22]:


get_ipython().system('cd tmp; gcc -c -O alias.c')
get_ipython().system('objdump --disassemble tmp/alias.o')


# * How can we prevent the value from `a` from being reloaded?
# * What happens without the `2*`?
