/* b.c */
register int bar asm ("rbx");
int h(int a, int b) {
int t = rand()*2000;
bar = t;
printf("bar inited to %d\n", t);
return bar;
}
(3/m)
register int bar asm ("rbx");
int h(int a, int b) {
int t = rand()*2000;
bar = t;
printf("bar inited to %d\n", t);
return bar;
}
(3/m)
Comments
void i();
int main(void) {
int a = 10;
int b = 20;
int result = g(a, b);
printf("%d\n", result);
result = h(a, b);
printf("%d\n", result);
i();
return 0;
} (4/m)
foo inited to 40311868
40311868
bar inited to 1644657376
1644657376
foo = 1644657376
foo is overwritten because of the assignment to bar (which can very well be in an dynamically linked library whose source you can't modify). (5/m)