//
// ec_GF2m_simple_set_compressed_coordinates from 0x888e24 to 0x8890ac (648 bytes)
//
// 3 xrefs:
// > EC_POINT_set_compressed_coordinates_GFp @ 0x7ed188
// > EC_POINT_set_compressed_coordinates_GF2m @ 0x7ed294
// > ??> @ 0x61bcc
//
// 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_set_compressed_coordinates(_DWORD *a1, _DWORD *a2, int a3, int a4, int ***a5)
{
int ***v5; // r4
void **v8; // r7
int **v9; // r10
int **v10; // r6
int **v11; // r11
_BOOL4 v12; // r5
int ***v14; // r0
unsigned int error; // r0
int is_odd; // r8
int v17; // r3
int **v20; // [sp+14h] [bp-8h]
v5 = a5;
ERR_clear_error();
if ( a5 )
{
v8 = nullptr;
LABEL_4:
BN_CTX_start((int)v5);
v9 = BN_CTX_get(v5);
v10 = BN_CTX_get(v5);
v11 = BN_CTX_get(v5);
v20 = BN_CTX_get(v5);
if ( !v20 || !BN_GF2m_mod_arr(v10, a3, a1 + 10) )
goto LABEL_6;
if ( BN_is_zero((int)v10) )
{
if ( BN_GF2m_mod_sqrt_arr(v11, a1[17], a1 + 10, v5) )
goto LABEL_10;
}
else if ( (*(int (__fastcall **)(_DWORD *, int **, int **, int ***))(*a1 + 140))(a1, v9, v10, v5)
&& (*(int (__fastcall **)(_DWORD *, int **, _DWORD, int **, int ***))(*a1 + 144))(a1, v9, a1[17], v9, v5)
&& BN_GF2m_add(v9, a1[16], v9)
&& BN_GF2m_add(v9, v10, v9) )
{
if ( !BN_GF2m_mod_solve_quad_arr(v20, v9, a1 + 10, v5) )
{
error = ERR_peek_last_error();
if ( HIBYTE(error) != 3 || error << 20 != 121634816 )
{
ERR_put_error(16, 164, 3, (int)"crypto/ec/ec2_oct.c", 99);
v12 = 0;
goto LABEL_7;
}
ERR_clear_error();
ERR_put_error(16, 164, 110, (int)"crypto/ec/ec2_oct.c", 96);
goto LABEL_6;
}
is_odd = BN_is_odd((int)v20);
if ( (*(int (__fastcall **)(_DWORD *, int **, int **, int **, int ***))(*a1 + 136))(a1, v11, v10, v20, v5) )
{
v17 = a4;
if ( a4 )
v17 = 1;
if ( v17 == (is_odd != 0) || BN_GF2m_add(v11, v11, v10) )
{
LABEL_10:
v12 = EC_POINT_set_affine_coordinates_GF2m((int)a1, a2) != 0;
goto LABEL_7;
}
}
}
LABEL_6:
v12 = 0;
LABEL_7:
BN_CTX_end(v5);
BN_CTX_free(v8);
return v12;
}
v14 = (int ***)BN_CTX_new();
v5 = v14;
if ( v14 )
{
v8 = (void **)v14;
goto LABEL_4;
}
return 0;
}