safecrt_wctomb_s

__int64 __fastcall safecrt_wctomb_s(int *a1, char *a2, unsigned __int64 a3, wchar_t a4){
  UINT64 BytesInUnicodeString; 
  UINT64 BytesInMultiByteString; 
  wchar_t UnicodeString; 

  UnicodeString = a4;
  if( !a2 && a3 )
  {
    if( a1 )
      *a1 = 0;
    return 0i64;
  }
  if( a1 )
    *a1 = -1;
  if( a3 > 0x7FFFFFFF )
  {
    xHalTimerWatchdogStop(0i64, 0i64);
    return 22i64;
  }
  if( !a2 )
  {
    if( a1 )
      *a1 = _mb_cur_max;
    return 0i64;
  }
  LODWORD(BytesInMultiByteString) = 0;
  LODWORD(BytesInUnicodeString) = 2;
  if( RtlUnicodeToMultiByteN(
         a2,
         (unsigned int)a3,
         (PULONG)&BytesInMultiByteString,
         &UnicodeString,
         BytesInUnicodeString) >= 0 )
  {
    if( a1 )
      *a1 = BytesInMultiByteString;
    return 0i64;
  }
  if( a3 )
    memset(a2, 0i64, a3);
  return 42i64;
}

Referenced by:

output_s