Problem 922

R(m, w) mod 10^9+7, compute R(8, 64). Uses FWT for XOR convolution and polynomial exponentiation.

Answer858945298
Output858945298
StatusPASS
Native helperno
Runtime80 ms
Peak memory1792 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(n * k)
Space complexityO(n^2)O(n)
ApproachFlow solutionKey search and XOR decryption
VerdictUnknown

Flow source

# Project Euler 922: Staircase Game
# R(m, w) mod 10^9+7, compute R(8, 64).
# Uses FWT for XOR convolution and polynomial exponentiation.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
    function memset(p: ptr<void>, c: i32, n: i64) -> ptr<void>
    function memcpy(dst: ptr<void>, src: ptr<void>, n: i64) -> ptr<void>
}

const MOD: i64 = 1000000007
const XOR_SIZE: i32 = 64
const W: i32 = 64
const M: i32 = 8
const DMAX: i32 = 62
const DIFF_COUNT: i32 = 125
const MAX_POLY: i32 = 1024

# counts[DIFF_COUNT][XOR_SIZE] flat
let mut g_counts: ptr<i64> = null
# Qhat[XOR_SIZE][MAX_POLY] flat
let mut g_qhat: ptr<i64> = null
# vec[XOR_SIZE]
let mut g_vec: ptr<i64> = null

# Polynomial buffers: 3 polynomials each with MAX_POLY coeffs
let mut g_poly_coeffs: ptr<i64> = null
let mut g_poly_len: ptr<i32> = null
let mut g_poly_offset: ptr<i64> = null
# tmp buffer for poly_mul
let mut g_pmul_tmp: ptr<i64> = null

function powmod(a0: i64, b0: i64, m: i64) -> i64 {
    let mut r: i64 = 1
    let mut a: i64 = a0 % m
    if a < 0 { a = a + m }
    let mut b: i64 = b0
    while b > 0 {
        if (b & 1) == 1 {
            let aw: i128 = r as i128
            let bw: i128 = a as i128
            let mw: i128 = m as i128
            r = ((aw * bw) % mw) as i64
        }
        let aw2: i128 = a as i128
        let bw2: i128 = a as i128
        let mw2: i128 = m as i128
        a = ((aw2 * bw2) % mw2) as i64
        b = b >> 1
    }
    return r
}

function fwt_xor(arr: ptr<i64>, n: i32, inverse: i32) -> void {
    let mut step: i32 = 1
    while step < n {
        let jump: i32 = step * 2
        let mut i: i32 = 0
        while i < n {
            let mut j: i32 = i
            while j < i + step {
                let x: i64 = arr[j]
                let y: i64 = arr[j + step]
                let mut s: i64 = x + y
                if s >= MOD { s = s - MOD }
                let mut d: i64 = x - y
                if d < 0 { d = d + MOD }
                arr[j] = s
                arr[j + step] = d
                j = j + 1
            }
            i = i + jump
        }
        step = jump
    }
    if inverse != 0 {
        let inv_n: i64 = powmod(n as i64, MOD - 2, MOD)
        let mut i: i32 = 0
        while i < n {
            let aw: i128 = arr[i] as i128
            let bw: i128 = inv_n as i128
            let mw: i128 = MOD as i128
            arr[i] = ((aw * bw) % mw) as i64
            i = i + 1
        }
    }
}

# poly_mul: res_idx = a_idx * b_idx
function poly_mul(res_idx: i32, a_idx: i32, b_idx: i32) -> void {
    let big_idx: i32 = a_idx
    let small_idx: i32 = b_idx
    if g_poly_len[a_idx] < g_poly_len[b_idx] {
        big_idx = b_idx
        small_idx = a_idx
    }
    let new_len: i32 = g_poly_len[big_idx] + g_poly_len[small_idx] - 1
    memset(g_pmul_tmp as ptr<void>, 0, (new_len as i64) * 8)
    let mut i: i32 = 0
    while i < g_poly_len[big_idx] {
        if g_poly_coeffs[big_idx * MAX_POLY + i] != 0 {
            let mut j: i32 = 0
            while j < g_poly_len[small_idx] {
                if g_poly_coeffs[small_idx * MAX_POLY + j] != 0 {
                    let aw: i128 = g_pmul_tmp[i + j] as i128
                    let bw: i128 = g_poly_coeffs[big_idx * MAX_POLY + i] as i128
                    let cw: i128 = g_poly_coeffs[small_idx * MAX_POLY + j] as i128
                    let mw: i128 = MOD as i128
                    g_pmul_tmp[i + j] = ((aw + bw * cw) % mw) as i64
                }
                j = j + 1
            }
        }
        i = i + 1
    }
    g_poly_len[res_idx] = new_len
    g_poly_offset[res_idx] = g_poly_offset[a_idx] + g_poly_offset[b_idx]
    memcpy(g_poly_coeffs + res_idx * MAX_POLY, g_pmul_tmp, (new_len as i64) * 8)
}

# poly_pow: res_idx = base_idx ^ exp
function poly_pow(res_idx: i32, base_idx: i32, exp: i32) -> void {
    # Copy base_in to buffer 1 first (before overwriting buffer 0)
    let base: i32 = 1
    g_poly_len[base] = g_poly_len[base_idx]
    g_poly_offset[base] = g_poly_offset[base_idx]
    memcpy(g_poly_coeffs + base * MAX_POLY, g_poly_coeffs + base_idx * MAX_POLY, (g_poly_len[base_idx] as i64) * 8)

    # result = {1} in buffer 0
    let res: i32 = 0
    g_poly_len[res] = 1
    g_poly_offset[res] = 0
    g_poly_coeffs[res * MAX_POLY + 0] = 1

    let tmp: i32 = 2
    let mut e: i32 = exp
    while e > 0 {
        if (e & 1) == 1 {
            poly_mul(tmp, res, base)
            # res = tmp
            g_poly_len[res] = g_poly_len[tmp]
            g_poly_offset[res] = g_poly_offset[tmp]
            memcpy(g_poly_coeffs + res * MAX_POLY, g_poly_coeffs + tmp * MAX_POLY, (g_poly_len[tmp] as i64) * 8)
        }
        e = e >> 1
        if e != 0 {
            poly_mul(tmp, base, base)
            # base = tmp
            g_poly_len[base] = g_poly_len[tmp]
            g_poly_offset[base] = g_poly_offset[tmp]
            memcpy(g_poly_coeffs + base * MAX_POLY, g_poly_coeffs + tmp * MAX_POLY, (g_poly_len[tmp] as i64) * 8)
        }
    }
    # res_idx = res
    g_poly_len[res_idx] = g_poly_len[res]
    g_poly_offset[res_idx] = g_poly_offset[res]
    memcpy(g_poly_coeffs + res_idx * MAX_POLY, g_poly_coeffs + res * MAX_POLY, (g_poly_len[res] as i64) * 8)
}

function main() -> i32 {
    let w: i32 = W
    let m: i32 = M
    let dmax: i32 = w - 2
    let diff_count: i32 = 2 * dmax + 1

    # Allocate arrays
    g_counts = calloc((diff_count * XOR_SIZE) as i64, 8)
    g_qhat = calloc((XOR_SIZE * MAX_POLY) as i64, 8)
    g_vec = calloc(XOR_SIZE as i64, 8)
    g_poly_coeffs = calloc((3 * MAX_POLY) as i64, 8)
    g_poly_len = calloc(3, 4)
    g_poly_offset = calloc(3, 8)
    g_pmul_tmp = calloc(MAX_POLY as i64, 8)

    # Build counts
    let mut k: i32 = 1
    while k < w - 1 {
        let limit: i32 = w - k
        if limit >= 2 {
            let g: i32 = k - 1
            let tmax: i32 = limit - 2
            let mut t: i32 = 0
            while t <= tmax {
                let c: i32 = (limit - t) / 2
                if c > 0 {
                    let idx1: i32 = (dmax + t) * XOR_SIZE + g
                    g_counts[idx1] = (g_counts[idx1] + c as i64) % MOD
                    if t != 0 {
                        let idx2: i32 = (dmax - t) * XOR_SIZE + g
                        g_counts[idx2] = (g_counts[idx2] + c as i64) % MOD
                    }
                }
                t = t + 1
            }
        }
        k = k + 1
    }

    # FWT each row
    let mut d: i32 = 0
    while d < diff_count {
        fwt_xor(g_counts + d * XOR_SIZE, XOR_SIZE, 0)
        d = d + 1
    }

    let final_offset: i32 = m * dmax
    let final_len: i32 = 2 * final_offset + 1

    # For each t, build polynomial and raise to power m
    let mut t: i32 = 0
    while t < XOR_SIZE {
        # poly = counts[:, t]
        g_poly_len[0] = diff_count
        g_poly_offset[0] = dmax
        let mut di: i32 = 0
        while di < diff_count {
            g_poly_coeffs[0 * MAX_POLY + di] = g_counts[di * XOR_SIZE + t]
            di = di + 1
        }

        poly_pow(1, 0, m)

        let mut i: i32 = 0
        while i < g_poly_len[1] {
            if i < final_len {
                g_qhat[t * MAX_POLY + i] = g_poly_coeffs[1 * MAX_POLY + i]
            }
            i = i + 1
        }
        t = t + 1
    }

    # Compute answer
    let mut ans: i64 = 0
    let mut idx: i32 = 0
    while idx < final_len {
        let mut ti: i32 = 0
        while ti < XOR_SIZE {
            g_vec[ti] = g_qhat[ti * MAX_POLY + idx]
            ti = ti + 1
        }
        fwt_xor(g_vec, XOR_SIZE, 1)

        let total_diff: i32 = idx - final_offset
        if total_diff > 0 {
            let mut s: i64 = 0
            let mut ti2: i32 = 0
            while ti2 < XOR_SIZE {
                s = s + g_vec[ti2]
                if s >= MOD { s = s - MOD }
                ti2 = ti2 + 1
            }
            ans = ans + s
            if ans >= MOD { ans = ans - MOD }
        } else {
            if total_diff == 0 {
                let mut s: i64 = 0
                let mut ti3: i32 = 1
                while ti3 < XOR_SIZE {
                    s = s + g_vec[ti3]
                    if s >= MOD { s = s - MOD }
                    ti3 = ti3 + 1
                }
                ans = ans + s
                if ans >= MOD { ans = ans - MOD }
            }
        }
        idx = idx + 1
    }

    printf("%lld\n", ans)
    return 0
}

