//
// RandTriggerGameObject::getTotalChance from 0x1001c30b0 to 0x1001c318e (222 bytes)
//
// 2 xrefs:
// > SetupRandAdvTriggerPopup::updateGroupIDButtons @ 0x10038e8ea
// > SetupRandAdvTriggerPopup::updateGroupIDButtons @ 0x10038ec56
//
// 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 RandTriggerGameObject::getTotalChance(RandTriggerGameObject *a1)
{
std::__vector_base::pointer begin; // rsi
std::__vector_base::pointer end; // rcx
unsigned __int64 v3; // rdi
int result; // eax
std::__vector_base::pointer v5; // rdx
__int64 v6; // rdi
__int64 v7; // rdx
__int64 v8; // rdi
int *p_m_chance; // rsi
__m128i v10; // xmm0
__m128i v11; // xmm1
__m128i v12; // xmm1
__m128i v13; // xmm0
begin = a1->m_chanceObjects.__begin_;
end = a1->m_chanceObjects.__end_;
if ( begin == end )
return 0;
v3 = (char *)end - (char *)begin - 16;
result = 0;
if ( v3 > 0x7F )
{
v6 = (v3 >> 4) + 1;
v7 = 8;
if ( (v6 & 7) != 0 )
v7 = v6 & 7;
v8 = v6 - v7;
v5 = &begin[v8];
p_m_chance = &begin[7].m_chance;
v10 = 0;
v11 = 0;
do
{
v10 = _mm_add_epi32(
v10,
_mm_insert_epi32(
_mm_insert_epi32(
_mm_insert_epi32(_mm_cvtsi32_si128(*(p_m_chance - 28)), *(p_m_chance - 24), 1),
*(p_m_chance - 20),
2),
*(p_m_chance - 16),
3));
v11 = _mm_add_epi32(
v11,
_mm_insert_epi32(
_mm_insert_epi32(
_mm_insert_epi32(_mm_cvtsi32_si128(*(p_m_chance - 12)), *(p_m_chance - 8), 1),
*(p_m_chance - 4),
2),
*p_m_chance,
3));
p_m_chance += 32;
v8 -= 8;
}
while ( v8 );
v12 = _mm_add_epi32(v11, v10);
v13 = _mm_add_epi32(_mm_shuffle_epi32(v12, 238), v12);
result = _mm_cvtsi128_si32(_mm_add_epi32(_mm_shuffle_epi32(v13, 85), v13));
}
else
{
v5 = begin;
}
do
{
result += v5->m_chance;
++v5;
}
while ( v5 != end );
return result;
}