//
// sub_C02D34 from 0xc02d34 to 0xc02e34 (256 bytes)
//
// 2 xrefs:
// > jinit_downsampler @ 0xc03704
// > jinit_downsampler @ 0xc0370c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
unsigned __int64 __fastcall sub_C02D34(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
unsigned int v7; // w2
unsigned int v8; // w21
int v9; // w23
unsigned __int64 result; // x0
__int64 v11; // x26
__int64 v12; // x22
size_t v13; // x25
__int64 v14; // x0
__int64 i; // x6
__int64 v16; // x5
unsigned __int8 *v17; // x1
__int64 v18; // x2
int v19; // w3
int v20; // w4
int v21; // w0
v7 = *(_DWORD *)(a1 + 48);
v8 = *(_DWORD *)(a2 + 36) * *(_DWORD *)(a2 + 28);
v9 = *(_DWORD *)(a1 + 356);
result = 2 * v8 - v7;
if ( (int)(2 * v8 - v7) > 0 )
{
if ( v9 <= 0 )
return result;
v11 = v7;
v12 = 0;
v13 = (int)result - 1 + 1LL;
do
{
v14 = *(_QWORD *)(a3 + 8 * v12++);
result = (unsigned __int64)memset((void *)(v14 + v11), *(unsigned __int8 *)(v14 + v11 - 1), v13);
}
while ( v9 > (int)v12 );
v9 = *(_DWORD *)(a1 + 356);
}
for ( i = 0; (int)i < v9; result = (unsigned int)i )
{
v16 = *(_QWORD *)(a4 + 8 * i);
v17 = *(unsigned __int8 **)(a3 + 8 * i);
if ( v8 )
{
v18 = 0;
v19 = 0;
do
{
v20 = *v17;
v17 += 2;
v21 = v20 + *(v17 - 1) + v19;
v19 ^= 1u;
*(_BYTE *)(v16 + v18++) = v21 >> 1;
}
while ( v8 > (unsigned int)v18 );
v9 = *(_DWORD *)(a1 + 356);
}
++i;
}
return result;
}