Problem 629

g(n) = f(n,2) + f(n,3) + (n-3)*f(n,4) for n=200, mod 1e9+7. f(n,k) = P(n) - L(n,k) where P(n) = partition count, L(n,k) = losing positions.

Answer626616617
Output626616617
StatusPASS
Native helperno
Runtime10 ms
Peak memory1344 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(n * m)
Space complexityO(n^2)O(n)
ApproachFlow solutionDynamic programming or generating function
VerdictUnknown

Flow source

# Project Euler 629: Scatterstone Nim
# g(n) = f(n,2) + f(n,3) + (n-3)*f(n,4) for n=200, mod 1e9+7.
# f(n,k) = P(n) - L(n,k) where P(n) = partition count, L(n,k) = losing positions.

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

const MOD: i64 = 1000000007
const N: i64 = 200
const WIDTH: i64 = 128

function count_losing(grundy: ptr<i64>) -> i64 {
    let dp: ptr<i64> = calloc((N + 1) * WIDTH, 8)
    if dp == null { return -1 }
    dp[0] = 1

    for size in 1..(N + 1) {
        let g: i64 = grundy[size]
        let pair: i64 = 2 * size

        # Step 1: unlimited pairs (coin size 2*size, XOR unchanged)
        if pair <= N {
            for s in pair..(N + 1) {
                for x in 0..WIDTH {
                    if dp[(s - pair) * WIDTH + x] != 0 {
                        dp[s * WIDTH + x] = (dp[s * WIDTH + x] + dp[(s - pair) * WIDTH + x]) % MOD
                    }
                }
            }
        }

        # Step 2: optional single (0/1 coin size, XOR with g)
        let mut s_rev: i64 = N
        while s_rev >= size {
            for x in 0..WIDTH {
                if dp[(s_rev - size) * WIDTH + x] != 0 {
                    let j: i64 = x ^ g
                    if j < WIDTH {
                        dp[s_rev * WIDTH + j] = (dp[s_rev * WIDTH + j] + dp[(s_rev - size) * WIDTH + x]) % MOD
                    }
                }
            }
            s_rev = s_rev - 1
        }
    }

    let result: i64 = dp[N * WIDTH]
    free(dp)
    return result
}

function main() -> i32 {
    # Step 1: Partition numbers up to N
    let partitions: ptr<i64> = calloc(N + 1, 8)
    if partitions == null { return 1 }
    partitions[0] = 1
    for part in 1..(N + 1) {
        for s in part..(N + 1) {
            partitions[s] = (partitions[s] + partitions[s - part]) % MOD
        }
    }

    # Step 2: Grundy numbers
    let g2: ptr<i64> = calloc(N + 1, 8)
    for s in 2..(N + 1) {
        if s % 2 == 0 { g2[s] = 1 } else { g2[s] = 0 }
    }

    let g3: ptr<i64> = calloc(N + 1, 8)
    let seen: ptr<i8> = calloc(256, 1)
    for n in 2..(N + 1) {
        for i in 0..256 { seen[i] = 0 }

        for a in 1..(n / 2 + 1) {
            let xor_val: i64 = g3[a] ^ g3[n - a]
            if xor_val < 256 { seen[xor_val] = 1 }
        }

        for a in 1..(n / 3 + 1) {
            let max_b: i64 = (n - a) / 2
            for b in a..(max_b + 1) {
                let c: i64 = n - a - b
                if b <= c {
                    let xor_val: i64 = g3[a] ^ g3[b] ^ g3[c]
                    if xor_val < 256 { seen[xor_val] = 1 }
                }
            }
        }

        let mut mex: i64 = 0
        while mex < 256 && seen[mex] == 1 { mex = mex + 1 }
        g3[n] = mex
    }
    free(seen)

    let g4: ptr<i64> = calloc(N + 1, 8)
    for s in 1..(N + 1) {
        g4[s] = s - 1
    }

    # Step 3: Compute f values
    let pn: i64 = partitions[N]
    let l2: i64 = count_losing(g2)
    let l3: i64 = count_losing(g3)
    let l4: i64 = count_losing(g4)

    let f2: i64 = (pn - l2 + MOD) % MOD
    let f3: i64 = (pn - l3 + MOD) % MOD
    let f4: i64 = (pn - l4 + MOD) % MOD

    let ans: i64 = (f2 + f3 + (N - 3) * f4 % MOD) % MOD
    printf("%lld\n", ans)

    free(g4)
    free(g3)
    free(g2)
    free(partitions)
    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 count_losing_ptr_i64(int64_t* grundy);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int64_t N = 200;
static const int64_t WIDTH = 128;



int64_t count_losing_ptr_i64(int64_t* grundy) {
    int64_t* dp = (int64_t*)(calloc(((N + 1) * WIDTH), 8));
    if (dp == NULL) {
        return (-1);
    }
    dp[0] = 1;
    int32_t __flow_step_1 = 1;
    for (int32_t size = 1; (1 <= (N + 1)) ? size < (N + 1) : size > (N + 1); size += (1 <= (N + 1)) ? 1 : -1) {
        int64_t g = grundy[size];
        int64_t pair = (2 * size);
        if (pair <= N) {
            int32_t __flow_step_2 = 1;
            for (int32_t s = pair; (pair <= (N + 1)) ? s < (N + 1) : s > (N + 1); s += (pair <= (N + 1)) ? 1 : -1) {
                int32_t __flow_step_3 = 1;
                for (int32_t x = 0; (0 <= WIDTH) ? x < WIDTH : x > WIDTH; x += (0 <= WIDTH) ? 1 : -1) {
                    if (dp[(((s - pair) * WIDTH) + x)] != 0) {
                        dp[((s * WIDTH) + x)] = FLOW_CHECKED_MOD(((dp[((s * WIDTH) + x)] + dp[(((s - pair) * WIDTH) + x)])), (MOD));
                    }
                }
            }
        }
        int64_t s_rev = N;
        while (s_rev >= size) {
            int32_t __flow_step_4 = 1;
            for (int32_t x = 0; (0 <= WIDTH) ? x < WIDTH : x > WIDTH; x += (0 <= WIDTH) ? 1 : -1) {
                if (dp[(((s_rev - size) * WIDTH) + x)] != 0) {
                    int64_t j = (x ^ g);
                    if (j < WIDTH) {
                        dp[((s_rev * WIDTH) + j)] = FLOW_CHECKED_MOD(((dp[((s_rev * WIDTH) + j)] + dp[(((s_rev - size) * WIDTH) + x)])), (MOD));
                    }
                }
            }
            s_rev = (s_rev - 1);
        }
    }
    int64_t result = dp[(N * WIDTH)];
    free(dp);
    return result;
}

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