//
// ec_GF2m_simple_add from 0xe33c98 to 0xe3408c (1012 bytes)
//
// 3 xrefs:
// > ec_GF2m_simple_dbl @ 0xe34094
// > ??> @ 0xb3880
// > ??> @ 0x12271e8
//
// 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_GF2m_simple_add(_QWORD *a1, _QWORD *a2, __int64 a3, __int64 a4, int32x2_t *a5)
{
unsigned int v10; // w20
void **v12; // x25
unsigned __int64 *v13; // x20
unsigned __int64 *v14; // x28
unsigned __int64 *v15; // x27
__int64 v16; // x26
_BOOL4 v17; // w20
int32x2_t *v18; // x0
__int64 v19; // [xsp+60h] [xbp+60h]
__int64 v20; // [xsp+68h] [xbp+68h]
__int64 v21; // [xsp+70h] [xbp+70h]
unsigned __int64 *v22; // [xsp+78h] [xbp+78h]
if ( (unsigned int)EC_POINT_is_at_infinity((__int64)a1, (_QWORD *)a3) )
return (unsigned int)EC_POINT_copy(a2, (_QWORD *)a4) != 0;
v10 = EC_POINT_is_at_infinity((__int64)a1, (_QWORD *)a4);
if ( !v10 )
{
v12 = nullptr;
if ( !a5 )
{
v18 = (int32x2_t *)BN_CTX_new();
a5 = v18;
if ( !v18 )
return v10;
v12 = (void **)v18;
}
BN_CTX_start((unsigned __int64)a5);
v13 = (unsigned __int64 *)BN_CTX_get(a5);
v14 = (unsigned __int64 *)BN_CTX_get(a5);
v15 = (unsigned __int64 *)BN_CTX_get(a5);
v22 = (unsigned __int64 *)BN_CTX_get(a5);
v20 = BN_CTX_get(a5);
v19 = BN_CTX_get(a5);
v21 = BN_CTX_get(a5);
v16 = BN_CTX_get(a5);
if ( !v16 )
goto LABEL_30;
if ( *(_DWORD *)(a3 + 32) )
{
if ( !BN_copy(v13, *(_QWORD *)(a3 + 8)) || !BN_copy(v14, *(_QWORD *)(a3 + 16)) )
goto LABEL_30;
}
else if ( !(unsigned int)EC_POINT_get_affine_coordinates_GF2m((__int64)a1, (_QWORD *)a3) )
{
goto LABEL_30;
}
if ( *(_DWORD *)(a4 + 32) )
{
if ( !BN_copy(v15, *(_QWORD *)(a4 + 8)) || !BN_copy(v22, *(_QWORD *)(a4 + 16)) )
goto LABEL_30;
}
else if ( !(unsigned int)EC_POINT_get_affine_coordinates_GF2m((__int64)a1, (_QWORD *)a4) )
{
goto LABEL_30;
}
if ( (unsigned int)BN_ucmp((__int64 *)v13, (__int64 *)v15) )
{
if ( !(unsigned int)BN_GF2m_add(v16, v13, v15)
|| !(unsigned int)BN_GF2m_add(v21, v14, v22)
|| !(*(unsigned int (__fastcall **)(_QWORD *, __int64, __int64, __int64, int32x2_t *))(*a1 + 280LL))(
a1,
v21,
v21,
v16,
a5)
|| !(*(unsigned int (__fastcall **)(_QWORD *, __int64, __int64, int32x2_t *))(*a1 + 272LL))(a1, v20, v21, a5)
|| !(unsigned int)BN_GF2m_add(v20, v20, a1[12])
|| !(unsigned int)BN_GF2m_add(v20, v20, v21)
|| !(unsigned int)BN_GF2m_add(v20, v20, v16) )
{
goto LABEL_30;
}
}
else
{
if ( (unsigned int)BN_ucmp((__int64 *)v14, (__int64 *)v22) || BN_is_zero((__int64)v15) )
{
v17 = EC_POINT_set_to_infinity((__int64)a1, a2) != 0;
goto LABEL_31;
}
if ( !(*(unsigned int (__fastcall **)(_QWORD *, __int64, unsigned __int64 *, unsigned __int64 *, int32x2_t *))(*a1 + 280LL))(
a1,
v21,
v22,
v15,
a5)
|| !(unsigned int)BN_GF2m_add(v21, v21, v15)
|| !(*(unsigned int (__fastcall **)(_QWORD *, __int64, __int64, int32x2_t *))(*a1 + 272LL))(a1, v20, v21, a5)
|| !(unsigned int)BN_GF2m_add(v20, v20, v21)
|| !(unsigned int)BN_GF2m_add(v20, v20, a1[12]) )
{
goto LABEL_30;
}
}
if ( (unsigned int)BN_GF2m_add(v19, v15, v20)
&& (*(unsigned int (__fastcall **)(_QWORD *, __int64, __int64, __int64, int32x2_t *))(*a1 + 264LL))(
a1,
v19,
v19,
v21,
a5)
&& (unsigned int)BN_GF2m_add(v19, v19, v20)
&& (unsigned int)BN_GF2m_add(v19, v19, v22) )
{
v17 = EC_POINT_set_affine_coordinates_GF2m((__int64)a1, a2) != 0;
LABEL_31:
BN_CTX_end((__int64)a5);
BN_CTX_free(v12);
return v17;
}
LABEL_30:
v17 = 0;
goto LABEL_31;
}
return (unsigned int)EC_POINT_copy(a2, (_QWORD *)a3) != 0;
}