
#define Stack_Lengthof(x) ((int)((sizeof(x) / sizeof((x)[0]))))
#define Stack(T, size) \
    struct {           \
        int len;       \
        T data[size];  \
    }
#define S_Add(s, val) (                                                              \
    ((s).len + 1 > Stack_Lengthof((s).data) && IO_Assert("Reached stack capacity")), \
    (s).data[(s).len++] = (val))
#define S_Alloc(s) (                                                                 \
    ((s).len + 1 > Stack_Lengthof((s).data) && IO_Assert("Reached stack capacity")), \
    ((s).data + (s).len++))

#define S_Pop(s) (                                                \
    ((s).len <= 0 && IO_Assert("Trying to pop stack of size 0")), \
    (s).data[--(s).len])
#define S_Get(s, i) (                                                     \
    ((i) >= (s).len && IO_Assert("Trying to index stack out of bounds")), \
    (s).data + (i))
#define S_GetLast(s) S_Get(s, (s).len - 1)
