RtlIntegerToUnicode

INT64 __fastcall RtlIntegerToUnicode(UINT64 Value, UINT64 Base, INT64 OutputLength, WCHAR *String){
  int v5; 
  unsigned int v6; 
  unsigned int v7; 
  int v8; 
  int v9; 
  UINT8 *v10; 
  int v11; 
  __int64 v12; 
  bool v13; 
  __int64 v15; 
  WCHAR *v16; 
  __int64 i; 
  char v18[14]; 
  v5 = OutputLength;
  v6 = Base;
  v7 = Value;
  switch( (_DWORD)Base )
  {
    case 0:
      v6 = 10;
      goto LABEL_3;
    case 0xA:
LABEL_3:
      v8 = 0;
      v9 = 0;
      goto LABEL_4;
    case 0x10:
      v8 = 4;
      break;
    case 2:
      v8 = 1;
      break;
    case 8:
      v8 = 3;
      break;
    default:
      return 3221225485i64;
  }
  v9 = (1 << v8) - 1;
LABEL_4:
  v10 = (UINT8 *)v18;
  do
  {
    if( v8 )
    {
      v11 = v7 & v9;
      v7 >>= v8;
    }
    else
    {
      v11 = v7 % v6;
      v7 /= v6;
    }
    v10 -= 2;
    *(_WORD *)v10 = RtlpIntegerWChars[v11];
  }
  while( v7 );
  v12 = (v18 - (char *)v10) >> 1;
  if( v5 >= 0 )
    goto LABEL_9;
  v5 = -v5;
  v13 = (int)v12 <= v5;
  if( (int)v12 < v5 )
  {
    v15 = (unsigned int)(v5 - v12);
    v16 = String;
    for( i = (unsigned int)v15; i; --i )
      *v16++ = 48;
    v5 = (v18 - (char *)v10) >> 1;
    String += v15;
LABEL_9:
    v13 = (int)v12 <= v5;
  }
  if( !v13 )
    return 2147483653i64;
  memmove((UINT8 *)String, v10, 2i64 * (unsigned int)v12);
  if( (int)v12 < v5 )
    String[(unsigned int)v12] = 0;
  return 0i64;
}

Referenced by:

RtlConvertSidToUnicodeString