//
// i2c_ASN1_INTEGER from 0x1087a64 to 0x1087fcc (1384 bytes)
//
// 3 xrefs:
// > sub_FEBC48 @ 0xfebedc
// > sub_FEBC48 @ 0xfebf84
// > ??> @ 0x85cf0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:17:14 +0000
//
__int64 __fastcall i2c_ASN1_INTEGER(unsigned int *a1, char **a2)
{
__int64 result; // x0
_BYTE *v4; // x3
unsigned int v6; // w6
size_t v7; // x2
int v8; // w4
unsigned __int64 v9; // x5
char *v10; // x0
__int64 v11; // x20
_BYTE *v12; // x3
char *v13; // x0
char v14; // w4
unsigned __int64 v15; // x1
unsigned __int64 v16; // x5
unsigned __int64 v17; // x4
unsigned __int64 v18; // x7
size_t v19; // x8
size_t v20; // x6
unsigned __int64 v21; // x1
unsigned __int64 v22; // x2
__int64 v23; // x9
unsigned __int64 v24; // x7
unsigned __int64 v25; // x8
int8x16_t *v26; // x3
int8x16_t *v27; // x0
int8x16_t v28; // q0
char v29; // w1
__int64 v30; // x1
size_t v31; // x4
result = *a1;
v4 = *((_BYTE **)a1 + 1);
v6 = a1[1];
v7 = (int)result;
if ( !(_DWORD)result || (v8 = v4 == nullptr, !v4) )
{
if ( !a2 )
return 1;
result = 1;
v11 = 1;
**a2 = 0;
goto LABEL_61;
}
v9 = (unsigned __int8)*v4;
if ( *v4 || (int)result != 1 )
{
v8 = v6 & 0x100;
if ( v9 <= 0x7F || (v6 & 0x100) != 0 )
{
if ( (v6 & 0x100) == 0 )
goto LABEL_5;
if ( v9 <= 0x80 )
{
if ( v9 != 128 || (unsigned __int64)(int)result <= 1 )
goto LABEL_5;
if ( !v4[1] )
{
v30 = 1;
while ( (int)result != ++v30 )
{
if ( v4[v30] )
goto LABEL_74;
}
goto LABEL_5;
}
}
LABEL_74:
v29 = -1;
}
else
{
v8 = 0;
v29 = 0;
}
v11 = (int)result + 1LL;
result = (unsigned int)(result + 1);
if ( !a2 )
return result;
v10 = *a2 + 1;
**a2 = v29;
if ( v8 )
goto LABEL_7;
LABEL_58:
memcpy(v10, v4, v7);
result = (unsigned int)v11;
goto LABEL_61;
}
LABEL_5:
if ( !a2 )
return result;
v10 = *a2;
v11 = v7;
if ( !v8 )
goto LABEL_58;
LABEL_7:
v12 = &v4[v7];
v13 = &v10[v7];
v14 = *(v12 - 1);
if ( !v14 )
{
if ( v7 <= 1 )
{
LABEL_73:
*(v13 - 1) = 0;
result = (unsigned int)v11;
goto LABEL_61;
}
while ( 1 )
{
--v12;
*--v13 = 0;
--v7;
v14 = *(v12 - 1);
if ( v14 )
break;
if ( v7 == 1 )
goto LABEL_73;
}
}
v15 = v7 - 1;
*(v13 - 1) = -v14;
v16 = (unsigned __int64)(v12 - 1);
v17 = (unsigned __int64)(v13 - 1);
if ( v7 != 1 )
{
if ( v16 > (unsigned __int64)(v13 - 17) && v17 > (unsigned __int64)(v12 - 17) || v15 <= 0x13 )
{
v31 = v7 - 2;
do
{
v13[v31 - v7] = ~v12[v31 - v7];
--v31;
}
while ( v31 != -1 );
result = (unsigned int)v11;
goto LABEL_61;
}
v18 = ((_BYTE)v12 - 17) & 0xF;
if ( v18 > v15 )
v18 = v7 - 1;
if ( v18 )
{
v19 = v7 - 2;
v17 = (unsigned __int64)(v13 - 2);
*(v13 - 2) = ~*(v12 - 2);
v20 = v7 - 2;
v16 = (unsigned __int64)(v12 - 2);
if ( v18 != 1 )
{
v17 = (unsigned __int64)(v13 - 3);
v16 = (unsigned __int64)(v12 - 3);
*(v13 - 3) = ~*(v12 - 3);
v20 = v7 - 3;
if ( v18 != 2 )
{
v17 = (unsigned __int64)(v13 - 4);
v16 = (unsigned __int64)(v12 - 4);
*(v13 - 4) = ~*(v12 - 4);
v20 = v7 - 4;
if ( v18 != 3 )
{
v17 = (unsigned __int64)(v13 - 5);
v16 = (unsigned __int64)(v12 - 5);
*(v13 - 5) = ~*(v12 - 5);
v20 = v7 - 5;
if ( v18 != 4 )
{
v17 = (unsigned __int64)(v13 - 6);
v16 = (unsigned __int64)(v12 - 6);
*(v13 - 6) = ~*(v12 - 6);
v20 = v7 - 6;
if ( v18 != 5 )
{
v17 = (unsigned __int64)(v13 - 7);
v16 = (unsigned __int64)(v12 - 7);
*(v13 - 7) = ~*(v12 - 7);
v20 = v7 - 7;
if ( v18 != 6 )
{
v17 = (unsigned __int64)(v13 - 8);
v16 = (unsigned __int64)(v12 - 8);
*(v13 - 8) = ~*(v12 - 8);
v20 = v7 - 8;
if ( v18 != 7 )
{
v17 = (unsigned __int64)(v13 - 9);
v16 = (unsigned __int64)(v12 - 9);
*(v13 - 9) = ~*(v12 - 9);
v20 = v7 - 9;
if ( v18 != 8 )
{
v17 = (unsigned __int64)(v13 - 10);
v16 = (unsigned __int64)(v12 - 10);
*(v13 - 10) = ~*(v12 - 10);
v20 = v7 - 10;
if ( v18 != 9 )
{
v17 = (unsigned __int64)(v13 - 11);
v16 = (unsigned __int64)(v12 - 11);
*(v13 - 11) = ~*(v12 - 11);
v20 = v7 - 11;
if ( v18 != 10 )
{
v17 = (unsigned __int64)(v13 - 12);
v16 = (unsigned __int64)(v12 - 12);
*(v13 - 12) = ~*(v12 - 12);
v20 = v7 - 12;
if ( v18 != 11 )
{
v17 = (unsigned __int64)(v13 - 13);
v16 = (unsigned __int64)(v12 - 13);
*(v13 - 13) = ~*(v12 - 13);
v20 = v7 - 13;
if ( v18 != 12 )
{
v17 = (unsigned __int64)(v13 - 14);
v16 = (unsigned __int64)(v12 - 14);
*(v13 - 14) = ~*(v12 - 14);
v20 = v7 - 14;
if ( v18 != 13 )
{
v17 = (unsigned __int64)(v13 - 15);
v16 = (unsigned __int64)(v12 - 15);
*(v13 - 15) = ~*(v12 - 15);
v20 = v7 - 15;
if ( v18 == 15 )
{
v17 = (unsigned __int64)(v13 - 16);
v16 = (unsigned __int64)(v12 - 16);
v20 = v7 - 16;
*(v13 - 16) = ~*(v12 - 16);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
v20 = v7 - 1;
v19 = v7 - 2;
}
v21 = v15 - v18;
v22 = ((v21 - 16) >> 4) + 1;
v23 = 16 * v22;
if ( v19 - v18 <= 0xE )
goto LABEL_37;
v24 = -17LL - v18;
v25 = 0;
v26 = (int8x16_t *)&v12[v24];
v27 = (int8x16_t *)&v13[v24];
do
{
v28 = *v26;
++v25;
--v26;
*v27-- = vqtbl1q_s8(vmvnq_s8(vqtbl1q_s8(v28, (int8x16_t)xmmword_1087FD0)), (int8x16_t)xmmword_1087FD0);
}
while ( v25 < v22 );
v17 -= v23;
v16 -= v23;
v20 -= v23;
if ( v21 != v23 )
{
LABEL_37:
*(_BYTE *)(v17 - 1) = ~*(_BYTE *)(v16 - 1);
if ( v20 != 1 )
{
*(_BYTE *)(v17 - 2) = ~*(_BYTE *)(v16 - 2);
if ( v20 != 2 )
{
*(_BYTE *)(v17 - 3) = ~*(_BYTE *)(v16 - 3);
if ( v20 != 3 )
{
*(_BYTE *)(v17 - 4) = ~*(_BYTE *)(v16 - 4);
if ( v20 != 4 )
{
*(_BYTE *)(v17 - 5) = ~*(_BYTE *)(v16 - 5);
if ( v20 != 5 )
{
*(_BYTE *)(v17 - 6) = ~*(_BYTE *)(v16 - 6);
if ( v20 != 6 )
{
*(_BYTE *)(v17 - 7) = ~*(_BYTE *)(v16 - 7);
if ( v20 != 7 )
{
*(_BYTE *)(v17 - 8) = ~*(_BYTE *)(v16 - 8);
if ( v20 != 8 )
{
*(_BYTE *)(v17 - 9) = ~*(_BYTE *)(v16 - 9);
if ( v20 != 9 )
{
*(_BYTE *)(v17 - 10) = ~*(_BYTE *)(v16 - 10);
if ( v20 != 10 )
{
*(_BYTE *)(v17 - 11) = ~*(_BYTE *)(v16 - 11);
if ( v20 != 11 )
{
*(_BYTE *)(v17 - 12) = ~*(_BYTE *)(v16 - 12);
if ( v20 != 12 )
{
*(_BYTE *)(v17 - 13) = ~*(_BYTE *)(v16 - 13);
if ( v20 != 13 )
{
*(_BYTE *)(v17 - 14) = ~*(_BYTE *)(v16 - 14);
if ( v20 != 14 )
*(_BYTE *)(v17 - 15) = ~*(_BYTE *)(v16 - 15);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
result = (unsigned int)v11;
LABEL_61:
*a2 += v11;
return result;
}