//
// ec_key_simple_generate_key from 0x9fda3c to 0x9fdb70 (308 bytes)
//
// 5 xrefs:
// > ??> @ 0x7b15c
// > ??> @ 0xd16e28
// > ??> @ 0xd16eec
// > ??> @ 0xd16fb0
// > ??> @ 0xd196f4
//
// 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:36 +0000
//
int __fastcall ec_key_simple_generate_key(_DWORD *a1)
{
int v2; // r7
int v3; // r4
int v4; // r5
int v5; // r3
int v6; // r8
v2 = BN_CTX_new();
if ( v2 )
{
v3 = a1[5];
if ( v3 || (v3 = BN_new()) != 0 )
{
v4 = EC_GROUP_get0_order(a1[3]);
if ( v4 )
{
do
{
if ( !BN_rand_range(v3, v4) )
{
v4 = 0;
goto LABEL_8;
}
}
while ( BN_is_zero(v3) );
v4 = a1[4];
if ( v4 || (v4 = EC_POINT_new(a1[3])) != 0 )
{
if ( EC_POINT_mul(a1[3], v4, v3, 0, 0, v2) )
{
a1[5] = v3;
a1[4] = v4;
v6 = 1;
goto LABEL_11;
}
v6 = 0;
v5 = a1[4];
}
else
{
v5 = a1[4];
v6 = 0;
}
}
else
{
LABEL_8:
v5 = a1[4];
v6 = 0;
}
}
else
{
v5 = a1[4];
v4 = 0;
v6 = 0;
}
}
else
{
v5 = a1[4];
v4 = 0;
v3 = 0;
v6 = 0;
}
if ( !v5 )
EC_POINT_free(v4);
LABEL_11:
if ( a1[5] != v3 )
BN_free(v3);
BN_CTX_free(v2);
return v6;
}