//=============================================================================================================
#include <stdint.h>
#include <stdlib.h>
#include <nfp/me.h>
#include <nfp/mem_atomic.h>
#include <pif_common.h>
#include "pif_plugin.h"

//=============================================================================================================

int pif_plugin_prime2(EXTRACTED_HEADERS_T *headers, MATCH_DATA_T *match_data) {

    PIF_PLUGIN_map_hdr_T *mapHdr = pif_plugin_hdr_get_map_hdr(headers);
    __gpr uint32_t i = 1, j = 0;
    // uint32_t length = mapHdr->data;
    uint32_t length = mapHdr->function_id;
    __gpr uint64_t ar[10000];
    int idx = -1;
    unsigned randval;
    // for (; j < length; j++) {
    //     for (;i < 1000; i++) {
    //         randval = local_csr_read(local_csr_pseudo_random_number);
    //         // idx = rand() % (10001);
    //         idx = randval % (10001);
    //         // ar[idx] = randval;
    //         // ar[idx] = rand();
    //     }
    // }
    // unsigned randval = local_csr_read(local_csr_pseudo_random_number);
    // int idx = -1;
    // length++;
    // mapHdr->data = idx | length;
    mapHdr->data = 0;
    mapHdr->function_id = length+2;
    return PIF_PLUGIN_RETURN_FORWARD; 
}