void printc(char val);
void printi(int val);
void printstr(char *str);

static int va_tiny_printf(char *format, __builtin_va_list ap)
{
  char *p;

  for (p = format; *p; p++) {
    switch (*p) {
    case 'c': printc(__builtin_va_arg(ap, int)); break;
    case 'i': printi(__builtin_va_arg(ap, int)); break;
    case 's': printstr(__builtin_va_arg(ap, char *)); break;
    default:
      break;
    }
  }

  return 0;
}

static int tiny_printf(char *format, ...)
{
  __builtin_va_list arg;
  int done;

  __builtin_va_start(arg, format);
  done = va_tiny_printf(format, arg);
  __builtin_va_end(arg);

  return done;
}

int main()
{
  tiny_printf("cis", 1, 100, "TEST");
  return 0;
}
