//
// sub_CC3040 from 0xcc3040 to 0xcc3194 (340 bytes)
//
// 10 xrefs:
// > EditorSFXManager::decodeSound @ 0xcc321c
// > EditorSFXManager::decodeSound @ 0xcc324c
// > EditorSFXManager::summarizeBlob @ 0xcc56e4
// > EditorSFXManager::summarizeBlob @ 0xcc5714
// > EditorSFXManager::summarizeBlob @ 0xcc5868
// > EditorSFXManager::summarizeBlob @ 0xcc58bc
// > EditorSFXManager::summarizeBlob @ 0xcc58ec
// > EditorSFXManager::deserializeAll @ 0xcc6310
// > EditorSFXManager::deserializeAll @ 0xcc6340
// > EditorSFXManager::deserializeAll @ 0xcc667c
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:06:18 +0000
//
__int64 __fastcall sub_CC3040(unsigned __int8 *a1, unsigned __int64 *a2, __int64 *a3, unsigned __int8 a4)
{
int v6; // w22
int v8; // w1
unsigned __int64 v9; // x19
unsigned __int64 v10; // x4
unsigned __int8 *v11; // x26
unsigned __int64 v12; // x21
unsigned __int64 v13; // x3
size_t v14; // x2
unsigned __int8 *v15; // x1
size_t v16; // x3
unsigned __int8 *v17; // x1
int v19; // w3
size_t v20; // x2
unsigned __int8 *v21; // x0
char *v22; // x0
v6 = *a1;
v8 = a4;
v9 = *a2;
if ( (v6 & 1) == 0 )
{
v19 = v6 >> 1;
if ( v9 <= v6 >> 1 )
{
v12 = v19;
if ( v9 >= v19 )
{
LABEL_13:
v13 = v12;
v14 = v12 - v9;
goto LABEL_5;
}
v20 = v19 - v9;
v11 = a1 + 1;
v21 = &a1[v9 + 1];
if ( !v20 )
{
LABEL_24:
v12 = v19;
goto LABEL_13;
}
LABEL_16:
v22 = (char *)memchr(v21, v8, v20);
if ( v22 )
{
v12 = v22 - (char *)v11;
if ( v22 - (char *)v11 != -1 )
{
v14 = v12 - v9;
v13 = (unsigned __int8)v6 >> 1;
if ( (v6 & 1) != 0 )
v13 = *((_QWORD *)a1 + 1);
goto LABEL_5;
}
}
v19 = v6 >> 1;
if ( (v6 & 1) != 0 )
{
v10 = *((_QWORD *)a1 + 1);
v12 = v10;
goto LABEL_4;
}
goto LABEL_24;
}
return 0;
}
v10 = *((_QWORD *)a1 + 1);
if ( v9 > v10 )
return 0;
v11 = *((unsigned __int8 **)a1 + 2);
v12 = *((_QWORD *)a1 + 1);
if ( v9 < v10 )
{
v20 = v10 - v9;
v21 = &v11[v9];
if ( v10 == v9 )
{
v12 = *((_QWORD *)a1 + 1);
goto LABEL_4;
}
goto LABEL_16;
}
LABEL_4:
v13 = v10;
v14 = v10 - v9;
LABEL_5:
if ( v9 > v13 )
sub_630DB8();
v15 = a1 + 1;
if ( (v6 & 1) != 0 )
v15 = *((unsigned __int8 **)a1 + 2);
v16 = v13 - v9;
v17 = &v15[v9];
if ( v16 <= v14 )
v14 = v16;
std::string::assign(a3, v17, v14);
*a2 = v12 + 1;
return 1;
}