//
// BN_GF2m_add from 0x8c9184 to 0x8c9254 (208 bytes)
//
// 35 xrefs:
// > ec_GF2m_simple_set_compressed_coordinates @ 0x888f88
// > ec_GF2m_simple_set_compressed_coordinates @ 0x888fa0
// > ec_GF2m_simple_set_compressed_coordinates @ 0x889074
// > ec_GF2m_simple_is_on_curve @ 0x88a284
// > ec_GF2m_simple_is_on_curve @ 0x88a2dc
// > ec_GF2m_simple_is_on_curve @ 0x88a314
// > ec_GF2m_simple_is_on_curve @ 0x88a348
// > ec_GF2m_simple_add @ 0x88a4d4
// > ec_GF2m_simple_add @ 0x88a4ec
// > ec_GF2m_simple_add @ 0x88a550
// > ec_GF2m_simple_add @ 0x88a568
// > ec_GF2m_simple_add @ 0x88a580
// > ec_GF2m_simple_add @ 0x88a598
// > ec_GF2m_simple_add @ 0x88a5d8
// > ec_GF2m_simple_add @ 0x88a5f0
// > ec_GF2m_simple_add @ 0x88a654
// > ec_GF2m_simple_add @ 0x88a690
// > ec_GF2m_simple_add @ 0x88a6a8
// > ec_GF2m_simple_invert @ 0x88a810
// > BN_GF2m_mod_solve_quad_arr @ 0x8c9b34
// > BN_GF2m_mod_solve_quad_arr @ 0x8c9b4c
// > BN_GF2m_mod_solve_quad_arr @ 0x8c9bd8
// > BN_GF2m_mod_solve_quad_arr @ 0x8c9c68
// > sub_8D1010 @ 0x8d11b0
// > sub_8D1010 @ 0x8d1390
// > sub_8D1010 @ 0x8d13f4
// > sub_8D1010 @ 0x8d150c
// > sub_8D1010 @ 0x8d15f8
// > sub_8D1010 @ 0x8d170c
// > sub_8D1010 @ 0x8d1774
// > sub_8D1010 @ 0x8d17d8
// > sub_8D1010 @ 0x8d1818
// > sub_8D1010 @ 0x8d18d0
// > sub_8D1010 @ 0x8d1910
// > ??> @ 0x6a84c
//
// 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
//
int __fastcall BN_GF2m_add(_DWORD *a1, _DWORD *a2, _DWORD *a3)
{
int v3; // r3
_DWORD *v4; // r6
int v5; // r1
_DWORD *v6; // r4
bool v7; // cc
int result; // r0
int v10; // r1
int v11; // r2
int v12; // lr
int v13; // r3
int v14; // r0
int v15; // t1
int v16; // t1
int v17; // r1
int *v18; // lr
_DWORD *v19; // r12
int v20; // t1
v3 = a2[1];
v4 = a2;
v5 = a3[1];
v6 = a3;
v7 = v3 < v5;
if ( v3 >= v5 )
{
v5 = v3;
v6 = v4;
}
if ( !v7 )
v4 = a3;
result = bn_wexpand((int)a1, v5);
if ( result )
{
if ( (int)v4[1] <= 0 )
{
v13 = 0;
}
else
{
v10 = *v6 - 4;
v11 = *v4 - 4;
v12 = *a1 - 4;
v13 = 0;
do
{
v15 = *(_DWORD *)(v11 + 4);
v11 += 4;
v14 = v15;
v16 = *(_DWORD *)(v10 + 4);
v10 += 4;
++v13;
*(_DWORD *)(v12 + 4) = v16 ^ v14;
v12 += 4;
}
while ( v4[1] > v13 );
}
v17 = v6[1];
if ( v13 < v17 )
{
v18 = (int *)(*v6 + 4 * v13);
v19 = (_DWORD *)(*a1 + 4 * v13);
do
{
v20 = *v18++;
*v19++ = v20;
v17 = v6[1];
++v13;
}
while ( v17 > v13 );
}
a1[1] = v17;
bn_correct_top(a1);
return 1;
}
return result;
}