//
// gen_random from 0x6f0308 to 0x6f04a8 (416 bytes)
//
// 13 xrefs:
// > GameLevelManager::uploadLevel @ 0x71c4e8
// > GameLevelManager::downloadLevel @ 0x71e0d0
// > GameLevelManager::rateStars @ 0x71ec2c
// > GameLevelManager::getLevelLeaderboard @ 0x720b9c
// > GameLevelManager::getLevelLeaderboard @ 0x720c28
// > GameLevelManager::likeItem @ 0x728c14
// > GameLevelManager::getGJSecretReward @ 0x7298d8
// > GameLevelManager::getGJRewards @ 0x72a018
// > GameLevelManager::getGJChallenges @ 0x72a74c
// > GameLevelManager::getGJDailyLevelState @ 0x72ada0
// > GameLevelManager::uploadLevelList @ 0x72d42c
// > GameLevelManager::updateUserScore @ 0x737d54
// > ??> @ 0x8a438
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __usercall gen_random@(int a1@, __int64 a2@)
{
const std::string *v4; // x1
cocos2d::CCString *v5; // x26
void *v6; // x0
int v7; // w25
int v8; // w0
char *v9; // x0
unsigned int *v11; // x3
int v12; // w1
char *CString; // [xsp+58h] [xbp+58h]
__int64 v14; // [xsp+70h] [xbp+70h] BYREF
sub_D153B8((int)&v14, &byte_F288A0);
v5 = (cocos2d::CCString *)cocos2d::CCString::create((cocos2d::CCString *)&v14, v4);
v6 = (void *)(v14 - 24);
if ( (__int64 *)(v14 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v14 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v6);
}
if ( a1 > 0 )
{
v7 = 0;
do
{
++v7;
CString = (char *)cocos2d::CCString::getCString(v5);
v8 = rand();
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s%c",
CString,
(unsigned __int8)a0123456789abcd_2[v8 % 0x3EuLL]);
}
while ( v7 != a1 );
}
v9 = (char *)cocos2d::CCString::getCString(v5);
sub_D153B8(a2, v9);
return a2;
}