//
// sub_1030610 from 0x1030610 to 0x1030794 (388 bytes)
//
// 1 xrefs:
// > ??> @ 0x1402b00
//
// 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 13:16:20 +0000
//
__int64 __fastcall sub_1030610(__int64 a1, int a2, int a3, void *a4)
{
_QWORD *v4; // x21
__int64 result; // x0
__int64 v7; // x19
__int64 v8; // x0
__int64 v9; // x0
__int64 v10; // x0
__int64 v11; // x0
__int64 v12; // x0
v4 = *(_QWORD **)(a1 + 40);
result = 4294967294LL;
v7 = a3;
switch ( a2 )
{
case 4099:
if ( !a4 )
goto LABEL_21;
*v4 = a4;
result = 1;
break;
case 4100:
if ( !a4 || !a3 )
goto LABEL_22;
if ( a3 < 0 )
goto LABEL_21;
v8 = v4[1];
if ( v8 )
CRYPTO_clear_free(v8, v4[2], "crypto/kdf/hkdf.c", 88);
v9 = CRYPTO_memdup(a4, v7, "crypto/kdf/hkdf.c", 90);
v4[1] = v9;
if ( !v9 )
goto LABEL_21;
v4[2] = v7;
result = 1;
break;
case 4101:
if ( a3 < 0 )
goto LABEL_21;
v10 = v4[3];
if ( v10 )
CRYPTO_clear_free(v10, v4[4], "crypto/kdf/hkdf.c", 102);
v11 = CRYPTO_memdup(a4, v7, "crypto/kdf/hkdf.c", 104);
v4[3] = v11;
if ( !v11 )
goto LABEL_21;
v4[4] = v7;
result = 1;
break;
case 4102:
if ( a4 && a3 )
{
if ( a3 < 0 || (v12 = v4[133], a3 > 1024 - (int)v12) )
{
LABEL_21:
result = 0;
}
else
{
memcpy((char *)v4 + v12 + 40, a4, a3);
v4[133] += v7;
result = 1;
}
}
else
{
LABEL_22:
result = 1;
}
break;
default:
return result;
}
return result;
}