//
// EndPortalObject::init from 0x100385d90 to 0x1003860b5 (805 bytes)
//
// 2 xrefs:
// > EndPortalObject::create @ 0x100385d49
// > ??> @ 0x100b2b898
//
// 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:29:10 +0000
//
__int64 __fastcall EndPortalObject::init(_BYTE *a1, double a2, double a3, __m128 a4)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // r14
__int64 v8; // rax
__m128 v9; // xmm0
__m128 v10; // xmm1
__int64 v11; // rax
__m128 v12; // xmm0
__m128 v13; // xmm1
__m128 v14; // xmm2
__int64 v15; // rax
__m128 v16; // xmm1
__m128 v17; // xmm0
int v18; // r13d
int v19; // r14d
double v20; // xmm0_8
char *v21; // r12
__m128 v22; // [rsp+8h] [rbp-48h] BYREF
_BYTE v23[4]; // [rsp+18h] [rbp-38h] BYREF
float v24; // [rsp+1Ch] [rbp-34h]
float v25; // [rsp+20h] [rbp-30h]
unsigned __int8 v26; // [rsp+27h] [rbp-29h]
result = GameObject::init(a1, "block001_01_001.png");
if ( (_BYTE)result )
{
v26 = result;
(*(void (__fastcall **)(_BYTE *, void *))(*(_QWORD *)a1 + 1136LL))(a1, &unk_100BE3238);
v5 = cocos2d::CCDirector::sharedDirector(a1, &unk_100BE3238);
cocos2d::CCDirector::getWinSize(v23, v5);
a1[999] = 0;
a1[1032] = 1;
*((_DWORD *)a1 + 230) = 7;
v6 = GameObject::createAndAddParticle(a1, 7, "endEffectPortal.plist", 4, 2);
if ( v6 )
{
v7 = v6;
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v6 + 1176LL))(v6, v24 * 0.5);
sub_100278250(v22.f32, -15.0, 0.0);
sub_100278300(a1 + 812, &v22);
v8 = *(_QWORD *)(*(_QWORD *)(GameManager::sharedState() + 544) + 3256LL);
v9 = 0;
v10 = 0;
v10.f32[0] = (float)(unsigned __int8)*(_WORD *)(v8 + 2602) / 255.0;
a4.f32[0] = (float)HIBYTE(*(unsigned __int16 *)(v8 + 2602)) / 255.0;
v9.f32[0] = (float)*(unsigned __int8 *)(v8 + 2604) / 255.0;
v22 = _mm_movelh_ps(_mm_insert_ps(v10, a4, 16), _mm_blend_ps(v9, (__m128)xmmword_100A03610, 14));
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v7 + 1360LL))(v7, &v22);
v11 = *(_QWORD *)(*(_QWORD *)(GameManager::sharedState() + 544) + 3256LL);
v12 = 0;
v12.f32[0] = (float)*(unsigned __int8 *)(v11 + 2604);
LODWORD(v11) = *(unsigned __int16 *)(v11 + 2602);
v13 = 0;
v14 = 0;
v13.f32[0] = (float)(unsigned __int8)v11 / 255.0;
v14.f32[0] = (float)((unsigned int)v11 >> 8) / 255.0;
v12.f32[0] = v12.f32[0] / 255.0;
v22 = _mm_movelh_ps(_mm_insert_ps(v13, v14, 16), _mm_blend_ps(v12, (__m128)xmmword_100A03610, 14));
a2 = (*(double (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v7 + 1392LL))(v7, &v22);
}
*((_QWORD *)a1 + 169) = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"gradientBar.png", a2);
v15 = GameManager::sharedState();
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(*(_QWORD *)(v15 + 544) + 2544LL) + 456LL))(
*(_QWORD *)(*(_QWORD *)(v15 + 544) + 2544LL),
*((_QWORD *)a1 + 169));
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)a1 + 169) + 1080LL))(*((_QWORD *)a1 + 169), 0x100000302LL);
(*(void (__fastcall **)(_QWORD, float))(**((_QWORD **)a1 + 169) + 144LL))(
*((_QWORD *)a1 + 169),
(float)(v24 * 1.5) / *(float *)(*((_QWORD *)a1 + 169) + 436LL));
v16 = (__m128)0x3FC00000u;
v16.f32[0] = (float)(1.5 * v24) / 30.0;
v17 = _mm_or_ps(_mm_and_ps((__m128)xmmword_100A035F0, v16), (__m128)xmmword_100A03600);
v17.f32[0] = v17.f32[0] + v16.f32[0];
v18 = (int)_mm_round_ss(v17, v17, 11).f32[0];
if ( v18 > 0 )
{
HIDWORD(v20) = 0;
v19 = 0;
*(float *)&v20 = (float)((unsigned int)v18 >> 1) * 30.0;
v25 = *(float *)&v20;
do
{
v21 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"square_02_001.png", v20);
(*(void (__fastcall **)(_BYTE *, char *))(*(_QWORD *)a1 + 456LL))(a1, v21);
(*(void (__fastcall **)(char *, float))(*(_QWORD *)v21 + 360LL))(v21, -90.0);
v20 = 0.0;
sub_100278250(v22.f32, 0.0, (float)((float)v19 * -30.0) + v25);
(*(void (__fastcall **)(char *, __m128 *))(*(_QWORD *)v21 + 184LL))(v21, &v22);
++v19;
}
while ( v18 != v19 );
}
a1[896] = 1;
return v26;
}
return result;
}