Slide 16
Slide 16 text
16 / 23
Resulting PS for example
int get_next_index(int a) {
return a + 1;
}
void print_element(int* arr ,
int num) {
printf("arr=%i\n",
arr[num]);
}
void print_next_element(int*
arr , int num) {
int idx =
get_next_index(num);
print_element(arr , idx);
}
int main(int argc , char*
argv []) {
int a[] = {1, 2, 3};
print_element(a, 0);
print_next_element(a, 0);
return 0;
}
main_ %0= alloca (3,(3 * 1)),
@I arraydecay1=gep[inbounds ](main_ %0 ,0+0+0),
print_next_element_num =0
print_next_element_arr=arraydecay1
)->(
@I next_index =( print_next_element_num + 1),
print_next_element_call=next_index
)->(
num=print_next_element_call
arr=print_next_element_arr
)->(
@I idxprom=cast(+ Integer (64), num),
@I arrayidx=gep(arr ,0+ idxprom))