Problem 814

Mezzo-forte: count looking-direction assignments for 4n people on a circle where exactly half scream. S(10^3) mod 998244353. Transfer-matrix DP over 2x(2n) twisted ladder with width-2 columns.

Answer307159326
Output307159326
StatusPASS
Native helperno
Runtime270 ms
Peak memory1184 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)?
Space complexityO(n^2)?
ApproachFlow solutionNot curated
VerdictUnknown

Flow source

# Project Euler 814
# Mezzo-forte: count looking-direction assignments for 4n people on a circle
# where exactly half scream. S(10^3) mod 998244353.
# Transfer-matrix DP over 2x(2n) twisted ladder with width-2 columns.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
}

const MOD: i64 = 998244353

function swap2bits(x: i32) -> i32 {
    return ((x & 1) << 1) | ((x >> 1) & 1)
}

# Transition step: read from src, write to dst (dst is cleared first)
function do_transition(g_out: ptr<i32>, g_delta: ptr<i32>, g_cnt: ptr<i32>, g_sizes: ptr<i32>, src: ptr<i64>, dst: ptr<i64>, target: i32) -> void {
    let stride: i32 = target + 1
    let mut i: i32 = 0
    while i < 4 * stride {
        dst[i] = 0
        i = i + 1
    }
    let mut mask_in: i32 = 0
    while mask_in < 4 {
        let base_in: i32 = mask_in * stride
        let mut gi: i32 = 0
        while gi < g_sizes[mask_in] {
            let out_mask: i32 = g_out[mask_in * 7 + gi]
            let delta: i32 = g_delta[mask_in * 7 + gi]
            let cnt: i32 = g_cnt[mask_in * 7 + gi]
            let base_out: i32 = out_mask * stride
            let mut k: i32 = 0
            while k <= target - delta {
                let idx: i32 = k + delta
                let add: i64 = (src[base_in + k] * (cnt as i64)) % MOD
                let x: i64 = dst[base_out + idx] + add
                if x >= MOD { x = x - MOD }
                dst[base_out + idx] = x
                k = k + 1
            }
            gi = gi + 1
        }
        mask_in = mask_in + 1
    }
}

function main() -> i32 {
    let n: i32 = 1000
    let target: i32 = n
    let cols: i32 = 2 * n
    let stride: i32 = target + 1

    # GROUPS flat data: 4 masks x 7 entries each
    let g_out: ptr<i32> = calloc(28, 4)
    let g_delta: ptr<i32> = calloc(28, 4)
    let g_cnt: ptr<i32> = calloc(28, 4)
    let g_sizes: ptr<i32> = calloc(4, 4)

    # mask 0: {{0,0,3},{2,0,2},{1,0,2},{3,0,1},{0,1,1}}
    g_out[0]=0; g_delta[0]=0; g_cnt[0]=3
    g_out[1]=2; g_delta[1]=0; g_cnt[1]=2
    g_out[2]=1; g_delta[2]=0; g_cnt[2]=2
    g_out[3]=3; g_delta[3]=0; g_cnt[3]=1
    g_out[4]=0; g_delta[4]=1; g_cnt[4]=1
    # mask 1: {{0,1,3},{2,1,1},{1,0,2},{3,0,1},{0,0,1},{2,0,1}}
    g_out[7]=0; g_delta[7]=1; g_cnt[7]=3
    g_out[8]=2; g_delta[8]=1; g_cnt[8]=1
    g_out[9]=1; g_delta[9]=0; g_cnt[9]=2
    g_out[10]=3; g_delta[10]=0; g_cnt[10]=1
    g_out[11]=0; g_delta[11]=0; g_cnt[11]=1
    g_out[12]=2; g_delta[12]=0; g_cnt[12]=1
    # mask 2: {{0,1,3},{2,0,2},{0,0,1},{1,1,1},{3,0,1},{1,0,1}}
    g_out[14]=0; g_delta[14]=1; g_cnt[14]=3
    g_out[15]=2; g_delta[15]=0; g_cnt[15]=2
    g_out[16]=0; g_delta[16]=0; g_cnt[16]=1
    g_out[17]=1; g_delta[17]=1; g_cnt[17]=1
    g_out[18]=3; g_delta[18]=0; g_cnt[18]=1
    g_out[19]=1; g_delta[19]=0; g_cnt[19]=1
    # mask 3: {{0,2,1},{2,1,1},{0,1,3},{1,1,1},{3,0,1},{1,0,1},{2,0,1}}
    g_out[21]=0; g_delta[21]=2; g_cnt[21]=1
    g_out[22]=2; g_delta[22]=1; g_cnt[22]=1
    g_out[23]=0; g_delta[23]=1; g_cnt[23]=3
    g_out[24]=1; g_delta[24]=1; g_cnt[24]=1
    g_out[25]=3; g_delta[25]=0; g_cnt[25]=1
    g_out[26]=1; g_delta[26]=0; g_cnt[26]=1
    g_out[27]=2; g_delta[27]=0; g_cnt[27]=1

    g_sizes[0]=5; g_sizes[1]=6; g_sizes[2]=6; g_sizes[3]=7

    # Build GROUPS_LAST (swap out_mask bits)
    let gl_out: ptr<i32> = calloc(28, 4)
    let gl_delta: ptr<i32> = calloc(28, 4)
    let gl_cnt: ptr<i32> = calloc(28, 4)
    let mut mi: i32 = 0
    while mi < 4 {
        let mut j: i32 = 0
        while j < g_sizes[mi] {
            gl_out[mi * 7 + j] = swap2bits(g_out[mi * 7 + j])
            gl_delta[mi * 7 + j] = g_delta[mi * 7 + j]
            gl_cnt[mi * 7 + j] = g_cnt[mi * 7 + j]
            j = j + 1
        }
        mi = mi + 1
    }

    # Allocate dp buffers
    let dp: ptr<i64> = calloc((4 * stride) as i64, 8)
    let dpn: ptr<i64> = calloc((4 * stride) as i64, 8)

    let mut total: i64 = 0

    let mut init_in: i32 = 0
    while init_in < 4 {
        # Clear dp
        let mut i: i32 = 0
        while i < 4 * stride {
            dp[i] = 0
            i = i + 1
        }
        dp[init_in * stride] = 1

        # cur=0 means dp is current, cur=1 means dpn is current
        let mut cur: i32 = 0

        # Normal columns 0 .. cols-2
        let mut col: i32 = 0
        while col < cols - 1 {
            if cur == 0 {
                do_transition(g_out, g_delta, g_cnt, g_sizes, dp, dpn, target)
                cur = 1
            } else {
                do_transition(g_out, g_delta, g_cnt, g_sizes, dpn, dp, target)
                cur = 0
            }
            col = col + 1
        }

        # Final column (wrap-around with row swap)
        if cur == 0 {
            do_transition(gl_out, gl_delta, gl_cnt, g_sizes, dp, dpn, target)
            cur = 1
        } else {
            do_transition(gl_out, gl_delta, gl_cnt, g_sizes, dpn, dp, target)
            cur = 0
        }

        # Read result from current buffer
        let val: i64 = 0
        if cur == 0 {
            val = dp[init_in * stride + target]
        } else {
            val = dpn[init_in * stride + target]
        }
        total = (total + val) % MOD
        init_in = init_in + 1
    }

    printf("%lld\n", total)
    free(dp); free(dpn)
    free(g_out); free(g_delta); free(g_cnt); free(g_sizes)
    free(gl_out); free(gl_delta); free(gl_cnt)
    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; }

