//
// sub_1005A2768 from 0x1005a2768 to 0x1005a30e4 (2428 bytes)
//
// 1 xrefs:
// > sub_1005E80E0 @ 0x1005e80f4
//
// 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
//
__int64 __fastcall sub_1005A2768(unsigned __int8 *a1, int *a2)
{
int v2; // w16
int v3; // w17
unsigned __int8 v4; // w13
unsigned __int8 v5; // w15
unsigned int v6; // w5
int v7; // w14
unsigned int v8; // w22
int v9; // w3
unsigned __int8 v10; // w12
unsigned __int8 v11; // w11
unsigned int v12; // w23
unsigned int v13; // w24
unsigned int v14; // w25
unsigned __int64 v15; // t2
int v16; // w2
int v17; // w0
int v18; // w24
int v19; // w4
unsigned int v20; // w3
int v21; // w7
unsigned int v22; // w14
unsigned int v23; // w20
unsigned int v24; // w21
int v25; // w6
int v26; // w24
int v27; // w19
int v28; // w20
int v29; // w6
int v30; // w20
int v31; // w21
int v32; // w20
int v33; // w6
unsigned int v34; // w19
unsigned int v35; // w7
int v36; // w3
int v37; // w5
unsigned int v38; // w19
unsigned int v39; // w21
unsigned int v40; // w20
int v41; // w6
int v42; // w7
unsigned int v43; // w3
unsigned int v44; // w5
unsigned int v45; // w19
int v46; // w22
int v47; // w0
int v48; // w2
unsigned int v49; // w4
unsigned int v50; // w5
unsigned int v51; // w3
int v52; // w20
int v53; // w16
int v54; // w17
unsigned int v55; // w3
int v56; // w7
int v57; // w13
int v58; // w15
__int64 result; // x0
int v60; // w5
int v61; // w12
int v62; // w11
unsigned int v63; // w12
unsigned int v64; // w11
v2 = a1[8];
v3 = a1[12];
v4 = a1[9];
v5 = a1[13];
v6 = a1[2];
v7 = (*a1 << 24) | (a1[1] << 16) | (v6 << 8);
v8 = a1[6];
v9 = (a1[4] << 24) | (a1[5] << 16) | (v8 << 8);
v10 = a1[10];
v11 = a1[14];
v12 = a1[3];
v13 = a1[7];
v15 = __PAIR64__(v13, v7);
v14 = __PAIR64__(v13, v7) >> 8;
v16 = a1[11];
v17 = a1[15];
v18 = v9 | v13;
v19 = (v2 << 24) | (v4 << 16) | (v10 << 8) | v16;
v20 = __PAIR64__(v12, v9) >> 8;
v21 = (v3 << 24) | (v5 << 16) | (v11 << 8) | v17;
v22 = (v7 | v12) + v19 + 1640531527;
v23 = v14 + v19 - 1013904243;
v24 = v20 + 1013904243 - v21;
v25 = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v18 - v21 + 31161) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v18 - v21 - 71)]
^ dword_10067A3B8[(unsigned __int8)((unsigned int)(v18 - v21 - 1640531527) >> 16)]
^ dword_10067A7B8[(unsigned int)(v18 - v21 - 1640531527) >> 24];
v26 = dword_100679FB8[BYTE1(v23)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v15) + v16 - 115)]
^ dword_10067A3B8[BYTE2(v23)];
v27 = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v20 - 3213 - v21) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v20 + 115 - v21)]
^ dword_10067A3B8[BYTE2(v24)];
*a2 = dword_100679FB8[BYTE1(v22)]
^ dword_100679BB8[(unsigned __int8)v22]
^ dword_10067A3B8[BYTE2(v22)]
^ dword_10067A7B8[HIBYTE(v22)];
v28 = dword_10067A7B8[HIBYTE(v23)];
a2[1] = v25;
v29 = v26 ^ v28;
v30 = dword_10067A7B8[HIBYTE(v24)];
a2[2] = v29;
a2[3] = v27 ^ v30;
v31 = (unsigned __int8)v3 | (v19 << 8);
v32 = (unsigned __int8)v2 | (v21 << 8);
v33 = dword_100679BB8[(unsigned __int8)(v20 - 26 - v2)];
a2[4] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(((unsigned int)v15 >> 8) + v31 + 6426) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v15) + v31 + 26)]
^ dword_10067A3B8[(unsigned __int8)((v14 + v31 - 2027808486) >> 16)]
^ dword_10067A7B8[(v14 + v31 - 2027808486) >> 24];
a2[5] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v20 - 6426 - v32) >> 8)]
^ v33
^ dword_10067A3B8[(unsigned __int8)((v20 + 2027808486 - v32) >> 16)]
^ dword_10067A7B8[(v20 + 2027808486 - v32) >> 24];
v34 = v20 >> 8;
v35 = __PAIR64__(v6, v20) >> 8;
a2[6] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v14 >> 8) + v31 + 12852) >> 8)]
^ dword_100679BB8[(unsigned __int8)(((unsigned __int16)((unsigned int)v15 >> 8) >> 8) + v31 + 52)]
^ dword_10067A3B8[(unsigned __int8)(((unsigned int)(__PAIR64__(v8, v14) >> 8) + v31 + 239350324) >> 16)]
^ dword_10067A7B8[((unsigned int)(__PAIR64__(v8, v14) >> 8) + v31 + 239350324) >> 24];
a2[7] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v35 - 12852 - v32) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v35 - 52 - v32)]
^ dword_10067A3B8[(unsigned __int8)((v35 - 239350324 - v32) >> 16)]
^ dword_10067A7B8[(v35 - 239350324 - v32) >> 24];
v36 = v5 | (v31 << 8);
v37 = v4 | (v32 << 8);
a2[8] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v14 >> 8) + v36 + 25703) >> 8)]
^ dword_100679BB8[(unsigned __int8)(((unsigned __int16)((unsigned int)v15 >> 8) >> 8) + v36 + 103)]
^ dword_10067A3B8[(unsigned __int8)(((unsigned int)(__PAIR64__(v8, v14) >> 8) + v36 + 478700647) >> 16)]
^ dword_10067A7B8[((unsigned int)(__PAIR64__(v8, v14) >> 8) + v36 + 478700647) >> 24];
a2[9] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v35 - 25703 - v37) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v35 - 103 - v4)]
^ dword_10067A3B8[(unsigned __int8)((v35 - 478700647 - v37) >> 16)]
^ dword_10067A7B8[(v35 - 478700647 - v37) >> 24];
HIDWORD(v15) = v34;
LODWORD(v15) = __PAIR64__(v8, v14) >> 8;
v38 = v15 >> 8;
v39 = v35 >> 8;
HIDWORD(v15) = v14 >> 8;
LODWORD(v15) = v35;
v40 = v15 >> 8;
a2[10] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v38 + v36 - 14131) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v38 + v36 - 51)]
^ dword_10067A3B8[(unsigned __int8)((v38 + v36 + 957401293) >> 16)]
^ dword_10067A7B8[(v38 + v36 + 957401293) >> 24];
a2[11] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v35 >> 8) + 14131 - v37) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v35) + 51 - v37)]
^ dword_10067A3B8[(unsigned __int8)((v40 - 957401293 - v37) >> 16)]
^ dword_10067A7B8[(v40 - 957401293 - v37) >> 24];
v41 = v11 | (v36 << 8);
v42 = v10 | (v37 << 8);
a2[12] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v38 + v41 - 28263) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v38 + v41 - 103)]
^ dword_10067A3B8[(unsigned __int8)((v38 + v41 + 1914802585) >> 16)]
^ dword_10067A7B8[(v38 + v41 + 1914802585) >> 24];
a2[13] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(((unsigned int)v15 >> 8) + 28263 - v42) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v15) + 103 - v42)]
^ dword_10067A3B8[(unsigned __int8)((v40 - 1914802585 - v42) >> 16)]
^ dword_10067A7B8[(v40 - 1914802585 - v42) >> 24];
v43 = v38 >> 8;
v44 = __PAIR64__(v39, v38) >> 8;
HIDWORD(v15) = (unsigned int)(__PAIR64__(v8, v14) >> 8) >> 8;
LODWORD(v15) = v40;
v45 = v15 >> 8;
v46 = dword_100679BB8[(unsigned __int8)(BYTE1(v40) - 49 - v42)];
a2[14] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v44 + v41 + 9009) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v44 + v41 + 49)]
^ dword_10067A3B8[(unsigned __int8)((v44 + v41 - 465362127) >> 16)]
^ dword_10067A7B8[(v44 + v41 - 465362127) >> 24];
a2[15] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v40 >> 8) - 9009 - v42) >> 8)]
^ v46
^ dword_10067A3B8[(unsigned __int8)((v45 + 465362127 - v42) >> 16)]
^ dword_10067A7B8[(v45 + 465362127 - v42) >> 24];
v47 = (unsigned __int8)v17 | (v41 << 8);
v48 = (unsigned __int8)v16 | (v42 << 8);
a2[16] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v44 + v47 + 18018) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v44 + v47 + 98)]
^ dword_10067A3B8[(unsigned __int8)((v44 + v47 - 930724254) >> 16)]
^ dword_10067A7B8[(v44 + v47 - 930724254) >> 24];
a2[17] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v40 >> 8) - 18018 - v48) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v40) - 98 - v48)]
^ dword_10067A3B8[(unsigned __int8)((v45 + 930724254 - v48) >> 16)]
^ dword_10067A7B8[(v45 + 930724254 - v48) >> 24];
v49 = v44 >> 8;
HIDWORD(v15) = v40 >> 8;
LODWORD(v15) = v44;
v50 = v15 >> 8;
v51 = __PAIR64__(v43, v45) >> 8;
v52 = dword_100679BB8[(unsigned __int8)(v51 + 60 - v48)];
a2[18] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(((unsigned int)v15 >> 8) + v47 - 29500) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v15) + v47 - 60)]
^ dword_10067A3B8[(unsigned __int8)((v50 + v47 - 1861448508) >> 16)]
^ dword_10067A7B8[(v50 + v47 - 1861448508) >> 24];
a2[19] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v51 + 29500 - v48) >> 8)]
^ v52
^ dword_10067A3B8[(unsigned __int8)((v51 + 1861448508 - v48) >> 16)]
^ dword_10067A7B8[(v51 + 1861448508 - v48) >> 24];
v53 = (unsigned __int8)v2 | (v47 << 8);
v54 = (unsigned __int8)v3 | (v48 << 8);
a2[20] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(((unsigned int)v15 >> 8) + v53 + 6536) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v15) + v53 - 120)]
^ dword_10067A3B8[(unsigned __int8)((v50 + v53 + 572070280) >> 16)]
^ dword_10067A7B8[(v50 + v53 + 572070280) >> 24];
a2[21] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v51 - 6536 - v54) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v51 + 120 - v54)]
^ dword_10067A3B8[(unsigned __int8)((v51 - 572070280 - v54) >> 16)]
^ dword_10067A7B8[(v51 - 572070280 - v54) >> 24];
HIDWORD(v15) = v45 >> 8;
LODWORD(v15) = v50;
v55 = __PAIR64__(v49, v51) >> 8;
v56 = dword_100679BB8[(unsigned __int8)(v55 - 15 - v54)];
a2[22] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v50 >> 8) + v53 + 13071) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v50) + v53 + 15)]
^ dword_10067A3B8[(unsigned __int8)(((unsigned int)(v15 >> 8) + v53 + 1144140559) >> 16)]
^ dword_10067A7B8[((unsigned int)(v15 >> 8) + v53 + 1144140559) >> 24];
a2[23] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v55 - 13071 - v54) >> 8)]
^ v56
^ dword_10067A3B8[(unsigned __int8)((v55 - 1144140559 - v54) >> 16)]
^ dword_10067A7B8[(v55 - 1144140559 - v54) >> 24];
v57 = v4 | (v53 << 8);
v58 = v5 | (v54 << 8);
a2[24] = dword_100679FB8[(unsigned __int8)((unsigned __int16)((v50 >> 8) + v57 + 26141) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE1(v50) + v57 + 29)]
^ dword_10067A3B8[(unsigned __int8)(((unsigned int)(v15 >> 8) + v57 - 2006686179) >> 16)]
^ dword_10067A7B8[((unsigned int)(v15 >> 8) + v57 - 2006686179) >> 24];
a2[25] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(v55 - 26141 - v58) >> 8)]
^ dword_100679BB8[(unsigned __int8)(v55 - 29 - v58)]
^ dword_10067A3B8[(unsigned __int8)((v55 + 2006686179 - v58) >> 16)]
^ dword_10067A7B8[(v55 + 2006686179 - v58) >> 24];
result = (unsigned int)(__PAIR64__(v50 >> 8, v55) >> 8);
v60 = dword_100679BB8[(unsigned __int8)(BYTE1(v55) - 58 - v58)];
a2[26] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(WORD1(v15) + v57 - 13254) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE2(v15) + v57 + 58)]
^ dword_10067A3B8[(unsigned __int8)(((unsigned int)(v15 >> 16) + v57 + 281594938) >> 16)]
^ dword_10067A7B8[((unsigned int)(v15 >> 16) + v57 + 281594938) >> 24];
a2[27] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(result + 13254 - v58) >> 8)]
^ v60
^ dword_10067A3B8[(unsigned __int8)((unsigned int)(result - 281594938 - v58) >> 16)]
^ dword_10067A7B8[(unsigned int)(result - 281594938 - v58) >> 24];
v61 = v10 | (v57 << 8);
v62 = v11 | (v58 << 8);
a2[28] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(WORD1(v15) + v61 - 26509) >> 8)]
^ dword_100679BB8[(unsigned __int8)(BYTE2(v15) + v61 + 115)]
^ dword_10067A3B8[(unsigned __int8)(((unsigned int)(v15 >> 16) + v61 + 563189875) >> 16)]
^ dword_10067A7B8[((unsigned int)(v15 >> 16) + v61 + 563189875) >> 24];
a2[29] = dword_100679FB8[(unsigned __int8)((unsigned __int16)(result + 26509 - v62) >> 8)]
^ dword_100679BB8[(unsigned __int8)(result - 115 - v62)]
^ dword_10067A3B8[(unsigned __int8)((unsigned int)(result - 563189875 - v62) >> 16)]
^ dword_10067A7B8[(unsigned int)(result - 563189875 - v62) >> 24];
v63 = (__PAIR64__(v55 >> 8, v15 >> 16) >> 8) + v61 + 1126379749;
v64 = (__PAIR64__((unsigned int)(v15 >> 8) >> 8, result) >> 8) - 1126379749 - v62;
a2[30] = dword_100679FB8[BYTE1(v63)]
^ dword_100679BB8[(unsigned __int8)v63]
^ dword_10067A3B8[BYTE2(v63)]
^ dword_10067A7B8[HIBYTE(v63)];
a2[31] = dword_100679FB8[BYTE1(v64)]
^ dword_100679BB8[(unsigned __int8)v64]
^ dword_10067A3B8[BYTE2(v64)]
^ dword_10067A7B8[HIBYTE(v64)];
return result;
}