//
// sub_704228 from 0x704228 to 0x7044f4 (716 bytes)
//
// 0 xrefs:
//
// 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
//
int __fastcall sub_704228(int a1, int a2, int a3, int a4, int a5, int a6)
{
unsigned __int8 *v6; // r0
int v7; // r10
unsigned __int8 *v8; // r3
_BYTE *v9; // r11
int v10; // r5
int v11; // r2
int v12; // r4
int v13; // r12
int v14; // lr
int v15; // r9
int v16; // r1
int v17; // r6
char v18; // r1
int v19; // r12
int v20; // r6
int v21; // r1
int v22; // r10
unsigned __int8 *v23; // r1
_BYTE *v24; // r11
int v25; // r5
int v26; // r2
int v27; // r4
int v28; // r12
int result; // r0
int v30; // lr
int v31; // r9
int v32; // r6
char v33; // r0
int v34; // r12
int v35; // r6
int v36; // r12
int v37; // r4
int v38; // r12
int v39; // r4
int v40; // [sp+0h] [bp-2Ch]
int v42; // [sp+8h] [bp-24h]
int v43; // [sp+8h] [bp-24h]
_BYTE *v44; // [sp+10h] [bp-1Ch]
_BYTE *v45; // [sp+10h] [bp-1Ch]
char *v46; // [sp+14h] [bp-18h]
char *v47; // [sp+14h] [bp-18h]
v40 = 2 * a4 + 1;
v6 = (unsigned __int8 *)(a1 - 4);
v44 = off_A2DBA4;
v7 = 8;
v8 = (unsigned __int8 *)off_A2DB98;
v9 = off_A2DB9C;
v46 = (char *)off_A2DBA0;
do
{
while ( 1 )
{
v10 = v6[2];
v11 = v6[3];
v12 = v6[4];
v13 = v10 - v6[5];
v42 = v6[5];
v14 = v6[1];
v15 = v6[6];
if ( v40 < 4 * v8[v11 - v12] + v8[v13] )
goto LABEL_12;
if ( a5 < v8[*v6 - v14] )
goto LABEL_12;
if ( a5 < v8[v14 - v10] )
goto LABEL_12;
v16 = v8[v10 - v11];
if ( a5 < v16 )
goto LABEL_12;
if ( a5 < v8[v6[7] - v15] )
goto LABEL_12;
if ( a5 < v8[v15 - v42] )
goto LABEL_12;
v17 = v8[v42 - v12];
if ( a5 < v17 )
goto LABEL_12;
if ( a6 < v16 || a6 < v17 )
break;
v18 = v44[3 * (v12 - v11) + (char)v44[v13]];
v19 = (9 * v18 + 63) >> 7;
v20 = (18 * v18 + 63) >> 7;
v21 = (27 * v18 + 63) >> 7;
v6[1] = v9[v14 + v19];
v6[2] = v9[v10 + v20];
v6[3] = v9[v11 + v21];
v6[4] = v9[v12 - v21];
v6[5] = v9[v42 - v20];
v6[6] = v9[v15 - v19];
LABEL_12:
--v7;
v6 += a3;
if ( !v7 )
goto LABEL_13;
}
--v7;
v36 = (char)v44[v13] + 3 * (v12 - v11);
v37 = v12 - v46[(v36 + 4) >> 3];
v6[3] = v9[v11 + v46[(v36 + 3) >> 3]];
v6[4] = v9[v37];
v6 += a3;
}
while ( v7 );
LABEL_13:
v22 = 8;
v45 = off_A2DBA4;
v23 = (unsigned __int8 *)(a2 - 4);
v24 = off_A2DB9C;
v47 = (char *)off_A2DBA0;
while ( 1 )
{
LABEL_14:
v25 = v23[2];
v26 = v23[3];
v27 = v23[4];
v28 = v25 - v23[5];
v43 = v23[5];
result = 4 * v8[v26 - v27] + v8[v28];
v30 = v23[1];
v31 = v23[6];
if ( v40 < result )
goto LABEL_24;
result = v8[*v23 - v30];
if ( a5 < result )
goto LABEL_24;
result = v8[v30 - v25];
if ( a5 < result )
goto LABEL_24;
result = v8[v25 - v26];
if ( a5 < result )
goto LABEL_24;
if ( a5 < v8[v23[7] - v31] )
goto LABEL_24;
if ( a5 < v8[v31 - v43] )
goto LABEL_24;
v32 = v8[v43 - v27];
if ( a5 < v32 )
goto LABEL_24;
if ( a6 < result || a6 < v32 )
break;
v33 = v45[3 * (v27 - v26) + (char)v45[v28]];
v34 = (9 * v33 + 63) >> 7;
v35 = (18 * v33 + 63) >> 7;
result = (27 * v33 + 63) >> 7;
v23[1] = v24[v30 + v34];
v23[2] = v24[v25 + v35];
v23[3] = v24[v26 + result];
v23[4] = v24[v27 - result];
v23[5] = v24[v43 - v35];
v23[6] = v24[v31 - v34];
LABEL_24:
--v22;
v23 += a3;
if ( !v22 )
return result;
}
--v22;
v38 = (char)v45[v28] + 3 * (v27 - v26);
result = v47[(v38 + 3) >> 3];
v39 = v27 - v47[(v38 + 4) >> 3];
v23[3] = v24[v26 + result];
v23[4] = v24[v39];
v23 += a3;
if ( v22 )
goto LABEL_14;
return result;
}