int32_t swap2bits_i32(int32_t x);
void do_transition_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i64_ptr_i64_i32(int32_t* g_out, int32_t* g_delta, int32_t* g_cnt, int32_t* g_sizes, int64_t* src, int64_t* dst, int32_t target);
int32_t main(void);

static const int64_t MOD = 998244353;



int32_t swap2bits_i32(int32_t x) {
    return (FLOW_CHECKED_SHL(((x & 1)), (1)) | (FLOW_CHECKED_SHR((x), (1)) & 1));
}

void do_transition_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i64_ptr_i64_i32(int32_t* g_out, int32_t* g_delta, int32_t* g_cnt, int32_t* g_sizes, int64_t* src, int64_t* dst, int32_t target) {
    int32_t stride = (target + 1);
    int32_t i = 0;
    while (i < (4 * stride)) {
        dst[i] = 0;
        i = (i + 1);
    }
    int32_t mask_in = 0;
    while (mask_in < 4) {
        int32_t base_in = (mask_in * stride);
        int32_t gi = 0;
        while (gi < g_sizes[mask_in]) {
            int32_t out_mask = g_out[((mask_in * 7) + gi)];
            int32_t delta = g_delta[((mask_in * 7) + gi)];
            int32_t cnt = g_cnt[((mask_in * 7) + gi)];
            int32_t base_out = (out_mask * stride);
            int32_t k = 0;
            while (k <= (target - delta)) {
                int32_t idx = (k + delta);
                int64_t add = FLOW_CHECKED_MOD(((src[(base_in + k)] * ((int64_t)(cnt)))), (MOD));
                int64_t x = (dst[(base_out + idx)] + add);
                if (x >= MOD) {
                    x = (x - MOD);
                }
                dst[(base_out + idx)] = x;
                k = (k + 1);
            }
            gi = (gi + 1);
        }
        mask_in = (mask_in + 1);
    }
}

