RtlIntegerToUnicode

NTSTATUS __stdcall RtlIntegerToUnicode(UINT64 Value, UINT64 Base, ULONG OutputLength, WCHAR *String, _STRING *a5){
  unsigned int v7; 
  unsigned int v8; 
  int v9; 
  int v10; 
  char *v11; 
  int v12; 
  __int64 v13; 
  bool v14; 
  __int64 v16; 
  WCHAR *v17; 
  __int64 i; 
  char v19[14]; 

  v7 = Base;
  v8 = Value;
  switch( (_DWORD)Base )
  {
    case 0:
      v7 = 10;
      goto LABEL_3;
    case 0xA:
LABEL_3:
      v9 = 0;
      v10 = 0;
      goto LABEL_4;
    case 0x10:
      v9 = 4;
      break;
    case 2:
      v9 = 1;
      break;
    case 8:
      v9 = 3;
      break;
    default:
      return -1073741811;
  }
  v10 = (1 << v9) - 1;
LABEL_4:
  v11 = v19;
  do
  {
    if( v9 )
    {
      v12 = v8 & v10;
      v8 >>= v9;
    }
    else
    {
      v12 = v8 % v7;
      v8 /= v7;
    }
    v11 -= 2;
    *(_WORD *)v11 = RtlpIntegerWChars[v12];
  }
  while( v8 );
  v13 = (v19 - v11) >> 1;
  if( (OutputLength & 0x80000000) == 0 )
    goto LABEL_9;
  OutputLength = -OutputLength;
  v14 = (int)v13 <= (int)OutputLength;
  if( (int)v13 < (int)OutputLength )
  {
    v16 = OutputLength - (unsigned int)v13;
    v17 = String;
    for( i = (unsigned int)v16; i; --i )
      *v17++ = 48;
    OutputLength = (v19 - v11) >> 1;
    String += v16;
LABEL_9:
    v14 = (int)v13 <= (int)OutputLength;
  }
  if( !v14 )
    return -2147483643;
  memmove(String, v11, 2 * v13);
  if( (int)v13 < (int)OutputLength )
    String[(unsigned int)v13] = 0;
  return 0;
}

Referenced by:

RtlConvertSidToUnicodeString