//
// BN_rshift from 0x7d8210 to 0x7d834c (316 bytes)
//
// 14 xrefs:
// > ossl_ecdsa_sign_sig @ 0x7ee428
// > ossl_ecdsa_verify_sig @ 0x7eec48
// > BN_div @ 0x86c7fc
// > int_bn_mod_inverse @ 0x86f874
// > int_bn_mod_inverse @ 0x86f8f0
// > BN_kronecker @ 0x870010
// > BN_kronecker @ 0x8700bc
// > BN_div_recp @ 0x871440
// > BN_div_recp @ 0x871478
// > BN_mod_sqrt @ 0x871900
// > BN_mod_sqrt @ 0x871a64
// > BN_mod_sqrt @ 0x871ae8
// > BN_is_prime_fasttest_ex @ 0x8cabd4
// > ??> @ 0x5ff6c
//
// 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_rshift(int a1, int *a2, int a3)
{
int v4; // r3
int v5; // r6
bool v6; // cc
int result; // r0
int v10; // r0
int v11; // r8
int v12; // r8
int v13; // r2
int v14; // r5
int v15; // r12
int *v16; // r4
int *v17; // r3
int *v18; // r2
int v19; // t1
int v20; // lr
unsigned int *v21; // r3
unsigned int v22; // r0
int *v23; // r2
unsigned int v24; // r1
unsigned int v25; // t1
int v26; // r0
if ( a3 < 0 )
{
ERR_put_error(3, 146, 119, "crypto/bn/bn_shift.c", 130);
return 0;
}
v4 = a2[1];
v5 = a3 >> 5;
v6 = v4 < 0;
if ( v4 )
v6 = v5 < v4;
if ( !v6 )
{
BN_set_word((int **)a1, 0);
return 1;
}
v10 = BN_num_bits(a2) - a3;
v11 = v10 + 31;
if ( v10 + 31 < 0 )
v11 = v10 + 62;
v12 = v11 >> 5;
if ( (int *)a1 == a2 )
{
if ( !a3 )
return 1;
}
else
{
*(_DWORD *)(a1 + 12) = a2[3];
result = bn_wexpand(a1, v12);
if ( !result )
return result;
}
v13 = *a2;
v14 = a3 & 0x1F;
v15 = a2[1] - v5;
*(_DWORD *)(a1 + 4) = v12;
v16 = *(int **)a1;
v17 = (int *)(v13 + 4 * v5);
if ( !v14 )
{
if ( v15 )
{
v18 = v16 - 1;
do
{
v19 = *v17++;
--v15;
v18[1] = v19;
++v18;
}
while ( v15 );
}
return 1;
}
v20 = v15 - 1;
v21 = (unsigned int *)(v17 + 1);
v22 = *(_DWORD *)(v13 + 4 * v5);
if ( v15 != 1 )
{
v23 = *(int **)a1;
do
{
v24 = v22 >> v14;
v25 = *v21++;
v22 = v25;
--v20;
*v23++ = v24 | (v25 << (32 - v14));
}
while ( v20 );
v16 += v15 + 0x3FFFFFFF;
}
v26 = v22 >> v14;
if ( v26 )
*v16 = v26;
return 1;
}