strncpy_s

INT64 __stdcall strncpy_s(PCHAR Dst, UINT64 SizeInBytes, PCHAR Src, UINT64 a4){
  unsigned int v5; 
  PCHAR v6; 
  UINT64 v7; 
  signed __int64 v8; 
  CHAR v9; 
  signed __int64 v10; 
  CHAR v11; 
  if( a4 )
  {
    if( !Dst )
      goto LABEL_4;
  }
  else if( !Dst )
  {
    if( SizeInBytes )
    {
LABEL_4:
      xHalTimerWatchdogStop(0i64, 0i64);
      return 22i64;
    }
    return 0i64;
  }
  if( !SizeInBytes )
    goto LABEL_4;
  if( !a4 )
  {
    *Dst = 0;
    return 0i64;
  }
  if( Src )
  {
    v6 = Dst;
    v7 = SizeInBytes;
    if( a4 == -1i64 )
    {
      v8 = Dst - Src;
      do
      {
        v9 = *Src;
        Src[v8] = *Src;
        ++Src;
        if( !v9 )
          break;
        --v7;
      }
      while( v7 );
    }
    else
    {
      v10 = Src - Dst;
      do
      {
        v11 = v6[v10];
        *v6++ = v11;
        if( !v11 )
          break;
        if( !--v7 )
          break;
        --a4;
      }
      while( a4 );
      if( !a4 )
        *v6 = 0;
    }
    if( v7 )
      return 0i64;
    if( a4 == -1i64 )
    {
      Dst[SizeInBytes - 1] = 0;
      return 80i64;
    }
    v5 = 34;
  }
  else
  {
    v5 = 22;
  }
  *Dst = 0;
  xHalTimerWatchdogStop(0i64, 0i64);
  return v5;
}

Referenced by:

CmpGetToken
HalGetEnvironmentVariable
splitpath_s