//
// sub_B8B4E4 from 0xb8b4e4 to 0xb8b64c (360 bytes)
//
// 1 xrefs:
// > sub_B8B64C @ 0xb8b65c
//
// 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
//
_BYTE *__fastcall sub_B8B4E4(int a1, char *a2, int a3)
{
_BYTE *v4; // x21
size_t v5; // x23
char *v6; // x19
__int64 v7; // x20
size_t v8; // x24
int v9; // w3
char *v11; // x0
size_t v12; // x22
_BYTE *v13; // x0
int v14; // [xsp+68h] [xbp+68h]
if ( a3 < 0 )
return nullptr;
if ( a3 )
{
v12 = a3 + 1LL;
v13 = off_1231000(v12);
v4 = v13;
if ( !v13 )
return nullptr;
goto LABEL_6;
}
v12 = strlen(a2) + 1;
v4 = off_1231000(v12);
if ( v4 )
{
if ( v12 == 1 )
{
v7 = 0;
LABEL_10:
v4[v7] = 0;
return v4;
}
LABEL_6:
v5 = v12;
v6 = a2;
v7 = 0;
v8 = v12 - 1;
do
{
v9 = (unsigned __int8)*v6;
switch ( *v6 )
{
case '-':
case '.':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case '~':
v4[v7++] = v9;
break;
default:
v5 += 2LL;
if ( v5 > v12 )
{
v12 *= 2LL;
v14 = (unsigned __int8)*v6;
v4 = (_BYTE *)sub_BA3184(v4, v12);
v9 = v14;
if ( !v4 )
return nullptr;
}
v11 = &v4[v7];
v7 += 3;
sub_B8C278(v11, 4, "%%%02X", v9);
break;
}
++v6;
}
while ( &a2[v8 - (_QWORD)v6] );
goto LABEL_10;
}
return nullptr;
}