void EncryptOutcomingData(const unsigned char* src, unsigned char* dst, size_t inLength, size_t* outLength)
{
size_t m_PermutateParts; // x21
signed int v10; // w23
int* v11; // x24
int* v12; // x19
int* v13; // x22
int* v14; // x26
__int64 v15; // x28
int v17; // w27
__int64 v18; // x8
unsigned __int64 v19; // x9
unsigned __int64 v20; // x25
__int64 v21; // x21
unsigned __int64 v22; // x8
unsigned __int64 v23; // x23
__int64 v24; // x0
signed __int64 v25; // x8
unsigned __int64 v26; // x8
int* v27; // x8
int v28; // t1
unsigned __int64 v29; // x10
__int64 v30; // x9
__int64 v31; // x11
__int64 v32; // x13
uint64_t* v33; // x11
int* v34; // x12
__int64 v35; // q0
__int64 v36; // q1
size_t v37; // x8
size_t v39; // [xsp+18h] [xbp-48h]
size_t v40; // [xsp+20h] [xbp-40h]
const unsigned __int8* v41; // [xsp+28h] [xbp-38h]
unsigned __int8* v42; // [xsp+30h] [xbp-30h]
std::vector<int> used; // [xsp+40h] [xbp-20h] BYREF
__int64 v45; // [xsp+58h] [xbp-8h]
m_PermutateParts = 4;
if (m_PermutateParts > inLength)
{
memcpy(dst, src, inLength);
*outLength = inLength;
return;
}
memset(&used, 0, sizeof(used));
*outLength = inLength + m_PermutateParts + 1;
v42 = &dst[m_PermutateParts + 1];
memcpy(v42, src, inLength);
v10 = m_PermutateParts;
if (v10)
{
v11 = 0LL;
v12 = 0LL;
v13 = 0LL;
v14 = 0LL;
v15 = 0LL;
v40 = inLength / m_PermutateParts;
v41 = src;
v39 = (int)(inLength / m_PermutateParts);
while (1)
{
v17 = rand() % v10;
if (v14 != v13)
{
do
{
v18 = 0LL;
v19 = v14 - v13;
if (v19 <= 1)
v19 = 1LL;
while (v17 != v13[v18])
{
if (v19 == ++v18)
goto LABEL_5;
}
v13 = v12;
v17 = rand() % v10;
} while (v14 != v12);
v13 = v12;
}
LABEL_5:
if (v14 == v11)
break;
*v14++ = v17;
used.push_back(v17);
LABEL_7:
dst[(unsigned int)(v15 + 1)] = v17;
memcpy(&v42[v15 * v39], &v41[v17 * (int)v40], v39);
v10 = m_PermutateParts;
if (v10 <= (unsigned int)++v15)
goto LABEL_44;
}
v20 = (char*)v11 - (char*)v12;
v21 = v11 - v12;
v22 = v21 + 1;
if ((unsigned __int64)(v21 + 1) >> 62)
return;
if (v20 >> 1 > v22)
v22 = v20 >> 1;
if (v20 >= 0x7FFFFFFFFFFFFFFCLL)
v23 = 0x3FFFFFFFFFFFFFFFLL;
else
v23 = v22;
if (v23)
{
if (v23 >> 62)
return;
void* memory_block = operator new(4 * v23);
v24 = reinterpret_cast<uintptr_t>(memory_block);
v13 = (int*)(v24 + 4 * v21);
v25 = (char*)v11 - (char*)v12;
*v13 = v17;
v14 = v13 + 1;
if (v11 == v12)
goto LABEL_30;
}
else
{
v24 = 0LL;
v13 = (int*)(4 * v21);
v25 = (char*)v11 - (char*)v12;
*(uint16_t*)(4 * v21) = v17;
v14 = (int*)(4 * v21 + 4);
if (v11 == v12)
goto LABEL_30;
}
v26 = v25 - 4;
if (v26 >= 0xBC)
{
v29 = ((char*)(v11 - 1) - (char*)v12) & 0xFFFFFFFFFFFFFFFCLL;
if (v24 + v20 - 4 - v29 > v24 + v20 - 4)
{
v27 = v11;
}
else if ((int*)((char*)v11 - v29 - 4) > v11 - 1)
{
v27 = v11;
}
else if ((unsigned __int64)v12 - v24 >= 0x20)
{
v30 = (v26 >> 2) + 1;
v31 = 4 * (v30 & 0x7FFFFFFFFFFFFFF8LL);
v32 = v30 & 0x7FFFFFFFFFFFFFF8LL;
v27 = &v11[v31 / 0xFFFFFFFFFFFFFFFCLL];
v13 = (int*)((char*)v13 - v31);
v33 = (uint64_t*)(v24 + 4 * v21 - 16);
v34 = v11 - 4;
do
{
v36 = *((uint64_t*)v34 - 1);
v35 = *(uint64_t*)v34;
v34 -= 8;
v32 -= 8LL;
*(v33 - 1) = v36;
*v33 = v35;
v33 -= 2;
} while (v32);
if (v30 == (v30 & 0x7FFFFFFFFFFFFFF8LL))
goto LABEL_30;
}
else
{
v27 = v11;
}
}
else
{
v27 = v11;
}
do
{
v28 = *--v27;
*--v13 = v28;
} while (v27 != v12);
LABEL_30:
v11 = (int*)(v24 + 4 * v23);
if (v12)
operator delete(v12);
v12 = v13;
goto LABEL_7;
}
v12 = 0LL;
LABEL_44:
if (*outLength)
{
v37 = 0LL;
do
dst[v37++] ^= LOBYTE(m_PermutateParts);
while (*outLength > v37);
}
*dst = 27;
if (v12)
operator delete(v12);
}