//
// bn_correct_top from 0xd7b264 to 0xd7b298 (52 bytes)
//
// 25 xrefs:
// > BN_bin2bn @ 0xd7b37c
// > BN_lebin2bn @ 0xd7b4b0
// > BN_clear_bit @ 0xd7b550
// > BN_mask_bits @ 0xd7b5a8
// > sub_D7B5F4 @ 0xd7b94c
// > sub_D7B5F4 @ 0xd7b954
// > BN_mod_mul_montgomery @ 0xd7bbac
// > BN_mul @ 0xd7d5cc
// > BN_hex2bn @ 0xd7dfd0
// > BN_dec2bn @ 0xd7e1ac
// > BN_lshift @ 0xd7ec08
// > BN_usub @ 0xe12f80
// > BN_div @ 0xe15f7c
// > BN_div @ 0xe15fb0
// > sub_E16110 @ 0xe161c8
// > sub_E16110 @ 0xe162d4
// > BN_mod_exp_mont @ 0xe17528
// > bn_set_static_words @ 0xe193d0
// > bn_set_words @ 0xe19418
// > BN_GF2m_add @ 0xe74b20
// > BN_GF2m_mod_arr @ 0xe74e78
// > BN_GF2m_mod_sqr_arr @ 0xe7501c
// > BN_GF2m_mod_mul_arr @ 0xe75990
// > BN_GF2m_mod_inv @ 0xe765d0
// > ??> @ 0x61488
//
// 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
//
__int64 __fastcall bn_correct_top(__int64 result)
{
int v1; // w1
__int64 v2; // x2
__int64 v3; // t1
v1 = *(_DWORD *)(result + 8);
if ( v1 > 0 )
{
v2 = *(_QWORD *)result + 8LL * v1;
do
{
v3 = *(_QWORD *)(v2 - 8);
v2 -= 8;
if ( v3 )
break;
--v1;
}
while ( v1 );
*(_DWORD *)(result + 8) = v1;
}
if ( !v1 )
*(_DWORD *)(result + 16) = 0;
return result;
}