Generated C

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
    while (flow_temp_head) {
        flow_temp_node* n = flow_temp_head;
        flow_temp_head = n->next;
        free(n);
    }
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
    flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
    if (!node) return NULL;
    node->next = flow_temp_head;
    flow_temp_head = node;
    if (!flow_temp_atexit_set) {
        flow_temp_atexit_set = 1;
        atexit(flow_temp_free_all);
    }
    return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
    size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
    char* r = (char*)flow_temp_alloc(la + lb + 1);
    if (!r) return NULL;
    if (la) memcpy(r, a, la);
    if (lb) memcpy(r + la, b, lb);
    r[la + lb] = '\0';
    return r;
}

#define __flow_in_arr(arr, val) __extension__ ({ \
    int _found = 0; \
    size_t _n = sizeof(arr)/sizeof((arr)[0]); \
    for (size_t _i = 0; _i < _n; _i++) { \
        if ((arr)[_i] == (val)) { _found = 1; break; } \
    } _found; })

/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
    fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
    abort();
#if defined(__GNUC__) || defined(__clang__)
    __builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")

#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif

#include <math.h>

void* _ui_state = NULL;

static inline float i32_to_f32(int32_t v) { return (float)v; }

/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }

int64_t powmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t m);
void fwt_xor_ptr_i64_i32_i32(int64_t* arr, int32_t n, int32_t inverse);
void poly_mul_i32_i32_i32(int32_t res_idx, int32_t a_idx, int32_t b_idx);
void poly_pow_i32_i32_i32(int32_t res_idx, int32_t base_idx, int32_t exp);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int32_t XOR_SIZE = 64;
static const int32_t W = 64;
static const int32_t M = 8;
static const int32_t DMAX = 62;
static const int32_t DIFF_COUNT = 125;
static const int32_t MAX_POLY = 1024;

/* Module statics */
static int64_t* g_counts = NULL;
static int64_t* g_qhat = NULL;
static int64_t* g_vec = NULL;
static int64_t* g_poly_coeffs = NULL;
static int32_t* g_poly_len = NULL;
static int64_t* g_poly_offset = NULL;
static int64_t* g_pmul_tmp = NULL;





int64_t powmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t m) {
    int64_t r = 1;
    int64_t a = FLOW_CHECKED_MOD((a0), (m));
    if (a < 0) {
        a = (a + m);
    }
    int64_t b = b0;
    while (b > 0) {
        if ((b & 1) == 1) {
            __int128 aw = ((__int128)(r));
            __int128 bw = ((__int128)(a));
            __int128 mw = ((__int128)(m));
            r = ((int64_t)(FLOW_CHECKED_MOD(((aw * bw)), (mw))));
        }
        __int128 aw2 = ((__int128)(a));
        __int128 bw2 = ((__int128)(a));
        __int128 mw2 = ((__int128)(m));
        a = ((int64_t)(FLOW_CHECKED_MOD(((aw2 * bw2)), (mw2))));
        b = FLOW_CHECKED_SHR((b), (1));
    }
    return r;
}

void fwt_xor_ptr_i64_i32_i32(int64_t* arr, int32_t n, int32_t inverse) {
    int32_t step = 1;
    while (step < n) {
        int32_t jump = (step * 2);
        int32_t i = 0;
        while (i < n) {
            int32_t j = i;
            while (j < (i + step)) {
                int64_t x = arr[j];
                int64_t y = arr[(j + step)];
                int64_t s = (x + y);
                if (s >= MOD) {
                    s = (s - MOD);
                }
                int64_t d = (x - y);
                if (d < 0) {
                    d = (d + MOD);
                }
                arr[j] = s;
                arr[(j + step)] = d;
                j = (j + 1);
            }
            i = (i + jump);
        }
        step = jump;
    }
    if (inverse != 0) {
        int64_t inv_n = powmod_i64_i64_i64(((int64_t)(n)), (MOD - 2), MOD);
        int32_t i = 0;
        while (i < n) {
            __int128 aw = ((__int128)(arr[i]));
            __int128 bw = ((__int128)(inv_n));
            __int128 mw = ((__int128)(MOD));
            arr[i] = ((int64_t)(FLOW_CHECKED_MOD(((aw * bw)), (mw))));
            i = (i + 1);
        }
    }
}

void poly_mul_i32_i32_i32(int32_t res_idx, int32_t a_idx, int32_t b_idx) {
    int32_t big_idx = a_idx;
    int32_t small_idx = b_idx;
    if (g_poly_len[a_idx] < g_poly_len[b_idx]) {
        big_idx = b_idx;
        small_idx = a_idx;
    }
    int32_t new_len = ((g_poly_len[big_idx] + g_poly_len[small_idx]) - 1);
    memset(((void*)(g_pmul_tmp)), 0, (((int64_t)(new_len)) * 8));
    int32_t i = 0;
    while (i < g_poly_len[big_idx]) {
        if (g_poly_coeffs[((big_idx * MAX_POLY) + i)] != 0) {
            int32_t j = 0;
            while (j < g_poly_len[small_idx]) {
                if (g_poly_coeffs[((small_idx * MAX_POLY) + j)] != 0) {
                    __int128 aw = ((__int128)(g_pmul_tmp[(i + j)]));
                    __int128 bw = ((__int128)(g_poly_coeffs[((big_idx * MAX_POLY) + i)]));
                    __int128 cw = ((__int128)(g_poly_coeffs[((small_idx * MAX_POLY) + j)]));
                    __int128 mw = ((__int128)(MOD));
                    g_pmul_tmp[(i + j)] = ((int64_t)(FLOW_CHECKED_MOD(((aw + (bw * cw))), (mw))));
                }
                j = (j + 1);
            }
        }
        i = (i + 1);
    }
    g_poly_len[res_idx] = new_len;
    g_poly_offset[res_idx] = (g_poly_offset[a_idx] + g_poly_offset[b_idx]);
    memcpy((g_poly_coeffs + (res_idx * MAX_POLY)), g_pmul_tmp, (((int64_t)(new_len)) * 8));
}

void poly_pow_i32_i32_i32(int32_t res_idx, int32_t base_idx, int32_t exp) {
    int32_t base = 1;
    g_poly_len[base] = g_poly_len[base_idx];
    g_poly_offset[base] = g_poly_offset[base_idx];
    memcpy((g_poly_coeffs + (base * MAX_POLY)), (g_poly_coeffs + (base_idx * MAX_POLY)), (((int64_t)(g_poly_len[base_idx])) * 8));
    int32_t res = 0;
    g_poly_len[res] = 1;
    g_poly_offset[res] = 0;
    g_poly_coeffs[((res * MAX_POLY) + 0)] = 1;
    int32_t tmp = 2;
    int32_t e = exp;
    while (e > 0) {
        if ((e & 1) == 1) {
            poly_mul_i32_i32_i32(tmp, res, base);
            g_poly_len[res] = g_poly_len[tmp];
            g_poly_offset[res] = g_poly_offset[tmp];
            memcpy((g_poly_coeffs + (res * MAX_POLY)), (g_poly_coeffs + (tmp * MAX_POLY)), (((int64_t)(g_poly_len[tmp])) * 8));
        }
        e = FLOW_CHECKED_SHR((e), (1));
        if (e != 0) {
            poly_mul_i32_i32_i32(tmp, base, base);
            g_poly_len[base] = g_poly_len[tmp];
            g_poly_offset[base] = g_poly_offset[tmp];
            memcpy((g_poly_coeffs + (base * MAX_POLY)), (g_poly_coeffs + (tmp * MAX_POLY)), (((int64_t)(g_poly_len[tmp])) * 8));
        }
    }
    g_poly_len[res_idx] = g_poly_len[res];
    g_poly_offset[res_idx] = g_poly_offset[res];
    memcpy((g_poly_coeffs + (res_idx * MAX_POLY)), (g_poly_coeffs + (res * MAX_POLY)), (((int64_t)(g_poly_len[res])) * 8));
}

