#include <avr/io.h>

#define B35 (1ULL<<35)

char * utoa10(uint32_t x, char *str){
  #define D ((B35 + 5) / 10)
  uint32_t i;
  char *s1, *s = str;
  do {
    x = (i = x) * D >> 35;
    *s++ = i - x * 10 + '0';
  } while (x);
  *(s1 = s) = 0;
  while ((unsigned int)--s > (unsigned int)str) {
    i = *s;
    *s = *str;
    *str++ = i;
  }
  return s1;
  #undef D
}

char* u32toa(uint32_t val, char *buf){
  buf+=10;
  buf[1] = 0;
  do{
    buf[0] = val % 10;
    val /= 10;
    if(buf[0] < 10)buf[0] += '0'; else buf[0] = buf[0] - 0x0A + 'A';
    buf--;
  }while(val);
  return buf;
}

int main(){
  char buf[20];
  volatile char *res;
  res = utoa10(0x12345678, buf);
  res = u32toa(0x87654321, buf);
}
