//
// ec_GFp_simple_group_set_curve from 0xd9a090 to 0xd9a24c (444 bytes)
//
// 3 xrefs:
// > ec_GFp_mont_group_set_curve @ 0xd964a0
// > ??> @ 0x757b0
// > ??> @ 0x1222420
//
// 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
//
__int64 __fastcall ec_GFp_simple_group_set_curve(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 is_odd; // x0
__int64 v11; // x1
__int64 v12; // x2
__int64 v13; // x25
__int64 *v14; // x24
unsigned int (__fastcall *v15)(__int64, _QWORD, __int64 *, __int64); // x4
unsigned int (__fastcall *v16)(__int64, _QWORD, _QWORD, __int64); // x4
unsigned int v17; // w19
__int64 result; // x0
if ( (int)BN_num_bits(a2) <= 2 || (is_odd = BN_is_odd(a2), !(_DWORD)is_odd) )
{
ERR_put_error(16, 166, 103, "crypto/ec/ecp_smpl.c", 143);
return 0;
}
v13 = 0;
if ( a5 )
{
LABEL_4:
BN_CTX_start(a5);
v14 = (__int64 *)BN_CTX_get(a5);
if ( !v14 )
goto LABEL_16;
if ( !BN_copy(*(unsigned __int64 **)(a1 + 64), a2) )
goto LABEL_16;
BN_set_negative(*(_QWORD *)(a1 + 64), 0);
if ( !(unsigned int)BN_nnmod(v14, a3, a2, a5) )
goto LABEL_16;
v15 = *(unsigned int (__fastcall **)(__int64, _QWORD, __int64 *, __int64))(*(_QWORD *)a1 + 288LL);
if ( v15 )
{
if ( !v15(a1, *(_QWORD *)(a1 + 96), v14, a5) )
goto LABEL_16;
}
else if ( !BN_copy(*(unsigned __int64 **)(a1 + 96), (__int64)v14) )
{
goto LABEL_16;
}
if ( (unsigned int)BN_nnmod(*(_QWORD *)(a1 + 104), a4, a2, a5) )
{
v16 = *(unsigned int (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(*(_QWORD *)a1 + 288LL);
if ( !v16 || v16(a1, *(_QWORD *)(a1 + 104), *(_QWORD *)(a1 + 104), a5) )
{
if ( (unsigned int)BN_add_word((__int64)v14, 3u) )
{
v17 = 1;
*(_DWORD *)(a1 + 112) = BN_cmp(v14, *(__int64 **)(a1 + 64)) == 0;
LABEL_17:
BN_CTX_end(a5);
BN_CTX_free(v13);
return v17;
}
}
}
LABEL_16:
v17 = 0;
goto LABEL_17;
}
result = BN_CTX_new(is_odd, v11, v12);
a5 = result;
if ( result )
{
v13 = result;
goto LABEL_4;
}
return result;
}