//
// rtsha1::calc from 0x5bbbd0 to 0x5bbf08 (824 bytes)
//
// 21 xrefs:
// > GameManager::recountUserStats @ 0x5fa514
// > GameLevelManager::onGetGJSecretRewardCompleted @ 0x6fcb14
// > GameLevelManager::onGetGJRewardsCompleted @ 0x6fd4e4
// > GameLevelManager::onGetGJChallengesCompleted @ 0x6fe088
// > GameLevelManager::onGetGJDailyLevelStateCompleted @ 0x6feee8
// > GameLevelManager::onGetOnlineLevelsCompleted @ 0x705680
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x7078cc
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x707bc4
// > GameLevelManager::onGetMapPacksCompleted @ 0x70d710
// > GameLevelManager::onGetGauntletsCompleted @ 0x70e118
// > GameLevelManager::uploadLevel @ 0x71c464
// > GameLevelManager::downloadLevel @ 0x71e1f0
// > GameLevelManager::rateStars @ 0x71ed48
// > GameLevelManager::getLevelLeaderboard @ 0x720ebc
// > GameLevelManager::uploadComment @ 0x7244e0
// > GameLevelManager::likeItem @ 0x728d3c
// > GameLevelManager::uploadLevelList @ 0x72d56c
// > GameLevelManager::updateUserScore @ 0x737ccc
// > GJAccountManager::getShaPassword @ 0x848144
// > GJMultiplayerManager::uploadComment @ 0x983bb8
// > ??> @ 0x366f0
//
// 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 rtsha1::calc(rtsha1 *this, const void *a2, __int64 a3, unsigned __int8 *a4)
{
int v4; // w23
const char *v7; // x27
__int64 v8; // x20
const char *v9; // x21
uint16x8_t v10; // q7
uint16x8_t v11; // q6
uint16x8_t v12; // q17
int8x16_t v13; // q5
int8x16_t v14; // q4
uint16x8_t v15; // q16
int v16; // w5
int v17; // w6
__int64 v18; // x0
int v19; // w4
char v20; // w3
int v21; // w1
_BYTE *v22; // x19
int i; // w0
int v24; // w1
char v25; // w2
uint8x16_t v27; // [xsp+60h] [xbp+60h]
uint8x16_t v28; // [xsp+70h] [xbp+70h]
uint8x16_t v29; // [xsp+90h] [xbp+90h]
int v30[6]; // [xsp+A8h] [xbp+A8h] BYREF
int8x16_t v31; // [xsp+C0h] [xbp+C0h] BYREF
int8x16_t v32; // [xsp+D0h] [xbp+D0h]
int8x16_t v33; // [xsp+E0h] [xbp+E0h]
int8x16_t v34; // [xsp+F0h] [xbp+F0h]
int8x16x4_t v35; // 0:q0.16,16:q1.16,32:q2.16,48:q3.16
v4 = (int)a2;
v30[0] = 1732584193;
v30[1] = -271733879;
v30[2] = -1732584194;
v30[3] = 271733878;
v30[4] = -1009589776;
if ( (int)a2 <= 63 )
{
v16 = 0;
}
else
{
v7 = (const char *)this;
v8 = (unsigned int)((_DWORD)a2 - 64) >> 6;
v9 = (char *)this + 64 * v8 + 64;
do
{
v35 = vld4q_s8(v7);
v7 += 64;
v27 = v35.val[0];
v28 = v35.val[1];
v29 = v35.val[3];
v35.val[1] = vmovl_u8((uint8x8_t)v35.val[2].n128_u64[0]);
v10 = vmovl_u8((uint8x8_t)v28.n128_u64[0]);
v35.val[0] = vmovl_high_u8(v35.val[2]);
v11 = vmovl_high_u8(v28);
v12 = vmovl_u8((uint8x8_t)v35.val[3].n128_u64[0]);
v13 = vorrq_s8(
vshlq_n_s32(vmovl_u16((uint16x4_t)v35.val[1].n128_u64[0]), 8u),
vshlq_n_s32(vmovl_u16((uint16x4_t)v10.n128_u64[0]), 0x10u));
v35.val[3] = vmovl_u8((uint8x8_t)v27.n128_u64[0]);
v35.val[2] = vmovl_high_u16(v35.val[1]);
v14 = vshlq_n_s32(vmovl_u16((uint16x4_t)v35.val[0].n128_u64[0]), 8u);
v15 = vmovl_high_u8(v29);
v35.val[1] = vshlq_n_s32(vmovl_high_u16(v35.val[0]), 8u);
v35.val[0] = vmovl_high_u8(v27);
v31 = vorrq_s8(
vorrq_s8(v13, vmovl_u16((uint16x4_t)v12.n128_u64[0])),
vshlq_n_s32(vmovl_u16((uint16x4_t)v35.val[3].n128_u64[0]), 0x18u));
v32 = vorrq_s8(
vorrq_s8(
vorrq_s8(vshlq_n_s32(v35.val[2], 8u), vshlq_n_s32(vmovl_high_u16(v10), 0x10u)),
vmovl_high_u16(v12)),
vshlq_n_s32(vmovl_high_u16(v35.val[3]), 0x18u));
v33 = vorrq_s8(
vorrq_s8(
vorrq_s8(v14, vshlq_n_s32(vmovl_u16((uint16x4_t)v11.n128_u64[0]), 0x10u)),
vmovl_u16((uint16x4_t)v15.n128_u64[0])),
vshlq_n_s32(vmovl_u16((uint16x4_t)v35.val[0].n128_u64[0]), 0x18u));
v34 = vorrq_s8(
vorrq_s8(vorrq_s8(v35.val[1], vshlq_n_s32(vmovl_high_u16(v11), 0x10u)), vmovl_high_u16(v15)),
vshlq_n_s32(vmovl_high_u16(v35.val[0]), 0x18u));
sub_5BB878(v30, (int *)&v31);
}
while ( v7 != v9 );
v16 = ((_DWORD)v8 + 1) << 6;
}
v17 = v4 - v16;
v18 = 0;
v34 = 0u;
v33 = 0u;
v32 = 0u;
v31 = 0u;
if ( v4 - v16 <= 0 )
{
v31.n128_u32[0] |= 0x80000000;
}
else
{
do
{
v19 = (int)v18 >> 2;
v20 = 8 * (~(_BYTE)v18 & 3);
v21 = *((unsigned __int8 *)this + v16 + v18++);
v31.n128_u32[v19] |= v21 << v20;
}
while ( v17 > (int)v18 );
v31.n128_u32[v17 >> 2] |= 128 << (8 * (~(_BYTE)v17 & 3));
if ( v17 > 55 )
{
sub_5BB878(v30, (int *)&v31);
v34 = 0u;
v33 = 0u;
v32 = 0u;
v31 = 0u;
}
}
v34.n128_u32[3] = 8 * v4;
sub_5BB878(v30, (int *)&v31);
v22 = (_BYTE *)(a3 + 19);
for ( i = 19; i != -1; --i )
{
v24 = i >> 2;
v25 = 8 * ((3 - i) & 3);
*v22-- = (unsigned int)v30[v24] >> v25;
}
return _stack_chk_guard;
}