ViFreeMapRegistersToFile

UINT64 __stdcall ViFreeMapRegistersToFile(_MAP_REGISTER_FILE *MapRegisterFile, VOID *CurrentSa, UINT64 Length){
  unsigned int v3; 
  unsigned __int64 v5; 
  UINT64 result; 
  UINT64 v7; 

  v3 = MapRegisterFile[8];
  if( (_DWORD)Length )
  {
    v5 = (((unsigned __int16)CurrentSa & 0xFFF) + (unsigned __int64)(unsigned int)Length + 4095) >> 12;
    if( (unsigned int)v5 >= v3 )
      LODWORD(v5) = MapRegisterFile[8];
  }
  else
  {
    if( v3 > 1 )
      v3 = 1;
    LODWORD(v5) = v3;
  }
  result = (UINT64)ViFindMappedRegisterInFile(MapRegisterFile, CurrentSa, 0i64);
  if( result )
  {
    if( (_DWORD)v5 )
    {
      v7 = result + 12;
      do
      {
        if( !*(_QWORD *)(v7 - 12) )
          break;
        ViCheckTag(
          (VOID *)(*(_QWORD *)(v7 + 4) + 4096i64 + (*(_DWORD *)(v7 - 12) & 0xFFF)),
          *(unsigned int *)(v7 - 4),
          1ui64,
          3u);
        *(_DWORD *)v7 &= 0xFFFFFFFC;
        *(_QWORD *)(v7 - 12) = 0i64;
        *(_DWORD *)(v7 - 4) = 0;
        v7 += 32i64;
        _InterlockedDecrement(MapRegisterFile + 8);
        LODWORD(v5) = v5 - 1;
      }
      while( (_DWORD)v5 );
    }
    return 1i64;
  }
  return result;
}

Referenced by:

ViFlushDoubleBuffer