//
// sub_E03144 from 0xe03144 to 0xe036d0 (1420 bytes)
//
// 2 xrefs:
// > sub_E02CA8 @ 0xe02f4c
// > sub_E02CA8 @ 0xe02f50
//
// 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 __fastcall sub_E03144(char *a1, unsigned __int64 a2, char *a3, unsigned __int64 a4, int a5)
{
char *v5; // x27
unsigned __int64 v7; // x22
const char *v8; // x23
char *v9; // x28
char *v10; // x21
__int64 v11; // x10
int v12; // w24
int v13; // w20
__int64 v14; // x19
unsigned __int64 v15; // x25
int v16; // w6
int v17; // w0
unsigned __int8 *v18; // x19
signed __int64 v19; // x10
__int64 v20; // x6
__int64 result; // x0
_BOOL4 v22; // w1
int v23; // w3
int v24; // w2
__int64 v25; // x1
char *v26; // x9
unsigned __int64 v28; // x0
unsigned int v29; // w1
int v30; // w2
unsigned __int8 *v31; // x5
unsigned __int8 *v32; // x22
unsigned int v33; // t1
const char *v34; // x20
const char *v35; // x21
int v36; // w8
unsigned __int8 *v37; // x28
const char *v38; // x5
int v39; // w2
int v40; // t1
__int64 v41; // x23
int v42; // w23
int v43; // w2
unsigned __int64 v44; // [xsp+70h] [xbp+70h]
__int64 v45; // [xsp+88h] [xbp+88h]
LODWORD(v44) = a5;
v5 = a1;
v7 = a2;
v8 = a3;
if ( a4 > 1 && *a3 == 46 )
goto LABEL_45;
if ( !a2 )
{
if ( (a5 & 0x8000) != 0 )
goto LABEL_61;
goto LABEL_107;
}
v9 = nullptr;
v10 = a1;
v11 = a5 & 4;
v12 = 0;
v13 = 1;
v14 = 0;
v15 = a2 - 1;
do
{
while ( 1 )
{
v16 = (unsigned __int8)*v10;
if ( v16 != 42 )
break;
v22 = v14 == v15 || v10[1] == 46;
if ( v9 || v13 & 8 | v12 || (_DWORD)v11 && (!v22 || !(v13 & 1)) || !(v22 | v13 & 1) )
goto LABEL_45;
v13 &= ~1u;
v9 = v10;
v12 = 0;
LABEL_10:
++v14;
++v10;
if ( v14 == v7 )
goto LABEL_18;
}
if ( (unsigned __int8)((v16 & 0xDF) - 65) > 0x19u && (unsigned __int8)(v16 - 48) > 9u )
{
if ( v16 == 46 )
{
if ( (v13 & 5) != 0 )
goto LABEL_45;
++v12;
v13 = 1;
}
else
{
if ( v16 != 45 || (v13 & 1) != 0 )
goto LABEL_45;
v13 |= 4u;
}
goto LABEL_10;
}
if ( (v13 & 1) != 0 && v7 - v14 > 3 )
{
v45 = v11;
v17 = strncasecmp(v10, "xn--", 4u);
v11 = v45;
if ( !v17 )
v13 |= 8u;
}
++v14;
v13 &= 0xFFFFFFFA;
++v10;
}
while ( v14 != v7 );
LABEL_18:
if ( (v13 & 5) != 0 || v12 <= 1 || !v9 )
{
LABEL_45:
if ( (v44 & 0x8000) != 0 )
{
if ( a4 < v7 )
{
if ( !*v5 )
goto LABEL_53;
v28 = ((unsigned __int64)(unsigned int)v44 >> 4) & 1;
if ( *v5 == 46 )
{
if ( (_DWORD)v28 )
goto LABEL_53;
}
else if ( (_DWORD)v28 )
{
do
{
--v7;
++v5;
}
while ( a4 < v7 && *v5 && *v5 != 46 );
goto LABEL_53;
}
do
{
--v7;
++v5;
}
while ( a4 < v7 && *v5 );
LABEL_53:
if ( a4 != v7 )
return 0;
goto LABEL_62;
}
LABEL_61:
result = 0;
if ( a4 != v7 )
return result;
LABEL_62:
v7 = a4;
LABEL_63:
if ( !v7 )
return 1;
v29 = (unsigned __int8)*v5;
v30 = *(unsigned __int8 *)v8;
if ( !*v5 )
return v29;
v31 = (unsigned __int8 *)(v5 + 1);
v32 = (unsigned __int8 *)&v5[v7];
while ( 1 )
{
++v8;
if ( v29 != v30 )
break;
LABEL_71:
if ( v31 == v32 )
return 1;
v33 = *v31++;
v29 = v33;
v30 = *(unsigned __int8 *)v8;
if ( !v33 )
return v29;
}
if ( (unsigned __int8)(v29 - 65) <= 0x19u )
{
v29 = (unsigned __int8)(v29 + 32);
if ( (unsigned __int8)(v30 - 65) > 0x19u )
{
LABEL_70:
if ( v29 != v30 )
return 0;
goto LABEL_71;
}
}
else if ( (unsigned __int8)(v30 - 65) > 0x19u )
{
return 0;
}
v30 = (unsigned __int8)(v30 + 32);
goto LABEL_70;
}
LABEL_107:
result = 0;
if ( a4 != v7 )
return result;
goto LABEL_63;
}
v18 = (unsigned __int8 *)&v5[v14];
v19 = v9 - v5;
v20 = v18 - (unsigned __int8 *)v9 - 1;
result = 0;
if ( a4 < v18 - 1 - (unsigned __int8 *)v5 )
return result;
if ( !v19 )
{
v34 = v8;
v35 = &v8[a4 - v20];
if ( v18 - (unsigned __int8 *)v9 != 1 )
goto LABEL_81;
v36 = (unsigned __int8)v9[1];
LABEL_94:
if ( v36 == 46 )
{
if ( v34 != v35 )
{
v41 = (v44 >> 3) & 1;
if ( v35 == v34 + 1 && *v34 == 42 )
return 1;
LABEL_97:
v42 = v41 ^ 1;
while ( 1 )
{
v43 = *(unsigned __int8 *)v34++;
if ( (unsigned __int8)(v43 - 48) > 9u
&& (unsigned __int8)((v43 & 0xDF) - 65) > 0x19u
&& v43 != 45
&& (v43 != 46 || v42) )
{
break;
}
if ( v35 == v34 )
return 1;
}
}
return 0;
}
LABEL_109:
if ( a4 > 3 )
{
result = strncasecmp(v8, "xn--", 4u);
if ( !(_DWORD)result )
return result;
}
LODWORD(v41) = 0;
if ( v35 != v34 + 1 || *v34 != 42 )
{
if ( v34 == v35 )
return 1;
goto LABEL_97;
}
return 1;
}
v23 = (unsigned __int8)*v5;
v24 = *(unsigned __int8 *)v8;
if ( *v5 )
{
v25 = 0;
while ( 1 )
{
v26 = &v5[v25];
if ( v23 == v24 )
goto LABEL_42;
if ( (unsigned __int8)(v23 - 65) > 0x19u )
break;
v23 = (unsigned __int8)(v23 + 32);
if ( (unsigned __int8)(v24 - 65) <= 0x19u )
goto LABEL_40;
LABEL_41:
if ( v23 != v24 )
return 0;
LABEL_42:
if ( v25++ == v19 - 1 )
{
v34 = &v8[v19];
v35 = &v8[a4 - v20];
if ( v18 - (unsigned __int8 *)v9 == 1 )
goto LABEL_109;
LABEL_81:
v29 = *(unsigned __int8 *)v35;
v36 = (unsigned __int8)v9[1];
if ( *v35 )
{
v37 = (unsigned __int8 *)(v9 + 2);
v38 = v35;
v39 = v36;
while ( 2 )
{
++v38;
if ( v29 == v39 )
goto LABEL_88;
if ( (unsigned __int8)(v29 - 65) <= 0x19u )
{
v29 = (unsigned __int8)(v29 + 32);
if ( (unsigned __int8)(v39 - 65) <= 0x19u )
goto LABEL_86;
}
else
{
if ( (unsigned __int8)(v39 - 65) > 0x19u )
return 0;
LABEL_86:
v39 = (unsigned __int8)(v39 + 32);
}
if ( v29 != v39 )
return 0;
LABEL_88:
if ( v37 == v18 )
{
if ( !v19 )
goto LABEL_94;
goto LABEL_109;
}
v29 = *(unsigned __int8 *)v38;
v40 = *v37++;
v39 = v40;
if ( !*v38 )
return *(unsigned __int8 *)v38;
continue;
}
}
return v29;
}
v23 = (unsigned __int8)v26[1];
v24 = (unsigned __int8)v8[v25];
if ( !v26[1] )
return (unsigned __int8)v26[1];
}
if ( (unsigned __int8)(v24 - 65) > 0x19u )
return 0;
LABEL_40:
v24 = (unsigned __int8)(v24 + 32);
goto LABEL_41;
}
return result;
}