//
// FMODAudioEngine::createStream from 0x1003d7610 to 0x1003d787c (620 bytes)
//
// 1 xrefs:
// > FMODAudioEngine::preloadMusic @ 0x1003d49d1
//
// This function is hookable on this platform (idp: pc, 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 12:29:42 +0000
//
FMOD::Sound *__fastcall FMODAudioEngine::createStream(__int64 a1, unsigned __int8 *a2)
{
__int64 v2; // rax
unsigned __int8 *v3; // rdx
const char *v4; // r15
size_t v5; // rax
size_t v6; // r12
char *v7; // r13
unsigned int v8; // edx
__int64 v9; // r15
unsigned __int8 *v10; // r14
__int64 v11; // rdx
size_t v12; // rbx
char *v13; // rbx
unsigned __int8 *v14; // rax
char *v15; // rax
bool v16; // zf
int v17; // eax
char *v18; // rsi
int v19; // eax
FMOD::Sound *v20; // rbx
__int128 v22; // [rsp+0h] [rbp-130h] BYREF
char *__s[2]; // [rsp+10h] [rbp-120h]
__int128 v24; // [rsp+20h] [rbp-110h]
__int128 v25; // [rsp+30h] [rbp-100h]
__int128 v26; // [rsp+40h] [rbp-F0h]
__int128 v27; // [rsp+50h] [rbp-E0h]
__int128 v28; // [rsp+60h] [rbp-D0h]
__int128 v29; // [rsp+70h] [rbp-C0h]
__int128 v30; // [rsp+80h] [rbp-B0h]
__int128 v31; // [rsp+90h] [rbp-A0h]
__int128 v32; // [rsp+A0h] [rbp-90h]
__int128 v33; // [rsp+B0h] [rbp-80h]
__int128 v34; // [rsp+C0h] [rbp-70h]
__int128 v35; // [rsp+D0h] [rbp-60h]
__int64 v36; // [rsp+E0h] [rbp-50h]
FMOD::Sound *v37; // [rsp+E8h] [rbp-48h] BYREF
_QWORD __dst[2]; // [rsp+F0h] [rbp-40h] BYREF
void *__p; // [rsp+100h] [rbp-30h]
v2 = cocos2d::CCFileUtils::sharedFileUtils(a1, a2);
if ( (*a2 & 1) != 0 )
v3 = *((unsigned __int8 **)a2 + 2);
else
v3 = a2 + 1;
(*(void (__fastcall **)(__int128 *, __int64, unsigned __int8 *, _QWORD))(*(_QWORD *)v2 + 48LL))(&v22, v2, v3, 0);
if ( (v22 & 1) != 0 )
v4 = __s[0];
else
v4 = (char *)&v22 + 1;
v5 = strlen(v4);
if ( v5 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v6 = v5;
v36 = a1;
if ( v5 >= 0x17 )
{
v12 = 26;
if ( (v5 | 7) != 0x17 )
v12 = (v5 | 7) + 1;
v7 = (char *)operator new(v12);
__p = v7;
__dst[0] = v12 | 1;
__dst[1] = v6;
}
else
{
LOBYTE(__dst[0]) = 2 * v5;
v7 = (char *)__dst + 1;
if ( !v5 )
{
BYTE1(__dst[0]) = 0;
if ( (v22 & 1) == 0 )
goto LABEL_12;
goto LABEL_11;
}
}
memmove(v7, v4, v6);
v7[v6] = 0;
if ( (v22 & 1) != 0 )
LABEL_11:
operator delete(__s[0]);
LABEL_12:
v22 = 0;
v35 = 0;
v34 = 0;
v33 = 0;
v32 = 0;
v31 = 0;
v30 = 0;
v29 = 0;
v28 = 0;
v27 = 0;
v26 = 0;
v25 = 0;
v24 = 0;
*(_OWORD *)__s = 0;
LODWORD(v22) = 224;
v8 = *a2;
v9 = v36;
if ( (v8 & 1) != 0 )
{
v11 = *((_QWORD *)a2 + 1);
v10 = *((unsigned __int8 **)a2 + 2);
if ( v11 < 4 )
goto LABEL_27;
}
else
{
v10 = a2 + 1;
v11 = v8 >> 1;
if ( v11 < 4 )
goto LABEL_27;
}
v13 = (char *)&v10[v11];
v14 = v10;
do
{
v15 = (char *)memchr(v14, 46, v11 - 3);
if ( !v15 )
break;
if ( *(_DWORD *)v15 == 1734831918 )
{
v16 = v15 != v13 && v15 - (char *)v10 != -1;
v17 = 10;
if ( v16 )
goto LABEL_28;
break;
}
v14 = (unsigned __int8 *)(v15 + 1);
v11 = v13 - (char *)v14;
}
while ( v13 - (char *)v14 >= 4 );
LABEL_27:
v17 = 9;
LABEL_28:
LODWORD(v29) = v17;
if ( (__dst[0] & 1) != 0 )
v18 = (char *)__p;
else
v18 = (char *)__dst + 1;
v19 = ((__int64 (__fastcall *)(_QWORD, char *, __int64, __int128 *, FMOD::Sound **))FMOD::System::createStream)(
*(_QWORD *)(v9 + 488),
v18,
134299658,
&v22,
&v37);
*(_DWORD *)(v9 + 536) = v19;
if ( !v19 )
{
FMOD::Sound::setLoopCount(v37, 0);
v20 = v37;
if ( (__dst[0] & 1) == 0 )
return v20;
goto LABEL_33;
}
v20 = nullptr;
if ( (__dst[0] & 1) != 0 )
LABEL_33:
operator delete(__p);
return v20;
}