//
// bn_sqr_normal from 0x7d8350 to 0x7d8428 (216 bytes)
//
// 4 xrefs:
// > bn_sqr_recursive @ 0x7d85a4
// > BN_sqr @ 0x7d8694
// > BN_sqr @ 0x7d8718
// > ??> @ 0x5ff7c
//
// 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_sqr_normal(_DWORD *a1, int *a2, int a3, int a4)
{
int v5; // r9
_DWORD *v8; // r5
int *v9; // r6
int v10; // r4
_DWORD *v11; // r11
int v12; // t1
int v13; // r0
v5 = 2 * a3;
a1[2 * a3 - 1] = 0;
*a1 = 0;
v8 = a1 + 1;
if ( a3 - 1 > 0 )
{
v9 = a2 + 1;
v8[a3 - 1] = bn_mul_words(a1 + 1, a2 + 1, a3 - 1, *a2);
v8 = a1 + 3;
}
else
{
v9 = a2;
}
v10 = a3 - 2;
if ( a3 - 2 > 0 )
{
v11 = &v8[a3 - 3];
do
{
v12 = *v9++;
v13 = bn_mul_add_words(v8, v9, v10--, v12);
v8 += 2;
v11[1] = v13;
++v11;
}
while ( v10 );
}
bn_add_words(a1, a1, a1, v5);
bn_sqr_words(a4, a2, a3);
return bn_add_words(a1, a1, a4, v5);
}