#include "game_types.h"

/* Spatial_HashQuery @ 0x08017FA4 (real 76B) -- triple-indirect hashed spatial query. Mirrors src/matched/Spatial_HashQuery.c. */
/* Resolves the table through the r0 slot, the multiplier through the r1
   slot, and the entry through the 5th-arg slot, spilling the middle result
   and 6th arg for the final indirect call through the r5 slot. All three
   dispatches use the bx-reg trampoline convention. */
int Spatial_HashQuery(int *t0, int *t1, int x, int y, int *t4, int z)
{
    int *tab = ((int *(*)(void))t0)();
    int *e = (int *)tab[1];
    int off = *(short *)((char *)e + 16);
    int *slot = (int *)((char *)e + 16 + off);
    int m = ((int (*)(void))t1)();
    int j = ((int (*)(void))t4)();
    int *fn = (int *)slot[1];
    int (*f)(int *, int, int, int, int, int) =
        (int (*)(int *, int, int, int, int, int))fn;
    return f(tab, m, x, y, j, z);
}
