//
// sub_100602980 from 0x100602980 to 0x100602afc (380 bytes)
//
// 2 xrefs:
// > sub_100602AFC @ 0x100602b80
// > sub_10060C140 @ 0x10060c1ac
//
// 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_100602980(__int64 a1, __int64 a2, int a3, int a4)
{
unsigned int *v8; // x19
int v9; // w0
int v10; // w8
int v11; // w20
int v12; // w22
_BOOL4 v13; // w23
__int64 v14; // x0
__int64 v15; // x21
int v16; // w0
int v17; // w21
__int64 v18; // x0
if ( !a1 )
return 0;
v8 = *(unsigned int **)a1;
v9 = sub_1005DEA4C(*(unsigned int **)a1);
v10 = a3 >= 0 ? a3 : v9;
v11 = v9 >= a3 ? v10 : v9;
*(_DWORD *)(a1 + 8) = 1;
if ( a4 == -1 )
{
if ( v11 )
{
v13 = 0;
v12 = *(_DWORD *)(sub_1005DEA60((__int64)v8, v11 - 1) + 16);
}
else
{
v12 = 0;
v13 = 1;
}
}
else
{
if ( v11 >= v9 )
v12 = v11 ? *(_DWORD *)(sub_1005DEA60((__int64)v8, v11 - 1) + 16) + 1 : 0;
else
v12 = *(_DWORD *)(sub_1005DEA60((__int64)v8, v11) + 16);
v13 = v12 == 0;
}
v14 = sub_1005F3334(a2);
v15 = v14;
if ( !v14 )
return 0;
*(_DWORD *)(v14 + 16) = v12;
if ( !(unsigned int)sub_1005DE538((void **)v8, v14, v11) )
{
sub_1005E0E48(11, 113, 65, (__int64)"x509name.c", 269);
sub_1005F3328(v15);
return 0;
}
if ( !v13 )
return 1;
v16 = sub_1005DEA4C(v8);
if ( v11 + 1 >= v16 )
return 1;
v17 = v16 - 1;
do
{
v18 = sub_1005DEA60((__int64)v8, v11);
++*(_DWORD *)(v18 + 16);
++v11;
}
while ( v17 != v11 );
return 1;
}