int32_t main(void) {
    int32_t n = 1000;
    int32_t target = n;
    int32_t cols = (2 * n);
    int32_t stride = (target + 1);
    int32_t* g_out = (int32_t*)(calloc(28, 4));
    int32_t* g_delta = (int32_t*)(calloc(28, 4));
    int32_t* g_cnt = (int32_t*)(calloc(28, 4));
    int32_t* g_sizes = (int32_t*)(calloc(4, 4));
    g_out[0] = 0;
    g_delta[0] = 0;
    g_cnt[0] = 3;
    g_out[1] = 2;
    g_delta[1] = 0;
    g_cnt[1] = 2;
    g_out[2] = 1;
    g_delta[2] = 0;
    g_cnt[2] = 2;
    g_out[3] = 3;
    g_delta[3] = 0;
    g_cnt[3] = 1;
    g_out[4] = 0;
    g_delta[4] = 1;
    g_cnt[4] = 1;
    g_out[7] = 0;
    g_delta[7] = 1;
    g_cnt[7] = 3;
    g_out[8] = 2;
    g_delta[8] = 1;
    g_cnt[8] = 1;
    g_out[9] = 1;
    g_delta[9] = 0;
    g_cnt[9] = 2;
    g_out[10] = 3;
    g_delta[10] = 0;
    g_cnt[10] = 1;
    g_out[11] = 0;
    g_delta[11] = 0;
    g_cnt[11] = 1;
    g_out[12] = 2;
    g_delta[12] = 0;
    g_cnt[12] = 1;
    g_out[14] = 0;
    g_delta[14] = 1;
    g_cnt[14] = 3;
    g_out[15] = 2;
    g_delta[15] = 0;
    g_cnt[15] = 2;
    g_out[16] = 0;
    g_delta[16] = 0;
    g_cnt[16] = 1;
    g_out[17] = 1;
    g_delta[17] = 1;
    g_cnt[17] = 1;
    g_out[18] = 3;
    g_delta[18] = 0;
    g_cnt[18] = 1;
    g_out[19] = 1;
    g_delta[19] = 0;
    g_cnt[19] = 1;
    g_out[21] = 0;
    g_delta[21] = 2;
    g_cnt[21] = 1;
    g_out[22] = 2;
    g_delta[22] = 1;
    g_cnt[22] = 1;
    g_out[23] = 0;
    g_delta[23] = 1;
    g_cnt[23] = 3;
    g_out[24] = 1;
    g_delta[24] = 1;
    g_cnt[24] = 1;
    g_out[25] = 3;
    g_delta[25] = 0;
    g_cnt[25] = 1;
    g_out[26] = 1;
    g_delta[26] = 0;
    g_cnt[26] = 1;
    g_out[27] = 2;
    g_delta[27] = 0;
    g_cnt[27] = 1;
    g_sizes[0] = 5;
    g_sizes[1] = 6;
    g_sizes[2] = 6;
    g_sizes[3] = 7;
    int32_t* gl_out = (int32_t*)(calloc(28, 4));
    int32_t* gl_delta = (int32_t*)(calloc(28, 4));
    int32_t* gl_cnt = (int32_t*)(calloc(28, 4));
    int32_t mi = 0;
    while (mi < 4) {
        int32_t j = 0;
        while (j < g_sizes[mi]) {
            gl_out[((mi * 7) + j)] = swap2bits_i32(g_out[((mi * 7) + j)]);
            gl_delta[((mi * 7) + j)] = g_delta[((mi * 7) + j)];
            gl_cnt[((mi * 7) + j)] = g_cnt[((mi * 7) + j)];
            j = (j + 1);
        }
        mi = (mi + 1);
    }
    int64_t* dp = (int64_t*)(calloc(((int64_t)((4 * stride))), 8));
    int64_t* dpn = (int64_t*)(calloc(((int64_t)((4 * stride))), 8));
    int64_t total = 0;
    int32_t init_in = 0;
    while (init_in < 4) {
        int32_t i = 0;
        while (i < (4 * stride)) {
            dp[i] = 0;
            i = (i + 1);
        }
        dp[(init_in * stride)] = 1;
        int32_t cur = 0;
        int32_t col = 0;
        while (col < (cols - 1)) {
            if (cur == 0) {
                do_transition_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i64_ptr_i64_i32(g_out, g_delta, g_cnt, g_sizes, dp, dpn, target);
                cur = 1;
            } else {
                do_transition_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i64_ptr_i64_i32(g_out, g_delta, g_cnt, g_sizes, dpn, dp, target);
                cur = 0;
            }
            col = (col + 1);
        }
        if (cur == 0) {
            do_transition_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i64_ptr_i64_i32(gl_out, gl_delta, gl_cnt, g_sizes, dp, dpn, target);
            cur = 1;
        } else {
            do_transition_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i64_ptr_i64_i32(gl_out, gl_delta, gl_cnt, g_sizes, dpn, dp, target);
            cur = 0;
        }
        int64_t val = 0;
        if (cur == 0) {
            val = dp[((init_in * stride) + target)];
        } else {
            val = dpn[((init_in * stride) + target)];
        }
        total = FLOW_CHECKED_MOD(((total + val)), (MOD));
        init_in = (init_in + 1);
    }
    printf("%lld\n", total);
    free(dp);
    free(dpn);
    free(g_out);
    free(g_delta);
    free(g_cnt);
    free(g_sizes);
    free(gl_out);
    free(gl_delta);
    free(gl_cnt);
    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) -> ()
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(998244353 : i64) : i64
  func.func @swap2bits(%arg0: i32) -> i32 {
    %0 = arith.constant 1 : i32
    %1 = arith.andi %arg0, %0 : i32
    %2 = arith.constant 1 : i32
    %3 = arith.shli %1, %2 : i32
    %4 = arith.constant 1 : i32
    %5 = arith.shrsi %arg0, %4 : i32
    %6 = arith.constant 1 : i32
    %7 = arith.andi %5, %6 : i32
    %8 = arith.ori %3, %7 : i32
    func.return %8 : i32
  }
  func.func @do_transition(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i32) -> () {
    %9 = arith.constant 1 : i32
    %10 = arith.addi %arg6, %9 : i32
    %11 = arith.constant 0 : i32
    %12 = llvm.mlir.constant(1 : i64) : i64
    %13 = llvm.alloca %12 x i32 : (i64) -> !llvm.ptr
    llvm.store %11, %13 : i32, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %14 = llvm.load %13 : !llvm.ptr -> i32
    %15 = arith.constant 4 : i32
    %16 = arith.muli %15, %10 : i32
    %17 = arith.cmpi slt, %14, %16 : i32
    cf.cond_br %17, ^bb1, ^bb2
    ^bb1:
      %18 = arith.constant 0 : i32
      %19 = llvm.load %13 : !llvm.ptr -> i32
      %20 = arith.extsi %18 : i32 to i64
      %21 = arith.extsi %19 : i32 to i64
      %22 = llvm.getelementptr %arg5[%21] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %20, %22 : i64, !llvm.ptr
      %23 = llvm.load %13 : !llvm.ptr -> i32
      %24 = arith.constant 1 : i32
      %25 = arith.addi %23, %24 : i32
      llvm.store %25, %13 : i32, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %26 = arith.constant 0 : i32
    %27 = llvm.mlir.constant(1 : i64) : i64
    %28 = llvm.alloca %27 x i32 : (i64) -> !llvm.ptr
    llvm.store %26, %28 : i32, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %29 = llvm.load %28 : !llvm.ptr -> i32
    %30 = arith.constant 4 : i32
    %31 = arith.cmpi slt, %29, %30 : i32
    cf.cond_br %31, ^bb4, ^bb5
    ^bb4:
      %32 = llvm.load %28 : !llvm.ptr -> i32
      %33 = arith.muli %32, %10 : i32
      %34 = arith.constant 0 : i32
      %35 = llvm.mlir.constant(1 : i64) : i64
      %36 = llvm.alloca %35 x i32 : (i64) -> !llvm.ptr
      llvm.store %34, %36 : i32, !llvm.ptr
      cf.br ^bb6
      ^bb6:
      %37 = llvm.load %36 : !llvm.ptr -> i32
      %39 = llvm.load %28 : !llvm.ptr -> i32
      %40 = arith.extsi %39 : i32 to i64
      %41 = llvm.getelementptr %arg3[%40] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %38 = llvm.load %41 : !llvm.ptr -> i32
      %42 = arith.cmpi slt, %37, %38 : i32
      cf.cond_br %42, ^bb7, ^bb8
      ^bb7:
        %44 = llvm.load %28 : !llvm.ptr -> i32
        %45 = arith.constant 7 : i32
        %46 = arith.muli %44, %45 : i32
        %47 = llvm.load %36 : !llvm.ptr -> i32
        %48 = arith.addi %46, %47 : i32
        %49 = arith.extsi %48 : i32 to i64
        %50 = llvm.getelementptr %arg0[%49] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %43 = llvm.load %50 : !llvm.ptr -> i32
        %52 = llvm.load %28 : !llvm.ptr -> i32
        %53 = arith.constant 7 : i32
        %54 = arith.muli %52, %53 : i32
        %55 = llvm.load %36 : !llvm.ptr -> i32
        %56 = arith.addi %54, %55 : i32
        %57 = arith.extsi %56 : i32 to i64
        %58 = llvm.getelementptr %arg1[%57] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %51 = llvm.load %58 : !llvm.ptr -> i32
        %60 = llvm.load %28 : !llvm.ptr -> i32
        %61 = arith.constant 7 : i32
        %62 = arith.muli %60, %61 : i32
        %63 = llvm.load %36 : !llvm.ptr -> i32
        %64 = arith.addi %62, %63 : i32
        %65 = arith.extsi %64 : i32 to i64
        %66 = llvm.getelementptr %arg2[%65] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %59 = llvm.load %66 : !llvm.ptr -> i32
        %67 = arith.muli %43, %10 : i32
        %68 = arith.constant 0 : i32
        %69 = llvm.mlir.constant(1 : i64) : i64
        %70 = llvm.alloca %69 x i32 : (i64) -> !llvm.ptr
        llvm.store %68, %70 : i32, !llvm.ptr
        cf.br ^bb9
        ^bb9:
        %71 = llvm.load %70 : !llvm.ptr -> i32
        %72 = arith.subi %arg6, %51 : i32
        %73 = arith.cmpi sle, %71, %72 : i32
        cf.cond_br %73, ^bb10, ^bb11
        ^bb10:
          %74 = llvm.load %70 : !llvm.ptr -> i32
          %75 = arith.addi %74, %51 : i32
          %77 = llvm.load %70 : !llvm.ptr -> i32
          %78 = arith.addi %33, %77 : i32
          %79 = arith.extsi %78 : i32 to i64
          %80 = llvm.getelementptr %arg4[%79] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %76 = llvm.load %80 : !llvm.ptr -> i64
          %81 = arith.extsi %59 : i32 to i64
          %82 = arith.muli %76, %81 : i64
          %83 = llvm.mlir.addressof @MOD : !llvm.ptr
          %84 = llvm.load %83 : !llvm.ptr -> i64
          %85 = arith.remsi %82, %84 : i64
          %87 = arith.addi %67, %75 : i32
          %88 = arith.extsi %87 : i32 to i64
          %89 = llvm.getelementptr %arg5[%88] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %86 = llvm.load %89 : !llvm.ptr -> i64
          %90 = arith.addi %86, %85 : i64
          %91 = llvm.mlir.addressof @MOD : !llvm.ptr
          %92 = llvm.load %91 : !llvm.ptr -> i64
          %93 = arith.cmpi sge, %90, %92 : i64
          %94 = scf.if %93 -> (i64) {
            %95 = llvm.mlir.addressof @MOD : !llvm.ptr
            %96 = llvm.load %95 : !llvm.ptr -> i64
            %97 = arith.subi %90, %96 : i64
            scf.yield %97 : i64
          } else {
            scf.yield %90 : i64
          }
          %98 = arith.addi %67, %75 : i32
          %99 = arith.extsi %98 : i32 to i64
          %100 = llvm.getelementptr %arg5[%99] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %94, %100 : i64, !llvm.ptr
          %101 = llvm.load %70 : !llvm.ptr -> i32
          %102 = arith.constant 1 : i32
          %103 = arith.addi %101, %102 : i32
          llvm.store %103, %70 : i32, !llvm.ptr
          cf.br ^bb9
        ^bb11:
        %104 = llvm.load %36 : !llvm.ptr -> i32
        %105 = arith.constant 1 : i32
        %106 = arith.addi %104, %105 : i32
        llvm.store %106, %36 : i32, !llvm.ptr
        cf.br ^bb6
      ^bb8:
      %107 = llvm.load %28 : !llvm.ptr -> i32
      %108 = arith.constant 1 : i32
      %109 = arith.addi %107, %108 : i32
      llvm.store %109, %28 : i32, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    func.return
  }
  func.func @main() -> i32 {
    %110 = arith.constant 1000 : i32
    %111 = arith.constant 2 : i32
    %112 = arith.muli %111, %110 : i32
    %113 = arith.constant 1 : i32
    %114 = arith.addi %110, %113 : i32
    %116 = arith.constant 28 : i32
    %117 = arith.constant 4 : i32
    %118 = arith.extsi %116 : i32 to i64
    %119 = arith.extsi %117 : i32 to i64
    %115 = func.call @calloc(%118, %119) : (i64, i64) -> !llvm.ptr
    %121 = arith.constant 28 : i32
    %122 = arith.constant 4 : i32
    %123 = arith.extsi %121 : i32 to i64
    %124 = arith.extsi %122 : i32 to i64
    %120 = func.call @calloc(%123, %124) : (i64, i64) -> !llvm.ptr
    %126 = arith.constant 28 : i32
    %127 = arith.constant 4 : i32
    %128 = arith.extsi %126 : i32 to i64
    %129 = arith.extsi %127 : i32 to i64
    %125 = func.call @calloc(%128, %129) : (i64, i64) -> !llvm.ptr
    %131 = arith.constant 4 : i32
    %132 = arith.constant 4 : i32
    %133 = arith.extsi %131 : i32 to i64
    %134 = arith.extsi %132 : i32 to i64
    %130 = func.call @calloc(%133, %134) : (i64, i64) -> !llvm.ptr
    %135 = arith.constant 0 : i32
    %136 = arith.constant 0 : i32
    %137 = arith.extsi %136 : i32 to i64
    %138 = llvm.getelementptr %115[%137] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %135, %138 : i32, !llvm.ptr
    %139 = arith.constant 0 : i32
    %140 = arith.constant 0 : i32
    %141 = arith.extsi %140 : i32 to i64
    %142 = llvm.getelementptr %120[%141] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %139, %142 : i32, !llvm.ptr
    %143 = arith.constant 3 : i32
    %144 = arith.constant 0 : i32
    %145 = arith.extsi %144 : i32 to i64
    %146 = llvm.getelementptr %125[%145] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %143, %146 : i32, !llvm.ptr
    %147 = arith.constant 2 : i32
    %148 = arith.constant 1 : i32
    %149 = arith.extsi %148 : i32 to i64
    %150 = llvm.getelementptr %115[%149] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %147, %150 : i32, !llvm.ptr
    %151 = arith.constant 0 : i32
    %152 = arith.constant 1 : i32
    %153 = arith.extsi %152 : i32 to i64
    %154 = llvm.getelementptr %120[%153] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %151, %154 : i32, !llvm.ptr
    %155 = arith.constant 2 : i32
    %156 = arith.constant 1 : i32
    %157 = arith.extsi %156 : i32 to i64
    %158 = llvm.getelementptr %125[%157] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %155, %158 : i32, !llvm.ptr
    %159 = arith.constant 1 : i32
    %160 = arith.constant 2 : i32
    %161 = arith.extsi %160 : i32 to i64
    %162 = llvm.getelementptr %115[%161] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %159, %162 : i32, !llvm.ptr
    %163 = arith.constant 0 : i32
    %164 = arith.constant 2 : i32
    %165 = arith.extsi %164 : i32 to i64
    %166 = llvm.getelementptr %120[%165] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %163, %166 : i32, !llvm.ptr
    %167 = arith.constant 2 : i32
    %168 = arith.constant 2 : i32
    %169 = arith.extsi %168 : i32 to i64
    %170 = llvm.getelementptr %125[%169] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %167, %170 : i32, !llvm.ptr
    %171 = arith.constant 3 : i32
    %172 = arith.constant 3 : i32
    %173 = arith.extsi %172 : i32 to i64
    %174 = llvm.getelementptr %115[%173] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %171, %174 : i32, !llvm.ptr
    %175 = arith.constant 0 : i32
    %176 = arith.constant 3 : i32
    %177 = arith.extsi %176 : i32 to i64
    %178 = llvm.getelementptr %120[%177] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %175, %178 : i32, !llvm.ptr
    %179 = arith.constant 1 : i32
    %180 = arith.constant 3 : i32
    %181 = arith.extsi %180 : i32 to i64
    %182 = llvm.getelementptr %125[%181] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %179, %182 : i32, !llvm.ptr
    %183 = arith.constant 0 : i32
    %184 = arith.constant 4 : i32
    %185 = arith.extsi %184 : i32 to i64
    %186 = llvm.getelementptr %115[%185] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %183, %186 : i32, !llvm.ptr
    %187 = arith.constant 1 : i32
    %188 = arith.constant 4 : i32
    %189 = arith.extsi %188 : i32 to i64
    %190 = llvm.getelementptr %120[%189] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %187, %190 : i32, !llvm.ptr
    %191 = arith.constant 1 : i32
    %192 = arith.constant 4 : i32
    %193 = arith.extsi %192 : i32 to i64
    %194 = llvm.getelementptr %125[%193] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %191, %194 : i32, !llvm.ptr
    %195 = arith.constant 0 : i32
    %196 = arith.constant 7 : i32
    %197 = arith.extsi %196 : i32 to i64
    %198 = llvm.getelementptr %115[%197] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %195, %198 : i32, !llvm.ptr
    %199 = arith.constant 1 : i32
    %200 = arith.constant 7 : i32
    %201 = arith.extsi %200 : i32 to i64
    %202 = llvm.getelementptr %120[%201] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %199, %202 : i32, !llvm.ptr
    %203 = arith.constant 3 : i32
    %204 = arith.constant 7 : i32
    %205 = arith.extsi %204 : i32 to i64
    %206 = llvm.getelementptr %125[%205] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %203, %206 : i32, !llvm.ptr
    %207 = arith.constant 2 : i32
    %208 = arith.constant 8 : i32
    %209 = arith.extsi %208 : i32 to i64
    %210 = llvm.getelementptr %115[%209] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %207, %210 : i32, !llvm.ptr
    %211 = arith.constant 1 : i32
    %212 = arith.constant 8 : i32
    %213 = arith.extsi %212 : i32 to i64
    %214 = llvm.getelementptr %120[%213] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %211, %214 : i32, !llvm.ptr
    %215 = arith.constant 1 : i32
    %216 = arith.constant 8 : i32
    %217 = arith.extsi %216 : i32 to i64
    %218 = llvm.getelementptr %125[%217] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %215, %218 : i32, !llvm.ptr
    %219 = arith.constant 1 : i32
    %220 = arith.constant 9 : i32
    %221 = arith.extsi %220 : i32 to i64
    %222 = llvm.getelementptr %115[%221] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %219, %222 : i32, !llvm.ptr
    %223 = arith.constant 0 : i32
    %224 = arith.constant 9 : i32
    %225 = arith.extsi %224 : i32 to i64
    %226 = llvm.getelementptr %120[%225] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %223, %226 : i32, !llvm.ptr
    %227 = arith.constant 2 : i32
    %228 = arith.constant 9 : i32
    %229 = arith.extsi %228 : i32 to i64
    %230 = llvm.getelementptr %125[%229] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %227, %230 : i32, !llvm.ptr
    %231 = arith.constant 3 : i32
    %232 = arith.constant 10 : i32
    %233 = arith.extsi %232 : i32 to i64
    %234 = llvm.getelementptr %115[%233] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %231, %234 : i32, !llvm.ptr
    %235 = arith.constant 0 : i32
    %236 = arith.constant 10 : i32
    %237 = arith.extsi %236 : i32 to i64
    %238 = llvm.getelementptr %120[%237] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %235, %238 : i32, !llvm.ptr
    %239 = arith.constant 1 : i32
    %240 = arith.constant 10 : i32
    %241 = arith.extsi %240 : i32 to i64
    %242 = llvm.getelementptr %125[%241] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %239, %242 : i32, !llvm.ptr
    %243 = arith.constant 0 : i32
    %244 = arith.constant 11 : i32
    %245 = arith.extsi %244 : i32 to i64
    %246 = llvm.getelementptr %115[%245] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %243, %246 : i32, !llvm.ptr
    %247 = arith.constant 0 : i32
    %248 = arith.constant 11 : i32
    %249 = arith.extsi %248 : i32 to i64
    %250 = llvm.getelementptr %120[%249] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %247, %250 : i32, !llvm.ptr
    %251 = arith.constant 1 : i32
    %252 = arith.constant 11 : i32
    %253 = arith.extsi %252 : i32 to i64
    %254 = llvm.getelementptr %125[%253] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %251, %254 : i32, !llvm.ptr
    %255 = arith.constant 2 : i32
    %256 = arith.constant 12 : i32
    %257 = arith.extsi %256 : i32 to i64
    %258 = llvm.getelementptr %115[%257] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %255, %258 : i32, !llvm.ptr
    %259 = arith.constant 0 : i32
    %260 = arith.constant 12 : i32
    %261 = arith.extsi %260 : i32 to i64
    %262 = llvm.getelementptr %120[%261] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %259, %262 : i32, !llvm.ptr
    %263 = arith.constant 1 : i32
    %264 = arith.constant 12 : i32
    %265 = arith.extsi %264 : i32 to i64
    %266 = llvm.getelementptr %125[%265] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %263, %266 : i32, !llvm.ptr
    %267 = arith.constant 0 : i32
    %268 = arith.constant 14 : i32
    %269 = arith.extsi %268 : i32 to i64
    %270 = llvm.getelementptr %115[%269] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %267, %270 : i32, !llvm.ptr
    %271 = arith.constant 1 : i32
    %272 = arith.constant 14 : i32
    %273 = arith.extsi %272 : i32 to i64
    %274 = llvm.getelementptr %120[%273] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %271, %274 : i32, !llvm.ptr
    %275 = arith.constant 3 : i32
    %276 = arith.constant 14 : i32
    %277 = arith.extsi %276 : i32 to i64
    %278 = llvm.getelementptr %125[%277] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %275, %278 : i32, !llvm.ptr
    %279 = arith.constant 2 : i32
    %280 = arith.constant 15 : i32
    %281 = arith.extsi %280 : i32 to i64
    %282 = llvm.getelementptr %115[%281] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %279, %282 : i32, !llvm.ptr
    %283 = arith.constant 0 : i32
    %284 = arith.constant 15 : i32
    %285 = arith.extsi %284 : i32 to i64
    %286 = llvm.getelementptr %120[%285] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %283, %286 : i32, !llvm.ptr
    %287 = arith.constant 2 : i32
    %288 = arith.constant 15 : i32
    %289 = arith.extsi %288 : i32 to i64
    %290 = llvm.getelementptr %125[%289] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %287, %290 : i32, !llvm.ptr
    %291 = arith.constant 0 : i32
    %292 = arith.constant 16 : i32
    %293 = arith.extsi %292 : i32 to i64
    %294 = llvm.getelementptr %115[%293] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %291, %294 : i32, !llvm.ptr
    %295 = arith.constant 0 : i32
    %296 = arith.constant 16 : i32
    %297 = arith.extsi %296 : i32 to i64
    %298 = llvm.getelementptr %120[%297] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %295, %298 : i32, !llvm.ptr
    %299 = arith.constant 1 : i32
    %300 = arith.constant 16 : i32
    %301 = arith.extsi %300 : i32 to i64
    %302 = llvm.getelementptr %125[%301] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %299, %302 : i32, !llvm.ptr
    %303 = arith.constant 1 : i32
    %304 = arith.constant 17 : i32
    %305 = arith.extsi %304 : i32 to i64
    %306 = llvm.getelementptr %115[%305] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %303, %306 : i32, !llvm.ptr
    %307 = arith.constant 1 : i32
    %308 = arith.constant 17 : i32
    %309 = arith.extsi %308 : i32 to i64
    %310 = llvm.getelementptr %120[%309] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %307, %310 : i32, !llvm.ptr
    %311 = arith.constant 1 : i32
    %312 = arith.constant 17 : i32
    %313 = arith.extsi %312 : i32 to i64
    %314 = llvm.getelementptr %125[%313] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %311, %314 : i32, !llvm.ptr
    %315 = arith.constant 3 : i32
    %316 = arith.constant 18 : i32
    %317 = arith.extsi %316 : i32 to i64
    %318 = llvm.getelementptr %115[%317] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %315, %318 : i32, !llvm.ptr
    %319 = arith.constant 0 : i32
    %320 = arith.constant 18 : i32
    %321 = arith.extsi %320 : i32 to i64
    %322 = llvm.getelementptr %120[%321] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %319, %322 : i32, !llvm.ptr
    %323 = arith.constant 1 : i32
    %324 = arith.constant 18 : i32
    %325 = arith.extsi %324 : i32 to i64
    %326 = llvm.getelementptr %125[%325] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %323, %326 : i32, !llvm.ptr
    %327 = arith.constant 1 : i32
    %328 = arith.constant 19 : i32
    %329 = arith.extsi %328 : i32 to i64
    %330 = llvm.getelementptr %115[%329] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %327, %330 : i32, !llvm.ptr
    %331 = arith.constant 0 : i32
    %332 = arith.constant 19 : i32
    %333 = arith.extsi %332 : i32 to i64
    %334 = llvm.getelementptr %120[%333] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %331, %334 : i32, !llvm.ptr
    %335 = arith.constant 1 : i32
    %336 = arith.constant 19 : i32
    %337 = arith.extsi %336 : i32 to i64
    %338 = llvm.getelementptr %125[%337] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %335, %338 : i32, !llvm.ptr
    %339 = arith.constant 0 : i32
    %340 = arith.constant 21 : i32
    %341 = arith.extsi %340 : i32 to i64
    %342 = llvm.getelementptr %115[%341] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %339, %342 : i32, !llvm.ptr
    %343 = arith.constant 2 : i32
    %344 = arith.constant 21 : i32
    %345 = arith.extsi %344 : i32 to i64
    %346 = llvm.getelementptr %120[%345] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %343, %346 : i32, !llvm.ptr
    %347 = arith.constant 1 : i32
    %348 = arith.constant 21 : i32
    %349 = arith.extsi %348 : i32 to i64
    %350 = llvm.getelementptr %125[%349] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %347, %350 : i32, !llvm.ptr
    %351 = arith.constant 2 : i32
    %352 = arith.constant 22 : i32
    %353 = arith.extsi %352 : i32 to i64
    %354 = llvm.getelementptr %115[%353] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %351, %354 : i32, !llvm.ptr
    %355 = arith.constant 1 : i32
    %356 = arith.constant 22 : i32
    %357 = arith.extsi %356 : i32 to i64
    %358 = llvm.getelementptr %120[%357] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %355, %358 : i32, !llvm.ptr
    %359 = arith.constant 1 : i32
    %360 = arith.constant 22 : i32
    %361 = arith.extsi %360 : i32 to i64
    %362 = llvm.getelementptr %125[%361] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %359, %362 : i32, !llvm.ptr
    %363 = arith.constant 0 : i32
    %364 = arith.constant 23 : i32
    %365 = arith.extsi %364 : i32 to i64
    %366 = llvm.getelementptr %115[%365] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %363, %366 : i32, !llvm.ptr
    %367 = arith.constant 1 : i32
    %368 = arith.constant 23 : i32
    %369 = arith.extsi %368 : i32 to i64
    %370 = llvm.getelementptr %120[%369] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %367, %370 : i32, !llvm.ptr
    %371 = arith.constant 3 : i32
    %372 = arith.constant 23 : i32
    %373 = arith.extsi %372 : i32 to i64
    %374 = llvm.getelementptr %125[%373] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %371, %374 : i32, !llvm.ptr
    %375 = arith.constant 1 : i32
    %376 = arith.constant 24 : i32
    %377 = arith.extsi %376 : i32 to i64
    %378 = llvm.getelementptr %115[%377] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %375, %378 : i32, !llvm.ptr
    %379 = arith.constant 1 : i32
    %380 = arith.constant 24 : i32
    %381 = arith.extsi %380 : i32 to i64
    %382 = llvm.getelementptr %120[%381] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %379, %382 : i32, !llvm.ptr
    %383 = arith.constant 1 : i32
    %384 = arith.constant 24 : i32
    %385 = arith.extsi %384 : i32 to i64
    %386 = llvm.getelementptr %125[%385] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %383, %386 : i32, !llvm.ptr
    %387 = arith.constant 3 : i32
    %388 = arith.constant 25 : i32
    %389 = arith.extsi %388 : i32 to i64
    %390 = llvm.getelementptr %115[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %387, %390 : i32, !llvm.ptr
    %391 = arith.constant 0 : i32
    %392 = arith.constant 25 : i32
    %393 = arith.extsi %392 : i32 to i64
    %394 = llvm.getelementptr %120[%393] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %391, %394 : i32, !llvm.ptr
    %395 = arith.constant 1 : i32
    %396 = arith.constant 25 : i32
    %397 = arith.extsi %396 : i32 to i64
    %398 = llvm.getelementptr %125[%397] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %395, %398 : i32, !llvm.ptr
    %399 = arith.constant 1 : i32
    %400 = arith.constant 26 : i32
    %401 = arith.extsi %400 : i32 to i64
    %402 = llvm.getelementptr %115[%401] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %399, %402 : i32, !llvm.ptr
    %403 = arith.constant 0 : i32
    %404 = arith.constant 26 : i32
    %405 = arith.extsi %404 : i32 to i64
    %406 = llvm.getelementptr %120[%405] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %403, %406 : i32, !llvm.ptr
    %407 = arith.constant 1 : i32
    %408 = arith.constant 26 : i32
    %409 = arith.extsi %408 : i32 to i64
    %410 = llvm.getelementptr %125[%409] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %407, %410 : i32, !llvm.ptr
    %411 = arith.constant 2 : i32
    %412 = arith.constant 27 : i32
    %413 = arith.extsi %412 : i32 to i64
    %414 = llvm.getelementptr %115[%413] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %411, %414 : i32, !llvm.ptr
    %415 = arith.constant 0 : i32
    %416 = arith.constant 27 : i32
    %417 = arith.extsi %416 : i32 to i64
    %418 = llvm.getelementptr %120[%417] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %415, %418 : i32, !llvm.ptr
    %419 = arith.constant 1 : i32
    %420 = arith.constant 27 : i32
    %421 = arith.extsi %420 : i32 to i64
    %422 = llvm.getelementptr %125[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %419, %422 : i32, !llvm.ptr
    %423 = arith.constant 5 : i32
    %424 = arith.constant 0 : i32
    %425 = arith.extsi %424 : i32 to i64
    %426 = llvm.getelementptr %130[%425] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %423, %426 : i32, !llvm.ptr
    %427 = arith.constant 6 : i32
    %428 = arith.constant 1 : i32
    %429 = arith.extsi %428 : i32 to i64
    %430 = llvm.getelementptr %130[%429] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %427, %430 : i32, !llvm.ptr
    %431 = arith.constant 6 : i32
    %432 = arith.constant 2 : i32
    %433 = arith.extsi %432 : i32 to i64
    %434 = llvm.getelementptr %130[%433] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %431, %434 : i32, !llvm.ptr
    %435 = arith.constant 7 : i32
    %436 = arith.constant 3 : i32
    %437 = arith.extsi %436 : i32 to i64
    %438 = llvm.getelementptr %130[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %435, %438 : i32, !llvm.ptr
    %440 = arith.constant 28 : i32
    %441 = arith.constant 4 : i32
    %442 = arith.extsi %440 : i32 to i64
    %443 = arith.extsi %441 : i32 to i64
    %439 = func.call @calloc(%442, %443) : (i64, i64) -> !llvm.ptr
    %445 = arith.constant 28 : i32
    %446 = arith.constant 4 : i32
    %447 = arith.extsi %445 : i32 to i64
    %448 = arith.extsi %446 : i32 to i64
    %444 = func.call @calloc(%447, %448) : (i64, i64) -> !llvm.ptr
    %450 = arith.constant 28 : i32
    %451 = arith.constant 4 : i32
    %452 = arith.extsi %450 : i32 to i64
    %453 = arith.extsi %451 : i32 to i64
    %449 = func.call @calloc(%452, %453) : (i64, i64) -> !llvm.ptr
    %454 = arith.constant 0 : i32
    %455 = llvm.mlir.constant(1 : i64) : i64
    %456 = llvm.alloca %455 x i32 : (i64) -> !llvm.ptr
    llvm.store %454, %456 : i32, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %457 = llvm.load %456 : !llvm.ptr -> i32
    %458 = arith.constant 4 : i32
    %459 = arith.cmpi slt, %457, %458 : i32
    cf.cond_br %459, ^bb13, ^bb14
    ^bb13:
      %460 = arith.constant 0 : i32
      %461 = llvm.mlir.constant(1 : i64) : i64
      %462 = llvm.alloca %461 x i32 : (i64) -> !llvm.ptr
      llvm.store %460, %462 : i32, !llvm.ptr
      cf.br ^bb15
      ^bb15:
      %463 = llvm.load %462 : !llvm.ptr -> i32
      %465 = llvm.load %456 : !llvm.ptr -> i32
      %466 = arith.extsi %465 : i32 to i64
      %467 = llvm.getelementptr %130[%466] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %464 = llvm.load %467 : !llvm.ptr -> i32
      %468 = arith.cmpi slt, %463, %464 : i32
      cf.cond_br %468, ^bb16, ^bb17
      ^bb16:
        %471 = llvm.load %456 : !llvm.ptr -> i32
        %472 = arith.constant 7 : i32
        %473 = arith.muli %471, %472 : i32
        %474 = llvm.load %462 : !llvm.ptr -> i32
        %475 = arith.addi %473, %474 : i32
        %476 = arith.extsi %475 : i32 to i64
        %477 = llvm.getelementptr %115[%476] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %470 = llvm.load %477 : !llvm.ptr -> i32
        %469 = func.call @swap2bits(%470) : (i32) -> i32
        %478 = llvm.load %456 : !llvm.ptr -> i32
        %479 = arith.constant 7 : i32
        %480 = arith.muli %478, %479 : i32
        %481 = llvm.load %462 : !llvm.ptr -> i32
        %482 = arith.addi %480, %481 : i32
        %483 = arith.extsi %482 : i32 to i64
        %484 = llvm.getelementptr %439[%483] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %469, %484 : i32, !llvm.ptr
        %486 = llvm.load %456 : !llvm.ptr -> i32
        %487 = arith.constant 7 : i32
        %488 = arith.muli %486, %487 : i32
        %489 = llvm.load %462 : !llvm.ptr -> i32
        %490 = arith.addi %488, %489 : i32
        %491 = arith.extsi %490 : i32 to i64
        %492 = llvm.getelementptr %120[%491] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %485 = llvm.load %492 : !llvm.ptr -> i32
        %493 = llvm.load %456 : !llvm.ptr -> i32
        %494 = arith.constant 7 : i32
        %495 = arith.muli %493, %494 : i32
        %496 = llvm.load %462 : !llvm.ptr -> i32
        %497 = arith.addi %495, %496 : i32
        %498 = arith.extsi %497 : i32 to i64
        %499 = llvm.getelementptr %444[%498] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %485, %499 : i32, !llvm.ptr
        %501 = llvm.load %456 : !llvm.ptr -> i32
        %502 = arith.constant 7 : i32
        %503 = arith.muli %501, %502 : i32
        %504 = llvm.load %462 : !llvm.ptr -> i32
        %505 = arith.addi %503, %504 : i32
        %506 = arith.extsi %505 : i32 to i64
        %507 = llvm.getelementptr %125[%506] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %500 = llvm.load %507 : !llvm.ptr -> i32
        %508 = llvm.load %456 : !llvm.ptr -> i32
        %509 = arith.constant 7 : i32
        %510 = arith.muli %508, %509 : i32
        %511 = llvm.load %462 : !llvm.ptr -> i32
        %512 = arith.addi %510, %511 : i32
        %513 = arith.extsi %512 : i32 to i64
        %514 = llvm.getelementptr %449[%513] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %500, %514 : i32, !llvm.ptr
        %515 = llvm.load %462 : !llvm.ptr -> i32
        %516 = arith.constant 1 : i32
        %517 = arith.addi %515, %516 : i32
        llvm.store %517, %462 : i32, !llvm.ptr
        cf.br ^bb15
      ^bb17:
      %518 = llvm.load %456 : !llvm.ptr -> i32
      %519 = arith.constant 1 : i32
      %520 = arith.addi %518, %519 : i32
      llvm.store %520, %456 : i32, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %522 = arith.constant 4 : i32
    %523 = arith.muli %522, %114 : i32
    %524 = arith.extsi %523 : i32 to i64
    %525 = arith.constant 8 : i32
    %526 = arith.extsi %525 : i32 to i64
    %521 = func.call @calloc(%524, %526) : (i64, i64) -> !llvm.ptr
    %528 = arith.constant 4 : i32
    %529 = arith.muli %528, %114 : i32
    %530 = arith.extsi %529 : i32 to i64
    %531 = arith.constant 8 : i32
    %532 = arith.extsi %531 : i32 to i64
    %527 = func.call @calloc(%530, %532) : (i64, i64) -> !llvm.ptr
    %533 = arith.constant 0 : i32
    %534 = arith.extsi %533 : i32 to i64
    %535 = llvm.mlir.constant(1 : i64) : i64
    %536 = llvm.alloca %535 x i64 : (i64) -> !llvm.ptr
    llvm.store %534, %536 : i64, !llvm.ptr
    %537 = arith.constant 0 : i32
    %538 = llvm.mlir.constant(1 : i64) : i64
    %539 = llvm.alloca %538 x i32 : (i64) -> !llvm.ptr
    llvm.store %537, %539 : i32, !llvm.ptr
    cf.br ^bb18
    ^bb18:
    %540 = llvm.load %539 : !llvm.ptr -> i32
    %541 = arith.constant 4 : i32
    %542 = arith.cmpi slt, %540, %541 : i32
    cf.cond_br %542, ^bb19, ^bb20
    ^bb19:
      %543 = arith.constant 0 : i32
      %544 = llvm.mlir.constant(1 : i64) : i64
      %545 = llvm.alloca %544 x i32 : (i64) -> !llvm.ptr
      llvm.store %543, %545 : i32, !llvm.ptr
      cf.br ^bb21
      ^bb21:
      %546 = llvm.load %545 : !llvm.ptr -> i32
      %547 = arith.constant 4 : i32
      %548 = arith.muli %547, %114 : i32
      %549 = arith.cmpi slt, %546, %548 : i32
      cf.cond_br %549, ^bb22, ^bb23
      ^bb22:
        %550 = arith.constant 0 : i32
        %551 = llvm.load %545 : !llvm.ptr -> i32
        %552 = arith.extsi %550 : i32 to i64
        %553 = arith.extsi %551 : i32 to i64
        %554 = llvm.getelementptr %521[%553] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %552, %554 : i64, !llvm.ptr
        %555 = llvm.load %545 : !llvm.ptr -> i32
        %556 = arith.constant 1 : i32
        %557 = arith.addi %555, %556 : i32
        llvm.store %557, %545 : i32, !llvm.ptr
        cf.br ^bb21
      ^bb23:
      %558 = arith.constant 1 : i32
      %559 = llvm.load %539 : !llvm.ptr -> i32
      %560 = arith.muli %559, %114 : i32
      %561 = arith.extsi %558 : i32 to i64
      %562 = arith.extsi %560 : i32 to i64
      %563 = llvm.getelementptr %521[%562] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %561, %563 : i64, !llvm.ptr
      %564 = arith.constant 0 : i32
      %565 = llvm.mlir.constant(1 : i64) : i64
      %566 = llvm.alloca %565 x i32 : (i64) -> !llvm.ptr
      llvm.store %564, %566 : i32, !llvm.ptr
      %567 = arith.constant 0 : i32
      %568 = llvm.mlir.constant(1 : i64) : i64
      %569 = llvm.alloca %568 x i32 : (i64) -> !llvm.ptr
      llvm.store %567, %569 : i32, !llvm.ptr
      cf.br ^bb24
      ^bb24:
      %570 = llvm.load %569 : !llvm.ptr -> i32
      %571 = arith.constant 1 : i32
      %572 = arith.subi %112, %571 : i32
      %573 = arith.cmpi slt, %570, %572 : i32
      cf.cond_br %573, ^bb25, ^bb26
      ^bb25:
        %574 = llvm.load %566 : !llvm.ptr -> i32
        %575 = arith.constant 0 : i32
        %576 = arith.cmpi eq, %574, %575 : i32
        cf.cond_br %576, ^bb27, ^bb28
        ^bb27:
          func.call @do_transition(%115, %120, %125, %130, %521, %527, %110) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> ()
          %578 = arith.constant 1 : i32
          llvm.store %578, %566 : i32, !llvm.ptr
          cf.br ^bb29
        ^bb28:
          func.call @do_transition(%115, %120, %125, %130, %527, %521, %110) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> ()
          %580 = arith.constant 0 : i32
          llvm.store %580, %566 : i32, !llvm.ptr
          cf.br ^bb29
        ^bb29:
        %581 = llvm.load %569 : !llvm.ptr -> i32
        %582 = arith.constant 1 : i32
        %583 = arith.addi %581, %582 : i32
        llvm.store %583, %569 : i32, !llvm.ptr
        cf.br ^bb24
      ^bb26:
      %584 = llvm.load %566 : !llvm.ptr -> i32
      %585 = arith.constant 0 : i32
      %586 = arith.cmpi eq, %584, %585 : i32
      cf.cond_br %586, ^bb30, ^bb31
      ^bb30:
        func.call @do_transition(%439, %444, %449, %130, %521, %527, %110) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> ()
        %588 = arith.constant 1 : i32
        llvm.store %588, %566 : i32, !llvm.ptr
        cf.br ^bb32
      ^bb31:
        func.call @do_transition(%439, %444, %449, %130, %527, %521, %110) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> ()
        %590 = arith.constant 0 : i32
        llvm.store %590, %566 : i32, !llvm.ptr
        cf.br ^bb32
      ^bb32:
      %591 = arith.constant 0 : i32
      %592 = arith.extsi %591 : i32 to i64
      %593 = llvm.load %566 : !llvm.ptr -> i32
      %594 = arith.constant 0 : i32
      %595 = arith.cmpi eq, %593, %594 : i32
      %596 = scf.if %595 -> (i64) {
        %598 = llvm.load %539 : !llvm.ptr -> i32
        %599 = arith.muli %598, %114 : i32
        %600 = arith.addi %599, %110 : i32
        %601 = arith.extsi %600 : i32 to i64
        %602 = llvm.getelementptr %521[%601] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %597 = llvm.load %602 : !llvm.ptr -> i64
        scf.yield %597 : i64
      } else {
        %604 = llvm.load %539 : !llvm.ptr -> i32
        %605 = arith.muli %604, %114 : i32
        %606 = arith.addi %605, %110 : i32
        %607 = arith.extsi %606 : i32 to i64
        %608 = llvm.getelementptr %527[%607] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %603 = llvm.load %608 : !llvm.ptr -> i64
        scf.yield %603 : i64
      }
      %609 = llvm.load %536 : !llvm.ptr -> i64
      %610 = arith.addi %609, %596 : i64
      %611 = llvm.mlir.addressof @MOD : !llvm.ptr
      %612 = llvm.load %611 : !llvm.ptr -> i64
      %613 = arith.remsi %610, %612 : i64
      llvm.store %613, %536 : i64, !llvm.ptr
      %614 = llvm.load %539 : !llvm.ptr -> i32
      %615 = arith.constant 1 : i32
      %616 = arith.addi %614, %615 : i32
      llvm.store %616, %539 : i32, !llvm.ptr
      cf.br ^bb18
    ^bb20:
    %617 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %618 = llvm.load %536 : !llvm.ptr -> i64
    %619 = llvm.call @printf(%617, %618) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%521) : (!llvm.ptr) -> ()
    func.call @free(%527) : (!llvm.ptr) -> ()
    func.call @free(%115) : (!llvm.ptr) -> ()
    func.call @free(%120) : (!llvm.ptr) -> ()
    func.call @free(%125) : (!llvm.ptr) -> ()
    func.call @free(%130) : (!llvm.ptr) -> ()
    func.call @free(%439) : (!llvm.ptr) -> ()
    func.call @free(%444) : (!llvm.ptr) -> ()
    func.call @free(%449) : (!llvm.ptr) -> ()
    %629 = arith.constant 0 : i32
    func.return %629 : i32
  }
}