#include extern char __heap_base; static int allocated; void set_sp(char *sp) { __asm__ __volatile__( ".globaltype __stack_pointer, i32\n" "local.get %0\n" "global.set __stack_pointer\n" : : "r"(sp) ); } void * alloc(int size) { void *result = &__heap_base + allocated; allocated += size; return(result); } static void impl(int *buffer, int index, int number) { buffer[index] = number; } void write_a_number(int *buffer, int index, int number) { int n = number * 2; impl(buffer, index, n); }