sub_1407A2064

INT64 __fastcall sub_1407A2064(INT64 a1, CHAR a2, VOID *a3, UINT64 a4, UINT64 *a5){
  unsigned int v5; 
  unsigned int v6; 
  unsigned __int64 v10; 
  unsigned __int16 *v11; 
  INT64 v12; 
  __int64 v13; 
  char *v14; 
  unsigned __int64 v15; 
  unsigned __int64 v16; 
  int v17; 
  __int64 v18; 
  unsigned __int16 *v19; 
  v5 = 0;
  v6 = a4;
  if( a3 )
    memset((INT64)a3, 0i64);
  v10 = (unsigned int)(*(_DWORD *)(a1 + 4) + 20);
  v11 = 0i64;
  if( a1 + 20 != v10 + a1 )
    v11 = (unsigned __int16 *)(a1 + 20);
  while( v11 )
  {
    v12 = (INT64)v11 - a1;
    if( a2 == 1 )
    {
      if( v12 + 20 > v10 )
        return 3221225534i64;
      v13 = *v11;
      if( v13 + v12 > v10 )
        return 3221225534i64;
      if( v11[1] > (unsigned __int16)v13 )
        return 3221225534i64;
      v14 = (char *)v11 + v13;
      if( (unsigned __int16 *)((char *)v11 + v13) < v11 )
        return 3221225534i64;
      v15 = (unsigned __int64)v11 + v11[1] + 16;
      if( v15 < (unsigned __int64)(v11 + 8) )
        return 3221225534i64;
      if( v15 > (unsigned __int64)v14 )
        return 3221225534i64;
      v16 = (unsigned __int64)v11 + v11[1] + (unsigned __int64)v11[3] + 16;
      if( v16 < (unsigned __int64)(v11 + 8) )
        return 3221225534i64;
      if( v16 > (unsigned __int64)v14 )
        return 3221225534i64;
      v17 = *((_DWORD *)v11 + 2);
      if( v17 )
      {
        if( (v17 & 3) == 0 )
          return 3221225534i64;
      }
    }
    if( a3 && v5 < v6 )
    {
      v18 = 2i64 * v5;
      *((_BYTE *)a3 + 8 * v18) = 2;
      *((_QWORD *)a3 + v18 + 1) = v11;
    }
    ++v5;
    v19 = (unsigned __int16 *)((char *)v11 + *v11);
    v11 = 0i64;
    if( v19 != (unsigned __int16 *)(v10 + a1) )
      v11 = v19;
  }
  if( a5 )
    *(_DWORD *)a5 = v5;
  return v6 < v5 ? 0xC0000023 : 0;
}

Referenced by:

ExpLoadAndSortLicensingCacheDescriptors
SLUpdateLicenseDataInternal