// File: kernel.cpp
#include "loop_114.h"
#include <stdint.h>

extern "C" void inner_loop_114(struct loop_114_data *data) {
    int16_t *d = data->data;
    int16_t *res = data->res;
    int32_t n = data->n;
    int32_t lags = data->lags;
    int16_t scale = data->scale;
    for (int lag = 0; lag < lags; lag++) {
        int32_t acc = 0;
        int lmt = n - lag;
        for (int i = 0; i < lmt; i++)
            acc += ((int32_t)d[i] * (int32_t)d[i + lag]) >> scale;
        res[lag] = (int16_t)(acc >> 16);
    }
}