//
// sub_B9130 from 0xb9130 to 0xb9360 (560 bytes)
//
// 2 xrefs:
// > sub_B8FA8 @ 0xb90f0
// > sub_BA6D0 @ 0xba718
//
// This function is hookable on this platform (idp: arm, 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:14:40 +0000
//
__int64 __fastcall sub_B9130(int a1, float *a2, char *s)
{
void *v5; // x0
__int64 v6; // x21
float v7; // s0
float v8; // s1
float v9; // s9
float v10; // s8
float v11; // s0
float v12; // s8
float v13; // s0
float v14; // s1
char v15; // w8
__int64 i; // x8
float *v17; // x13
__int64 v18; // x12
float v19; // s0
__int64 j; // x13
_DWORD *v21; // x14
__int64 v22; // x22
float *v23; // x20
__int64 v24; // x26
float *v25; // x8
float v26; // s8
float v27; // s9
float v28; // s0
float v29; // s1
char v30; // w8
_DWORD v32[16]; // [xsp+0h] [xbp-A0h] BYREF
v5 = memset(s, 0, 0xA0u);
v6 = *(int *)a2;
if ( (_DWORD)v6 == 1 )
{
v7 = a2[1];
v8 = a2[3];
v9 = (float)(v7 * v7) + (float)(v8 * v8);
v10 = v9 + (float)(a2[2] * a2[2]);
if ( v7 != 0.0 || v8 != 0.0 )
{
v11 = atan2f(v7, v8);
*((float *)s + 4) = sqrtf(v9);
*((float *)s + 1) = v11 * 57.296;
}
v12 = sqrtf(v10);
sub_BAAF0(v5, a2[7], a2[9]);
if ( (v15 & 1) == 0 )
*((float *)s + 2) = atan2f(v13, v14) * 57.296;
*((float *)s + 3) = v12;
*(_DWORD *)s = 1065353216;
}
else
{
for ( i = 0; i < v6; ++i )
{
v17 = &a2[12 * i];
v18 = 0;
v19 = sqrtf((float)((float)(v17[1] * v17[1]) + (float)(v17[2] * v17[2])) + (float)(v17[3] * v17[3]));
*(float *)&v32[i + 8] = v19;
while ( i != v18 && v19 >= *(float *)&v32[v32[v18] + 8] )
++v18;
for ( j = i; j > v18; --j )
{
v21 = &v32[j];
*v21 = *(v21 - 1);
}
v32[v18] = i;
}
v22 = 0;
v23 = (float *)(s + 8);
while ( v22 < v6 )
{
v24 = (int)v32[v22];
v25 = &a2[12 * v24];
v26 = v25[1];
v27 = v25[3];
if ( v26 != 0.0 || v27 != 0.0 )
{
*(v23 - 1) = atan2f(v26, v27) * 57.296;
v23[2] = sqrtf((float)(v26 * v26) + (float)(v27 * v27));
}
v5 = (void *)sub_BAAF0(v5, a2[12 * v24 + 7], a2[12 * v24 + 9]);
if ( (v30 & 1) == 0 )
*v23 = atan2f(v28, v29) * 57.296;
++v22;
v23[1] = *(float *)&v32[v24 + 8];
*(v23 - 2) = a2[v24 + 97];
v23 += 5;
}
}
return 0;
}