convert load with load from getElementPtr

I am new to writing LLVM pass so please help me. I want to replace my pure load instruction like

 %a = alloca i32, align 4
 %0 = load i32, i32* %a, align 4

to the load from getElementPtr like

%a = alloca i32, align 4
%p = alloca i32*, align 8
store i32* %a, i32** %p, align 8
%0 = load i32*, i32** %p, align 8
%1 = load i32, i32* %0, align 4

How to write LLVM pass to replace the above?

Where is the getElementPtr?