//
// ec_GFp_simple_set_compressed_coordinates from 0xa06e2c to 0xa07278 (1100 bytes)
//
// 3 xrefs:
// > EC_POINT_set_compressed_coordinates_GFp @ 0xa01d94
// > EC_POINT_set_compressed_coordinates_GF2m @ 0xa01ea0
// > ??> @ 0x7b65c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:07:41 +0000
//
bool __fastcall ec_GFp_simple_set_compressed_coordinates(_DWORD *a1, _DWORD *a2, int a3, int a4, int a5)
{
int v5; // r4
int v9; // r0
int v10; // r7
int v11; // r10
int v12; // r9
int v13; // r8
_BOOL4 v14; // r5
int (__fastcall *v16)(_DWORD *, int, _DWORD, int); // r12
int (__fastcall *v17)(_DWORD *, int, _DWORD, int); // r12
int v18; // r1
int v19; // r2
int v20; // r3
int is_odd; // r0
int v22; // r6
int v23; // r0
int v24; // r0
unsigned int error; // r0
int v26; // [sp+0h] [bp-14h]
int v28; // [sp+Ch] [bp-8h]
v5 = a5;
v9 = ERR_clear_error(a1);
if ( a5 )
{
v10 = 0;
LABEL_4:
BN_CTX_start(v5);
v11 = BN_CTX_get(v5);
v12 = BN_CTX_get(v5);
v13 = BN_CTX_get(v5);
v28 = BN_CTX_get(v5);
if ( !v28 || !BN_nnmod(v13, a3, a1[9], v5, v26) )
goto LABEL_6;
if ( *(_DWORD *)(*a1 + 152) )
{
if ( !BN_mod_sqr(v12, a3, a1[9], v5) || !BN_mod_mul(v11, v12, a3, a1[9], v5) )
goto LABEL_6;
}
else if ( !(*(int (__fastcall **)(_DWORD *, int, int, int))(*a1 + 140))(a1, v12, a3, v5)
|| !(*(int (__fastcall **)(_DWORD *, int, int, int, int))(*a1 + 136))(a1, v11, v12, a3, v5) )
{
goto LABEL_6;
}
if ( a1[18] )
{
if ( !BN_mod_lshift1_quick(v12, v13, a1[9])
|| !BN_mod_add_quick(v12, v12, v13, a1[9])
|| !BN_mod_sub_quick(v11, v11, v12, a1[9]) )
{
goto LABEL_6;
}
}
else
{
v16 = *(int (__fastcall **)(_DWORD *, int, _DWORD, int))(*a1 + 152);
if ( v16 )
{
if ( !v16(a1, v12, a1[16], v5) || !BN_mod_mul(v12, v12, v13, a1[9], v5) )
goto LABEL_6;
}
else if ( !(*(int (__fastcall **)(_DWORD *, int, _DWORD, int, int))(*a1 + 136))(a1, v12, a1[16], v13, v5) )
{
goto LABEL_6;
}
if ( !BN_mod_add_quick(v11, v11, v12, a1[9]) )
{
LABEL_6:
v14 = 0;
LABEL_7:
BN_CTX_end(v5);
BN_CTX_free(v10);
return v14;
}
}
v17 = *(int (__fastcall **)(_DWORD *, int, _DWORD, int))(*a1 + 152);
if ( v17 )
{
if ( !v17(a1, v12, a1[17], v5) || !BN_mod_add_quick(v11, v11, v12, a1[9]) )
goto LABEL_6;
}
else if ( !BN_mod_add_quick(v11, v11, a1[17], a1[9]) )
{
goto LABEL_6;
}
if ( !BN_mod_sqrt(v28, v11, a1[9], v5) )
{
error = ERR_peek_last_error(0, v18, v19, v20);
if ( HIBYTE(error) == 3 && error << 20 == 116391936 )
{
ERR_clear_error(116391936);
v14 = 0;
ERR_put_error(16, 169, 110, "crypto/ec/ecp_oct.c", 113);
}
else
{
ERR_put_error(16, 169, 3, "crypto/ec/ecp_oct.c", 116);
v14 = 0;
}
goto LABEL_7;
}
is_odd = BN_is_odd(v28);
v22 = a4;
if ( a4 )
v22 = 1;
if ( is_odd != v22 )
{
if ( BN_is_zero(v28) )
{
v23 = BN_kronecker(v13, a1[9], v5);
if ( v23 != -2 )
{
if ( v23 != 1 )
{
ERR_put_error(16, 169, 110, "crypto/ec/ecp_oct.c", 136);
v14 = 0;
goto LABEL_7;
}
ERR_put_error(16, 169, 109, "crypto/ec/ecp_oct.c", 130);
}
goto LABEL_6;
}
if ( !BN_usub(v28, a1[9]) )
goto LABEL_6;
}
if ( BN_is_odd(v28) == v22 )
{
v14 = EC_POINT_set_affine_coordinates_GFp((int)a1, a2) != 0;
}
else
{
ERR_put_error(16, 169, 68, "crypto/ec/ecp_oct.c", 144);
v14 = 0;
}
goto LABEL_7;
}
v24 = BN_CTX_new(v9);
v5 = v24;
if ( v24 )
{
v10 = v24;
goto LABEL_4;
}
return 0;
}