//
// BN_mask_bits from 0x7d5268 to 0x7d52c4 (92 bytes)
//
// 3 xrefs:
// > dsa_builtin_paramgen @ 0x880808
// > dsa_builtin_paramgen2 @ 0x881348
// > ??> @ 0x5fcdc
//
// 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_mask_bits(int *a1, int a2)
{
int v2; // r12
int v3; // r3
bool v4; // zf
int v5; // r1
if ( a2 < 0 )
return 0;
v3 = a2 >> 5;
if ( a2 >> 5 >= a1[1] )
return 0;
v5 = a2 & 0x1F;
v4 = v5 == 0;
if ( v5 )
{
v2 = *a1;
a1[1] = v3 + 1;
v5 = *(_DWORD *)(v2 + 4 * v3) & ~(-1 << v5);
}
else
{
a1[1] = v3;
}
if ( !v4 )
*(_DWORD *)(v2 + 4 * v3) = v5;
bn_correct_top(a1);
return 1;
}