//
// ec_GF2m_simple_add from 0x88a37c to 0x88a798 (1052 bytes)
//
// 3 xrefs:
// > ec_GF2m_simple_dbl @ 0x88a7a8
// > ??> @ 0x6aa1c
// > ??> @ 0xab4fc8
//
// 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
//
bool __fastcall ec_GF2m_simple_add(_DWORD *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, int ***a5)
{
int ***v9; // r4
void **v10; // r10
int *v11; // r9
int *v12; // r11
_BOOL4 v13; // r5
int ***v15; // r0
int *v16; // [sp+8h] [bp-1Ch]
int *v17; // [sp+Ch] [bp-18h]
int **v18; // [sp+10h] [bp-14h]
int **v19; // [sp+14h] [bp-10h]
int **v20; // [sp+18h] [bp-Ch]
int **v21; // [sp+1Ch] [bp-8h]
v9 = a5;
if ( EC_POINT_is_at_infinity((int)a1, a3) )
return EC_POINT_copy(a2, a4) != 0;
v10 = (void **)EC_POINT_is_at_infinity((int)a1, a4);
if ( !v10 )
{
if ( !a5 )
{
v15 = (int ***)BN_CTX_new();
v9 = v15;
if ( !v15 )
return (bool)v10;
v10 = (void **)v15;
}
BN_CTX_start((int)v9);
v11 = (int *)BN_CTX_get(v9);
v16 = (int *)BN_CTX_get(v9);
v12 = (int *)BN_CTX_get(v9);
v17 = (int *)BN_CTX_get(v9);
v20 = BN_CTX_get(v9);
v21 = BN_CTX_get(v9);
v19 = BN_CTX_get(v9);
v18 = BN_CTX_get(v9);
if ( !v18 )
goto LABEL_30;
if ( a3[4] )
{
if ( !BN_copy((int)v11, a3[1]) || !BN_copy((int)v16, a3[2]) )
goto LABEL_30;
}
else if ( !EC_POINT_get_affine_coordinates_GF2m((int)a1, a3) )
{
goto LABEL_30;
}
if ( a4[4] )
{
if ( !BN_copy((int)v12, a4[1]) || !BN_copy((int)v17, a4[2]) )
goto LABEL_30;
}
else if ( !EC_POINT_get_affine_coordinates_GF2m((int)a1, a4) )
{
goto LABEL_30;
}
if ( BN_ucmp(v11, v12) )
{
if ( !BN_GF2m_add(v18, v11, v12)
|| !BN_GF2m_add(v19, v16, v17)
|| !(*(int (__fastcall **)(_DWORD *, int **, int **, int **, int ***))(*a1 + 144))(a1, v19, v19, v18, v9)
|| !(*(int (__fastcall **)(_DWORD *, int **, int **, int ***))(*a1 + 140))(a1, v20, v19, v9)
|| !BN_GF2m_add(v20, v20, a1[16])
|| !BN_GF2m_add(v20, v20, v19)
|| !BN_GF2m_add(v20, v20, v18) )
{
goto LABEL_30;
}
}
else
{
if ( BN_ucmp(v16, v17) || BN_is_zero((int)v12) )
{
v13 = EC_POINT_set_to_infinity((int)a1, a2) != 0;
goto LABEL_31;
}
if ( !(*(int (__fastcall **)(_DWORD *, int **, int *, int *, int ***))(*a1 + 144))(a1, v19, v17, v12, v9)
|| !BN_GF2m_add(v19, v19, v12)
|| !(*(int (__fastcall **)(_DWORD *, int **, int **, int ***))(*a1 + 140))(a1, v20, v19, v9)
|| !BN_GF2m_add(v20, v20, v19)
|| !BN_GF2m_add(v20, v20, a1[16]) )
{
goto LABEL_30;
}
}
if ( BN_GF2m_add(v21, v12, v20)
&& (*(int (__fastcall **)(_DWORD *, int **, int **, int **, int ***))(*a1 + 136))(a1, v21, v21, v19, v9)
&& BN_GF2m_add(v21, v21, v20)
&& BN_GF2m_add(v21, v21, v17) )
{
v13 = EC_POINT_set_affine_coordinates_GF2m((int)a1, a2) != 0;
LABEL_31:
BN_CTX_end(v9);
BN_CTX_free(v10);
return v13;
}
LABEL_30:
v13 = 0;
goto LABEL_31;
}
return EC_POINT_copy(a2, a3) != 0;
}