//
// DSA_dup_DH from 0x7e21f4 to 0x7e23b0 (444 bytes)
//
// 2 xrefs:
// > sub_87FC88 @ 0x87fe7c
// > ??> @ 0x60eec
//
// 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
//
_DWORD *__fastcall DSA_dup_DH(int *a1)
{
_DWORD *v2; // r6
int v3; // r4
int v4; // r0
int v5; // r8
int v6; // r7
_DWORD *v7; // r0
bool v8; // zf
int v9; // r10
int v10; // r9
int v11; // r0
if ( !a1 || (v2 = DH_new()) == nullptr )
{
v3 = 0;
v10 = 0;
v6 = 0;
v9 = 0;
v5 = 0;
v2 = nullptr;
goto LABEL_21;
}
v3 = a1[2];
v4 = a1[4];
if ( v3 )
{
if ( v4 )
{
v4 = a1[3];
if ( v4 )
{
v5 = BN_dup(a1[2]);
v6 = BN_dup(a1[4]);
v7 = (_DWORD *)BN_dup(a1[3]);
v8 = v5 == 0;
if ( v5 )
v8 = v6 == 0;
v9 = (int)v7;
if ( v8 )
{
v3 = 0;
v10 = 0;
goto LABEL_21;
}
if ( !v7 )
{
v3 = 0;
v10 = 0;
goto LABEL_21;
}
if ( !DH_set0_pqg(__SPAIR64__(v5, (unsigned int)v2), v7, v6) )
{
v3 = 0;
v10 = 0;
goto LABEL_21;
}
goto LABEL_11;
}
}
LABEL_18:
v3 = v4;
LABEL_19:
v10 = v3;
goto LABEL_20;
}
if ( v4 )
goto LABEL_19;
if ( a1[3] )
goto LABEL_18;
LABEL_11:
v4 = a1[5];
if ( !v4 )
{
if ( !a1[6] )
return v2;
goto LABEL_18;
}
v10 = BN_dup(v4);
if ( !v10 )
{
v3 = 0;
v6 = 0;
v9 = 0;
v5 = 0;
goto LABEL_21;
}
v11 = a1[6];
if ( !v11 )
{
v3 = 0;
goto LABEL_15;
}
v3 = BN_dup(v11);
if ( !v3 )
{
LABEL_20:
v6 = v3;
v9 = v3;
v5 = v3;
goto LABEL_21;
}
LABEL_15:
if ( DH_set0_key((int)v2, v10, v3) )
return v2;
v6 = 0;
v9 = 0;
v5 = 0;
LABEL_21:
BN_free(v5);
BN_free(v6);
BN_free(v9);
BN_free(v10);
BN_free(v3);
DH_free((int)v2);
return nullptr;
}