[Sony Xperia XZ1 Compact ROMs, Kernels, Recoveries,] munjeni:
This function is seems for decompressing whole package

struct __attribute__((packed)) __attribute__((aligned(4))) struct_v16_2
{
_BYTE gap0[8];
_DWORD dword8;
_BYTE gapC[4];
unsigned int unsigned10;
_BYTE gap14[1028];
__int64 (__fastcall *pfunc418)(__int64, signed __int64);
_QWORD qword420;
_DWORD dword428;
_BYTE gap42C[4];
_DWORD dword430;
};

signed __int64 __fastcall sub_416304(struct_v16_2 *a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7, long double a8, long double a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13, __int64 a14, __int64 a15, __int64 a16)
{
struct_v16_2 *v16; // x19
__int64 v17; // x8
unsigned int v18; // w9
__int64 v19; // x6
__int64 v20; // x10
unsigned __int64 v21; // x0
__int64 v22; // x8
int v23; // w9
unsigned __int16 *v24; // x0
int v25; // w19
const char *v27; // x5
signed __int64 v28; // x2
const char *v29; // x5
signed __int64 v30; // x2
const char *v31; // x5
signed __int64 v32; // x2

v16 = a1;
if ( !a1 || (v17 = a1->qword420) == 0 )
{
LOG(
0LL,
0LL,
226LL,
0LL,
"ERROR",
"package info is not initialised\n",
a15,
a16,
*(double *)&a2,
*(double *)&a3,
*(double *)&a4,
*(double *)&a5,
*(double *)&a6,
*(double *)&a7,
*(double *)&a8,
*(double *)&a9);
return 0LL;
}
if ( *(_DWORD *)&a1->gap0[4] != 1 )
{
v27 = "package header type is unexpected (0x%x)\n";
v28 = 0xEDLL;
LABEL_21:
LOG(
0LL,
0LL,
v28,
0LL,
"ERROR",
v27,
*(double *)&a2,
*(double *)&a3,
*(double *)&a4,
*(double *)&a5,
*(double *)&a6,
*(double *)&a7,
*(double *)&a8,
*(double *)&a9);
return 0LL;
}
if ( *(_DWORD *)a1->gapC != 0x10000 )
{
v27 = "RedBend sector size is unexpected (0x%x)\n";
v28 = 245LL;
goto LABEL_21;
}
v18 = a1->unsigned10;
if ( v18 )
{
v19 = 0LL;
v20 = (__int64)&a1->gap14[4];
while ( 1 )
{
if ( *(_DWORD *)(v20 - 4) >= 0x40u )
{
v29 = "increments[%d] type is unexpected (0x%x)\n";
v30 = 254LL;
goto LABEL_29;
}
if ( *(_QWORD *)(v17 + 16) < *(_QWORD *)v20 )
break;
if ( !(*(_QWORD *)(v20 + 16) & 3LL) )
{
v31 = "increments[%d] is not FS or image update (0x%llx)\n";
v32 = 269LL;
goto LABEL_27;
}
if ( (unsigned int)(*(_DWORD *)(v20 + 0x18) - 1) >= 3 )
{
v29 = "increments[%d] has not been generated by valid generator (0x%x)\n";
v30 = 278LL;
LABEL_29:
LOG(
0LL,
0LL,
v30,
0LL,
"ERROR",
v29,
v19,
*(double *)&a2,
*(double *)&a3,
*(double *)&a4,
*(double *)&a5,
*(double *)&a6,
*(double *)&a7,
*(double *)&a8,
*(double *)&a9);
return 0LL;
}
v19 = (unsigned int)(v19 + 1);
v20 += 32LL;
if ( (unsigned int)v19 >= v18 )
goto LABEL_12;
}
v31 = "increments[%d] size is bigger than package (0x%llx)\n";
v32 = 261LL;
LABEL_27:
LOG(
0LL,
0LL,
v32,
0LL,
"ERROR",
v31,
v19,
*(double *)&a2,
*(double *)&a3,
*(double *)&a4,
*(double *)&a5,
*(double *)&a6,
*(double *)&a7,
*(double *)&a8,
*(double *)&a9);
return 0LL;
}
LABEL_12:
if ( *(_QWORD *)(a1->qword420 + 0x10LL) < (unsigned __int64)((__int64 (*)(void))a1->pfunc418)() )
return 0LL;
if ( *(_QWORD *)(v16->qword420 + 16LL) < (unsigned __int64)v16->pfunc418((__int64)v16, 4LL) )
return 0LL;
v21 = v16->pfunc418((__int64)v16, 5LL);
v22 = v16->qword420;
if ( *(_QWORD *)(v22 + 16) < v21 )
return 0LL;
v23 = *(_DWORD *)v16->gap0;
v24 = *(unsigned __int16 **)(v22 + 8);
if ( *(unsigned __int16 *)((char *)v24 + (unsigned int)(*(_DWORD *)v16->gap0 - 4)) )
return 0LL;
v25 = *(unsigned __int16 *)((char *)v24 + (unsigned int)(v23 - 2));
if ( (unsigned __int16)sub_415288(v24, v23 - 2) != v25 )
return 0LL;
return 1LL;
}

