//
// sub_6FB078 from 0x6fb078 to 0x6fb9c0 (2376 bytes)
//
// 3 xrefs:
// > sub_6FBFE4 @ 0x6fc0a4
// > sub_6FBFE4 @ 0x6fc162
// > sub_6FBFE4 @ 0x6fc2fa
//
// 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_6FB078(unsigned int *a1, int a2, int a3, int a4, int a5, int a6)
{
unsigned int v6; // lr
int v7; // r10
unsigned __int8 *v8; // r5
int v10; // r3
int v11; // r9
unsigned int v12; // r4
unsigned int v13; // r6
unsigned int v14; // r1
unsigned int v15; // r0
unsigned int v16; // r2
int v17; // r4
unsigned int v18; // r9
int i; // r6
unsigned int v20; // r0
unsigned int v21; // r7
unsigned int v22; // r1
unsigned int v23; // r4
int v24; // r0
unsigned __int8 *v25; // t1
int v26; // r7
unsigned int *v27; // r1
unsigned int v28; // t1
unsigned int v29; // r2
int v30; // r9
int v31; // r6
unsigned int v32; // r4
unsigned int v33; // r6
unsigned int v34; // r0
unsigned int v35; // r2
int v36; // r1
unsigned int v37; // r4
int v38; // r6
unsigned int v39; // r7
unsigned int v40; // r0
bool v41; // cc
unsigned int v42; // r1
int v43; // r2
unsigned int v44; // r1
int v45; // r2
int v47; // r7
unsigned int v48; // r2
unsigned int v49; // r4
unsigned int v50; // r0
unsigned int v51; // r1
int v52; // r1
int v53; // r6
unsigned int v54; // r2
unsigned int v55; // r6
unsigned int v56; // r0
unsigned int v57; // r1
int v58; // r1
int v59; // r4
unsigned int v60; // r2
unsigned int v61; // r5
unsigned int v62; // r4
unsigned int v63; // r1
int v64; // r1
unsigned int v65; // r2
unsigned int v66; // r6
unsigned int v67; // r0
unsigned int v68; // r1
int v69; // r1
__int16 v70; // r4
unsigned int v71; // r2
unsigned int v72; // r1
unsigned int v73; // r0
unsigned int v74; // r5
int v75; // r2
unsigned int *v76; // r1
unsigned int v77; // t1
unsigned int v78; // r2
int v79; // r6
unsigned int v80; // r1
unsigned int v81; // r6
unsigned int v82; // r0
unsigned int v83; // r2
int v84; // r1
unsigned int *v85; // r1
unsigned int v86; // t1
unsigned int v87; // r2
unsigned int *v88; // r2
unsigned int v89; // t1
unsigned int v90; // r4
int v91; // r7
unsigned int v92; // r2
unsigned int v93; // r7
unsigned int v94; // r12
unsigned int v95; // r1
int v96; // r1
int v97; // r4
unsigned int v98; // r2
unsigned int v99; // r4
unsigned int v100; // r1
int v101; // r1
_BYTE *v102; // r2
int v103; // r5
int v104; // r7
int v105; // r10
unsigned int v106; // r6
unsigned int v107; // r2
unsigned int v108; // r12
unsigned int v109; // r0
int v110; // r4
int v111; // r0
int v112; // t1
unsigned int *v113; // r0
unsigned int v114; // t1
unsigned int v115; // r1
unsigned int v116; // r2
unsigned int v117; // r6
unsigned int v118; // r1
int v119; // r1
unsigned int *v120; // r0
unsigned int v121; // t1
unsigned int v122; // r4
int v123; // r4
unsigned int v124; // r2
unsigned int v125; // r1
unsigned int v126; // r0
int v127; // r2
unsigned int *v128; // r0
unsigned int v129; // t1
unsigned int v130; // r2
unsigned int *v131; // r0
unsigned int v132; // t1
unsigned int v133; // r2
unsigned int *v134; // r1
unsigned int v135; // t1
unsigned int v136; // r5
unsigned int *v137; // r0
unsigned int v138; // t1
unsigned int v139; // r2
unsigned int *v140; // r1
unsigned int v141; // r2
char *v142; // r0
unsigned int v143; // r1
unsigned int *v144; // r1
unsigned int v145; // t1
unsigned int v146; // r5
unsigned int *v147; // r6
unsigned int v148; // t1
unsigned int v149; // r2
unsigned int *v150; // r6
unsigned int v151; // t1
unsigned int v152; // r2
unsigned int *v153; // r1
unsigned int v154; // t1
unsigned int v155; // r2
int v158; // [sp+Ch] [bp-10h]
char v159; // [sp+14h] [bp-8h]
unsigned int v160; // [sp+14h] [bp-8h]
int v161; // [sp+40h] [bp+24h]
v7 = a5;
v8 = (unsigned __int8 *)(*(_DWORD *)(a2 + 4 * a5) + 11 * a3);
if ( a5 > 15 )
return 16;
while ( 1 )
{
v10 = a1[2];
v11 = *v8;
v12 = a1[1];
if ( v10 >= 0 )
goto LABEL_3;
v76 = (unsigned int *)a1[3];
if ( (unsigned int)v76 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_3:
v13 = *a1;
goto LABEL_4;
}
v77 = *v76;
v10 += 24;
v78 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v76 + 3;
v13 = (v78 << 24) | (bswap32(v77) >> 8);
*a1 = v13;
LABEL_4:
v14 = (v12 * v11) >> 8;
v15 = (v14 - (v13 >> v10)) >> 31;
if ( v14 < v13 >> v10 )
{
v16 = v14 + 1;
v14 = v12 - v14 - 1;
*a1 = v13 - (v16 << v10);
}
if ( v14 <= 0x7E )
{
v17 = byte_A06768[v14];
v14 = byte_A067E8[v14];
v10 -= v17;
a1[2] = v10;
}
a1[1] = v14;
if ( !v15 )
return v7;
v18 = v14;
for ( i = a2 + 4 * v7; ; i += 4 )
{
v26 = v8[1];
if ( v10 >= 0 )
goto LABEL_10;
v27 = (unsigned int *)a1[3];
if ( (unsigned int)v27 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_10:
v20 = *a1;
goto LABEL_11;
}
v28 = *v27;
v10 += 24;
v29 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v27 + 3;
v20 = (v29 << 24) | (bswap32(v28) >> 8);
*a1 = v20;
LABEL_11:
v21 = (v18 * v26) >> 8;
v22 = (v21 - (v20 >> v10)) >> 31;
if ( v21 < v20 >> v10 )
{
v23 = v21 + 1;
v21 = v18 - v21 - 1;
*a1 = v20 - (v23 << v10);
}
if ( v21 <= 0x7E )
{
v24 = byte_A06768[v21];
v21 = byte_A067E8[v21];
v10 -= v24;
a1[2] = v10;
}
a1[1] = v21;
if ( v22 )
break;
++v7;
v18 = v21;
v25 = *(unsigned __int8 **)(i + 4);
v8 = v25;
if ( v7 == 16 )
return 16;
}
v30 = v7 + 1;
v31 = v8[2];
v158 = *(_DWORD *)(a2 + 4 * (v7 + 1));
if ( v10 >= 0 )
goto LABEL_22;
v88 = (unsigned int *)a1[3];
if ( (unsigned int)v88 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_22:
v32 = *a1;
}
else
{
v89 = *v88;
v10 += 24;
v90 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v88 + 3;
v32 = (v90 << 24) | (bswap32(v89) >> 8);
*a1 = v32;
}
v33 = (v21 * v31) >> 8;
v34 = (v33 - (v32 >> v10)) >> 31;
if ( v33 < v32 >> v10 )
{
v35 = v33 + 1;
v33 = v21 - v33 - 1;
*a1 = v32 - (v35 << v10);
}
if ( v33 <= 0x7E )
{
v36 = byte_A06768[v33];
v33 = byte_A067E8[v33];
v10 -= v36;
a1[2] = v10;
}
a1[1] = v33;
if ( v34 )
{
v47 = v8[3];
if ( v10 >= 0 )
goto LABEL_37;
v120 = (unsigned int *)a1[3];
if ( (unsigned int)v120 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_37:
v48 = *a1;
}
else
{
v121 = *v120;
v10 += 24;
v122 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v120 + 3;
v48 = (v122 << 24) | (bswap32(v121) >> 8);
*a1 = v48;
}
v49 = (v47 * v33) >> 8;
v50 = (v49 - (v48 >> v10)) >> 31;
if ( v49 < v48 >> v10 )
{
v51 = v49 + 1;
v49 = v33 - v49 - 1;
*a1 = v48 - (v51 << v10);
}
if ( v49 <= 0x7E )
{
v52 = byte_A06768[v49];
v49 = byte_A067E8[v49];
v10 -= v52;
a1[2] = v10;
}
a1[1] = v49;
if ( v50 )
{
v53 = v8[6];
if ( v10 >= 0 )
goto LABEL_44;
v128 = (unsigned int *)a1[3];
if ( (unsigned int)v128 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_44:
v54 = *a1;
}
else
{
v129 = *v128;
v10 += 24;
v130 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v128 + 3;
v54 = (v130 << 24) | (bswap32(v129) >> 8);
*a1 = v54;
}
v55 = (v53 * v49) >> 8;
v56 = (v55 - (v54 >> v10)) >> 31;
if ( v55 < v54 >> v10 )
{
v57 = v55 + 1;
v55 = v49 - v55 - 1;
*a1 = v54 - (v57 << v10);
}
if ( v55 <= 0x7E )
{
v58 = byte_A06768[v55];
v55 = byte_A067E8[v55];
v10 -= v58;
a1[2] = v10;
}
a1[1] = v55;
if ( !v56 )
{
v59 = v8[7];
if ( v10 >= 0 )
goto LABEL_51;
v134 = (unsigned int *)a1[3];
if ( (unsigned int)v134 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_51:
v60 = *a1;
}
else
{
v135 = *v134;
v10 += 24;
v136 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v134 + 3;
v60 = (v136 << 24) | (bswap32(v135) >> 8);
*a1 = v60;
}
v61 = (v59 * v55) >> 8;
v62 = (v61 - (v60 >> v10)) >> 31;
if ( v61 < v60 >> v10 )
{
v63 = v61 + 1;
v61 = v55 - v61 - 1;
*a1 = v60 - (v63 << v10);
}
if ( v61 <= 0x7E )
{
v64 = byte_A06768[v61];
v61 = byte_A067E8[v61];
v10 -= v64;
a1[2] = v10;
}
a1[1] = v61;
if ( v62 )
{
if ( v10 >= 0 )
goto LABEL_58;
v147 = (unsigned int *)a1[3];
if ( (unsigned int)v147 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_58:
v65 = *a1;
}
else
{
v148 = *v147;
v10 += 24;
v149 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v147 + 3;
v65 = (v149 << 24) | (bswap32(v148) >> 8);
*a1 = v65;
}
v66 = (165 * v61) >> 8;
v67 = (v66 - (v65 >> v10)) >> 31;
if ( v66 < v65 >> v10 )
{
v68 = v66 + 1;
v66 = v61 - v66 - 1;
*a1 = v65 - (v68 << v10);
}
if ( v66 <= 0x7E )
{
v69 = byte_A06768[v66];
v66 = byte_A067E8[v66];
v10 -= v69;
a1[2] = v10;
}
a1[1] = v66;
v70 = 2 * v67 + 7;
if ( v10 < 0 )
{
v144 = (unsigned int *)a1[3];
if ( (unsigned int)v144 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
goto LABEL_64;
}
v145 = *v144;
v10 += 24;
v146 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v144 + 3;
v71 = (v146 << 24) | (bswap32(v145) >> 8);
*a1 = v71;
}
else
{
LABEL_64:
v71 = *a1;
}
v72 = (145 * v66) >> 8;
v73 = (v72 - (v71 >> v10)) >> 31;
if ( v72 < v71 >> v10 )
{
v74 = v72 + 1;
v72 = v66 - v72 - 1;
*a1 = v71 - (v74 << v10);
}
if ( v72 <= 0x7E )
{
v75 = byte_A06768[v72];
v72 = byte_A067E8[v72];
v10 -= v75;
a1[2] = v10;
}
a1[1] = v72;
LOWORD(v37) = v70 + v73;
LABEL_79:
v38 = byte_A00B70[v7];
v8 = (unsigned __int8 *)(v158 + 22);
if ( v10 < 0 )
goto LABEL_80;
goto LABEL_29;
}
if ( v10 < 0 )
{
v150 = (unsigned int *)a1[3];
if ( (unsigned int)v150 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
goto LABEL_113;
}
v151 = *v150;
v10 += 24;
v152 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v150 + 3;
v116 = (v152 << 24) | (bswap32(v151) >> 8);
*a1 = v116;
}
else
{
LABEL_113:
v116 = *a1;
}
v117 = (159 * v61) >> 8;
v37 = (v117 - (v116 >> v10)) >> 31;
if ( v117 < v116 >> v10 )
{
v118 = v117 + 1;
v117 = v61 - v117 - 1;
*a1 = v116 - (v118 << v10);
}
if ( v117 <= 0x7E )
{
v119 = byte_A06768[v117];
v117 = byte_A067E8[v117];
v10 -= v119;
a1[2] = v10;
}
a1[1] = v117;
LOWORD(v37) = v37 + 5;
goto LABEL_79;
}
v91 = v8[8];
if ( v10 < 0 )
{
v140 = (unsigned int *)a1[3];
if ( (unsigned int)v140 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
goto LABEL_87;
}
v141 = *a1;
v142 = (char *)v140 + 3;
v143 = *v140;
v10 += 24;
a1[2] = v10;
a1[3] = (unsigned int)v142;
v92 = (v141 << 24) | (bswap32(v143) >> 8);
*a1 = v92;
}
else
{
LABEL_87:
v92 = *a1;
}
v93 = (v91 * v55) >> 8;
v94 = (v93 - (v92 >> v10)) >> 31;
if ( v93 < v92 >> v10 )
{
v95 = v93 + 1;
v93 = v55 - v93 - 1;
*a1 = v92 - (v95 << v10);
}
if ( v93 <= 0x7E )
{
v96 = byte_A06768[v93];
v93 = byte_A067E8[v93];
v10 -= v96;
a1[2] = v10;
}
a1[1] = v93;
v97 = v8[v94 + 9];
if ( v10 < 0 )
{
v137 = (unsigned int *)a1[3];
if ( (unsigned int)v137 >= a1[5] )
{
v160 = v94;
sub_733378(a1);
v10 = a1[2];
v98 = *a1;
v94 = v160;
}
else
{
v138 = *v137;
v10 += 24;
v139 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v137 + 3;
v98 = (v139 << 24) | (bswap32(v138) >> 8);
*a1 = v98;
}
}
else
{
v98 = *a1;
}
v99 = (v97 * v93) >> 8;
v6 = (v99 - (v98 >> v10)) >> 31;
if ( v99 < v98 >> v10 )
{
v100 = v99 + 1;
v99 = v93 - v99 - 1;
*a1 = v98 - (v100 << v10);
}
if ( v99 <= 0x7E )
{
v101 = byte_A06768[v99];
v99 = byte_A067E8[v99];
v10 -= v101;
a1[2] = v10;
}
v159 = v6 + 2 * v94;
a1[1] = v99;
v102 = *(&off_A2DB88 + 2 * v94 + v6);
v103 = (unsigned __int8)*v102;
if ( !*v102 )
{
v104 = (unsigned __int8)*v102;
LABEL_110:
v37 = (8 << v159) + 3 + v104;
goto LABEL_79;
}
v161 = v7;
v104 = 0;
v105 = (int)*(&off_A2DB88 + 2 * v94 + v6);
while ( 2 )
{
if ( v10 < 0 )
{
v10 += 24;
v113 = (unsigned int *)a1[3];
if ( (unsigned int)v113 < a1[5] )
{
v114 = *v113;
v115 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v113 + 3;
v106 = (v115 << 24) | (bswap32(v114) >> 8);
*a1 = v106;
LABEL_101:
v6 = -2220;
v107 = (v103 * v99) >> 8;
v108 = v99 - v107;
v109 = v107 - (v106 >> v10);
v110 = (v107 + 1) << v10;
if ( v107 < v106 >> v10 )
{
v107 = v108 - 1;
*a1 = v106 - v110;
}
v104 = (v109 >> 31) + 2 * v104;
if ( v107 <= 0x7E )
{
v111 = byte_A06768[v107];
v107 = byte_A067E8[v107];
v10 -= v111;
a1[2] = v10;
}
a1[1] = v107;
v99 = v107;
v112 = *(unsigned __int8 *)++v105;
v103 = v112;
if ( !v112 )
{
v7 = v161;
goto LABEL_110;
}
continue;
}
sub_733378(a1);
v10 = a1[2];
}
break;
}
v106 = *a1;
goto LABEL_101;
}
v79 = v8[4];
if ( v10 < 0 )
{
v131 = (unsigned int *)a1[3];
if ( (unsigned int)v131 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
goto LABEL_73;
}
v132 = *v131;
v10 += 24;
v133 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v131 + 3;
v80 = (v133 << 24) | (bswap32(v132) >> 8);
*a1 = v80;
}
else
{
LABEL_73:
v80 = *a1;
}
v81 = (v79 * v49) >> 8;
v82 = (v81 - (v80 >> v10)) >> 31;
if ( v81 < v80 >> v10 )
{
v83 = v81 + 1;
v81 = v49 - v81 - 1;
*a1 = v80 - (v83 << v10);
}
if ( v81 <= 0x7E )
{
v84 = byte_A06768[v81];
v81 = byte_A067E8[v81];
v10 -= v84;
a1[2] = v10;
}
a1[1] = v81;
LOWORD(v37) = 2;
if ( !v82 )
goto LABEL_79;
v123 = v8[5];
if ( v10 < 0 )
{
v153 = (unsigned int *)a1[3];
if ( (unsigned int)v153 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
goto LABEL_124;
}
v154 = *v153;
v10 += 24;
v155 = *a1;
a1[2] = v10;
a1[3] = (unsigned int)v153 + 3;
v124 = (v155 << 24) | (bswap32(v154) >> 8);
*a1 = v124;
}
else
{
LABEL_124:
v124 = *a1;
}
v125 = (v123 * v81) >> 8;
v37 = (v125 - (v124 >> v10)) >> 31;
if ( v125 < v124 >> v10 )
{
v126 = v125 + 1;
v125 = v81 - v125 - 1;
*a1 = v124 - (v126 << v10);
}
if ( v125 <= 0x7E )
{
v127 = byte_A06768[v125];
v125 = byte_A067E8[v125];
v10 -= v127;
a1[2] = v10;
}
a1[1] = v125;
LOWORD(v37) = v37 + 3;
goto LABEL_79;
}
LOWORD(v37) = 1;
v8 = (unsigned __int8 *)(v158 + 11);
v38 = byte_A00B70[v7];
if ( v10 >= 0 )
goto LABEL_29;
LABEL_80:
v85 = (unsigned int *)a1[3];
if ( (unsigned int)v85 >= a1[5] )
{
sub_733378(a1);
v10 = a1[2];
LABEL_29:
v39 = *a1;
goto LABEL_30;
}
v86 = *v85;
v10 += 24;
v87 = *a1;
a1[3] = (unsigned int)v85 + 3;
v39 = (v87 << 24) | (bswap32(v86) >> 8);
LABEL_30:
v40 = a1[1];
v41 = v7 <= 0;
v7 = v30;
v42 = v40 >> 1;
if ( !v41 )
v6 = 4;
v43 = v42 - (v39 >> v10);
v44 = v42 + 1;
if ( v41 )
v6 = 0;
v45 = v43 >> 31;
a1[2] = v10 - 1;
a1[1] = (v40 + v45) | 1;
*a1 = v39 - ((v44 & v45) << v10);
*(_WORD *)(a6 + 2 * v38) = *(_DWORD *)(a4 + v6) * ((v37 ^ v45) - v45);
if ( v30 == 16 )
return 16;
}
}