//
// o2i_SCT from 0x7db6e8 to 0x7db9ac (708 bytes)
//
// 2 xrefs:
// > o2i_SCT_LIST @ 0x7dbe0c
// > ??> @ 0x604ec
//
// 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 o2i_SCT(int *a1, unsigned __int8 **a2, unsigned int a3)
{
int v6; // r4
unsigned __int8 *v7; // r0
int v8; // r7
int v9; // r0
unsigned int v10; // r12
unsigned __int8 *v11; // r3
unsigned __int64 v12; // r8
__int64 v13; // r10
unsigned __int64 v14; // r10
unsigned __int64 v15; // r8
unsigned __int8 *v16; // r0
unsigned int v17; // r7
unsigned int v18; // r8
int v19; // r0
int v21; // r0
int v22; // r0
unsigned __int8 *v23; // r12
unsigned int v24; // [sp+Ch] [bp-10h]
unsigned __int8 *v25; // [sp+14h] [bp-8h] BYREF
if ( a3 - 1 > 0xFFFE )
{
ERR_put_error(50, 110, 104, "crypto/ct/ct_oct.c", 76);
SCT_free(0);
return 0;
}
v6 = SCT_new();
if ( !v6 )
goto LABEL_18;
v7 = *a2;
v25 = v7;
v8 = *v7;
*(_DWORD *)v6 = v8;
if ( !v8 )
{
if ( a3 <= 0x2A )
{
ERR_put_error(50, 110, 104, "crypto/ct/ct_oct.c", 99);
goto LABEL_18;
}
v25 = v7 + 1;
v9 = CRYPTO_memdup(v7 + 1, 32, "crypto/ct/ct_oct.c", 104);
v10 = a3 - 43;
*(_DWORD *)(v6 + 12) = v9;
if ( v9 )
{
v11 = v25;
*(_DWORD *)(v6 + 16) = 32;
LODWORD(v12) = 0;
HIDWORD(v12) = v11[32] << 24;
*(_QWORD *)(v6 + 24) = v12;
LODWORD(v13) = 0;
HIDWORD(v13) = (v11[33] << 16) | HIDWORD(v12);
*(_QWORD *)(v6 + 24) = v13;
LODWORD(v12) = 0;
HIDWORD(v12) = (v11[34] << 8) | HIDWORD(v13);
*(_QWORD *)(v6 + 24) = v12;
LODWORD(v12) = 0;
HIDWORD(v12) |= v11[35];
*(_QWORD *)(v6 + 24) = v12;
LODWORD(v12) = v11[36] << 24;
*(_QWORD *)(v6 + 24) = v12;
v14 = (v11[37] << 16) | v12;
*(_QWORD *)(v6 + 24) = v14;
v15 = (v11[38] << 8) | v14;
*(_QWORD *)(v6 + 24) = v15;
LODWORD(v15) = v15 | v11[39];
*(_QWORD *)(v6 + 24) = v15;
v16 = v11 + 42;
v17 = v11[41] | (v11[40] << 8);
v25 = v11 + 42;
if ( v10 < v17 )
{
ERR_put_error(50, 110, 104, "crypto/ct/ct_oct.c", 114);
goto LABEL_18;
}
if ( v17 )
{
v24 = v10;
v21 = CRYPTO_memdup(v16, v17, "crypto/ct/ct_oct.c", 118);
*(_DWORD *)(v6 + 32) = v21;
if ( !v21 )
goto LABEL_18;
v16 = v25;
v10 = v24;
}
v18 = v10 - v17;
*(_DWORD *)(v6 + 36) = v17;
v25 = &v16[v17];
v19 = o2i_SCT_signature(v6, &v25, v10 - v17);
if ( v19 > 0 )
{
*a2 = &v25[v18 - v19];
goto LABEL_10;
}
ERR_put_error(50, 110, 104, "crypto/ct/ct_oct.c", 128);
}
LABEL_18:
SCT_free(v6);
return 0;
}
v22 = CRYPTO_memdup(v7, a3, "crypto/ct/ct_oct.c", 135);
*(_DWORD *)(v6 + 4) = v22;
if ( !v22 )
goto LABEL_18;
v23 = v25;
*(_DWORD *)(v6 + 8) = a3;
*a2 = &v23[a3];
LABEL_10:
if ( !a1 )
return v6;
SCT_free(*a1);
*a1 = v6;
return v6;
}