//
// bn_probable_prime_dh from 0x8caf78 to 0x8cb0b4 (316 bytes)
//
// 2 xrefs:
// > BN_generate_prime_ex @ 0x8cb35c
// > ??> @ 0x6babc
//
// 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_probable_prime_dh(int *a1, int a2, int *a3, int *a4, int ***a5)
{
int *v9; // r6
int v10; // r4
unsigned __int16 *v12; // r5
unsigned int v13; // t1
unsigned int v14; // r0
BN_CTX_start((int)a5);
v9 = (int *)BN_CTX_get(a5);
if ( !v9 || !BN_rand(a1, a2, 0, 1) || !BN_div(nullptr, (int)v9, a1, a3, a5) || !BN_sub(a1, a1, v9) )
goto LABEL_3;
if ( a4 )
{
if ( !BN_add(a1, a1, a4) )
goto LABEL_3;
}
else if ( !BN_add_word((int)a1, 1u) )
{
goto LABEL_3;
}
LABEL_9:
v12 = (unsigned __int16 *)&unk_A23158;
while ( 1 )
{
v13 = v12[1];
++v12;
v14 = BN_mod_word(a1, v13);
if ( v14 == -1 )
break;
if ( v14 <= 1 )
{
if ( BN_add(a1, a1, a3) )
goto LABEL_9;
break;
}
if ( v12 == (unsigned __int16 *)&unk_A24156 )
{
v10 = 1;
goto LABEL_4;
}
}
LABEL_3:
v10 = 0;
LABEL_4:
BN_CTX_end(a5);
return v10;
}