//
// sub_180082EF0 from 0x180082ef0 to 0x1800833d3 (1251 bytes)
//
// 2 xrefs:
// > sub_180083740 @ 0x180083d36
// > ??> @ 0x1801b5460
//
// 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
//
char *__fastcall sub_180082EF0(__int64 a1, _BYTE *a2, __int64 a3, __int16 a4, unsigned __int8 a5)
{
char v5; // al
__int64 v6; // rbx
__int64 v8; // r14
char *v10; // rbx
int v11; // edi
__int64 *v12; // rax
unsigned __int8 *v13; // rdi
unsigned __int8 *v14; // rdx
__int64 v15; // rbx
__int64 k; // rax
unsigned __int8 v17; // cl
unsigned __int8 *v18; // rax
char j; // al
char v20; // al
__int64 v22; // r15
__int64 *v23; // rax
__int64 *v24; // r13
char *v25; // rdi
unsigned __int8 *v26; // rdx
__int64 v27; // r14
__int64 i; // rax
unsigned __int8 *v29; // rbx
unsigned __int8 v30; // cl
char v31; // al
char v32; // al
char v33; // al
char v34; // al
char v35; // al
unsigned __int8 *v36; // rdi
char *v37; // rax
__int64 v38; // rax
__int64 *v39; // rax
v5 = a2[1];
v6 = (__int64)(a2 + 1);
v8 = a3;
if ( v5 != 45 )
{
switch ( v5 )
{
case 91:
v6 = (__int64)(a2 + 2);
if ( a2[2] == 67 )
{
v6 = (__int64)(a2 + 3);
if ( a2[3] == 68 )
{
v6 = (__int64)(a2 + 4);
if ( a2[4] == 65 )
{
v6 = (__int64)(a2 + 5);
if ( a2[5] == 84 )
{
v6 = (__int64)(a2 + 6);
if ( a2[6] == 65 )
{
v6 = (__int64)(a2 + 7);
if ( a2[7] == 91 )
{
v10 = a2 + 8;
v22 = 0;
if ( (a4 & 4) != 0 )
{
v23 = sub_18007F9D0(a3, (__int64 *)a1, 4);
v24 = v23;
if ( !v23 )
goto LABEL_5;
v23[3] = (__int64)v10;
if ( (a4 & 0x20) != 0 )
{
v25 = v10;
v26 = nullptr;
v27 = 0;
while ( 1 )
{
while ( 1 )
{
for ( i = (unsigned __int8)*v25; (byte_180101290[i] & 0x10) == 0; ++v25 )
i = (unsigned __int8)v25[1];
if ( (_BYTE)i != 13 )
break;
*v25++ = 10;
if ( *v25 == 10 )
{
if ( v26 )
memmove(&v26[-v27], v26, v25 - (char *)v26);
v26 = (unsigned __int8 *)++v25;
++v27;
}
}
if ( (_BYTE)i == 93 )
{
v29 = (unsigned __int8 *)(v25 + 1);
if ( v25[1] != 93 )
goto LABEL_64;
v30 = v25[2];
if ( v30 == 62 )
goto LABEL_65;
if ( v30 )
goto LABEL_64;
if ( a5 == 62 )
{
LABEL_65:
if ( v26 )
{
memmove(&v26[-v27], v26, v25 - (char *)v26);
v25 -= v27;
}
*v25 = 0;
if ( !v29 )
{
LABEL_68:
*(_QWORD *)(a1 + 16) = v24[3];
*(_DWORD *)(a1 + 24) = 8;
return nullptr;
}
LABEL_79:
LOBYTE(v22) = v29[1] == 62;
return (char *)&v29[v22 + 1];
}
}
if ( !(_BYTE)i )
goto LABEL_68;
LABEL_64:
++v25;
}
}
v31 = *v10;
if ( *v10 )
{
while ( 1 )
{
if ( v31 == 93 && v10[1] == 93 )
{
v32 = v10[2];
if ( v32 == 62 || !v32 && a5 == 62 )
break;
}
v31 = *++v10;
if ( !v31 )
goto LABEL_76;
}
*v10 = 0;
LABEL_78:
v29 = (unsigned __int8 *)(v10 + 1);
goto LABEL_79;
}
}
else
{
v33 = *v10;
if ( *v10 )
{
while ( 1 )
{
if ( v33 == 93 && v10[1] == 93 )
{
v34 = v10[2];
if ( v34 == 62 || !v34 && a5 == 62 )
break;
}
v33 = *++v10;
if ( !v33 )
{
*(_QWORD *)(a1 + 16) = v10;
*(_DWORD *)(a1 + 24) = 8;
return nullptr;
}
}
goto LABEL_78;
}
}
LABEL_76:
*(_QWORD *)(a1 + 16) = v10;
*(_DWORD *)(a1 + 24) = 8;
return nullptr;
}
}
}
}
}
}
LABEL_88:
*(_DWORD *)(a1 + 24) = 8;
goto LABEL_113;
case 68:
if ( a2[2] == 79 && a2[3] == 67 && a2[4] == 84 && a2[5] == 89 && a2[6] == 80 )
{
v35 = a2[7];
if ( v35 == 69 || !v35 && a5 == 69 )
{
v6 = (__int64)(a2 - 1);
if ( !*(_QWORD *)(a3 + 8) )
{
v36 = (unsigned __int8 *)(v6 + 9);
v37 = sub_180082B50(a1, v6, a5, 1);
v10 = v37;
if ( !v37 )
return nullptr;
if ( *v37 )
{
*v37 = 0;
v10 = v37 + 1;
}
if ( (a4 & 0x200) == 0 )
return v10;
if ( (byte_180101290[*v36] & 8) != 0 )
{
do
v38 = *++v36;
while ( (byte_180101290[v38] & 8) != 0 );
}
v39 = sub_18007F9D0(v8, (__int64 *)a1, 8);
if ( v39 )
{
v39[3] = (__int64)v36;
return v10;
}
goto LABEL_5;
}
*(_DWORD *)(a1 + 24) = 9;
LABEL_113:
*(_QWORD *)(a1 + 16) = v6;
return nullptr;
}
}
break;
case 0:
if ( a5 == 45 )
goto LABEL_39;
if ( a5 == 91 )
goto LABEL_88;
break;
}
*(_DWORD *)(a1 + 24) = 5;
goto LABEL_113;
}
v6 = (__int64)(a2 + 2);
if ( a2[2] != 45 )
{
LABEL_39:
*(_DWORD *)(a1 + 24) = 7;
goto LABEL_113;
}
v10 = a2 + 3;
v11 = a4 & 2;
if ( (a4 & 2) != 0 )
{
v12 = sub_18007F9D0(a3, (__int64 *)a1, 5);
v8 = (__int64)v12;
if ( !v12 )
{
LABEL_5:
*(_QWORD *)(a1 + 16) = v10;
*(_DWORD *)(a1 + 24) = 3;
return nullptr;
}
v12[3] = (__int64)v10;
}
if ( (a4 & 0x22) != 0x22 )
{
for ( j = *v10; j; ++v10 )
{
if ( j == 45 && v10[1] == 45 )
{
v20 = v10[2];
if ( v20 == 62 || !v20 && a5 == 62 )
{
if ( v11 )
*v10 = 0;
return &v10[(v20 == 62) + 2];
}
}
j = v10[1];
}
*(_QWORD *)(a1 + 16) = v10;
*(_DWORD *)(a1 + 24) = 7;
return nullptr;
}
v13 = (unsigned __int8 *)v10;
v14 = nullptr;
v15 = 0;
while ( 1 )
{
while ( 1 )
{
for ( k = *v13; (byte_180101290[k] & 0x20) == 0; ++v13 )
k = v13[1];
if ( (_BYTE)k != 13 )
break;
*v13++ = 10;
if ( *v13 == 10 )
{
if ( v14 )
memmove(&v14[-v15], v14, v13 - v14);
v14 = ++v13;
++v15;
}
}
if ( (_BYTE)k == 45 )
{
if ( v13[1] != 45 )
goto LABEL_22;
v17 = v13[2];
if ( v17 == 62 )
break;
if ( v17 )
goto LABEL_22;
if ( a5 == 62 )
break;
}
if ( !(_BYTE)k )
goto LABEL_27;
LABEL_22:
++v13;
}
if ( v14 )
{
memmove(&v14[-v15], v14, v13 - v14);
v18 = &v13[-v15];
}
else
{
v18 = v13;
}
*v18 = 0;
v10 = (char *)&v13[(v13[2] == 62) + 2];
if ( !v10 )
{
LABEL_27:
*(_QWORD *)(a1 + 16) = *(_QWORD *)(v8 + 24);
*(_DWORD *)(a1 + 24) = 7;
return nullptr;
}
return v10;
}