void printi(int val);

static int va_getargs(int *val, int n, __builtin_va_list ap)
{
  int i;

  for (i = 0; i < n; i++) {
    val[i] = __builtin_va_arg((ap), int);
  }

  return 0;
}

static int getargs(int *val, int n, ...)
{
  __builtin_va_list arg;
  int done;

  __builtin_va_start((arg), (n));
  done = va_getargs(val, n, arg);
  __builtin_va_end((arg));

  return done;
}

int main()
{
  int val[8];
  int i;

  getargs(val, 8, 1, 2, 3, 4, 5, 6, 7, 8); 

  for (i = 0; i < 8; i++) {
    printi(val[i]);
  }

  return 0;
}
