//
// sub_A2059C from 0xa2059c to 0xa206a4 (264 bytes)
//
// 1 xrefs:
// > ??> @ 0xc79698
//
// 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:07:55 +0000
//
int __fastcall sub_A2059C(int a1, int a2, int a3, void *a4)
{
int v5; // r4
bool v8; // zf
int v9; // r0
int v10; // r0
int v11; // r0
v5 = *(_DWORD *)(a1 + 20);
if ( a2 == 4097 )
{
if ( a3 >= 0 )
{
v10 = *(_DWORD *)(v5 + 4);
if ( v10 )
CRYPTO_clear_free(v10, *(_DWORD *)(v5 + 8), "crypto/kdf/tls1_prf.c", 68);
OPENSSL_cleanse((_BYTE *)(v5 + 12), *(_DWORD *)(v5 + 1036));
*(_DWORD *)(v5 + 1036) = 0;
v11 = CRYPTO_memdup(a4, a3, "crypto/kdf/tls1_prf.c", 71);
*(_DWORD *)(v5 + 4) = v11;
if ( v11 )
{
*(_DWORD *)(v5 + 8) = a3;
return 1;
}
}
return 0;
}
if ( a2 == 4098 )
{
v8 = a3 == 0;
if ( a3 )
v8 = a4 == nullptr;
if ( v8 )
return 1;
if ( a3 >= 0 )
{
v9 = *(_DWORD *)(v5 + 1036);
if ( a3 <= 1024 - v9 )
{
memcpy((void *)(v5 + v9 + 12), a4, a3);
*(_DWORD *)(v5 + 1036) += a3;
return 1;
}
}
return 0;
}
if ( a2 != 4096 )
return -2;
*(_DWORD *)v5 = a4;
return 1;
}