//
// MusicDownloadManager::urlEncode from 0x100669190 to 0x1006692e2 (338 bytes)
//
// 2 xrefs:
// > MusicDownloadManager::linkRowString @ 0x100665fd8
// > MusicDownloadManager::linkRowString @ 0x100665ff0
//
// 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:34:59 +0000
//
std::string *__fastcall MusicDownloadManager::urlEncode(std::string *a1, unsigned __int8 *a2)
{
unsigned int v3; // esi
std::string::size_type v4; // rsi
unsigned int v5; // ecx
bool v6; // al
unsigned __int64 v7; // r13
unsigned __int8 *v8; // rcx
unsigned __int8 v9; // bl
int v10; // eax
unsigned int v11; // ecx
*(_OWORD *)&a1->__r_.__value_.__l.0 = 0;
a1->__r_.__value_.__r.__words[2] = 0;
v3 = *a2;
if ( (v3 & 1) != 0 )
v4 = *((_QWORD *)a2 + 1);
else
v4 = v3 >> 1;
std::string::reserve(a1, v4);
v5 = *a2;
v6 = (v5 & 1) == 0;
if ( (v5 & 1) != 0 )
{
if ( !*((_QWORD *)a2 + 1) )
return a1;
}
else if ( !(v5 >> 1) )
{
return a1;
}
v7 = 0;
do
{
while ( 1 )
{
v8 = a2 + 1;
if ( !v6 )
v8 = *((unsigned __int8 **)a2 + 2);
v9 = v8[v7];
v10 = (v9 & 0x80u) != 0 ? __maskrune(v9, 1280) : _DefaultRuneLocale.__runetype[v9] & 0x500;
if ( !v10 && (unsigned int)v9 - 45 >= 2 && v9 != 95 && v9 != 126 )
{
std::string::push_back(a1, 37);
std::string::push_back(a1, a0123456789abcd_3[v9 >> 4]);
v9 = a0123456789abcd_3[v9 & 0xF];
}
std::string::push_back(a1, v9);
v11 = *a2;
v6 = (v11 & 1) == 0;
if ( (v11 & 1) == 0 )
break;
if ( ++v7 >= *((_QWORD *)a2 + 1) )
return a1;
}
++v7;
}
while ( v7 < v11 >> 1 );
return a1;
}