//
// sub_AC9BBC from 0xac9bbc to 0xac9ee0 (804 bytes)
//
// 1 xrefs:
// > ??> @ 0xc81654
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:09:19 +0000
//
size_t __fastcall sub_AC9BBC(int a1, char *a2, int a3)
{
char *v3; // r7
int *data; // r4
int v6; // r0
bool v7; // zf
_BOOL4 v8; // r5
size_t v9; // r8
int v10; // r1
size_t v11; // r3
int v12; // r3
char *v13; // r3
char *v14; // r5
signed int v15; // r5
int v16; // r2
int v20; // r0
signed int v21; // r5
void *v22; // r0
int v23; // r0
int v24; // r11
size_t v25; // r2
size_t v26; // r6
int v28; // [sp+10h] [bp-1Ch]
int v29; // [sp+18h] [bp-14h]
int v30; // [sp+1Ch] [bp-10h]
int v31; // [sp+24h] [bp-8h] BYREF
v3 = a2;
if ( !a2 )
return 0;
data = (int *)BIO_get_data(a1);
v6 = BIO_next(a1);
v7 = data == nullptr;
if ( data )
v7 = v6 == 0;
v29 = v6;
v8 = v7;
if ( v7 )
return 0;
if ( *data > 0 )
{
v10 = data[1];
if ( a3 < *data - v10 )
v9 = a3;
else
v9 = *data - v10;
memcpy(v3, (char *)data + v10 + 32, v9);
a3 -= v9;
v11 = v9 + data[1];
v7 = v11 == *data;
v3 += v9;
data[1] = v11;
if ( v7 )
{
*data = v8;
data[1] = v8;
}
}
else
{
v9 = v8;
}
v12 = EVP_CIPHER_CTX_block_size(data[5]);
if ( v12 == 1 )
v12 = 0;
v28 = v12;
if ( a3 > 0 && data[2] > 0 )
{
v13 = (char *)data[6];
v30 = (int)(data + 80);
while ( 1 )
{
v14 = (char *)data[7];
if ( v14 != v13 )
break;
while ( 1 )
{
data[6] = v30;
data[7] = v30;
v23 = BIO_read(v29, v30, 4096);
v15 = v23;
if ( v23 <= 0 )
{
LABEL_35:
if ( !BIO_test_flags(v29, 8) )
{
data[2] = v15;
v20 = EVP_CipherFinal_ex((_DWORD *)data[5], (unsigned int)(data + 8), data);
v16 = *data;
data[1] = 0;
data[4] = v20;
LABEL_37:
if ( v16 >= a3 )
v21 = a3;
else
v21 = v16;
if ( v21 > 0 )
{
v22 = v3;
v9 += v21;
a3 -= v21;
v3 += v21;
memcpy(v22, data + 8, v21);
data[1] = v21;
goto LABEL_42;
}
goto LABEL_29;
}
v7 = v9 == 0;
v26 = v9;
v9 = v15;
if ( !v7 )
{
BIO_clear_flags(a1, 15);
BIO_copy_next_retry(a1);
return v26;
}
goto LABEL_29;
}
v13 = (char *)data[6];
data[7] += v23;
if ( a3 <= 256 )
break;
LABEL_47:
v24 = a3 - v28;
if ( v15 >= a3 - v28 )
v25 = a3 - v28;
else
v25 = v15;
if ( !EVP_CipherUpdate((_DWORD *)data[5], v3, &v31, v13, v25) )
{
BIO_clear_flags(a1, 15);
return 0;
}
v15 -= v24;
v9 += v31;
v3 += v31;
a3 -= v31;
if ( v15 > 0 )
{
v13 = (char *)(data[6] + v24);
data[6] = (int)v13;
break;
}
data[6] = data[7];
LABEL_42:
if ( a3 <= 0 || data[2] <= 0 )
goto LABEL_29;
v13 = (char *)data[6];
v14 = (char *)data[7];
if ( v14 != v13 )
goto LABEL_21;
}
LABEL_23:
if ( v15 >= 256 )
v15 = 256;
if ( !EVP_CipherUpdate((_DWORD *)data[5], (char *)data + 32, data, v13, v15) )
{
BIO_clear_flags(a1, 15);
data[4] = 0;
return 0;
}
v16 = *data;
v13 = (char *)(data[6] + v15);
v7 = *data == 0;
data[2] = 1;
data[6] = (int)v13;
if ( !v7 )
goto LABEL_37;
if ( a3 <= 0 )
goto LABEL_29;
}
LABEL_21:
v15 = v14 - v13;
if ( v15 <= 0 )
goto LABEL_35;
if ( a3 <= 256 )
goto LABEL_23;
goto LABEL_47;
}
LABEL_29:
BIO_clear_flags(a1, 15);
BIO_copy_next_retry(a1);
if ( v9 )
return v9;
else
return data[2];
}