//
// sub_80B99C from 0x80b99c to 0x80baa4 (264 bytes)
//
// 1 xrefs:
// > ??> @ 0xa32418
//
// 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
//
int __fastcall sub_80B99C(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;
}