safecrt_wctomb_s

__int64 __fastcall safecrt_wctomb_s(_DWORD *a1, CHAR *a2, size_t a3, WCHAR a4){
  UINT64 BytesInUnicodeString; 
  UINT64 BytesInMultiByteString; 
  WCHAR 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, &BytesInMultiByteString, &UnicodeString, BytesInUnicodeString) >= 0 )
  {
    if( a1 )
      *a1 = BytesInMultiByteString;
    return 0i64;
  }
  if( a3 )
    memset((INT64)a2, 0i64);
  return 42i64;
}

Referenced by:

output_s