//
// sub_180085EC0 from 0x180085ec0 to 0x1800863b3 (1267 bytes)
//
// 2 xrefs:
// > sub_180086730 @ 0x180086d0d
// > ??> @ 0x1801bf700
//
// 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 11:22:04 +0000
//
char *__fastcall sub_180085EC0(__int64 a1, char *a2, __int64 a3, __int16 a4, unsigned __int8 a5)
{
char v5; // al
char *v6; // rbx
__int64 v8; // r14
int v10; // edi
__int64 *v11; // rax
unsigned __int8 *v12; // rdi
unsigned __int8 *v13; // rdx
__int64 v14; // rbx
__int64 j; // rax
unsigned __int8 v16; // cl
unsigned __int8 *v17; // rax
char v18; // al
char v19; // al
__int64 v21; // r15
__int64 *v22; // rax
__int64 *v23; // r13
char *v24; // rdi
unsigned __int8 *v25; // rdx
__int64 v26; // r14
__int64 i; // rax
unsigned __int8 *v28; // rbx
unsigned __int8 v29; // cl
char v30; // al
char v31; // al
char v32; // al
char v33; // al
char v34; // al
unsigned __int8 *v35; // rdi
char *v36; // rax
__int64 v37; // rax
__int64 *v38; // rax
v5 = a2[1];
v6 = a2 + 1;
v8 = a3;
if ( v5 != 45 )
{
switch ( v5 )
{
case 91:
v6 = a2 + 2;
if ( a2[2] == 67 )
{
v6 = a2 + 3;
if ( a2[3] == 68 )
{
v6 = a2 + 4;
if ( a2[4] == 65 )
{
v6 = a2 + 5;
if ( a2[5] == 84 )
{
v6 = a2 + 6;
if ( a2[6] == 65 )
{
v6 = a2 + 7;
if ( a2[7] == 91 )
{
v6 = a2 + 8;
v21 = 0;
if ( (a4 & 4) != 0 )
{
v22 = sub_1800828E0(a3, (__int64 *)a1, 4);
v23 = v22;
if ( !v22 )
goto LABEL_5;
v22[3] = (__int64)v6;
if ( (a4 & 0x20) != 0 )
{
v24 = v6;
v25 = nullptr;
v26 = 0;
while ( 1 )
{
while ( 1 )
{
for ( i = (unsigned __int8)*v24; (byte_1801079B0[i] & 0x10) == 0; ++v24 )
i = (unsigned __int8)v24[1];
if ( (_BYTE)i != 13 )
break;
*v24++ = 10;
if ( *v24 == 10 )
{
if ( v25 )
memmove(&v25[-v26], v25, v24 - (char *)v25);
v25 = (unsigned __int8 *)++v24;
++v26;
}
}
if ( *v24 == 93 )
{
v28 = (unsigned __int8 *)(v24 + 1);
if ( v24[1] == 93 )
{
v29 = v24[2];
if ( v29 == 62 || !v29 && a5 == 62 )
break;
}
}
if ( !(_BYTE)i )
goto LABEL_70;
++v24;
}
if ( v25 )
{
memmove(&v25[-v26], v25, v24 - (char *)v25);
v24 -= v26;
}
*v24 = 0;
if ( !v28 )
{
LABEL_70:
*(_QWORD *)(a1 + 16) = v23[3];
*(_DWORD *)(a1 + 24) = 8;
return nullptr;
}
goto LABEL_91;
}
v30 = *v6;
if ( !*v6 )
goto LABEL_80;
do
{
if ( v30 == 93 && v6[1] == 93 )
{
v31 = v6[2];
if ( v31 == 62 || !v31 && a5 == 62 )
break;
}
v30 = *++v6;
}
while ( v30 );
if ( !*v6 )
{
LABEL_80:
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 24) = 8;
return nullptr;
}
*v6 = 0;
LABEL_90:
v28 = (unsigned __int8 *)(v6 + 1);
LABEL_91:
LOBYTE(v21) = v28[1] == 62;
return (char *)&v28[v21 + 1];
}
v32 = *v6;
if ( *v6 )
{
while ( 1 )
{
if ( v32 == 93 && v6[1] == 93 )
{
v33 = v6[2];
if ( v33 == 62 || !v33 && a5 == 62 )
break;
}
v32 = *++v6;
if ( !v32 )
goto LABEL_88;
}
if ( *v6 )
goto LABEL_90;
}
}
}
}
}
}
}
LABEL_88:
*(_DWORD *)(a1 + 24) = 8;
goto LABEL_116;
case 68:
if ( a2[2] == 79 && a2[3] == 67 && a2[4] == 84 && a2[5] == 89 && a2[6] == 80 )
{
v34 = a2[7];
if ( v34 == 69 || !v34 && a5 == 69 )
{
v6 = a2 - 1;
if ( !*(_QWORD *)(a3 + 8) )
{
v35 = (unsigned __int8 *)(v6 + 9);
v36 = sub_180085B00(a1, (__int64)v6, a5, 1);
v6 = v36;
if ( !v36 )
return nullptr;
if ( *v36 )
{
*v36 = 0;
v6 = v36 + 1;
}
if ( (a4 & 0x200) != 0 )
{
if ( (byte_1801079B0[*v35] & 8) != 0 )
{
do
v37 = *++v35;
while ( (byte_1801079B0[v37] & 8) != 0 );
}
v38 = sub_1800828E0(v8, (__int64 *)a1, 8);
if ( !v38 )
goto LABEL_5;
v38[3] = (__int64)v35;
}
return v6;
}
*(_DWORD *)(a1 + 24) = 9;
LABEL_116:
*(_QWORD *)(a1 + 16) = v6;
return nullptr;
}
}
break;
case 0:
if ( a5 == 45 )
goto LABEL_41;
if ( a5 == 91 )
goto LABEL_88;
break;
}
*(_DWORD *)(a1 + 24) = 5;
goto LABEL_116;
}
v6 = a2 + 2;
if ( a2[2] != 45 )
{
LABEL_41:
*(_DWORD *)(a1 + 24) = 7;
goto LABEL_116;
}
v6 = a2 + 3;
v10 = a4 & 2;
if ( (a4 & 2) != 0 )
{
v11 = sub_1800828E0(a3, (__int64 *)a1, 5);
v8 = (__int64)v11;
if ( !v11 )
{
LABEL_5:
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 24) = 3;
return nullptr;
}
v11[3] = (__int64)v6;
}
if ( (a4 & 0x20) != 0 && v10 )
{
v12 = (unsigned __int8 *)v6;
v13 = nullptr;
v14 = 0;
while ( 1 )
{
while ( 1 )
{
for ( j = *v12; (byte_1801079B0[j] & 0x20) == 0; ++v12 )
j = v12[1];
if ( (_BYTE)j != 13 )
break;
*v12++ = 10;
if ( *v12 == 10 )
{
if ( v13 )
memmove(&v13[-v14], v13, v12 - v13);
v13 = ++v12;
++v14;
}
}
if ( *v12 == 45 && v12[1] == 45 )
{
v16 = v12[2];
if ( v16 == 62 || !v16 && a5 == 62 )
break;
}
if ( !(_BYTE)j )
goto LABEL_28;
++v12;
}
if ( v13 )
{
memmove(&v13[-v14], v13, v12 - v13);
v17 = &v12[-v14];
}
else
{
v17 = v12;
}
*v17 = 0;
v6 = (char *)&v12[(v12[2] == 62) + 2];
if ( !v6 )
{
LABEL_28:
*(_QWORD *)(a1 + 16) = *(_QWORD *)(v8 + 24);
*(_DWORD *)(a1 + 24) = 7;
return nullptr;
}
return v6;
}
v18 = *v6;
if ( !*v6 )
goto LABEL_40;
do
{
if ( v18 == 45 && v6[1] == 45 )
{
v19 = v6[2];
if ( v19 == 62 || !v19 && a5 == 62 )
break;
}
v18 = *++v6;
}
while ( v18 );
if ( !*v6 )
{
LABEL_40:
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 24) = 7;
return nullptr;
}
if ( v10 )
*v6 = 0;
return &v6[(v6[2] == 62) + 2];
}