/* DxeIplLzmaDecodeStream @ 0xffc18496 size=0x295 */
int __fastcall DxeIplLzmaDecodeStream(
int a1,
unsigned int a2,
unsigned __int8 *a3,
unsigned int *a4,
int a5,
_DWORD *a6)
{
unsigned int *v6; // edi
unsigned int n0x14; // ebx
unsigned __int8 *v10; // edx
unsigned int n5; // ecx
int v12; // ecx
int v13; // eax
unsigned int n0x14_2; // edi
unsigned __int8 *v15; // edi
unsigned __int8 *v16; // eax
int n2; // eax
_BYTE *v18; // eax
unsigned int n0x14_1; // ecx
int n2_1; // eax
unsigned int n0x14_4; // eax
unsigned int n0x14_5; // edi
unsigned int v23; // eax
int v25; // ecx
unsigned int n0x14_3; // [esp+14h] [ebp-4h]
int v28; // [esp+28h] [ebp+10h]
v6 = a4; /*0xffc1849c*/
n0x14 = *a4; /*0xffc184a8*/
*a4 = 0; /*0xffc184aa*/
DxeIplLzmaDecodeLiteral(); /*0xffc184ad*/
*a6 = 0; /*0xffc184b9*/
if ( *(_DWORD *)(a1 + 72) == 274 ) /*0xffc184c4*/
{
LABEL_52:
v25 = *(_DWORD *)(a1 + 32); /*0xffc1870f*/
if ( !v25 ) /*0xffc18714*/
*a6 = 1; /*0xffc18716*/
return v25 != 0; /*0xffc18721*/
}
v10 = a3; /*0xffc184ca*/
while ( 1 ) /*0xffc184ce*/
{
if ( *(_DWORD *)(a1 + 76) ) /*0xffc184ce*/
{
if ( n0x14 ) /*0xffc184d6*/
{
do /*0xffc184ef*/
{
n5 = *(_DWORD *)(a1 + 88); /*0xffc184d8*/
if ( n5 >= 5 ) /*0xffc184de*/
break; /*0xffc184de*/
*(_BYTE *)(n5 + a1 + 92) = *v10; /*0xffc184e2*/
++*(_DWORD *)(a1 + 88); /*0xffc184e6*/
++v10; /*0xffc184e9*/
++*v6; /*0xffc184ea*/
--n0x14; /*0xffc184ec*/
}
while ( n0x14 ); /*0xffc184ef*/
a3 = v10; /*0xffc184f3*/
}
if ( *(_DWORD *)(a1 + 88) < 5u ) /*0xffc184fc*/
goto LABEL_42; /*0xffc184fc*/
if ( *(_BYTE *)(a1 + 92) ) /*0xffc18502*/
return 1; /*0xffc18506*/
v12 = *(unsigned __int8 *)(a1 + 95) /*0xffc18522*/
| ((*(unsigned __int8 *)(a1 + 94) | (*(unsigned __int8 *)(a1 + 93) << 8)) << 8);
v13 = *(unsigned __int8 *)(a1 + 96); /*0xffc18524*/
*(_DWORD *)(a1 + 28) = -1; /*0xffc18528*/
*(_DWORD *)(a1 + 76) = 0; /*0xffc18531*/
*(_DWORD *)(a1 + 32) = v13 | (v12 << 8); /*0xffc18534*/
*(_DWORD *)(a1 + 88) = 0; /*0xffc18539*/
}
v28 = 0; /*0xffc18545*/
if ( *(_DWORD *)(a1 + 36) >= a2 ) /*0xffc1854c*/
{
if ( *(_DWORD *)(a1 + 72) ) /*0xffc1854e*/
{
*a6 = 2; /*0xffc186d4*/
return 1; /*0xffc186dd*/
}
if ( !*(_DWORD *)(a1 + 32) ) /*0xffc1855a*/
{
*a6 = 4; /*0xffc186cb*/
return 0; /*0xffc186d2*/
}
v28 = 1; /*0xffc18560*/
}
if ( *(_DWORD *)(a1 + 80) ) /*0xffc18564*/
{
memset32(*(void **)(a1 + 16), 67109888, (unsigned int)((768 << (*(_BYTE *)a1 + *(_BYTE *)(a1 + 4))) + 1846) >> 1); /*0xffc18585*/
*(_DWORD *)(a1 + 68) = 1; /*0xffc1858f*/
*(_DWORD *)(a1 + 64) = 1; /*0xffc18592*/
*(_DWORD *)(a1 + 60) = 1; /*0xffc18595*/
*(_DWORD *)(a1 + 56) = 1; /*0xffc18598*/
*(_DWORD *)(a1 + 52) = 0; /*0xffc1859b*/
*(_DWORD *)(a1 + 80) = 0; /*0xffc1859f*/
}
n0x14_2 = *(_DWORD *)(a1 + 88); /*0xffc185a3*/
if ( !n0x14_2 ) /*0xffc185a8*/
{
if ( n0x14 >= 0x14 && !v28 ) /*0xffc185b3*/
{
v15 = a3; /*0xffc185b5*/
v16 = &a3[n0x14 - 20]; /*0xffc185bc*/
LABEL_25:
*(_DWORD *)(a1 + 24) = v15; /*0xffc185eb*/
if ( DxeIplLzmaDecodeMatch(v16) ) /*0xffc185f5*/
return 1; /*0xffc185fc*/
v10 = *(unsigned __int8 **)(a1 + 24); /*0xffc18605*/
v18 = (_BYTE *)(v10 - v15); /*0xffc18608*/
v6 = a4; /*0xffc1860a*/
a3 = v10; /*0xffc1860e*/
*a4 += (unsigned int)v18; /*0xffc18612*/
n0x14 -= (unsigned int)v18; /*0xffc18614*/
goto LABEL_40; /*0xffc18616*/
}
v15 = a3; /*0xffc185c0*/
n2 = DxeIplLzmaDecodeBitTree((_DWORD *)a1, a3, n0x14); /*0xffc185c9*/
if ( n2 ) /*0xffc185d1*/
{
if ( v28 && n2 != 2 ) /*0xffc185e3*/
break; /*0xffc185e3*/
v16 = a3; /*0xffc185e9*/
goto LABEL_25; /*0xffc185e9*/
}
DxeIplFvFreePages(n0x14); /*0xffc186ed*/
*(_DWORD *)(a1 + 88) = n0x14; /*0xffc186f7*/
*a4 += n0x14; /*0xffc186fa*/
LABEL_42:
*a6 = 3; /*0xffc186c0*/
return 0; /*0xffc186c9*/
}
n0x14_1 = 0; /*0xffc1861b*/
n0x14_3 = 0; /*0xffc1861d*/
if ( n0x14_2 < 0x14 ) /*0xffc18624*/
{
do /*0xffc18636*/
{
if ( n0x14_1 >= n0x14 ) /*0xffc18628*/
break; /*0xffc18628*/
*(_BYTE *)(n0x14_2 + a1 + 92) = v10[n0x14_1]; /*0xffc1862d*/
++n0x14_2; /*0xffc18631*/
++n0x14_1; /*0xffc18632*/
}
while ( n0x14_2 < 0x14 ); /*0xffc18636*/
n0x14_3 = n0x14_1; /*0xffc18638*/
}
*(_DWORD *)(a1 + 88) = n0x14_2; /*0xffc1863c*/
if ( n0x14_2 < 0x14 || v28 ) /*0xffc18649*/
{
n2_1 = DxeIplLzmaDecodeBitTree((_DWORD *)a1, (unsigned __int8 *)(a1 + 92), n0x14_2); /*0xffc18651*/
if ( !n2_1 ) /*0xffc18659*/
{
*a4 += n0x14_3; /*0xffc1870b*/
goto LABEL_42; /*0xffc1870d*/
}
if ( v28 && n2_1 != 2 ) /*0xffc1866b*/
break; /*0xffc1866b*/
}
*(_DWORD *)(a1 + 24) = a1 + 92; /*0xffc18677*/
if ( DxeIplLzmaDecodeMatch(a1 + 92) ) /*0xffc1867a*/
return 1; /*0xffc18681*/
n0x14_4 = *(_DWORD *)(a1 + 24) - a1 - 92; /*0xffc18688*/
if ( n0x14_2 < n0x14_4 ) /*0xffc1868d*/
return 11; /*0xffc1868d*/
n0x14_5 = n0x14_2 - n0x14_4; /*0xffc1868f*/
if ( n0x14_3 < n0x14_5 ) /*0xffc18697*/
return 11; /*0xffc18701*/
v23 = n0x14_3 - n0x14_5; /*0xffc18699*/
v6 = a4; /*0xffc1869b*/
a3 += v23; /*0xffc1869f*/
n0x14 -= v23; /*0xffc186a3*/
v10 = a3; /*0xffc186a5*/
*a4 += v23; /*0xffc186a9*/
*(_DWORD *)(a1 + 88) = 0; /*0xffc186ab*/
LABEL_40:
if ( *(_DWORD *)(a1 + 72) == 274 ) /*0xffc186b6*/
goto LABEL_52; /*0xffc186b6*/
}
*a6 = 2; /*0xffc186df*/
return 1; /*0xffc18724*/
}