//
// ec_GF2m_simple_point2oct from 0x10b0ba8 to 0x10b0f58 (944 bytes)
//
// 2 xrefs:
// > EC_POINT_point2oct @ 0x10122e0
// > ??> @ 0x8b408
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:17:43 +0000
//
int32x2_t *__fastcall ec_GF2m_simple_point2oct(
__int64 a1,
_QWORD *a2,
int a3,
_BYTE *a4,
unsigned __int64 a5,
int32x2_t *a6)
{
bool v6; // zf
unsigned int v8; // w2
int v9; // w24
void **v15; // x19
int32x2_t *result; // x0
int degree; // w0
bool v18; // nf
int v19; // w1
int v20; // w0
int v21; // w1
size_t v22; // x27
unsigned __int64 v23; // x26
_QWORD *v24; // x28
_QWORD *v25; // d8
int v26; // w0
int v27; // w1
int v28; // w0
size_t v29; // x2
__int64 v30; // x22
size_t v31; // x24
int v32; // w0
int v33; // w1
int v34; // w0
size_t v35; // x2
_BYTE *v36; // x0
__int64 v37; // [xsp+78h] [xbp+78h]
v6 = a3 == 4;
v8 = a3 & 0xFFFFFFFB;
v9 = !v6;
if ( v8 != 2 && v9 )
{
ERR_put_error(16, 161, 104, (__int64)"crypto/ec/ec2_oct.c", 140);
LABEL_7:
v15 = nullptr;
LABEL_8:
BN_CTX_free(v15);
return nullptr;
}
if ( !(unsigned int)EC_POINT_is_at_infinity(a1, a2) )
{
degree = EC_GROUP_get_degree(a1);
v19 = degree + 7;
v18 = degree + 7 < 0;
v20 = degree + 14;
if ( !v18 )
v20 = v19;
v21 = v20 >> 3;
v22 = v20 >> 3;
if ( a3 == 2 )
v23 = v21 + 1LL;
else
v23 = 2LL * v21 + 1;
if ( a4 )
{
if ( v23 > a5 )
{
ERR_put_error(16, 161, 100, (__int64)"crypto/ec/ec2_oct.c", 165);
goto LABEL_7;
}
v15 = nullptr;
if ( !a6 )
{
result = (int32x2_t *)BN_CTX_new();
a6 = result;
if ( !result )
return result;
v15 = (void **)result;
}
BN_CTX_start((unsigned __int64)a6);
v24 = (_QWORD *)BN_CTX_get(a6);
v25 = (_QWORD *)BN_CTX_get(a6);
v37 = BN_CTX_get(a6);
if ( !v37 || !(unsigned int)EC_POINT_get_affine_coordinates_GF2m(a1, a2) )
{
LABEL_32:
BN_CTX_end((__int64)a6);
goto LABEL_8;
}
*a4 = a3;
if ( v9 && !BN_is_zero((__int64)v24) )
{
if ( !(*(unsigned int (__fastcall **)(__int64, __int64, _QWORD *, _QWORD *, int32x2_t *))(*(_QWORD *)a1 + 280LL))(
a1,
v37,
v25,
v24,
a6) )
goto LABEL_32;
if ( (unsigned int)BN_is_odd(v37) )
++*a4;
}
v26 = BN_num_bits((__int64)v24);
v27 = v26 + 14;
v28 = v26 + 7;
if ( v28 >= 0 )
v27 = v28;
v29 = v22 - (v27 >> 3);
if ( v22 < v29 )
{
ERR_put_error(16, 161, 68, (__int64)"crypto/ec/ec2_oct.c", 198);
goto LABEL_32;
}
v30 = 1;
if ( v29 )
{
v30 = v29 + 1;
memset(a4 + 1, 0, v29);
}
v31 = v22 + 1;
if ( v22 + 1 != v30 + (int)BN_bn2bin(v24, &a4[v30]) )
{
ERR_put_error(16, 161, 68, (__int64)"crypto/ec/ec2_oct.c", 208);
goto LABEL_32;
}
if ( (a3 & 0xFFFFFFFD) == 4 )
{
v32 = BN_num_bits((__int64)v25);
v33 = v32 + 7;
v18 = v32 + 7 < 0;
v34 = v32 + 14;
if ( !v18 )
v34 = v33;
v35 = v22 - (v34 >> 3);
if ( v22 < v35 )
{
ERR_put_error(16, 161, 68, (__int64)"crypto/ec/ec2_oct.c", 216);
goto LABEL_32;
}
if ( v35 )
{
v36 = &a4[v31];
v31 += v35;
memset(v36, 0, v35);
}
v31 += (int)BN_bn2bin(v25, &a4[v31]);
}
if ( v31 != v23 )
{
ERR_put_error(16, 161, 68, (__int64)"crypto/ec/ec2_oct.c", 228);
goto LABEL_32;
}
BN_CTX_end((__int64)a6);
}
else
{
v15 = nullptr;
}
BN_CTX_free(v15);
return (int32x2_t *)v23;
}
if ( !a4 )
return (int32x2_t *)(dword_0 + 1);
if ( a5 )
{
*a4 = 0;
return (int32x2_t *)(dword_0 + 1);
}
else
{
ERR_put_error(16, 161, 100, (__int64)"crypto/ec/ec2_oct.c", 148);
return nullptr;
}
}