//
// sub_1004EE620 from 0x1004ee620 to 0x1004ee7f4 (468 bytes)
//
// 2 xrefs:
// > sub_10029BD30 @ 0x10029bdba
// > sub_100431460 @ 0x100431c08
//
// 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:31:23 +0000
//
__int64 __fastcall sub_1004EE620(unsigned __int8 *a1, const char *a2)
{
unsigned int v2; // r14d
signed __int64 v3; // r15
char *v4; // r13
__int64 v5; // r12
__int64 result; // rax
char *v7; // rbx
int v8; // r14d
size_t v9; // r12
char *v10; // rax
char *v11; // r13
bool v12; // al
__int64 v13; // r13
bool v14; // zf
unsigned __int64 v15; // rbx
unsigned __int8 *v16; // rcx
unsigned __int8 *v17; // r12
__int64 v18; // rsi
unsigned __int64 v19; // r13
signed __int64 v20; // rdx
unsigned __int8 *v21; // r13
int v22; // r14d
size_t v23; // rdx
unsigned __int8 *v24; // rax
unsigned __int8 *v25; // r13
unsigned __int8 v26; // [rsp+8h] [rbp-48h]
unsigned __int8 *v27; // [rsp+10h] [rbp-40h]
char *v29; // [rsp+20h] [rbp-30h]
unsigned int v30; // [rsp+20h] [rbp-30h]
v2 = *a1;
if ( (v2 & 1) == 0 )
{
if ( *a1 )
{
v3 = strlen(a2);
v4 = (char *)(a1 + 1);
v5 = v2 >> 1;
if ( v3 )
goto LABEL_4;
while ( 1 )
LABEL_13:
;
}
return 0;
}
v5 = *((_QWORD *)a1 + 1);
if ( !v5 )
return 0;
v3 = strlen(a2);
v4 = *((char **)a1 + 2);
if ( !v3 )
goto LABEL_13;
LABEL_4:
result = 1;
if ( v5 >= v3 )
{
v26 = *a1;
v7 = &v4[v5];
v8 = *a2;
v29 = v4;
while ( 1 )
{
v9 = v5 - v3 + 1;
if ( !v9 )
return 1;
v10 = (char *)memchr(v4, v8, v9);
if ( !v10 )
return 1;
v11 = v10;
if ( !memcmp(v10, a2, v3) )
break;
v4 = v11 + 1;
v5 = v7 - v4;
if ( v7 - v4 < v3 )
return 1;
}
v12 = v11 == v7;
v13 = v11 - v29;
v14 = !v12 && v13 != -1;
result = 1;
if ( v14 )
{
if ( (v26 & 1) != 0 )
{
v15 = *((_QWORD *)a1 + 1);
v16 = *((unsigned __int8 **)a1 + 2);
}
else
{
v16 = a1 + 1;
v15 = v26 >> 1;
}
v17 = &v16[v15];
LODWORD(result) = 1;
v27 = v16;
do
{
result = (unsigned int)(result + 1);
v19 = v3 + v13;
v18 = -1;
v20 = v15 - v19;
if ( v15 >= v19 )
{
if ( v20 < v3 )
return result;
v30 = result;
v21 = &v16[v19];
v22 = *a2;
while ( 1 )
{
v23 = v20 - v3 + 1;
if ( !v23 )
return v30;
v24 = (unsigned __int8 *)memchr(v21, v22, v23);
if ( !v24 )
return v30;
v25 = v24;
if ( !memcmp(v24, a2, v3) )
break;
v21 = v25 + 1;
v20 = v17 - v21;
if ( v17 - v21 < v3 )
return v30;
}
result = v30;
if ( v25 == v17 )
return result;
v16 = v27;
v18 = v25 - v27;
}
v13 = v18;
}
while ( v18 != -1 );
}
}
return result;
}