//
// ec_key_simple_generate_key from 0x100e18c to 0x100e2c8 (316 bytes)
//
// 5 xrefs:
// > ??> @ 0x102628
// > ??> @ 0x1539fd0
// > ??> @ 0x153a150
// > ??> @ 0x153a2d0
// > ??> @ 0x153f010
//
// 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:01 +0000
//
__int64 __fastcall ec_key_simple_generate_key(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 v4; // x22
__int64 v5; // x19
__int64 v6; // x20
__int64 v7; // x1
unsigned int v8; // w23
v4 = BN_CTX_new(a1, a2, a3);
if ( v4 )
{
v5 = a1[5];
if ( v5 || (v5 = BN_new()) != 0 )
{
v6 = EC_GROUP_get0_order(a1[3]);
if ( !v6 )
goto LABEL_19;
do
{
if ( !(unsigned int)BN_rand_range(v5) )
{
v6 = 0;
v7 = a1[4];
v8 = 0;
goto LABEL_8;
}
}
while ( BN_is_zero(v5) );
v6 = a1[4];
if ( v6 || (v6 = EC_POINT_new(a1[3])) != 0 )
{
if ( (unsigned int)EC_POINT_mul(a1[3], v6, v5, 0, 0, v4) )
{
a1[5] = v5;
v8 = 1;
a1[4] = v6;
goto LABEL_10;
}
v7 = a1[4];
v8 = 0;
}
else
{
LABEL_19:
v7 = a1[4];
v8 = v6;
}
}
else
{
v7 = a1[4];
v6 = 0;
v8 = 0;
}
}
else
{
v7 = a1[4];
v6 = 0;
v5 = 0;
v8 = 0;
}
LABEL_8:
if ( !v7 )
EC_POINT_free(v6);
LABEL_10:
if ( a1[5] != v5 )
BN_free(v5);
BN_CTX_free(v4);
return v8;
}