//
// sub_1005325F0 from 0x1005325f0 to 0x100532774 (388 bytes)
//
// 3 xrefs:
// > sub_100414B90 @ 0x100414c94
// > sub_100532F70 @ 0x100532fbc
// > AutoBackupOptionsPopup::FLAlert_Clicked @ 0x100533630
//
// This function is hookable on this platform (idp: arm, 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 11:07:21 +0000
//
__int64 __fastcall sub_1005325F0(const void **a1, int a2, const void **a3, char a4)
{
__int64 v7; // x8
__int64 v8; // x25
unsigned __int64 v9; // x26
__int64 v10; // x22
__int64 v11; // x8
_QWORD *v12; // x0
int v13; // w8
std::error_code *v14; // x1
const std::__fs::filesystem::path *v15; // x0
_BOOL4 v16; // w0
_BOOL4 v17; // w24
char *v18; // x1
void *__p[2]; // [xsp+0h] [xbp-A0h] BYREF
char v21; // [xsp+17h] [xbp-89h]
__int64 *v22; // [xsp+18h] [xbp-88h] BYREF
_QWORD v23[2]; // [xsp+20h] [xbp-80h] BYREF
__int64 v24; // [xsp+30h] [xbp-70h] BYREF
__int64 v25; // [xsp+38h] [xbp-68h]
__int64 v26; // [xsp+40h] [xbp-60h]
char v27; // [xsp+4Fh] [xbp-51h] BYREF
if ( a2 < 1 )
return 0;
v24 = 0;
v25 = 0;
v26 = 0;
sub_100530FA8(a1, &v24, a3);
v23[0] = 0;
v23[1] = 0;
v22 = v23;
v7 = v24;
if ( v25 != v24 )
{
v8 = 0;
v9 = 0;
v10 = 0;
while ( 1 )
{
v11 = v7 + v8;
if ( (*(char *)(v11 + 47) & 0x8000000000000000LL) != 0 )
{
if ( !*(_QWORD *)(v11 + 32) )
goto LABEL_16;
}
else if ( !*(_BYTE *)(v11 + 47) )
{
goto LABEL_16;
}
__p[0] = (void *)(v11 + 24);
v12 = sub_1001E791C(&v22, v11 + 24, (__int64)&unk_10077071F, (__int64)__p, (__int64)&v27);
v13 = *((_DWORD *)v12 + 14);
*((_DWORD *)v12 + 14) = v13 + 1;
if ( v13 >= a2 )
{
if ( (a4 & 1) != 0 )
goto LABEL_15;
sub_10011E060(a1, (const void **)(v24 + v8), (__int64)__p);
if ( v21 >= 0 )
v15 = (const std::__fs::filesystem::path *)__p;
else
v15 = (const std::__fs::filesystem::path *)__p[0];
v16 = remove(v15, v14);
v17 = v16;
if ( v21 < 0 )
{
operator delete(__p[0]);
if ( v17 )
goto LABEL_16;
LABEL_15:
v10 = (unsigned int)(v10 + 1);
goto LABEL_16;
}
if ( !v16 )
goto LABEL_15;
}
LABEL_16:
++v9;
v7 = v24;
v8 += 128;
if ( v9 >= (v25 - v24) >> 7 )
{
v18 = (char *)v23[0];
goto LABEL_22;
}
}
}
v18 = nullptr;
v10 = 0;
LABEL_22:
sub_1000D8D9C((__int64)&v22, v18);
v22 = &v24;
sub_1005339C0(&v22);
return v10;
}