#include "string.h"

#define padding (sizeof(uint32_t)-1)

void * memcpy(void * _dst, void const * _src, uint32_t len)
{
  uint32_t * uidst = (uint32_t *) _dst;
  const uint32_t * uisrc = (const uint32_t *) _src;

  if (!((uint32_t)_src & padding) && !((uint32_t)_dst & padding))
  {
    while (len >= sizeof(uint32_t))
    {
      *uidst++ = *uisrc++;
      len -= sizeof(uint32_t);
    }
  }

  uint8_t * cdst = (uint8_t *) uidst;
  uint8_t * csrc = (uint8_t *) uisrc;

  while (len--)
  {
    *cdst++ = *csrc++;
  }

  return (_dst);
} 

char *itoa(int value, char *dst, int base)
{
  int t1 = value;
  uint32_t t2;

  int i = 30;
  dst[31]='\0';
  const char val[] = "0123456789abcdef";
  if (t1 == 0)
  {
    dst[30]='0';
    return dst+30;
  }
  if (t1 < 0)
  {
    t2 = (uint32_t)t1;
    /*t ^= 0xffffffff;
      t-=1;*/
    while (t2 && i)
    {
      dst[i] = val[t2%base];
      t2 /= base;
      i--;
    }
  }
  else
  {
    while (t1 && i)
    {
      dst[i] = val[t1%base];
      t1 /= base;
      i--;
    }
  }
  return dst+i+1;
}