int32_t main(void) {
    int32_t w = W;
    int32_t m = M;
    int32_t dmax = (w - 2);
    int32_t diff_count = ((2 * dmax) + 1);
    g_counts = calloc(((int64_t)((diff_count * XOR_SIZE))), 8);
    g_qhat = calloc(((int64_t)((XOR_SIZE * MAX_POLY))), 8);
    g_vec = calloc(((int64_t)(XOR_SIZE)), 8);
    g_poly_coeffs = calloc(((int64_t)((3 * MAX_POLY))), 8);
    g_poly_len = calloc(3, 4);
    g_poly_offset = calloc(3, 8);
    g_pmul_tmp = calloc(((int64_t)(MAX_POLY)), 8);
    int32_t k = 1;
    while (k < (w - 1)) {
        int32_t limit = (w - k);
        if (limit >= 2) {
            int32_t g = (k - 1);
            int32_t tmax = (limit - 2);
            int32_t t = 0;
            while (t <= tmax) {
                int32_t c = FLOW_CHECKED_DIV(((limit - t)), (2));
                if (c > 0) {
                    int32_t idx1 = (((dmax + t) * XOR_SIZE) + g);
                    g_counts[idx1] = FLOW_CHECKED_MOD(((g_counts[idx1] + ((int64_t)(c)))), (MOD));
                    if (t != 0) {
                        int32_t idx2 = (((dmax - t) * XOR_SIZE) + g);
                        g_counts[idx2] = FLOW_CHECKED_MOD(((g_counts[idx2] + ((int64_t)(c)))), (MOD));
                    }
                }
                t = (t + 1);
            }
        }
        k = (k + 1);
    }
    int32_t d = 0;
    while (d < diff_count) {
        fwt_xor_ptr_i64_i32_i32((g_counts + (d * XOR_SIZE)), XOR_SIZE, 0);
        d = (d + 1);
    }
    int32_t final_offset = (m * dmax);
    int32_t final_len = ((2 * final_offset) + 1);
    int32_t t = 0;
    while (t < XOR_SIZE) {
        g_poly_len[0] = diff_count;
        g_poly_offset[0] = dmax;
        int32_t di = 0;
        while (di < diff_count) {
            g_poly_coeffs[((0 * MAX_POLY) + di)] = g_counts[((di * XOR_SIZE) + t)];
            di = (di + 1);
        }
        poly_pow_i32_i32_i32(1, 0, m);
        int32_t i = 0;
        while (i < g_poly_len[1]) {
            if (i < final_len) {
                g_qhat[((t * MAX_POLY) + i)] = g_poly_coeffs[((1 * MAX_POLY) + i)];
            }
            i = (i + 1);
        }
        t = (t + 1);
    }
    int64_t ans = 0;
    int32_t idx = 0;
    while (idx < final_len) {
        int32_t ti = 0;
        while (ti < XOR_SIZE) {
            g_vec[ti] = g_qhat[((ti * MAX_POLY) + idx)];
            ti = (ti + 1);
        }
        fwt_xor_ptr_i64_i32_i32(g_vec, XOR_SIZE, 1);
        int32_t total_diff = (idx - final_offset);
        if (total_diff > 0) {
            int64_t s = 0;
            int32_t ti2 = 0;
            while (ti2 < XOR_SIZE) {
                s = (s + g_vec[ti2]);
                if (s >= MOD) {
                    s = (s - MOD);
                }
                ti2 = (ti2 + 1);
            }
            ans = (ans + s);
            if (ans >= MOD) {
                ans = (ans - MOD);
            }
        } else {
            if (total_diff == 0) {
                int64_t s = 0;
                int32_t ti3 = 1;
                while (ti3 < XOR_SIZE) {
                    s = (s + g_vec[ti3]);
                    if (s >= MOD) {
                        s = (s - MOD);
                    }
                    ti3 = (ti3 + 1);
                }
                ans = (ans + s);
                if (ans >= MOD) {
                    ans = (ans - MOD);
                }
            }
        }
        idx = (idx + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @memset(!llvm.ptr, i32, i64) -> !llvm.ptr
  func.func private @memcpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  // Constant: XOR_SIZE
  llvm.mlir.global internal constant @XOR_SIZE(64 : i32) : i32
  // Constant: W
  llvm.mlir.global internal constant @W(64 : i32) : i32
  // Constant: M
  llvm.mlir.global internal constant @M(8 : i32) : i32
  // Constant: DMAX
  llvm.mlir.global internal constant @DMAX(62 : i32) : i32
  // Constant: DIFF_COUNT
  llvm.mlir.global internal constant @DIFF_COUNT(125 : i32) : i32
  // Constant: MAX_POLY
  llvm.mlir.global internal constant @MAX_POLY(1024 : i32) : i32
  // Module static: g_counts
  llvm.mlir.global internal @g_counts() {addr_space = 0 : i32} : !llvm.ptr {
    %0 = llvm.mlir.zero : !llvm.ptr
    llvm.return %0 : !llvm.ptr
  }
  // Module static: g_qhat
  llvm.mlir.global internal @g_qhat() {addr_space = 0 : i32} : !llvm.ptr {
    %1 = llvm.mlir.zero : !llvm.ptr
    llvm.return %1 : !llvm.ptr
  }
  // Module static: g_vec
  llvm.mlir.global internal @g_vec() {addr_space = 0 : i32} : !llvm.ptr {
    %2 = llvm.mlir.zero : !llvm.ptr
    llvm.return %2 : !llvm.ptr
  }
  // Module static: g_poly_coeffs
  llvm.mlir.global internal @g_poly_coeffs() {addr_space = 0 : i32} : !llvm.ptr {
    %3 = llvm.mlir.zero : !llvm.ptr
    llvm.return %3 : !llvm.ptr
  }
  // Module static: g_poly_len
  llvm.mlir.global internal @g_poly_len() {addr_space = 0 : i32} : !llvm.ptr {
    %4 = llvm.mlir.zero : !llvm.ptr
    llvm.return %4 : !llvm.ptr
  }
  // Module static: g_poly_offset
  llvm.mlir.global internal @g_poly_offset() {addr_space = 0 : i32} : !llvm.ptr {
    %5 = llvm.mlir.zero : !llvm.ptr
    llvm.return %5 : !llvm.ptr
  }
  // Module static: g_pmul_tmp
  llvm.mlir.global internal @g_pmul_tmp() {addr_space = 0 : i32} : !llvm.ptr {
    %6 = llvm.mlir.zero : !llvm.ptr
    llvm.return %6 : !llvm.ptr
  }
  func.func @powmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %7 = arith.constant 1 : i32
    %8 = arith.extsi %7 : i32 to i64
    %9 = llvm.mlir.constant(1 : i64) : i64
    %10 = llvm.alloca %9 x i64 : (i64) -> !llvm.ptr
    llvm.store %8, %10 : i64, !llvm.ptr
    %11 = arith.remsi %arg0, %arg2 : i64
    %12 = llvm.mlir.constant(1 : i64) : i64
    %13 = llvm.alloca %12 x i64 : (i64) -> !llvm.ptr
    llvm.store %11, %13 : i64, !llvm.ptr
    %14 = llvm.load %13 : !llvm.ptr -> i64
    %15 = arith.constant 0 : i32
    %17 = arith.extsi %15 : i32 to i64
    %16 = arith.cmpi slt, %14, %17 : i64
    cf.cond_br %16, ^bb0, ^bb1
    ^bb0:
      %18 = llvm.load %13 : !llvm.ptr -> i64
      %19 = arith.addi %18, %arg2 : i64
      llvm.store %19, %13 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %20 = llvm.mlir.constant(1 : i64) : i64
    %21 = llvm.alloca %20 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %21 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %22 = llvm.load %21 : !llvm.ptr -> i64
    %23 = arith.constant 0 : i32
    %25 = arith.extsi %23 : i32 to i64
    %24 = arith.cmpi sgt, %22, %25 : i64
    cf.cond_br %24, ^bb4, ^bb5
    ^bb4:
      %26 = llvm.load %21 : !llvm.ptr -> i64
      %27 = arith.constant 1 : i32
      %29 = arith.extsi %27 : i32 to i64
      %28 = arith.andi %26, %29 : i64
      %30 = arith.constant 1 : i32
      %32 = arith.extsi %30 : i32 to i64
      %31 = arith.cmpi eq, %28, %32 : i64
      cf.cond_br %31, ^bb6, ^bb7
      ^bb6:
        %33 = llvm.load %10 : !llvm.ptr -> i64
        %34 = arith.extsi %33 : i64 to i128
        %35 = llvm.load %13 : !llvm.ptr -> i64
        %36 = arith.extsi %35 : i64 to i128
        %37 = arith.extsi %arg2 : i64 to i128
        %39 = arith.trunci %34 : i128 to i64
        %40 = arith.trunci %36 : i128 to i64
        %38 = arith.muli %39, %40 : i64
        %42 = arith.trunci %37 : i128 to i64
        %41 = arith.remsi %38, %42 : i64
        llvm.store %41, %10 : i64, !llvm.ptr
        cf.br ^bb8
      ^bb7:
        cf.br ^bb8
      ^bb8:
      %43 = llvm.load %13 : !llvm.ptr -> i64
      %44 = arith.extsi %43 : i64 to i128
      %45 = llvm.load %13 : !llvm.ptr -> i64
      %46 = arith.extsi %45 : i64 to i128
      %47 = arith.extsi %arg2 : i64 to i128
      %49 = arith.trunci %44 : i128 to i64
      %50 = arith.trunci %46 : i128 to i64
      %48 = arith.muli %49, %50 : i64
      %52 = arith.trunci %47 : i128 to i64
      %51 = arith.remsi %48, %52 : i64
      llvm.store %51, %13 : i64, !llvm.ptr
      %53 = llvm.load %21 : !llvm.ptr -> i64
      %54 = arith.constant 1 : i32
      %56 = arith.extsi %54 : i32 to i64
      %55 = arith.shrsi %53, %56 : i64
      llvm.store %55, %21 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %57 = llvm.load %10 : !llvm.ptr -> i64
    func.return %57 : i64
  }
  func.func @fwt_xor(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> () {
    %58 = arith.constant 1 : i32
    %59 = llvm.mlir.constant(1 : i64) : i64
    %60 = llvm.alloca %59 x i32 : (i64) -> !llvm.ptr
    llvm.store %58, %60 : i32, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %61 = llvm.load %60 : !llvm.ptr -> i32
    %62 = arith.cmpi slt, %61, %arg1 : i32
    cf.cond_br %62, ^bb10, ^bb11
    ^bb10:
      %63 = llvm.load %60 : !llvm.ptr -> i32
      %64 = arith.constant 2 : i32
      %65 = arith.muli %63, %64 : i32
      %66 = arith.constant 0 : i32
      %67 = llvm.mlir.constant(1 : i64) : i64
      %68 = llvm.alloca %67 x i32 : (i64) -> !llvm.ptr
      llvm.store %66, %68 : i32, !llvm.ptr
      cf.br ^bb12
      ^bb12:
      %69 = llvm.load %68 : !llvm.ptr -> i32
      %70 = arith.cmpi slt, %69, %arg1 : i32
      cf.cond_br %70, ^bb13, ^bb14
      ^bb13:
        %71 = llvm.load %68 : !llvm.ptr -> i32
        %72 = llvm.mlir.constant(1 : i64) : i64
        %73 = llvm.alloca %72 x i32 : (i64) -> !llvm.ptr
        llvm.store %71, %73 : i32, !llvm.ptr
        cf.br ^bb15
        ^bb15:
        %74 = llvm.load %73 : !llvm.ptr -> i32
        %75 = llvm.load %68 : !llvm.ptr -> i32
        %76 = llvm.load %60 : !llvm.ptr -> i32
        %77 = arith.addi %75, %76 : i32
        %78 = arith.cmpi slt, %74, %77 : i32
        cf.cond_br %78, ^bb16, ^bb17
        ^bb16:
          %80 = llvm.load %73 : !llvm.ptr -> i32
          %81 = arith.extsi %80 : i32 to i64
          %82 = llvm.getelementptr %arg0[%81] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %79 = llvm.load %82 : !llvm.ptr -> i64
          %84 = llvm.load %73 : !llvm.ptr -> i32
          %85 = llvm.load %60 : !llvm.ptr -> i32
          %86 = arith.addi %84, %85 : i32
          %87 = arith.extsi %86 : i32 to i64
          %88 = llvm.getelementptr %arg0[%87] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %83 = llvm.load %88 : !llvm.ptr -> i64
          %89 = arith.addi %79, %83 : i64
          %90 = llvm.mlir.constant(1 : i64) : i64
          %91 = llvm.alloca %90 x i64 : (i64) -> !llvm.ptr
          llvm.store %89, %91 : i64, !llvm.ptr
          %92 = llvm.load %91 : !llvm.ptr -> i64
          %93 = llvm.mlir.addressof @MOD : !llvm.ptr
          %94 = llvm.load %93 : !llvm.ptr -> i64
          %95 = arith.cmpi sge, %92, %94 : i64
          cf.cond_br %95, ^bb18, ^bb19
          ^bb18:
            %96 = llvm.load %91 : !llvm.ptr -> i64
            %97 = llvm.mlir.addressof @MOD : !llvm.ptr
            %98 = llvm.load %97 : !llvm.ptr -> i64
            %99 = arith.subi %96, %98 : i64
            llvm.store %99, %91 : i64, !llvm.ptr
            cf.br ^bb20
          ^bb19:
            cf.br ^bb20
          ^bb20:
          %100 = arith.subi %79, %83 : i64
          %101 = llvm.mlir.constant(1 : i64) : i64
          %102 = llvm.alloca %101 x i64 : (i64) -> !llvm.ptr
          llvm.store %100, %102 : i64, !llvm.ptr
          %103 = llvm.load %102 : !llvm.ptr -> i64
          %104 = arith.constant 0 : i32
          %106 = arith.extsi %104 : i32 to i64
          %105 = arith.cmpi slt, %103, %106 : i64
          cf.cond_br %105, ^bb21, ^bb22
          ^bb21:
            %107 = llvm.load %102 : !llvm.ptr -> i64
            %108 = llvm.mlir.addressof @MOD : !llvm.ptr
            %109 = llvm.load %108 : !llvm.ptr -> i64
            %110 = arith.addi %107, %109 : i64
            llvm.store %110, %102 : i64, !llvm.ptr
            cf.br ^bb23
          ^bb22:
            cf.br ^bb23
          ^bb23:
          %111 = llvm.load %91 : !llvm.ptr -> i64
          %112 = llvm.load %73 : !llvm.ptr -> i32
          %113 = arith.extsi %112 : i32 to i64
          %114 = llvm.getelementptr %arg0[%113] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %111, %114 : i64, !llvm.ptr
          %115 = llvm.load %102 : !llvm.ptr -> i64
          %116 = llvm.load %73 : !llvm.ptr -> i32
          %117 = llvm.load %60 : !llvm.ptr -> i32
          %118 = arith.addi %116, %117 : i32
          %119 = arith.extsi %118 : i32 to i64
          %120 = llvm.getelementptr %arg0[%119] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %115, %120 : i64, !llvm.ptr
          %121 = llvm.load %73 : !llvm.ptr -> i32
          %122 = arith.constant 1 : i32
          %123 = arith.addi %121, %122 : i32
          llvm.store %123, %73 : i32, !llvm.ptr
          cf.br ^bb15
        ^bb17:
        %124 = llvm.load %68 : !llvm.ptr -> i32
        %125 = arith.addi %124, %65 : i32
        llvm.store %125, %68 : i32, !llvm.ptr
        cf.br ^bb12
      ^bb14:
      llvm.store %65, %60 : i32, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %126 = arith.constant 0 : i32
    %127 = arith.cmpi ne, %arg2, %126 : i32
    cf.cond_br %127, ^bb24, ^bb25
    ^bb24:
      %129 = arith.extsi %arg1 : i32 to i64
      %130 = llvm.mlir.addressof @MOD : !llvm.ptr
      %131 = llvm.load %130 : !llvm.ptr -> i64
      %132 = arith.constant 2 : i32
      %134 = arith.extsi %132 : i32 to i64
      %133 = arith.subi %131, %134 : i64
      %135 = llvm.mlir.addressof @MOD : !llvm.ptr
      %136 = llvm.load %135 : !llvm.ptr -> i64
      %128 = func.call @powmod(%129, %133, %136) : (i64, i64, i64) -> i64
      %137 = arith.constant 0 : i32
      %138 = llvm.mlir.constant(1 : i64) : i64
      %139 = llvm.alloca %138 x i32 : (i64) -> !llvm.ptr
      llvm.store %137, %139 : i32, !llvm.ptr
      cf.br ^bb27
      ^bb27:
      %140 = llvm.load %139 : !llvm.ptr -> i32
      %141 = arith.cmpi slt, %140, %arg1 : i32
      cf.cond_br %141, ^bb28, ^bb29
      ^bb28:
        %143 = llvm.load %139 : !llvm.ptr -> i32
        %144 = arith.extsi %143 : i32 to i64
        %145 = llvm.getelementptr %arg0[%144] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %142 = llvm.load %145 : !llvm.ptr -> i64
        %146 = arith.extsi %142 : i64 to i128
        %147 = arith.extsi %128 : i64 to i128
        %148 = llvm.mlir.addressof @MOD : !llvm.ptr
        %149 = llvm.load %148 : !llvm.ptr -> i64
        %150 = arith.extsi %149 : i64 to i128
        %152 = arith.trunci %146 : i128 to i64
        %153 = arith.trunci %147 : i128 to i64
        %151 = arith.muli %152, %153 : i64
        %155 = arith.trunci %150 : i128 to i64
        %154 = arith.remsi %151, %155 : i64
        %156 = llvm.load %139 : !llvm.ptr -> i32
        %157 = arith.extsi %156 : i32 to i64
        %158 = llvm.getelementptr %arg0[%157] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %154, %158 : i64, !llvm.ptr
        %159 = llvm.load %139 : !llvm.ptr -> i32
        %160 = arith.constant 1 : i32
        %161 = arith.addi %159, %160 : i32
        llvm.store %161, %139 : i32, !llvm.ptr
        cf.br ^bb27
      ^bb29:
      cf.br ^bb26
    ^bb25:
      cf.br ^bb26
    ^bb26:
    func.return
  }
  func.func @poly_mul(%arg0: i32, %arg1: i32, %arg2: i32) -> () {
    %163 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %164 = llvm.load %163 : !llvm.ptr -> !llvm.ptr
    %165 = arith.extsi %arg1 : i32 to i64
    %166 = llvm.getelementptr %164[%165] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %162 = llvm.load %166 : !llvm.ptr -> i32
    %168 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %169 = llvm.load %168 : !llvm.ptr -> !llvm.ptr
    %170 = arith.extsi %arg2 : i32 to i64
    %171 = llvm.getelementptr %169[%170] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %167 = llvm.load %171 : !llvm.ptr -> i32
    %172 = arith.cmpi slt, %162, %167 : i32
    %173, %174 = scf.if %172 -> (i32, i32) {
      scf.yield %arg2, %arg1 : i32, i32
    } else {
      scf.yield %arg1, %arg2 : i32, i32
    }
    %176 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %177 = llvm.load %176 : !llvm.ptr -> !llvm.ptr
    %178 = arith.extsi %173 : i32 to i64
    %179 = llvm.getelementptr %177[%178] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %175 = llvm.load %179 : !llvm.ptr -> i32
    %181 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %182 = llvm.load %181 : !llvm.ptr -> !llvm.ptr
    %183 = arith.extsi %174 : i32 to i64
    %184 = llvm.getelementptr %182[%183] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %180 = llvm.load %184 : !llvm.ptr -> i32
    %185 = arith.addi %175, %180 : i32
    %186 = arith.constant 1 : i32
    %187 = arith.subi %185, %186 : i32
    %189 = llvm.mlir.addressof @g_pmul_tmp : !llvm.ptr
    %190 = llvm.load %189 : !llvm.ptr -> !llvm.ptr
    %191 = arith.constant 0 : i32
    %192 = arith.extsi %187 : i32 to i64
    %193 = arith.constant 8 : i32
    %195 = arith.extsi %193 : i32 to i64
    %194 = arith.muli %192, %195 : i64
    %188 = func.call @memset(%190, %191, %194) : (!llvm.ptr, i32, i64) -> !llvm.ptr
    %196 = arith.constant 0 : i32
    %197 = llvm.mlir.constant(1 : i64) : i64
    %198 = llvm.alloca %197 x i32 : (i64) -> !llvm.ptr
    llvm.store %196, %198 : i32, !llvm.ptr
    cf.br ^bb30
    ^bb30:
    %199 = llvm.load %198 : !llvm.ptr -> i32
    %201 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %202 = llvm.load %201 : !llvm.ptr -> !llvm.ptr
    %203 = arith.extsi %173 : i32 to i64
    %204 = llvm.getelementptr %202[%203] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %200 = llvm.load %204 : !llvm.ptr -> i32
    %205 = arith.cmpi slt, %199, %200 : i32
    cf.cond_br %205, ^bb31, ^bb32
    ^bb31:
      %207 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
      %208 = llvm.load %207 : !llvm.ptr -> !llvm.ptr
      %209 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
      %210 = llvm.load %209 : !llvm.ptr -> i32
      %211 = arith.muli %173, %210 : i32
      %212 = llvm.load %198 : !llvm.ptr -> i32
      %213 = arith.addi %211, %212 : i32
      %214 = arith.extsi %213 : i32 to i64
      %215 = llvm.getelementptr %208[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %206 = llvm.load %215 : !llvm.ptr -> i64
      %216 = arith.constant 0 : i32
      %218 = arith.extsi %216 : i32 to i64
      %217 = arith.cmpi ne, %206, %218 : i64
      cf.cond_br %217, ^bb33, ^bb34
      ^bb33:
        %219 = arith.constant 0 : i32
        %220 = llvm.mlir.constant(1 : i64) : i64
        %221 = llvm.alloca %220 x i32 : (i64) -> !llvm.ptr
        llvm.store %219, %221 : i32, !llvm.ptr
        cf.br ^bb36
        ^bb36:
        %222 = llvm.load %221 : !llvm.ptr -> i32
        %224 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %225 = llvm.load %224 : !llvm.ptr -> !llvm.ptr
        %226 = arith.extsi %174 : i32 to i64
        %227 = llvm.getelementptr %225[%226] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %223 = llvm.load %227 : !llvm.ptr -> i32
        %228 = arith.cmpi slt, %222, %223 : i32
        cf.cond_br %228, ^bb37, ^bb38
        ^bb37:
          %230 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
          %231 = llvm.load %230 : !llvm.ptr -> !llvm.ptr
          %232 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
          %233 = llvm.load %232 : !llvm.ptr -> i32
          %234 = arith.muli %174, %233 : i32
          %235 = llvm.load %221 : !llvm.ptr -> i32
          %236 = arith.addi %234, %235 : i32
          %237 = arith.extsi %236 : i32 to i64
          %238 = llvm.getelementptr %231[%237] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %229 = llvm.load %238 : !llvm.ptr -> i64
          %239 = arith.constant 0 : i32
          %241 = arith.extsi %239 : i32 to i64
          %240 = arith.cmpi ne, %229, %241 : i64
          cf.cond_br %240, ^bb39, ^bb40
          ^bb39:
            %243 = llvm.mlir.addressof @g_pmul_tmp : !llvm.ptr
            %244 = llvm.load %243 : !llvm.ptr -> !llvm.ptr
            %245 = llvm.load %198 : !llvm.ptr -> i32
            %246 = llvm.load %221 : !llvm.ptr -> i32
            %247 = arith.addi %245, %246 : i32
            %248 = arith.extsi %247 : i32 to i64
            %249 = llvm.getelementptr %244[%248] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %242 = llvm.load %249 : !llvm.ptr -> i64
            %250 = arith.extsi %242 : i64 to i128
            %252 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
            %253 = llvm.load %252 : !llvm.ptr -> !llvm.ptr
            %254 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
            %255 = llvm.load %254 : !llvm.ptr -> i32
            %256 = arith.muli %173, %255 : i32
            %257 = llvm.load %198 : !llvm.ptr -> i32
            %258 = arith.addi %256, %257 : i32
            %259 = arith.extsi %258 : i32 to i64
            %260 = llvm.getelementptr %253[%259] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %251 = llvm.load %260 : !llvm.ptr -> i64
            %261 = arith.extsi %251 : i64 to i128
            %263 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
            %264 = llvm.load %263 : !llvm.ptr -> !llvm.ptr
            %265 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
            %266 = llvm.load %265 : !llvm.ptr -> i32
            %267 = arith.muli %174, %266 : i32
            %268 = llvm.load %221 : !llvm.ptr -> i32
            %269 = arith.addi %267, %268 : i32
            %270 = arith.extsi %269 : i32 to i64
            %271 = llvm.getelementptr %264[%270] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %262 = llvm.load %271 : !llvm.ptr -> i64
            %272 = arith.extsi %262 : i64 to i128
            %273 = llvm.mlir.addressof @MOD : !llvm.ptr
            %274 = llvm.load %273 : !llvm.ptr -> i64
            %275 = arith.extsi %274 : i64 to i128
            %277 = arith.trunci %261 : i128 to i64
            %278 = arith.trunci %272 : i128 to i64
            %276 = arith.muli %277, %278 : i64
            %280 = arith.trunci %250 : i128 to i64
            %279 = arith.addi %280, %276 : i64
            %282 = arith.trunci %275 : i128 to i64
            %281 = arith.remsi %279, %282 : i64
            %283 = llvm.mlir.addressof @g_pmul_tmp : !llvm.ptr
            %284 = llvm.load %283 : !llvm.ptr -> !llvm.ptr
            %285 = llvm.load %198 : !llvm.ptr -> i32
            %286 = llvm.load %221 : !llvm.ptr -> i32
            %287 = arith.addi %285, %286 : i32
            %288 = arith.extsi %287 : i32 to i64
            %289 = llvm.getelementptr %284[%288] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %281, %289 : i64, !llvm.ptr
            cf.br ^bb41
          ^bb40:
            cf.br ^bb41
          ^bb41:
          %290 = llvm.load %221 : !llvm.ptr -> i32
          %291 = arith.constant 1 : i32
          %292 = arith.addi %290, %291 : i32
          llvm.store %292, %221 : i32, !llvm.ptr
          cf.br ^bb36
        ^bb38:
        cf.br ^bb35
      ^bb34:
        cf.br ^bb35
      ^bb35:
      %293 = llvm.load %198 : !llvm.ptr -> i32
      %294 = arith.constant 1 : i32
      %295 = arith.addi %293, %294 : i32
      llvm.store %295, %198 : i32, !llvm.ptr
      cf.br ^bb30
    ^bb32:
    %296 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %297 = llvm.load %296 : !llvm.ptr -> !llvm.ptr
    %298 = arith.extsi %arg0 : i32 to i64
    %299 = llvm.getelementptr %297[%298] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %187, %299 : i32, !llvm.ptr
    %301 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %302 = llvm.load %301 : !llvm.ptr -> !llvm.ptr
    %303 = arith.extsi %arg1 : i32 to i64
    %304 = llvm.getelementptr %302[%303] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %300 = llvm.load %304 : !llvm.ptr -> i64
    %306 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %307 = llvm.load %306 : !llvm.ptr -> !llvm.ptr
    %308 = arith.extsi %arg2 : i32 to i64
    %309 = llvm.getelementptr %307[%308] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %305 = llvm.load %309 : !llvm.ptr -> i64
    %310 = arith.addi %300, %305 : i64
    %311 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %312 = llvm.load %311 : !llvm.ptr -> !llvm.ptr
    %313 = arith.extsi %arg0 : i32 to i64
    %314 = llvm.getelementptr %312[%313] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %310, %314 : i64, !llvm.ptr
    # String concatenation: !llvm.ptr + i32
    %317 = llvm.mlir.addressof @g_pmul_tmp : !llvm.ptr
    %318 = llvm.load %317 : !llvm.ptr -> !llvm.ptr
    %319 = arith.extsi %187 : i32 to i64
    %320 = arith.constant 8 : i32
    %322 = arith.extsi %320 : i32 to i64
    %321 = arith.muli %319, %322 : i64
    %315 = func.call @memcpy(%316, %318, %321) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
    func.return
  }
  func.func @poly_pow(%arg0: i32, %arg1: i32, %arg2: i32) -> () {
    %323 = arith.constant 1 : i32
    %325 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %326 = llvm.load %325 : !llvm.ptr -> !llvm.ptr
    %327 = arith.extsi %arg1 : i32 to i64
    %328 = llvm.getelementptr %326[%327] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %324 = llvm.load %328 : !llvm.ptr -> i32
    %329 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %330 = llvm.load %329 : !llvm.ptr -> !llvm.ptr
    %331 = arith.extsi %323 : i32 to i64
    %332 = llvm.getelementptr %330[%331] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %324, %332 : i32, !llvm.ptr
    %334 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %335 = llvm.load %334 : !llvm.ptr -> !llvm.ptr
    %336 = arith.extsi %arg1 : i32 to i64
    %337 = llvm.getelementptr %335[%336] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %333 = llvm.load %337 : !llvm.ptr -> i64
    %338 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %339 = llvm.load %338 : !llvm.ptr -> !llvm.ptr
    %340 = arith.extsi %323 : i32 to i64
    %341 = llvm.getelementptr %339[%340] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %333, %341 : i64, !llvm.ptr
    # String concatenation: !llvm.ptr + i32
    # String concatenation: !llvm.ptr + i32
    %346 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %347 = llvm.load %346 : !llvm.ptr -> !llvm.ptr
    %348 = arith.extsi %arg1 : i32 to i64
    %349 = llvm.getelementptr %347[%348] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %345 = llvm.load %349 : !llvm.ptr -> i32
    %350 = arith.extsi %345 : i32 to i64
    %351 = arith.constant 8 : i32
    %353 = arith.extsi %351 : i32 to i64
    %352 = arith.muli %350, %353 : i64
    %342 = func.call @memcpy(%343, %344, %352) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
    %354 = arith.constant 0 : i32
    %355 = arith.constant 1 : i32
    %356 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %357 = llvm.load %356 : !llvm.ptr -> !llvm.ptr
    %358 = arith.extsi %354 : i32 to i64
    %359 = llvm.getelementptr %357[%358] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %355, %359 : i32, !llvm.ptr
    %360 = arith.constant 0 : i32
    %361 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %362 = llvm.load %361 : !llvm.ptr -> !llvm.ptr
    %363 = arith.extsi %360 : i32 to i64
    %364 = arith.extsi %354 : i32 to i64
    %365 = llvm.getelementptr %362[%364] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %363, %365 : i64, !llvm.ptr
    %366 = arith.constant 1 : i32
    %367 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
    %368 = llvm.load %367 : !llvm.ptr -> !llvm.ptr
    %369 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
    %370 = llvm.load %369 : !llvm.ptr -> i32
    %371 = arith.muli %354, %370 : i32
    %372 = arith.constant 0 : i32
    %373 = arith.addi %371, %372 : i32
    %374 = arith.extsi %366 : i32 to i64
    %375 = arith.extsi %373 : i32 to i64
    %376 = llvm.getelementptr %368[%375] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %374, %376 : i64, !llvm.ptr
    %377 = arith.constant 2 : i32
    %378 = llvm.mlir.constant(1 : i64) : i64
    %379 = llvm.alloca %378 x i32 : (i64) -> !llvm.ptr
    llvm.store %arg2, %379 : i32, !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %380 = llvm.load %379 : !llvm.ptr -> i32
    %381 = arith.constant 0 : i32
    %382 = arith.cmpi sgt, %380, %381 : i32
    cf.cond_br %382, ^bb43, ^bb44
    ^bb43:
      %383 = llvm.load %379 : !llvm.ptr -> i32
      %384 = arith.constant 1 : i32
      %385 = arith.andi %383, %384 : i32
      %386 = arith.constant 1 : i32
      %387 = arith.cmpi eq, %385, %386 : i32
      cf.cond_br %387, ^bb45, ^bb46
      ^bb45:
        func.call @poly_mul(%377, %354, %323) : (i32, i32, i32) -> ()
        %390 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %391 = llvm.load %390 : !llvm.ptr -> !llvm.ptr
        %392 = arith.extsi %377 : i32 to i64
        %393 = llvm.getelementptr %391[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %389 = llvm.load %393 : !llvm.ptr -> i32
        %394 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %395 = llvm.load %394 : !llvm.ptr -> !llvm.ptr
        %396 = arith.extsi %354 : i32 to i64
        %397 = llvm.getelementptr %395[%396] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %389, %397 : i32, !llvm.ptr
        %399 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
        %400 = llvm.load %399 : !llvm.ptr -> !llvm.ptr
        %401 = arith.extsi %377 : i32 to i64
        %402 = llvm.getelementptr %400[%401] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %398 = llvm.load %402 : !llvm.ptr -> i64
        %403 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
        %404 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
        %405 = arith.extsi %354 : i32 to i64
        %406 = llvm.getelementptr %404[%405] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %398, %406 : i64, !llvm.ptr
        # String concatenation: !llvm.ptr + i32
        # String concatenation: !llvm.ptr + i32
        %411 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %412 = llvm.load %411 : !llvm.ptr -> !llvm.ptr
        %413 = arith.extsi %377 : i32 to i64
        %414 = llvm.getelementptr %412[%413] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %410 = llvm.load %414 : !llvm.ptr -> i32
        %415 = arith.extsi %410 : i32 to i64
        %416 = arith.constant 8 : i32
        %418 = arith.extsi %416 : i32 to i64
        %417 = arith.muli %415, %418 : i64
        %407 = func.call @memcpy(%408, %409, %417) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
        cf.br ^bb47
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %419 = llvm.load %379 : !llvm.ptr -> i32
      %420 = arith.constant 1 : i32
      %421 = arith.shrsi %419, %420 : i32
      llvm.store %421, %379 : i32, !llvm.ptr
      %422 = llvm.load %379 : !llvm.ptr -> i32
      %423 = arith.constant 0 : i32
      %424 = arith.cmpi ne, %422, %423 : i32
      cf.cond_br %424, ^bb48, ^bb49
      ^bb48:
        func.call @poly_mul(%377, %323, %323) : (i32, i32, i32) -> ()
        %427 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %428 = llvm.load %427 : !llvm.ptr -> !llvm.ptr
        %429 = arith.extsi %377 : i32 to i64
        %430 = llvm.getelementptr %428[%429] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %426 = llvm.load %430 : !llvm.ptr -> i32
        %431 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %432 = llvm.load %431 : !llvm.ptr -> !llvm.ptr
        %433 = arith.extsi %323 : i32 to i64
        %434 = llvm.getelementptr %432[%433] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %426, %434 : i32, !llvm.ptr
        %436 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
        %437 = llvm.load %436 : !llvm.ptr -> !llvm.ptr
        %438 = arith.extsi %377 : i32 to i64
        %439 = llvm.getelementptr %437[%438] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %435 = llvm.load %439 : !llvm.ptr -> i64
        %440 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
        %441 = llvm.load %440 : !llvm.ptr -> !llvm.ptr
        %442 = arith.extsi %323 : i32 to i64
        %443 = llvm.getelementptr %441[%442] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %435, %443 : i64, !llvm.ptr
        # String concatenation: !llvm.ptr + i32
        # String concatenation: !llvm.ptr + i32
        %448 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
        %449 = llvm.load %448 : !llvm.ptr -> !llvm.ptr
        %450 = arith.extsi %377 : i32 to i64
        %451 = llvm.getelementptr %449[%450] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %447 = llvm.load %451 : !llvm.ptr -> i32
        %452 = arith.extsi %447 : i32 to i64
        %453 = arith.constant 8 : i32
        %455 = arith.extsi %453 : i32 to i64
        %454 = arith.muli %452, %455 : i64
        %444 = func.call @memcpy(%445, %446, %454) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
        cf.br ^bb50
      ^bb49:
        cf.br ^bb50
      ^bb50:
      cf.br ^bb42
    ^bb44:
    %457 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %458 = llvm.load %457 : !llvm.ptr -> !llvm.ptr
    %459 = arith.extsi %354 : i32 to i64
    %460 = llvm.getelementptr %458[%459] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %456 = llvm.load %460 : !llvm.ptr -> i32
    %461 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %462 = llvm.load %461 : !llvm.ptr -> !llvm.ptr
    %463 = arith.extsi %arg0 : i32 to i64
    %464 = llvm.getelementptr %462[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %456, %464 : i32, !llvm.ptr
    %466 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %467 = llvm.load %466 : !llvm.ptr -> !llvm.ptr
    %468 = arith.extsi %354 : i32 to i64
    %469 = llvm.getelementptr %467[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %465 = llvm.load %469 : !llvm.ptr -> i64
    %470 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    %471 = llvm.load %470 : !llvm.ptr -> !llvm.ptr
    %472 = arith.extsi %arg0 : i32 to i64
    %473 = llvm.getelementptr %471[%472] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %465, %473 : i64, !llvm.ptr
    # String concatenation: !llvm.ptr + i32
    # String concatenation: !llvm.ptr + i32
    %478 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    %479 = llvm.load %478 : !llvm.ptr -> !llvm.ptr
    %480 = arith.extsi %354 : i32 to i64
    %481 = llvm.getelementptr %479[%480] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %477 = llvm.load %481 : !llvm.ptr -> i32
    %482 = arith.extsi %477 : i32 to i64
    %483 = arith.constant 8 : i32
    %485 = arith.extsi %483 : i32 to i64
    %484 = arith.muli %482, %485 : i64
    %474 = func.call @memcpy(%475, %476, %484) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
    func.return
  }
  func.func @main() -> i32 {
    %486 = llvm.mlir.addressof @W : !llvm.ptr
    %487 = llvm.load %486 : !llvm.ptr -> i32
    %488 = llvm.mlir.addressof @M : !llvm.ptr
    %489 = llvm.load %488 : !llvm.ptr -> i32
    %490 = arith.constant 2 : i32
    %491 = arith.subi %487, %490 : i32
    %492 = arith.constant 2 : i32
    %493 = arith.muli %492, %491 : i32
    %494 = arith.constant 1 : i32
    %495 = arith.addi %493, %494 : i32
    %497 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
    %498 = llvm.load %497 : !llvm.ptr -> i32
    %499 = arith.muli %495, %498 : i32
    %500 = arith.extsi %499 : i32 to i64
    %501 = arith.constant 8 : i32
    %502 = arith.extsi %501 : i32 to i64
    %496 = func.call @calloc(%500, %502) : (i64, i64) -> !llvm.ptr
    %503 = llvm.mlir.addressof @g_counts : !llvm.ptr
    llvm.store %496, %503 : !llvm.ptr, !llvm.ptr
    %505 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
    %506 = llvm.load %505 : !llvm.ptr -> i32
    %507 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
    %508 = llvm.load %507 : !llvm.ptr -> i32
    %509 = arith.muli %506, %508 : i32
    %510 = arith.extsi %509 : i32 to i64
    %511 = arith.constant 8 : i32
    %512 = arith.extsi %511 : i32 to i64
    %504 = func.call @calloc(%510, %512) : (i64, i64) -> !llvm.ptr
    %513 = llvm.mlir.addressof @g_qhat : !llvm.ptr
    llvm.store %504, %513 : !llvm.ptr, !llvm.ptr
    %515 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
    %516 = llvm.load %515 : !llvm.ptr -> i32
    %517 = arith.extsi %516 : i32 to i64
    %518 = arith.constant 8 : i32
    %519 = arith.extsi %518 : i32 to i64
    %514 = func.call @calloc(%517, %519) : (i64, i64) -> !llvm.ptr
    %520 = llvm.mlir.addressof @g_vec : !llvm.ptr
    llvm.store %514, %520 : !llvm.ptr, !llvm.ptr
    %522 = arith.constant 3 : i32
    %523 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
    %524 = llvm.load %523 : !llvm.ptr -> i32
    %525 = arith.muli %522, %524 : i32
    %526 = arith.extsi %525 : i32 to i64
    %527 = arith.constant 8 : i32
    %528 = arith.extsi %527 : i32 to i64
    %521 = func.call @calloc(%526, %528) : (i64, i64) -> !llvm.ptr
    %529 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
    llvm.store %521, %529 : !llvm.ptr, !llvm.ptr
    %531 = arith.constant 3 : i32
    %532 = arith.constant 4 : i32
    %533 = arith.extsi %531 : i32 to i64
    %534 = arith.extsi %532 : i32 to i64
    %530 = func.call @calloc(%533, %534) : (i64, i64) -> !llvm.ptr
    %535 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
    llvm.store %530, %535 : !llvm.ptr, !llvm.ptr
    %537 = arith.constant 3 : i32
    %538 = arith.constant 8 : i32
    %539 = arith.extsi %537 : i32 to i64
    %540 = arith.extsi %538 : i32 to i64
    %536 = func.call @calloc(%539, %540) : (i64, i64) -> !llvm.ptr
    %541 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
    llvm.store %536, %541 : !llvm.ptr, !llvm.ptr
    %543 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
    %544 = llvm.load %543 : !llvm.ptr -> i32
    %545 = arith.extsi %544 : i32 to i64
    %546 = arith.constant 8 : i32
    %547 = arith.extsi %546 : i32 to i64
    %542 = func.call @calloc(%545, %547) : (i64, i64) -> !llvm.ptr
    %548 = llvm.mlir.addressof @g_pmul_tmp : !llvm.ptr
    llvm.store %542, %548 : !llvm.ptr, !llvm.ptr
    %549 = arith.constant 1 : i32
    %550 = llvm.mlir.constant(1 : i64) : i64
    %551 = llvm.alloca %550 x i32 : (i64) -> !llvm.ptr
    llvm.store %549, %551 : i32, !llvm.ptr
    cf.br ^bb51
    ^bb51:
    %552 = llvm.load %551 : !llvm.ptr -> i32
    %553 = arith.constant 1 : i32
    %554 = arith.subi %487, %553 : i32
    %555 = arith.cmpi slt, %552, %554 : i32
    cf.cond_br %555, ^bb52, ^bb53
    ^bb52:
      %556 = llvm.load %551 : !llvm.ptr -> i32
      %557 = arith.subi %487, %556 : i32
      %558 = arith.constant 2 : i32
      %559 = arith.cmpi sge, %557, %558 : i32
      cf.cond_br %559, ^bb54, ^bb55
      ^bb54:
        %560 = llvm.load %551 : !llvm.ptr -> i32
        %561 = arith.constant 1 : i32
        %562 = arith.subi %560, %561 : i32
        %563 = arith.constant 2 : i32
        %564 = arith.subi %557, %563 : i32
        %565 = arith.constant 0 : i32
        %566 = llvm.mlir.constant(1 : i64) : i64
        %567 = llvm.alloca %566 x i32 : (i64) -> !llvm.ptr
        llvm.store %565, %567 : i32, !llvm.ptr
        cf.br ^bb57
        ^bb57:
        %568 = llvm.load %567 : !llvm.ptr -> i32
        %569 = arith.cmpi sle, %568, %564 : i32
        cf.cond_br %569, ^bb58, ^bb59
        ^bb58:
          %570 = llvm.load %567 : !llvm.ptr -> i32
          %571 = arith.subi %557, %570 : i32
          %572 = arith.constant 2 : i32
          %573 = arith.divsi %571, %572 : i32
          %574 = arith.constant 0 : i32
          %575 = arith.cmpi sgt, %573, %574 : i32
          cf.cond_br %575, ^bb60, ^bb61
          ^bb60:
            %576 = llvm.load %567 : !llvm.ptr -> i32
            %577 = arith.addi %491, %576 : i32
            %578 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
            %579 = llvm.load %578 : !llvm.ptr -> i32
            %580 = arith.muli %577, %579 : i32
            %581 = arith.addi %580, %562 : i32
            %583 = llvm.mlir.addressof @g_counts : !llvm.ptr
            %584 = llvm.load %583 : !llvm.ptr -> !llvm.ptr
            %585 = arith.extsi %581 : i32 to i64
            %586 = llvm.getelementptr %584[%585] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %582 = llvm.load %586 : !llvm.ptr -> i64
            %587 = arith.extsi %573 : i32 to i64
            %588 = arith.addi %582, %587 : i64
            %589 = llvm.mlir.addressof @MOD : !llvm.ptr
            %590 = llvm.load %589 : !llvm.ptr -> i64
            %591 = arith.remsi %588, %590 : i64
            %592 = llvm.mlir.addressof @g_counts : !llvm.ptr
            %593 = llvm.load %592 : !llvm.ptr -> !llvm.ptr
            %594 = arith.extsi %581 : i32 to i64
            %595 = llvm.getelementptr %593[%594] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %591, %595 : i64, !llvm.ptr
            %596 = llvm.load %567 : !llvm.ptr -> i32
            %597 = arith.constant 0 : i32
            %598 = arith.cmpi ne, %596, %597 : i32
            cf.cond_br %598, ^bb63, ^bb64
            ^bb63:
              %599 = llvm.load %567 : !llvm.ptr -> i32
              %600 = arith.subi %491, %599 : i32
              %601 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
              %602 = llvm.load %601 : !llvm.ptr -> i32
              %603 = arith.muli %600, %602 : i32
              %604 = arith.addi %603, %562 : i32
              %606 = llvm.mlir.addressof @g_counts : !llvm.ptr
              %607 = llvm.load %606 : !llvm.ptr -> !llvm.ptr
              %608 = arith.extsi %604 : i32 to i64
              %609 = llvm.getelementptr %607[%608] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %605 = llvm.load %609 : !llvm.ptr -> i64
              %610 = arith.extsi %573 : i32 to i64
              %611 = arith.addi %605, %610 : i64
              %612 = llvm.mlir.addressof @MOD : !llvm.ptr
              %613 = llvm.load %612 : !llvm.ptr -> i64
              %614 = arith.remsi %611, %613 : i64
              %615 = llvm.mlir.addressof @g_counts : !llvm.ptr
              %616 = llvm.load %615 : !llvm.ptr -> !llvm.ptr
              %617 = arith.extsi %604 : i32 to i64
              %618 = llvm.getelementptr %616[%617] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %614, %618 : i64, !llvm.ptr
              cf.br ^bb65
            ^bb64:
              cf.br ^bb65
            ^bb65:
            cf.br ^bb62
          ^bb61:
            cf.br ^bb62
          ^bb62:
          %619 = llvm.load %567 : !llvm.ptr -> i32
          %620 = arith.constant 1 : i32
          %621 = arith.addi %619, %620 : i32
          llvm.store %621, %567 : i32, !llvm.ptr
          cf.br ^bb57
        ^bb59:
        cf.br ^bb56
      ^bb55:
        cf.br ^bb56
      ^bb56:
      %622 = llvm.load %551 : !llvm.ptr -> i32
      %623 = arith.constant 1 : i32
      %624 = arith.addi %622, %623 : i32
      llvm.store %624, %551 : i32, !llvm.ptr
      cf.br ^bb51
    ^bb53:
    %625 = arith.constant 0 : i32
    %626 = llvm.mlir.constant(1 : i64) : i64
    %627 = llvm.alloca %626 x i32 : (i64) -> !llvm.ptr
    llvm.store %625, %627 : i32, !llvm.ptr
    cf.br ^bb66
    ^bb66:
    %628 = llvm.load %627 : !llvm.ptr -> i32
    %629 = arith.cmpi slt, %628, %495 : i32
    cf.cond_br %629, ^bb67, ^bb68
    ^bb67:
      # String concatenation: !llvm.ptr + i32
      %632 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
      %633 = llvm.load %632 : !llvm.ptr -> i32
      %634 = arith.constant 0 : i32
      func.call @fwt_xor(%631, %633, %634) : (!llvm.ptr, i32, i32) -> ()
      %635 = llvm.load %627 : !llvm.ptr -> i32
      %636 = arith.constant 1 : i32
      %637 = arith.addi %635, %636 : i32
      llvm.store %637, %627 : i32, !llvm.ptr
      cf.br ^bb66
    ^bb68:
    %638 = arith.muli %489, %491 : i32
    %639 = arith.constant 2 : i32
    %640 = arith.muli %639, %638 : i32
    %641 = arith.constant 1 : i32
    %642 = arith.addi %640, %641 : i32
    %643 = arith.constant 0 : i32
    %644 = llvm.mlir.constant(1 : i64) : i64
    %645 = llvm.alloca %644 x i32 : (i64) -> !llvm.ptr
    llvm.store %643, %645 : i32, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %646 = llvm.load %645 : !llvm.ptr -> i32
    %647 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
    %648 = llvm.load %647 : !llvm.ptr -> i32
    %649 = arith.cmpi slt, %646, %648 : i32
    cf.cond_br %649, ^bb70, ^bb71
    ^bb70:
      %650 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
      %651 = llvm.load %650 : !llvm.ptr -> !llvm.ptr
      %652 = arith.constant 0 : i32
      %653 = arith.extsi %652 : i32 to i64
      %654 = llvm.getelementptr %651[%653] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %495, %654 : i32, !llvm.ptr
      %655 = llvm.mlir.addressof @g_poly_offset : !llvm.ptr
      %656 = llvm.load %655 : !llvm.ptr -> !llvm.ptr
      %657 = arith.constant 0 : i32
      %658 = arith.extsi %491 : i32 to i64
      %659 = arith.extsi %657 : i32 to i64
      %660 = llvm.getelementptr %656[%659] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %658, %660 : i64, !llvm.ptr
      %661 = arith.constant 0 : i32
      %662 = llvm.mlir.constant(1 : i64) : i64
      %663 = llvm.alloca %662 x i32 : (i64) -> !llvm.ptr
      llvm.store %661, %663 : i32, !llvm.ptr
      cf.br ^bb72
      ^bb72:
      %664 = llvm.load %663 : !llvm.ptr -> i32
      %665 = arith.cmpi slt, %664, %495 : i32
      cf.cond_br %665, ^bb73, ^bb74
      ^bb73:
        %667 = llvm.mlir.addressof @g_counts : !llvm.ptr
        %668 = llvm.load %667 : !llvm.ptr -> !llvm.ptr
        %669 = llvm.load %663 : !llvm.ptr -> i32
        %670 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
        %671 = llvm.load %670 : !llvm.ptr -> i32
        %672 = arith.muli %669, %671 : i32
        %673 = llvm.load %645 : !llvm.ptr -> i32
        %674 = arith.addi %672, %673 : i32
        %675 = arith.extsi %674 : i32 to i64
        %676 = llvm.getelementptr %668[%675] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %666 = llvm.load %676 : !llvm.ptr -> i64
        %677 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
        %678 = llvm.load %677 : !llvm.ptr -> !llvm.ptr
        %679 = arith.constant 0 : i32
        %680 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
        %681 = llvm.load %680 : !llvm.ptr -> i32
        %682 = arith.muli %679, %681 : i32
        %683 = llvm.load %663 : !llvm.ptr -> i32
        %684 = arith.addi %682, %683 : i32
        %685 = arith.extsi %684 : i32 to i64
        %686 = llvm.getelementptr %678[%685] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %666, %686 : i64, !llvm.ptr
        %687 = llvm.load %663 : !llvm.ptr -> i32
        %688 = arith.constant 1 : i32
        %689 = arith.addi %687, %688 : i32
        llvm.store %689, %663 : i32, !llvm.ptr
        cf.br ^bb72
      ^bb74:
      %691 = arith.constant 1 : i32
      %692 = arith.constant 0 : i32
      func.call @poly_pow(%691, %692, %489) : (i32, i32, i32) -> ()
      %693 = arith.constant 0 : i32
      %694 = llvm.mlir.constant(1 : i64) : i64
      %695 = llvm.alloca %694 x i32 : (i64) -> !llvm.ptr
      llvm.store %693, %695 : i32, !llvm.ptr
      cf.br ^bb75
      ^bb75:
      %696 = llvm.load %695 : !llvm.ptr -> i32
      %698 = llvm.mlir.addressof @g_poly_len : !llvm.ptr
      %699 = llvm.load %698 : !llvm.ptr -> !llvm.ptr
      %700 = arith.constant 1 : i32
      %701 = arith.extsi %700 : i32 to i64
      %702 = llvm.getelementptr %699[%701] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %697 = llvm.load %702 : !llvm.ptr -> i32
      %703 = arith.cmpi slt, %696, %697 : i32
      cf.cond_br %703, ^bb76, ^bb77
      ^bb76:
        %704 = llvm.load %695 : !llvm.ptr -> i32
        %705 = arith.cmpi slt, %704, %642 : i32
        cf.cond_br %705, ^bb78, ^bb79
        ^bb78:
          %707 = llvm.mlir.addressof @g_poly_coeffs : !llvm.ptr
          %708 = llvm.load %707 : !llvm.ptr -> !llvm.ptr
          %709 = arith.constant 1 : i32
          %710 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
          %711 = llvm.load %710 : !llvm.ptr -> i32
          %712 = arith.muli %709, %711 : i32
          %713 = llvm.load %695 : !llvm.ptr -> i32
          %714 = arith.addi %712, %713 : i32
          %715 = arith.extsi %714 : i32 to i64
          %716 = llvm.getelementptr %708[%715] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %706 = llvm.load %716 : !llvm.ptr -> i64
          %717 = llvm.mlir.addressof @g_qhat : !llvm.ptr
          %718 = llvm.load %717 : !llvm.ptr -> !llvm.ptr
          %719 = llvm.load %645 : !llvm.ptr -> i32
          %720 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
          %721 = llvm.load %720 : !llvm.ptr -> i32
          %722 = arith.muli %719, %721 : i32
          %723 = llvm.load %695 : !llvm.ptr -> i32
          %724 = arith.addi %722, %723 : i32
          %725 = arith.extsi %724 : i32 to i64
          %726 = llvm.getelementptr %718[%725] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %706, %726 : i64, !llvm.ptr
          cf.br ^bb80
        ^bb79:
          cf.br ^bb80
        ^bb80:
        %727 = llvm.load %695 : !llvm.ptr -> i32
        %728 = arith.constant 1 : i32
        %729 = arith.addi %727, %728 : i32
        llvm.store %729, %695 : i32, !llvm.ptr
        cf.br ^bb75
      ^bb77:
      %730 = llvm.load %645 : !llvm.ptr -> i32
      %731 = arith.constant 1 : i32
      %732 = arith.addi %730, %731 : i32
      llvm.store %732, %645 : i32, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    %733 = arith.constant 0 : i32
    %734 = arith.extsi %733 : i32 to i64
    %735 = llvm.mlir.constant(1 : i64) : i64
    %736 = llvm.alloca %735 x i64 : (i64) -> !llvm.ptr
    llvm.store %734, %736 : i64, !llvm.ptr
    %737 = arith.constant 0 : i32
    %738 = llvm.mlir.constant(1 : i64) : i64
    %739 = llvm.alloca %738 x i32 : (i64) -> !llvm.ptr
    llvm.store %737, %739 : i32, !llvm.ptr
    cf.br ^bb81
    ^bb81:
    %740 = llvm.load %739 : !llvm.ptr -> i32
    %741 = arith.cmpi slt, %740, %642 : i32
    cf.cond_br %741, ^bb82, ^bb83
    ^bb82:
      %742 = arith.constant 0 : i32
      %743 = llvm.mlir.constant(1 : i64) : i64
      %744 = llvm.alloca %743 x i32 : (i64) -> !llvm.ptr
      llvm.store %742, %744 : i32, !llvm.ptr
      cf.br ^bb84
      ^bb84:
      %745 = llvm.load %744 : !llvm.ptr -> i32
      %746 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
      %747 = llvm.load %746 : !llvm.ptr -> i32
      %748 = arith.cmpi slt, %745, %747 : i32
      cf.cond_br %748, ^bb85, ^bb86
      ^bb85:
        %750 = llvm.mlir.addressof @g_qhat : !llvm.ptr
        %751 = llvm.load %750 : !llvm.ptr -> !llvm.ptr
        %752 = llvm.load %744 : !llvm.ptr -> i32
        %753 = llvm.mlir.addressof @MAX_POLY : !llvm.ptr
        %754 = llvm.load %753 : !llvm.ptr -> i32
        %755 = arith.muli %752, %754 : i32
        %756 = llvm.load %739 : !llvm.ptr -> i32
        %757 = arith.addi %755, %756 : i32
        %758 = arith.extsi %757 : i32 to i64
        %759 = llvm.getelementptr %751[%758] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %749 = llvm.load %759 : !llvm.ptr -> i64
        %760 = llvm.mlir.addressof @g_vec : !llvm.ptr
        %761 = llvm.load %760 : !llvm.ptr -> !llvm.ptr
        %762 = llvm.load %744 : !llvm.ptr -> i32
        %763 = arith.extsi %762 : i32 to i64
        %764 = llvm.getelementptr %761[%763] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %749, %764 : i64, !llvm.ptr
        %765 = llvm.load %744 : !llvm.ptr -> i32
        %766 = arith.constant 1 : i32
        %767 = arith.addi %765, %766 : i32
        llvm.store %767, %744 : i32, !llvm.ptr
        cf.br ^bb84
      ^bb86:
      %769 = llvm.mlir.addressof @g_vec : !llvm.ptr
      %770 = llvm.load %769 : !llvm.ptr -> !llvm.ptr
      %771 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
      %772 = llvm.load %771 : !llvm.ptr -> i32
      %773 = arith.constant 1 : i32
      func.call @fwt_xor(%770, %772, %773) : (!llvm.ptr, i32, i32) -> ()
      %774 = llvm.load %739 : !llvm.ptr -> i32
      %775 = arith.subi %774, %638 : i32
      %776 = arith.constant 0 : i32
      %777 = arith.cmpi sgt, %775, %776 : i32
      cf.cond_br %777, ^bb87, ^bb88
      ^bb87:
        %778 = arith.constant 0 : i32
        %779 = arith.extsi %778 : i32 to i64
        %780 = llvm.mlir.constant(1 : i64) : i64
        %781 = llvm.alloca %780 x i64 : (i64) -> !llvm.ptr
        llvm.store %779, %781 : i64, !llvm.ptr
        %782 = arith.constant 0 : i32
        %783 = llvm.mlir.constant(1 : i64) : i64
        %784 = llvm.alloca %783 x i32 : (i64) -> !llvm.ptr
        llvm.store %782, %784 : i32, !llvm.ptr
        cf.br ^bb90
        ^bb90:
        %785 = llvm.load %784 : !llvm.ptr -> i32
        %786 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
        %787 = llvm.load %786 : !llvm.ptr -> i32
        %788 = arith.cmpi slt, %785, %787 : i32
        cf.cond_br %788, ^bb91, ^bb92
        ^bb91:
          %789 = llvm.load %781 : !llvm.ptr -> i64
          %791 = llvm.mlir.addressof @g_vec : !llvm.ptr
          %792 = llvm.load %791 : !llvm.ptr -> !llvm.ptr
          %793 = llvm.load %784 : !llvm.ptr -> i32
          %794 = arith.extsi %793 : i32 to i64
          %795 = llvm.getelementptr %792[%794] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %790 = llvm.load %795 : !llvm.ptr -> i64
          %796 = arith.addi %789, %790 : i64
          llvm.store %796, %781 : i64, !llvm.ptr
          %797 = llvm.load %781 : !llvm.ptr -> i64
          %798 = llvm.mlir.addressof @MOD : !llvm.ptr
          %799 = llvm.load %798 : !llvm.ptr -> i64
          %800 = arith.cmpi sge, %797, %799 : i64
          cf.cond_br %800, ^bb93, ^bb94
          ^bb93:
            %801 = llvm.load %781 : !llvm.ptr -> i64
            %802 = llvm.mlir.addressof @MOD : !llvm.ptr
            %803 = llvm.load %802 : !llvm.ptr -> i64
            %804 = arith.subi %801, %803 : i64
            llvm.store %804, %781 : i64, !llvm.ptr
            cf.br ^bb95
          ^bb94:
            cf.br ^bb95
          ^bb95:
          %805 = llvm.load %784 : !llvm.ptr -> i32
          %806 = arith.constant 1 : i32
          %807 = arith.addi %805, %806 : i32
          llvm.store %807, %784 : i32, !llvm.ptr
          cf.br ^bb90
        ^bb92:
        %808 = llvm.load %736 : !llvm.ptr -> i64
        %809 = llvm.load %781 : !llvm.ptr -> i64
        %810 = arith.addi %808, %809 : i64
        llvm.store %810, %736 : i64, !llvm.ptr
        %811 = llvm.load %736 : !llvm.ptr -> i64
        %812 = llvm.mlir.addressof @MOD : !llvm.ptr
        %813 = llvm.load %812 : !llvm.ptr -> i64
        %814 = arith.cmpi sge, %811, %813 : i64
        cf.cond_br %814, ^bb96, ^bb97
        ^bb96:
          %815 = llvm.load %736 : !llvm.ptr -> i64
          %816 = llvm.mlir.addressof @MOD : !llvm.ptr
          %817 = llvm.load %816 : !llvm.ptr -> i64
          %818 = arith.subi %815, %817 : i64
          llvm.store %818, %736 : i64, !llvm.ptr
          cf.br ^bb98
        ^bb97:
          cf.br ^bb98
        ^bb98:
        cf.br ^bb89
      ^bb88:
        %819 = arith.constant 0 : i32
        %820 = arith.cmpi eq, %775, %819 : i32
        cf.cond_br %820, ^bb99, ^bb100
        ^bb99:
          %821 = arith.constant 0 : i32
          %822 = arith.extsi %821 : i32 to i64
          %823 = llvm.mlir.constant(1 : i64) : i64
          %824 = llvm.alloca %823 x i64 : (i64) -> !llvm.ptr
          llvm.store %822, %824 : i64, !llvm.ptr
          %825 = arith.constant 1 : i32
          %826 = llvm.mlir.constant(1 : i64) : i64
          %827 = llvm.alloca %826 x i32 : (i64) -> !llvm.ptr
          llvm.store %825, %827 : i32, !llvm.ptr
          cf.br ^bb102
          ^bb102:
          %828 = llvm.load %827 : !llvm.ptr -> i32
          %829 = llvm.mlir.addressof @XOR_SIZE : !llvm.ptr
          %830 = llvm.load %829 : !llvm.ptr -> i32
          %831 = arith.cmpi slt, %828, %830 : i32
          cf.cond_br %831, ^bb103, ^bb104
          ^bb103:
            %832 = llvm.load %824 : !llvm.ptr -> i64
            %834 = llvm.mlir.addressof @g_vec : !llvm.ptr
            %835 = llvm.load %834 : !llvm.ptr -> !llvm.ptr
            %836 = llvm.load %827 : !llvm.ptr -> i32
            %837 = arith.extsi %836 : i32 to i64
            %838 = llvm.getelementptr %835[%837] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %833 = llvm.load %838 : !llvm.ptr -> i64
            %839 = arith.addi %832, %833 : i64
            llvm.store %839, %824 : i64, !llvm.ptr
            %840 = llvm.load %824 : !llvm.ptr -> i64
            %841 = llvm.mlir.addressof @MOD : !llvm.ptr
            %842 = llvm.load %841 : !llvm.ptr -> i64
            %843 = arith.cmpi sge, %840, %842 : i64
            cf.cond_br %843, ^bb105, ^bb106
            ^bb105:
              %844 = llvm.load %824 : !llvm.ptr -> i64
              %845 = llvm.mlir.addressof @MOD : !llvm.ptr
              %846 = llvm.load %845 : !llvm.ptr -> i64
              %847 = arith.subi %844, %846 : i64
              llvm.store %847, %824 : i64, !llvm.ptr
              cf.br ^bb107
            ^bb106:
              cf.br ^bb107
            ^bb107:
            %848 = llvm.load %827 : !llvm.ptr -> i32
            %849 = arith.constant 1 : i32
            %850 = arith.addi %848, %849 : i32
            llvm.store %850, %827 : i32, !llvm.ptr
            cf.br ^bb102
          ^bb104:
          %851 = llvm.load %736 : !llvm.ptr -> i64
          %852 = llvm.load %824 : !llvm.ptr -> i64
          %853 = arith.addi %851, %852 : i64
          llvm.store %853, %736 : i64, !llvm.ptr
          %854 = llvm.load %736 : !llvm.ptr -> i64
          %855 = llvm.mlir.addressof @MOD : !llvm.ptr
          %856 = llvm.load %855 : !llvm.ptr -> i64
          %857 = arith.cmpi sge, %854, %856 : i64
          cf.cond_br %857, ^bb108, ^bb109
          ^bb108:
            %858 = llvm.load %736 : !llvm.ptr -> i64
            %859 = llvm.mlir.addressof @MOD : !llvm.ptr
            %860 = llvm.load %859 : !llvm.ptr -> i64
            %861 = arith.subi %858, %860 : i64
            llvm.store %861, %736 : i64, !llvm.ptr
            cf.br ^bb110
          ^bb109:
            cf.br ^bb110
          ^bb110:
          cf.br ^bb101
        ^bb100:
          cf.br ^bb101
        ^bb101:
        cf.br ^bb89
      ^bb89:
      %862 = llvm.load %739 : !llvm.ptr -> i32
      %863 = arith.constant 1 : i32
      %864 = arith.addi %862, %863 : i32
      llvm.store %864, %739 : i32, !llvm.ptr
      cf.br ^bb81
    ^bb83:
    %865 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %866 = llvm.load %736 : !llvm.ptr -> i64
    %867 = llvm.call @printf(%865, %866) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %868 = arith.constant 0 : i32
    func.return %868 : i32
  }
}