//
// BN_mod_word from 0xd7f4f0 to 0xd7f5b0 (192 bytes)
//
// 10 xrefs:
// > DH_check @ 0xe298fc
// > DH_check @ 0xe299c8
// > BN_is_prime_fasttest_ex @ 0xe76e98
// > bn_probable_prime_dh_retry @ 0xe77298
// > bn_probable_prime_dh_coprime @ 0xe77408
// > bn_probable_prime_dh @ 0xe7752c
// > BN_generate_prime_ex @ 0xe779dc
// > BN_generate_prime_ex @ 0xe779f0
// > BN_generate_prime_ex @ 0xe77a40
// > ??> @ 0xa9fe0
//
// 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
//
unsigned __int64 __fastcall BN_mod_word(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // x0
int v3; // w4
__int64 v4; // x3
__int64 v5; // x2
__int64 v6; // x4
unsigned __int64 *v7; // x3
unsigned __int64 *v8; // x4
unsigned __int64 v9; // t1
unsigned __int64 *v11; // x0
__int64 v12; // x20
__int64 v13; // x19
if ( !a2 )
return -1;
if ( a2 > 0x100000000LL )
{
v11 = BN_dup(a1);
v12 = (__int64)v11;
if ( v11 )
{
v13 = BN_div_word((__int64)v11, a2);
BN_free(v12);
return v13;
}
return -1;
}
v3 = *(_DWORD *)(a1 + 8) - 1;
if ( v3 < 0 )
return 0;
v4 = *(_QWORD *)a1;
v5 = v3;
result = 0;
v6 = v4 + 8 * (v3 - (unsigned __int64)(unsigned int)v3);
v7 = (unsigned __int64 *)(v4 + 8 * v5);
v8 = (unsigned __int64 *)(v6 - 8);
do
{
v9 = *v7--;
result = ((unsigned int)v9 | ((((result << 32) | HIDWORD(v9)) % a2) << 32)) % a2;
}
while ( v7 != v8 );
return result;
}