//
// BN_mod_word from 0xffd850 to 0xffd910 (192 bytes)
//
// 10 xrefs:
// > DH_check @ 0x10a7bfc
// > DH_check @ 0x10a7cc8
// > BN_is_prime_fasttest_ex @ 0x10f4e98
// > bn_probable_prime_dh_retry @ 0x10f5298
// > bn_probable_prime_dh_coprime @ 0x10f5408
// > bn_probable_prime_dh @ 0x10f552c
// > BN_generate_prime_ex @ 0x10f59dc
// > BN_generate_prime_ex @ 0x10f59f0
// > BN_generate_prime_ex @ 0x10f5a40
// > ??> @ 0xded30
//
// 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:15:52 +0000
//
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;
}