//
// sub_100587F7C from 0x100587f7c to 0x100588190 (532 bytes)
//
// 1 xrefs:
// > sub_1006207F0 @ 0x100620800
//
// 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_100587F7C(__int64 a1)
{
_DWORD *v1; // x0
_QWORD *v2; // x19
__int64 v3; // x0
__int64 v4; // x20
__int64 v5; // x2
__int64 v6; // x4
int v8; // w8
if ( !off_100882BD8 )
{
v5 = 100;
v6 = 248;
LABEL_20:
sub_1005E0E48(15, 103, v5, "cryptlib.c", v6);
return 0;
}
if ( off_100882BF8 )
a1 = ((__int64 (__fastcall *)(__int64, __int64, const char *, __int64))off_100882BF8)(9, 29, "cryptlib.c", 251);
if ( !qword_100882BE0 )
{
qword_100882BE0 = sub_1005DE4A4(a1);
if ( !qword_100882BE0 )
{
if ( off_100882BF8 )
((void (__fastcall *)(__int64, __int64, const char *, __int64))off_100882BF8)(10, 29, "cryptlib.c", 254);
v5 = 65;
v6 = 255;
goto LABEL_20;
}
}
if ( off_100882BF8 )
((void (__fastcall *)(__int64, __int64, const char *, __int64))off_100882BF8)(10, 29, "cryptlib.c", 258);
v1 = (_DWORD *)sub_100588710(16, "cryptlib.c", 260);
v2 = v1;
if ( !v1 )
{
v5 = 65;
v6 = 262;
goto LABEL_20;
}
*v1 = 1;
v3 = off_100882BD8("cryptlib.c", 266);
v2[1] = v3;
if ( !v3 )
{
sub_100588C44(v2);
v5 = 65;
v6 = 269;
goto LABEL_20;
}
if ( off_100882BF8 )
((void (__fastcall *)(__int64, __int64, const char *, __int64))off_100882BF8)(9, 29, "cryptlib.c", 273);
v4 = sub_1005DE730(qword_100882BE0, 0);
if ( (_DWORD)v4 == -1 )
LODWORD(v4) = sub_1005DE80C(qword_100882BE0, v2) - 1;
else
sub_1005DEA90(qword_100882BE0, v4, v2);
if ( off_100882BF8 )
((void (__fastcall *)(__int64, __int64, const char *, __int64))off_100882BF8)(10, 29, "cryptlib.c", 289);
if ( (_DWORD)v4 == -1 )
{
off_100882BE8(v2[1], "cryptlib.c", 292);
sub_100588C44(v2);
v8 = -1;
}
else
{
v8 = v4 + 1;
}
return (unsigned int)-v8;
}