//
// sub_ED1BB0 from 0xed1bb0 to 0xed21c8 (1560 bytes)
//
// 1 xrefs:
// > sub_ED3238 @ 0xed3328
//
// 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:11:40 +0000
//
char *__fastcall sub_ED1BB0(__int64 a1, char *a2, signed __int64 byte_count)
{
int v3; // w21
__int64 v6; // x22
signed __int64 v7; // x20
char *result; // x0
__int64 v9; // x19
char *v10; // x25
char *v11; // x6
__int64 i; // x5
unsigned int v13; // w0
char *v14; // x2
__int64 v15; // x1
char v16; // t1
signed __int64 v17; // x3
__int64 v18; // x4
signed __int64 v19; // x9
unsigned __int64 v20; // x2
char *v21; // x1
signed __int64 v22; // x5
unsigned __int64 v23; // x17
unsigned __int64 v24; // x14
__int64 v25; // x16
int8x16_t *v26; // x15
int8x16_t *v27; // x2
int8x16_t *v28; // x19
unsigned __int64 v29; // x18
int8x16_t v30; // q1
int8x16_t v31; // q0
__int64 v32; // x1
char *v33; // x1
v3 = *(unsigned __int16 *)(a1 + 116) >> 3;
v6 = *(_WORD *)(a1 + 116) >> 3;
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 848) + 8LL);
result = (char *)TIFFmalloc(byte_count);
v9 = byte_count / v6;
v10 = result;
if ( result )
{
TIFFmemcpy(result, a2, byte_count);
if ( v9 > 0 )
{
v11 = v10;
for ( i = 0; i != v9; ++i )
{
if ( v3 )
{
v13 = v3 - 1;
v14 = v11;
do
{
v15 = v13;
v16 = *v14++;
--v13;
a2[i + v15 * v9] = v16;
}
while ( v13 != -1 );
}
v11 += v6;
}
}
TIFFfree(v10);
v17 = byte_count - v7;
result = &a2[byte_count - v7 - 1];
if ( v7 < byte_count )
{
v18 = v7 - 4;
v19 = v7 - 15;
while ( 1 )
{
if ( (unsigned __int64)v7 <= 4 )
{
switch ( (int)v7 )
{
case 0:
break;
case 1:
v32 = 1;
goto LABEL_55;
case 2:
v32 = 2;
goto LABEL_54;
case 3:
v32 = 3;
goto LABEL_53;
case 4:
v32 = 4;
goto LABEL_52;
}
}
else
{
if ( v18 <= 0 )
{
v32 = v7;
}
else
{
if ( (&result[v19] >= result + 1 || v7 + 1 < -14) && (unsigned __int64)v18 > 0x12 )
{
v20 = ((_BYTE)result + (_BYTE)v19) & 0xF;
if ( v20 > v18 )
v20 = v7 - 4;
if ( v20 )
{
v21 = result - 1;
v22 = v7 - 5;
result[v7] -= *result;
if ( v20 != 1 )
{
v22 = v7 - 6;
v21[v7] -= *(result - 1);
v21 = result - 2;
if ( v20 != 2 )
{
v22 = v7 - 7;
v21[v7] -= *(result - 2);
v21 = result - 3;
if ( v20 != 3 )
{
v22 = v7 - 8;
v21[v7] -= *(result - 3);
v21 = result - 4;
if ( v20 != 4 )
{
v22 = v7 - 9;
v21[v7] -= *(result - 4);
v21 = result - 5;
if ( v20 != 5 )
{
v22 = v7 - 10;
v21[v7] -= *(result - 5);
v21 = result - 6;
if ( v20 != 6 )
{
v22 = v7 - 11;
v21[v7] -= *(result - 6);
v21 = result - 7;
if ( v20 != 7 )
{
v22 = v7 - 12;
v21[v7] -= *(result - 7);
v21 = result - 8;
if ( v20 != 8 )
{
v22 = v7 - 13;
v21[v7] -= *(result - 8);
v21 = result - 9;
if ( v20 != 9 )
{
v22 = v7 - 14;
v21[v7] -= *(result - 9);
v21 = result - 10;
if ( v20 != 10 )
{
v22 = v7 - 15;
v21[v7] -= *(result - 10);
v21 = result - 11;
if ( v20 != 11 )
{
v22 = v7 - 16;
v21[v7] -= *(result - 11);
v21 = result - 12;
if ( v20 != 12 )
{
v22 = v7 - 17;
v21[v7] -= *(result - 12);
v21 = result - 13;
if ( v20 != 13 )
{
v22 = v7 - 18;
v21[v7] -= *(result - 13);
v21 = result - 14;
if ( v20 == 15 )
{
v22 = v7 - 19;
v21[v7] -= *(result - 14);
v21 = result - 15;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
v22 = v7 - 4;
v21 = result;
}
v23 = v18 - v20;
v24 = ((v18 - v20 - 16) >> 4) + 1;
v25 = 16 * v24;
if ( v7 - 5 - v20 <= 0xE )
goto LABEL_36;
v26 = (int8x16_t *)&result[v19 - v20];
v27 = (int8x16_t *)&result[-15LL - v20];
v28 = v26;
v29 = 0;
do
{
v30 = *v26;
++v29;
v31 = *v27;
--v26;
--v27;
*v28-- = vqtbl1q_s8(
vsubq_s8(
vqtbl1q_s8(v30, (int8x16_t)xmmword_ED21D0),
vqtbl1q_s8(v31, (int8x16_t)xmmword_ED21D0)),
(int8x16_t)xmmword_ED21D0);
}
while ( v24 > v29 );
v21 -= v25;
v22 -= v25;
if ( v25 != v23 )
{
LABEL_36:
v21[v7] -= *v21;
if ( v22 - 1 > 0 )
{
v21[v7 - 1] -= *(v21 - 1);
if ( v22 != 2 )
{
v21[v7 - 2] -= *(v21 - 2);
if ( v22 != 3 )
{
v21[v7 - 3] -= *(v21 - 3);
if ( v22 != 4 )
{
v21[v7 - 4] -= *(v21 - 4);
if ( v22 != 5 )
{
v21[v7 - 5] -= *(v21 - 5);
if ( v22 != 6 )
{
v21[v7 - 6] -= *(v21 - 6);
if ( v22 != 7 )
{
v21[v7 - 7] -= *(v21 - 7);
if ( v22 != 8 )
{
v21[v7 - 8] -= *(v21 - 8);
if ( v22 != 9 )
{
v21[v7 - 9] -= *(v21 - 9);
if ( v22 != 10 )
{
v21[v7 - 10] -= *(v21 - 10);
if ( v22 != 11 )
{
v21[v7 - 11] -= *(v21 - 11);
if ( v22 != 12 )
{
v21[v7 - 12] -= *(v21 - 12);
if ( v22 != 13 )
{
v21[v7 - 13] -= *(v21 - 13);
if ( v22 != 14 )
v21[v7 - 14] -= *(v21 - 14);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
v33 = &result[v7];
do
{
*v33 -= v33[-v7];
--v33;
}
while ( v33 != result + 4 );
}
result += 4 - v7;
v32 = v7;
}
LABEL_52:
result[v32] -= *result;
--result;
LABEL_53:
result[v32] -= *result;
--result;
LABEL_54:
result[v32] -= *result;
--result;
LABEL_55:
result[v32] -= *result;
--result;
}
if ( v7 >= v17 )
break;
v17 -= v7;
}
}
}
return result;
}