//
// c2i_ASN1_BIT_STRING from 0xa74864 to 0xa749e0 (380 bytes)
//
// 2 xrefs:
// > sub_9D92C4 @ 0x9d9810
// > ??> @ 0x7844c
//
// 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:43 +0000
//
size_t *__fastcall c2i_ASN1_BIT_STRING(size_t **a1, unsigned __int8 **a2, int a3)
{
size_t *v6; // r4
int v7; // r3
unsigned int v8; // r8
char *v9; // r6
bool v10; // zf
size_t v11; // r5
_BYTE *v12; // r0
_BYTE *v13; // r10
void *v14; // r0
size_t *result; // r0
__int16 v16; // r2
if ( a3 <= 0 )
{
v16 = 152;
v6 = nullptr;
goto LABEL_12;
}
if ( !a1 || (v6 = *a1) == nullptr )
{
v6 = (size_t *)ASN1_BIT_STRING_new();
if ( !v6 )
return nullptr;
v7 = (int)*a2;
v8 = **a2;
if ( v8 <= 7 )
goto LABEL_5;
v16 = 220;
LABEL_12:
ERR_put_error(13, 189, v16, (int)"crypto/asn1/a_bitstr.c", 131);
if ( !a1 )
goto LABEL_14;
goto LABEL_13;
}
v7 = (int)*a2;
v8 = **a2;
if ( v8 > 7 )
{
ERR_put_error(13, 189, 220, (int)"crypto/asn1/a_bitstr.c", 131);
LABEL_13:
if ( *a1 == v6 )
return nullptr;
LABEL_14:
ASN1_BIT_STRING_free((int)v6);
return nullptr;
}
LABEL_5:
v9 = (char *)(v7 + 1);
v10 = a3 == 1;
v11 = a3 - 1;
v6[3] = v8 | 8 | v6[3] & 0xFFFFFFF0;
if ( v10 )
{
v13 = nullptr;
goto LABEL_8;
}
v12 = CRYPTO_malloc((void *)v11, (int)"crypto/asn1/a_bitstr.c", 111);
v13 = v12;
if ( !v12 )
{
v16 = 65;
goto LABEL_12;
}
memcpy(v12, v9, v11);
v9 += v11;
v13[v11 - 1] &= -1 << v8;
LABEL_8:
v14 = (void *)v6[2];
*v6 = v11;
CRYPTO_free(v14, (int)"crypto/asn1/a_bitstr.c", 123);
result = v6;
v6[1] = 3;
v6[2] = (size_t)v13;
if ( a1 )
*a1 = v6;
*a2 = (unsigned __int8 *)v9;
return result;
}