//
// RandTriggerGameObject::getRandomGroupID from 0x1001c3190 to 0x1001c32e2 (338 bytes)
//
// 0 xrefs:
//
// 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::getRandomGroupID(RandTriggerGameObject *a1)
{
std::__vector_base::pointer begin; // rdx
std::__vector_base::pointer end; // rax
unsigned __int64 v4; // rsi
int v5; // edi
std::__vector_base::pointer v6; // rcx
__m128 v7; // xmm0
__int64 v8; // rsi
__int64 v9; // rdi
__int64 v10; // rsi
int *p_m_chance; // rdx
__m128i v12; // xmm0
__m128i v13; // xmm1
__m128i v14; // xmm1
__m128i v15; // xmm0
std::__vector_base::pointer v16; // rax
std::__vector_base::pointer v17; // rcx
__m128 v18; // xmm1
int v19; // edx
int v20; // esi
float v22; // [rsp+0h] [rbp-Ch]
begin = a1->m_chanceObjects.__begin_;
end = a1->m_chanceObjects.__end_;
if ( begin == end )
{
v7 = 0;
}
else
{
v4 = (char *)end - (char *)begin - 16;
v5 = 0;
if ( v4 >= 0x80 )
{
v8 = (v4 >> 4) + 1;
v9 = 8;
if ( (v8 & 7) != 0 )
v9 = v8 & 7;
v10 = v8 - v9;
v6 = &begin[v10];
p_m_chance = &begin[7].m_chance;
v12 = 0;
v13 = 0;
do
{
v12 = _mm_add_epi32(
v12,
_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));
v13 = _mm_add_epi32(
v13,
_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;
v10 -= 8;
}
while ( v10 );
v14 = _mm_add_epi32(v13, v12);
v15 = _mm_add_epi32(_mm_shuffle_epi32(v14, 238), v14);
v5 = _mm_cvtsi128_si32(_mm_add_epi32(_mm_shuffle_epi32(v15, 85), v15));
}
else
{
v6 = begin;
}
do
{
v5 += v6->m_chance;
++v6;
}
while ( v6 != end );
v7 = 0;
v7.f32[0] = (float)v5;
}
v22 = v7.f32[0];
v7.f32[0] = GameToolbox::fast_rand_0_1();
v16 = a1->m_chanceObjects.__begin_;
v17 = a1->m_chanceObjects.__end_;
if ( v16 == v17 )
return 0;
v7.f32[0] = v7.f32[0] * v22;
v18 = _mm_or_ps(_mm_and_ps((__m128)xmmword_1008150B0, v7), (__m128)xmmword_1008150C0);
v18.f32[0] = v18.f32[0] + v7.f32[0];
v19 = (int)_mm_round_ss((__m128)0LL, v18, 11).f32[0];
v20 = 0;
while ( 1 )
{
v20 += v16->m_chance;
if ( v20 >= v19 )
break;
if ( ++v16 == v17 )
return 0;
}
return v16->m_groupID;
}