signed __int64 __fastcall sub_416518(struct_v16_2 *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, long double a9, long double a10, long double a11, long double a12, long double a13, long double a14, long double a15, long double a16)
{
struct_v16_2 *v16; // x19
signed __int64 v17; // x0
__int64 v18; // x20
__int64 v19; // x20
__int64 v20; // x20
__int64 v21; // x0
__int64 v22; // x8
unsigned __int64 v23; // x9
__int64 v24; // x10
char *v25; // x11
__int64 v26; // t1
__int64 v27; // x8
__int64 v28; // x20
const char *v29; // x5
signed __int64 v30; // x2
signed __int64 result; // x0
__int64 v32; // x8
__int64 v33; // x20

v16 = a1;
if ( !a1 || !a1->qword420 )
{
v29 = "package info is not initialised\n";
v30 = 371LL;
v17 = 0LL;
LABEL_10:
LOG(
v17,
0LL,
v30,
0LL,
"ERROR",
v29,
a7,
a8,
*(double *)&a9,
*(double *)&a10,
*(double *)&a11,
*(double *)&a12,
*(double *)&a13,
*(double *)&a14,
*(double *)&a15,
*(double *)&a16);
return 0LL;
}
v17 = sub_416304((struct_v16 *)a1, a9, a10, a11, a12, a13, a14, a15, a16, a2, a3, a4, a5, a6, a7, a8);
if ( !(_DWORD)v17 )
{
v29 = "The package looks as mad as a hatter\n";
v30 = 378LL;
goto LABEL_10;
}
v18 = *(_QWORD *)(v16->qword420 + 8LL);
*(_QWORD *)(v16->qword420 + 64LL) = v18 + v16->pfunc418((__int64)v16, 4LL);
v19 = *(_QWORD *)(v16->qword420 + 8LL);
*(_QWORD *)(v16->qword420 + 24LL) = v19 + v16->pfunc418((__int64)v16, 5LL);
v20 = *(_QWORD *)(v16->qword420 + 8LL);
v21 = v16->pfunc418((__int64)v16, 1LL);
*(_DWORD *)(v16->qword420 + 0x548LL) = v16->dword8;
if ( v16->unsigned10 )
{
v22 = 0LL;
v23 = 0LL;
v24 = v20 + v21;
v25 = &v16->gap14[4];
do
{
++v23;
*(_DWORD *)(v16->qword420 + v22 + 0x48) = *((_QWORD *)v25 + 2);
*(_DWORD *)(v16->qword420 + v22 + 76) = *((_DWORD *)v25 - 1);
*(_QWORD *)(v16->qword420 + v22 + 80) = *((_QWORD *)v25 + 1);
*(_QWORD *)(v16->qword420 + v22 + 88) = *(_QWORD *)v25;
*(_DWORD *)(v16->qword420 + v22 + 96) = *((_DWORD *)v25 + 6);
*(_QWORD *)(v16->qword420 + v22 + 104) = v24;
v26 = *(_QWORD *)v25;
v25 += 32;
v22 += 40LL;
v24 += v26;
}
while ( v23 < v16->unsigned10 );
}
*(_DWORD *)(v16->qword420 + 56LL) = v16->dword430;
v27 = v16->qword420;
if ( *(_DWORD *)(v27 + 56) )
{
v28 = *(_QWORD *)(v27 + 8);
*(_QWORD *)(v16->qword420 + 48LL) = v28 + v16->pfunc418((__int64)v16, 3LL);
}
else
{
*(_QWORD *)(v27 + 48) = 0LL;
}
*(_DWORD *)(v16->qword420 + 40LL) = v16->dword428;
v32 = v16->qword420;
if ( *(_DWORD *)(v32 + 40) )
{
v33 = *(_QWORD *)(v32 + 8);
*(_QWORD *)(v16->qword420 + 32LL) = v33 + v16->pfunc418((__int64)v16, 2LL);
}
else
{
*(_QWORD *)(v32 + 32) = 0LL;
}
result = 1LL;
*(_DWORD *)v16->qword420 = 1;
return result;
}

What this does?

(unsigned __int64)((__int64 (*)(void))a1->pfunc418)() )