//
// sub_10058B924 from 0x10058b924 to 0x10058b9cc (168 bytes)
//
// 12 xrefs:
// > sub_100540938 @ 0x100540944
// > sub_10058C078 @ 0x10058c0ec
// > sub_10058C12C @ 0x10058c1a4
// > sub_1005EB490 @ 0x1005eb530
// > sub_1005EB6B8 @ 0x1005eb738
// > sub_1005EC3E4 @ 0x1005ec4f0
// > sub_1005F8FBC @ 0x1005f9048
// > sub_1005FBDF4 @ 0x1005fbe48
// > sub_100605D74 @ 0x100605dd4
// > sub_100606530 @ 0x100606578
// > sub_1006065E4 @ 0x100606630
// > sub_10060C8E8 @ 0x10060ce84
//
// 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_10058B924(
__int64 a1,
__int64 a2,
__int64 a3,
int a4,
__int64 (__fastcall *a5)(__int64, __int64))
{
__int64 v7; // x24
__int64 v10; // x20
int v11; // w25
int v12; // w0
__int64 v13; // x26
v7 = a3;
v10 = 0;
if ( (_DWORD)a3 )
{
v11 = 0;
v12 = 0;
while ( 2 )
{
v13 = v7;
do
{
v7 = v13;
if ( v11 >= (int)v13 )
{
if ( v12 )
return 0;
return v10;
}
v13 = (unsigned int)(((int)v13 + v11) / 2);
v10 = a2 + (int)v13 * a4;
v12 = a5(a1, v10);
}
while ( v12 < 0 );
v11 = v13 + 1;
if ( v12 > 0 )
continue;
break;
}
}
return v10;
}