//
// BN_exp from 0xa817e8 to 0xa81974 (396 bytes)
//
// 1 xrefs:
// > ??> @ 0x8377c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:08:50 +0000
//
int __fastcall BN_exp(int a1, int a2, _DWORD *a3, int ***a4)
{
bool v8; // zf
int **v9; // r9
int **v10; // r0
bool v11; // zf
int **v12; // r7
int v13; // r4
int v15; // r10
int v16; // r4
int v17; // r0
int v18; // r1
if ( !BN_get_flags((int)a3, 4) )
{
BN_CTX_start((int)a4);
v8 = a1 == a2;
if ( a1 != a2 )
v8 = a1 == (_DWORD)a3;
if ( v8 )
v9 = BN_CTX_get(a4);
else
v9 = (int **)a1;
v10 = BN_CTX_get(a4);
v11 = v9 == nullptr;
if ( v9 )
v11 = v10 == nullptr;
v12 = v10;
if ( v11 || !BN_copy((int)v10, a2) )
goto LABEL_11;
v15 = BN_num_bits(a3);
if ( BN_is_odd((int)a3) )
{
if ( !BN_copy((int)v9, a2) )
goto LABEL_11;
}
else if ( !BN_set_word(v9, 1) )
{
goto LABEL_11;
}
if ( v15 <= 1 )
{
LABEL_27:
if ( (int **)a1 != v9 )
BN_copy(a1, (int)v9);
v13 = 1;
goto LABEL_12;
}
v16 = 1;
while ( 1 )
{
v17 = BN_sqr((int)v12, v12, (int)a4);
v18 = v16++;
if ( !v17 || BN_is_bit_set(a3, v18) && !BN_mul(v9, v9, v12, (int)a4) )
break;
if ( v16 == v15 )
goto LABEL_27;
}
LABEL_11:
v13 = 0;
LABEL_12:
BN_CTX_end(a4);
return v13;
}
ERR_put_error(3, 123, 66, (int)"crypto/bn/bn_exp.c", 48);
return 0;
}