//
// RandTriggerGameObject::getTotalChance from 0x1001a3980 to 0x1001a3a5e (222 bytes)
//
// 2 xrefs:
// > SetupRandAdvTriggerPopup::updateGroupIDButtons @ 0x100379626
// > SetupRandAdvTriggerPopup::updateGroupIDButtons @ 0x10037996c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:26:00 +0000
//
__int64 __fastcall RandTriggerGameObject::getTotalChance(__int64 a1)
{
__int64 v1; // rsi
__int64 v2; // rcx
unsigned __int64 v3; // rdi
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rdi
__int64 v7; // rdx
__int64 v8; // rdi
int *v9; // rsi
__m128i v10; // xmm0
__m128i v11; // xmm1
__m128i v12; // xmm1
__m128i v13; // xmm0
v1 = *(_QWORD *)(a1 + 1840);
v2 = *(_QWORD *)(a1 + 1848);
if ( v1 == v2 )
return 0;
v3 = v2 - v1 - 16;
LODWORD(result) = 0;
if ( v3 > 0x7F )
{
v6 = (v3 >> 4) + 1;
v7 = 8;
if ( (v6 & 7) != 0 )
v7 = v6 & 7;
v8 = v6 - v7;
v5 = v1 + 16 * v8;
v9 = (int *)(v1 + 120);
v10 = 0;
v11 = 0;
do
{
v10 = _mm_add_epi32(
v10,
_mm_insert_epi32(
_mm_insert_epi32(_mm_insert_epi32(_mm_cvtsi32_si128(*(v9 - 28)), *(v9 - 24), 1), *(v9 - 20), 2),
*(v9 - 16),
3));
v11 = _mm_add_epi32(
v11,
_mm_insert_epi32(
_mm_insert_epi32(_mm_insert_epi32(_mm_cvtsi32_si128(*(v9 - 12)), *(v9 - 8), 1), *(v9 - 4), 2),
*v9,
3));
v9 += 32;
v8 -= 8;
}
while ( v8 );
v12 = _mm_add_epi32(v11, v10);
v13 = _mm_add_epi32(_mm_shuffle_epi32(v12, 238), v12);
LODWORD(result) = _mm_cvtsi128_si32(_mm_add_epi32(_mm_shuffle_epi32(v13, 85), v13));
}
else
{
v5 = v1;
}
do
{
result = (unsigned int)(*(_DWORD *)(v5 + 8) + result);
v5 += 16;
}
while ( v5 != v2 );
return result;
}