Problem 269

Z(10^16): polynomials with an integer root. Inclusion-exclusion over integer roots -1 through -9. State contains up to nine signed bytes, encoded as an i128 key.

Answer1311109198529286
Output1311109198529286
StatusPASS
Native helperno
Runtime11200 ms
Peak memory32368 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(1)
Space complexityO(n^2)O(1)
ApproachFlow solutionClosed-form formula
VerdictSuboptimal

Flow source

# Project Euler 269
# Z(10^16): polynomials with an integer root.
# Inclusion-exclusion over integer roots -1 through -9.
# State contains up to nine signed bytes, encoded as an i128 key.

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

const CAP: i64 = 200003

function hash_key(key: i128) -> i64 {
    let mut h: i64 = (key % (CAP as i128)) as i64
    if h < 0 { h = h + CAP }
    return h
}

function find_slot(keys: ptr<i128>, used: ptr<i8>, key: i128) -> i64 {
    let mut h: i64 = hash_key(key)
    while used[h] != 0 {
        if keys[h] == key { return h }
        h = h + 1
        if h == CAP { h = 0 }
    }
    return h
}

function map_add(keys: ptr<i128>, vals: ptr<i64>, used: ptr<i8>, key: i128, value: i64) -> void {
    let h: i64 = find_slot(keys, used, key)
    if used[h] == 0 {
        used[h] = 1
        keys[h] = key
        vals[h] = value
    } else {
        vals[h] = vals[h] + value
    }
}

function encode(coeffs: ptr<i64>, m: i64) -> i128 {
    let mut key: i128 = 0
    let mut i: i64 = 0
    while i < m {
        let byte: i128 = ((coeffs[i] + 128) & 255) as i128
        key = (key << 8) | byte
        i = i + 1
    }
    return key
}

function decode(key0: i128, coeffs: ptr<i64>, m: i64) -> void {
    let mut key: i128 = key0
    let mut i: i64 = m - 1
    while i >= 0 {
        coeffs[i] = ((key & (255 as i128)) as i64) - 128
        key = key >> 8
        i = i - 1
    }
}

function count_for(roots: ptr<i64>, m: i64, length: i64) -> i64 {
    let a_keys: ptr<i128> = calloc(CAP, 16)
    let a_vals: ptr<i64> = calloc(CAP, 8)
    let a_used: ptr<i8> = calloc(CAP, 1)
    let b_keys: ptr<i128> = calloc(CAP, 16)
    let b_vals: ptr<i64> = calloc(CAP, 8)
    let b_used: ptr<i8> = calloc(CAP, 1)

    let mut cur_keys: ptr<i128> = a_keys
    let mut cur_vals: ptr<i64> = a_vals
    let mut cur_used: ptr<i8> = a_used
    let mut nxt_keys: ptr<i128> = b_keys
    let mut nxt_vals: ptr<i64> = b_vals
    let mut nxt_used: ptr<i8> = b_used

    let coeffs: ptr<i64> = calloc(9, 8)
    let narr: ptr<i64> = calloc(9, 8)

    let zero: i128 = encode(coeffs, m)
    map_add(cur_keys, cur_vals, cur_used, zero, 1)

    let mut pos: i64 = 0
    while pos < length {
        # clear next map
        let mut ci: i64 = 0
        while ci < CAP {
            nxt_used[ci] = 0
            ci = ci + 1
        }
        let mut lo: i64 = 0
        if pos == 0 || pos == length - 1 {
            lo = 1
        }
        let mut h: i64 = 0
        while h < CAP {
            if cur_used[h] != 0 {
                decode(cur_keys[h], coeffs, m)
                let ways: i64 = cur_vals[h]
                let mut d: i64 = lo
                while d <= 9 {
                    let mut ok: bool = true
                    let mut j: i64 = 0
                    while j < m {
                        let s: i64 = coeffs[j] + d
                        if s % roots[j] != 0 {
                            ok = false
                            break
                        }
                        narr[j] = 0 - (s / roots[j])
                        j = j + 1
                    }
                    if ok {
                        let nk: i128 = encode(narr, m)
                        map_add(nxt_keys, nxt_vals, nxt_used, nk, ways)
                    }
                    d = d + 1
                }
            }
            h = h + 1
        }
        # swap cur and nxt
        let tk: ptr<i128> = cur_keys
        cur_keys = nxt_keys
        nxt_keys = tk
        let tv: ptr<i64> = cur_vals
        cur_vals = nxt_vals
        nxt_vals = tv
        let tu: ptr<i8> = cur_used
        cur_used = nxt_used
        nxt_used = tu
        pos = pos + 1
    }

    let h: i64 = find_slot(cur_keys, cur_used, zero)
    let mut answer: i64 = 0
    if cur_used[h] != 0 {
        answer = cur_vals[h]
    }

    free(a_keys); free(a_vals); free(a_used)
    free(b_keys); free(b_vals); free(b_used)
    free(coeffs); free(narr)
    return answer
}

function main() -> i32 {
    let base: i64 = 1000000000000000
    let mut total: i64 = 0
    let roots: ptr<i64> = calloc(9, 8)
    let one: i64 = 1
    let mut mask: i64 = 1
    while mask < (one << 9) {
        let mut m: i64 = 0
        let mut i: i64 = 0
        while i < 9 {
            if (mask & (one << i)) != 0 {
                roots[m] = i + 1
                m = m + 1
            }
            i = i + 1
        }
        let mut sgn: i64 = 1
        if m % 2 == 0 { sgn = -1 }
        let mut subtotal: i64 = 0
        let mut L: i64 = 1
        while L <= 16 {
            subtotal = subtotal + count_for(roots, m, L)
            L = L + 1
        }
        total = total + sgn * subtotal
        mask = mask + 1
    }
    printf("%lld\n", base + total)
    free(roots)
    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 hash_key_i128(__int128 key);
int64_t find_slot_ptr_i128_ptr_i8_i128(__int128* keys, int8_t* used, __int128 key);
void map_add_ptr_i128_ptr_i64_ptr_i8_i128_i64(__int128* keys, int64_t* vals, int8_t* used, __int128 key, int64_t value);
__int128 encode_ptr_i64_i64(int64_t* coeffs, int64_t m);
void decode_i128_ptr_i64_i64(__int128 key0, int64_t* coeffs, int64_t m);
int64_t count_for_ptr_i64_i64_i64(int64_t* roots, int64_t m, int64_t length);
int32_t main(void);

static const int64_t CAP = 200003;



int64_t hash_key_i128(__int128 key) {
    int64_t h = ((int64_t)(FLOW_CHECKED_MOD((key), (((__int128)(CAP))))));
    if (h < 0) {
        h = (h + CAP);
    }
    return h;
}

int64_t find_slot_ptr_i128_ptr_i8_i128(__int128* keys, int8_t* used, __int128 key) {
    int64_t h = hash_key_i128(key);
    while (used[h] != 0) {
        if (keys[h] == key) {
            return h;
        }
        h = (h + 1);
        if (h == CAP) {
            h = 0;
        }
    }
    return h;
}

void map_add_ptr_i128_ptr_i64_ptr_i8_i128_i64(__int128* keys, int64_t* vals, int8_t* used, __int128 key, int64_t value) {
    int64_t h = find_slot_ptr_i128_ptr_i8_i128(keys, used, key);
    if (used[h] == 0) {
        used[h] = 1;
        keys[h] = key;
        vals[h] = value;
    } else {
        vals[h] = (vals[h] + value);
    }
}

__int128 encode_ptr_i64_i64(int64_t* coeffs, int64_t m) {
    __int128 key = 0;
    int64_t i = 0;
    while (i < m) {
        __int128 byte = ((__int128)(((coeffs[i] + 128) & 255)));
        key = (FLOW_CHECKED_SHL((key), (8)) | byte);
        i = (i + 1);
    }
    return key;
}

void decode_i128_ptr_i64_i64(__int128 key0, int64_t* coeffs, int64_t m) {
    __int128 key = key0;
    int64_t i = (m - 1);
    while (i >= 0) {
        coeffs[i] = (((int64_t)((key & ((__int128)(255))))) - 128);
        key = FLOW_CHECKED_SHR((key), (8));
        i = (i - 1);
    }
}

int64_t count_for_ptr_i64_i64_i64(int64_t* roots, int64_t m, int64_t length) {
    __int128* a_keys = (__int128*)(calloc(CAP, 16));
    int64_t* a_vals = (int64_t*)(calloc(CAP, 8));
    int8_t* a_used = (int8_t*)(calloc(CAP, 1));
    __int128* b_keys = (__int128*)(calloc(CAP, 16));
    int64_t* b_vals = (int64_t*)(calloc(CAP, 8));
    int8_t* b_used = (int8_t*)(calloc(CAP, 1));
    __int128* cur_keys = (__int128*)(a_keys);
    int64_t* cur_vals = (int64_t*)(a_vals);
    int8_t* cur_used = (int8_t*)(a_used);
    __int128* nxt_keys = (__int128*)(b_keys);
    int64_t* nxt_vals = (int64_t*)(b_vals);
    int8_t* nxt_used = (int8_t*)(b_used);
    int64_t* coeffs = (int64_t*)(calloc(9, 8));
    int64_t* narr = (int64_t*)(calloc(9, 8));
    __int128 zero = encode_ptr_i64_i64(coeffs, m);
    map_add_ptr_i128_ptr_i64_ptr_i8_i128_i64(cur_keys, cur_vals, cur_used, zero, 1);
    int64_t pos = 0;
    while (pos < length) {
        int64_t ci = 0;
        while (ci < CAP) {
            nxt_used[ci] = 0;
            ci = (ci + 1);
        }
        int64_t lo = 0;
        if ((pos == 0 || pos == (length - 1))) {
            lo = 1;
        }
        int64_t h = 0;
        while (h < CAP) {
            if (cur_used[h] != 0) {
                decode_i128_ptr_i64_i64(cur_keys[h], coeffs, m);
                int64_t ways = cur_vals[h];
                int64_t d = lo;
                while (d <= 9) {
                    bool ok = 1;
                    int64_t j = 0;
                    while (j < m) {
                        int64_t s = (coeffs[j] + d);
                        if (FLOW_CHECKED_MOD((s), (roots[j])) != 0) {
                            ok = 0;
                            break;
                        }
                        narr[j] = (0 - FLOW_CHECKED_DIV((s), (roots[j])));
                        j = (j + 1);
                    }
                    if (ok) {
                        __int128 nk = encode_ptr_i64_i64(narr, m);
                        map_add_ptr_i128_ptr_i64_ptr_i8_i128_i64(nxt_keys, nxt_vals, nxt_used, nk, ways);
                    }
                    d = (d + 1);
                }
            }
            h = (h + 1);
        }
        __int128* tk = (__int128*)(cur_keys);
        cur_keys = nxt_keys;
        nxt_keys = tk;
        int64_t* tv = (int64_t*)(cur_vals);
        cur_vals = nxt_vals;
        nxt_vals = tv;
        int8_t* tu = (int8_t*)(cur_used);
        cur_used = nxt_used;
        nxt_used = tu;
        pos = (pos + 1);
    }
    int64_t h = find_slot_ptr_i128_ptr_i8_i128(cur_keys, cur_used, zero);
    int64_t answer = 0;
    if (cur_used[h] != 0) {
        answer = cur_vals[h];
    }
    free(a_keys);
    free(a_vals);
    free(a_used);
    free(b_keys);
    free(b_vals);
    free(b_used);
    free(coeffs);
    free(narr);
    return answer;
}

int32_t main(void) {
    int64_t base = 1000000000000000;
    int64_t total = 0;
    int64_t* roots = (int64_t*)(calloc(9, 8));
    int64_t one = 1;
    int64_t mask = 1;
    while (mask < FLOW_CHECKED_SHL((one), (9))) {
        int64_t m = 0;
        int64_t i = 0;
        while (i < 9) {
            if ((mask & FLOW_CHECKED_SHL((one), (i))) != 0) {
                roots[m] = (i + 1);
                m = (m + 1);
            }
            i = (i + 1);
        }
        int64_t sgn = 1;
        if (FLOW_CHECKED_MOD((m), (2)) == 0) {
            sgn = (-1);
        }
        int64_t subtotal = 0;
        int64_t L = 1;
        while (L <= 16) {
            subtotal = (subtotal + count_for_ptr_i64_i64_i64(roots, m, L));
            L = (L + 1);
        }
        total = (total + (sgn * subtotal));
        mask = (mask + 1);
    }
    printf("%lld\n", (base + total));
    free(roots);
    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: CAP
  llvm.mlir.global internal constant @CAP(200003 : i64) : i64
  func.func @hash_key(%arg0: i128) -> i64 {
    %0 = llvm.mlir.addressof @CAP : !llvm.ptr
    %1 = llvm.load %0 : !llvm.ptr -> i64
    %2 = arith.extsi %1 : i64 to i128
    %4 = arith.trunci %arg0 : i128 to i64
    %5 = arith.trunci %2 : i128 to i64
    %3 = arith.remsi %4, %5 : i64
    %6 = llvm.mlir.constant(1 : i64) : i64
    %7 = llvm.alloca %6 x i64 : (i64) -> !llvm.ptr
    llvm.store %3, %7 : i64, !llvm.ptr
    %8 = llvm.load %7 : !llvm.ptr -> i64
    %9 = arith.constant 0 : i32
    %11 = arith.extsi %9 : i32 to i64
    %10 = arith.cmpi slt, %8, %11 : i64
    cf.cond_br %10, ^bb0, ^bb1
    ^bb0:
      %12 = llvm.load %7 : !llvm.ptr -> i64
      %13 = llvm.mlir.addressof @CAP : !llvm.ptr
      %14 = llvm.load %13 : !llvm.ptr -> i64
      %15 = arith.addi %12, %14 : i64
      llvm.store %15, %7 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %16 = llvm.load %7 : !llvm.ptr -> i64
    func.return %16 : i64
  }
  func.func @find_slot(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i128) -> i64 {
    %17 = func.call @hash_key(%arg2) : (i128) -> i64
    %18 = llvm.mlir.constant(1 : i64) : i64
    %19 = llvm.alloca %18 x i64 : (i64) -> !llvm.ptr
    llvm.store %17, %19 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %21 = llvm.load %19 : !llvm.ptr -> i64
    %22 = llvm.getelementptr %arg1[%21] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %20 = llvm.load %22 : !llvm.ptr -> i8
    %23 = arith.constant 0 : i32
    %25 = arith.extsi %20 : i8 to i32
    %24 = arith.cmpi ne, %25, %23 : i32
    cf.cond_br %24, ^bb4, ^bb5
    ^bb4:
      %27 = llvm.load %19 : !llvm.ptr -> i64
      %28 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i64) -> !llvm.ptr, i128
      %26 = llvm.load %28 : !llvm.ptr -> i128
      %30 = arith.trunci %26 : i128 to i64
      %31 = arith.trunci %arg2 : i128 to i64
      %29 = arith.cmpi eq, %30, %31 : i64
      cf.cond_br %29, ^bb6, ^bb7
      ^bb6:
        %32 = llvm.load %19 : !llvm.ptr -> i64
        func.return %32 : i64
      ^bb7:
        cf.br ^bb8
      ^bb8:
      %33 = llvm.load %19 : !llvm.ptr -> i64
      %34 = arith.constant 1 : i32
      %36 = arith.extsi %34 : i32 to i64
      %35 = arith.addi %33, %36 : i64
      llvm.store %35, %19 : i64, !llvm.ptr
      %37 = llvm.load %19 : !llvm.ptr -> i64
      %38 = llvm.mlir.addressof @CAP : !llvm.ptr
      %39 = llvm.load %38 : !llvm.ptr -> i64
      %40 = arith.cmpi eq, %37, %39 : i64
      cf.cond_br %40, ^bb9, ^bb10
      ^bb9:
        %41 = arith.constant 0 : i32
        %42 = arith.extsi %41 : i32 to i64
        llvm.store %42, %19 : i64, !llvm.ptr
        cf.br ^bb11
      ^bb10:
        cf.br ^bb11
      ^bb11:
      cf.br ^bb3
    ^bb5:
    %43 = llvm.load %19 : !llvm.ptr -> i64
    func.return %43 : i64
  }
  func.func @map_add(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i128, %arg4: i64) -> () {
    %44 = func.call @find_slot(%arg0, %arg2, %arg3) : (!llvm.ptr, !llvm.ptr, i128) -> i64
    %46 = llvm.getelementptr %arg2[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %45 = llvm.load %46 : !llvm.ptr -> i8
    %47 = arith.constant 0 : i32
    %49 = arith.extsi %45 : i8 to i32
    %48 = arith.cmpi eq, %49, %47 : i32
    cf.cond_br %48, ^bb12, ^bb13
    ^bb12:
      %50 = arith.constant 1 : i32
      %51 = arith.trunci %50 : i32 to i8
      %52 = llvm.getelementptr %arg2[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %51, %52 : i8, !llvm.ptr
      %53 = llvm.getelementptr %arg0[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i128
      llvm.store %arg3, %53 : i128, !llvm.ptr
      %54 = llvm.getelementptr %arg1[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %arg4, %54 : i64, !llvm.ptr
      cf.br ^bb14
    ^bb13:
      %56 = llvm.getelementptr %arg1[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %55 = llvm.load %56 : !llvm.ptr -> i64
      %57 = arith.addi %55, %arg4 : i64
      %58 = llvm.getelementptr %arg1[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %57, %58 : i64, !llvm.ptr
      cf.br ^bb14
    ^bb14:
    func.return
  }
  func.func @encode(%arg0: !llvm.ptr, %arg1: i64) -> i128 {
    %59 = arith.constant 0 : i32
    %60 = arith.extsi %59 : i32 to i128
    %61 = llvm.mlir.constant(1 : i64) : i64
    %62 = llvm.alloca %61 x i128 : (i64) -> !llvm.ptr
    llvm.store %60, %62 : i128, !llvm.ptr
    %63 = arith.constant 0 : i32
    %64 = arith.extsi %63 : i32 to i64
    %65 = llvm.mlir.constant(1 : i64) : i64
    %66 = llvm.alloca %65 x i64 : (i64) -> !llvm.ptr
    llvm.store %64, %66 : i64, !llvm.ptr
    cf.br ^bb15
    ^bb15:
    %67 = llvm.load %66 : !llvm.ptr -> i64
    %68 = arith.cmpi slt, %67, %arg1 : i64
    cf.cond_br %68, ^bb16, ^bb17
    ^bb16:
      %70 = llvm.load %66 : !llvm.ptr -> i64
      %71 = llvm.getelementptr %arg0[%70] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %69 = llvm.load %71 : !llvm.ptr -> i64
      %72 = arith.constant 128 : i32
      %74 = arith.extsi %72 : i32 to i64
      %73 = arith.addi %69, %74 : i64
      %75 = arith.constant 255 : i32
      %77 = arith.extsi %75 : i32 to i64
      %76 = arith.andi %73, %77 : i64
      %78 = arith.extsi %76 : i64 to i128
      %79 = llvm.load %62 : !llvm.ptr -> i128
      %80 = arith.constant 8 : i32
      %82 = arith.trunci %79 : i128 to i64
      %83 = arith.extsi %80 : i32 to i64
      %81 = arith.shli %82, %83 : i64
      %85 = arith.trunci %78 : i128 to i64
      %84 = arith.ori %81, %85 : i64
      %86 = arith.extsi %84 : i64 to i128
      llvm.store %86, %62 : i128, !llvm.ptr
      %87 = llvm.load %66 : !llvm.ptr -> i64
      %88 = arith.constant 1 : i32
      %90 = arith.extsi %88 : i32 to i64
      %89 = arith.addi %87, %90 : i64
      llvm.store %89, %66 : i64, !llvm.ptr
      cf.br ^bb15
    ^bb17:
    %91 = llvm.load %62 : !llvm.ptr -> i128
    func.return %91 : i128
  }
  func.func @decode(%arg0: i128, %arg1: !llvm.ptr, %arg2: i64) -> () {
    %92 = llvm.mlir.constant(1 : i64) : i64
    %93 = llvm.alloca %92 x i128 : (i64) -> !llvm.ptr
    llvm.store %arg0, %93 : i128, !llvm.ptr
    %94 = arith.constant 1 : i32
    %96 = arith.extsi %94 : i32 to i64
    %95 = arith.subi %arg2, %96 : i64
    %97 = llvm.mlir.constant(1 : i64) : i64
    %98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
    llvm.store %95, %98 : i64, !llvm.ptr
    cf.br ^bb18
    ^bb18:
    %99 = llvm.load %98 : !llvm.ptr -> i64
    %100 = arith.constant 0 : i32
    %102 = arith.extsi %100 : i32 to i64
    %101 = arith.cmpi sge, %99, %102 : i64
    cf.cond_br %101, ^bb19, ^bb20
    ^bb19:
      %103 = llvm.load %93 : !llvm.ptr -> i128
      %104 = arith.constant 255 : i32
      %105 = arith.extsi %104 : i32 to i128
      %107 = arith.trunci %103 : i128 to i64
      %108 = arith.trunci %105 : i128 to i64
      %106 = arith.andi %107, %108 : i64
      %109 = arith.constant 128 : i32
      %111 = arith.extsi %109 : i32 to i64
      %110 = arith.subi %106, %111 : i64
      %112 = llvm.load %98 : !llvm.ptr -> i64
      %113 = llvm.getelementptr %arg1[%112] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %110, %113 : i64, !llvm.ptr
      %114 = llvm.load %93 : !llvm.ptr -> i128
      %115 = arith.constant 8 : i32
      %117 = arith.trunci %114 : i128 to i64
      %118 = arith.extsi %115 : i32 to i64
      %116 = arith.shrsi %117, %118 : i64
      %119 = arith.extsi %116 : i64 to i128
      llvm.store %119, %93 : i128, !llvm.ptr
      %120 = llvm.load %98 : !llvm.ptr -> i64
      %121 = arith.constant 1 : i32
      %123 = arith.extsi %121 : i32 to i64
      %122 = arith.subi %120, %123 : i64
      llvm.store %122, %98 : i64, !llvm.ptr
      cf.br ^bb18
    ^bb20:
    func.return
  }
  func.func @count_for(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 {
    %125 = llvm.mlir.addressof @CAP : !llvm.ptr
    %126 = llvm.load %125 : !llvm.ptr -> i64
    %127 = arith.constant 16 : i32
    %128 = arith.extsi %127 : i32 to i64
    %124 = func.call @calloc(%126, %128) : (i64, i64) -> !llvm.ptr
    %130 = llvm.mlir.addressof @CAP : !llvm.ptr
    %131 = llvm.load %130 : !llvm.ptr -> i64
    %132 = arith.constant 8 : i32
    %133 = arith.extsi %132 : i32 to i64
    %129 = func.call @calloc(%131, %133) : (i64, i64) -> !llvm.ptr
    %135 = llvm.mlir.addressof @CAP : !llvm.ptr
    %136 = llvm.load %135 : !llvm.ptr -> i64
    %137 = arith.constant 1 : i32
    %138 = arith.extsi %137 : i32 to i64
    %134 = func.call @calloc(%136, %138) : (i64, i64) -> !llvm.ptr
    %140 = llvm.mlir.addressof @CAP : !llvm.ptr
    %141 = llvm.load %140 : !llvm.ptr -> i64
    %142 = arith.constant 16 : i32
    %143 = arith.extsi %142 : i32 to i64
    %139 = func.call @calloc(%141, %143) : (i64, i64) -> !llvm.ptr
    %145 = llvm.mlir.addressof @CAP : !llvm.ptr
    %146 = llvm.load %145 : !llvm.ptr -> i64
    %147 = arith.constant 8 : i32
    %148 = arith.extsi %147 : i32 to i64
    %144 = func.call @calloc(%146, %148) : (i64, i64) -> !llvm.ptr
    %150 = llvm.mlir.addressof @CAP : !llvm.ptr
    %151 = llvm.load %150 : !llvm.ptr -> i64
    %152 = arith.constant 1 : i32
    %153 = arith.extsi %152 : i32 to i64
    %149 = func.call @calloc(%151, %153) : (i64, i64) -> !llvm.ptr
    %154 = llvm.mlir.constant(1 : i64) : i64
    %155 = llvm.alloca %154 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %124, %155 : !llvm.ptr, !llvm.ptr
    %156 = llvm.mlir.constant(1 : i64) : i64
    %157 = llvm.alloca %156 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %129, %157 : !llvm.ptr, !llvm.ptr
    %158 = llvm.mlir.constant(1 : i64) : i64
    %159 = llvm.alloca %158 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %134, %159 : !llvm.ptr, !llvm.ptr
    %160 = llvm.mlir.constant(1 : i64) : i64
    %161 = llvm.alloca %160 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %139, %161 : !llvm.ptr, !llvm.ptr
    %162 = llvm.mlir.constant(1 : i64) : i64
    %163 = llvm.alloca %162 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %144, %163 : !llvm.ptr, !llvm.ptr
    %164 = llvm.mlir.constant(1 : i64) : i64
    %165 = llvm.alloca %164 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %149, %165 : !llvm.ptr, !llvm.ptr
    %167 = arith.constant 9 : i32
    %168 = arith.constant 8 : i32
    %169 = arith.extsi %167 : i32 to i64
    %170 = arith.extsi %168 : i32 to i64
    %166 = func.call @calloc(%169, %170) : (i64, i64) -> !llvm.ptr
    %172 = arith.constant 9 : i32
    %173 = arith.constant 8 : i32
    %174 = arith.extsi %172 : i32 to i64
    %175 = arith.extsi %173 : i32 to i64
    %171 = func.call @calloc(%174, %175) : (i64, i64) -> !llvm.ptr
    %176 = func.call @encode(%166, %arg1) : (!llvm.ptr, i64) -> i128
    %178 = llvm.load %155 : !llvm.ptr -> !llvm.ptr
    %179 = llvm.load %157 : !llvm.ptr -> !llvm.ptr
    %180 = llvm.load %159 : !llvm.ptr -> !llvm.ptr
    %181 = arith.constant 1 : i32
    %182 = arith.extsi %181 : i32 to i64
    func.call @map_add(%178, %179, %180, %176, %182) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i128, i64) -> ()
    %183 = arith.constant 0 : i32
    %184 = arith.extsi %183 : i32 to i64
    %185 = llvm.mlir.constant(1 : i64) : i64
    %186 = llvm.alloca %185 x i64 : (i64) -> !llvm.ptr
    llvm.store %184, %186 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %187 = llvm.load %186 : !llvm.ptr -> i64
    %188 = arith.cmpi slt, %187, %arg2 : i64
    cf.cond_br %188, ^bb22, ^bb23
    ^bb22:
      %189 = arith.constant 0 : i32
      %190 = arith.extsi %189 : i32 to i64
      %191 = llvm.mlir.constant(1 : i64) : i64
      %192 = llvm.alloca %191 x i64 : (i64) -> !llvm.ptr
      llvm.store %190, %192 : i64, !llvm.ptr
      cf.br ^bb24
      ^bb24:
      %193 = llvm.load %192 : !llvm.ptr -> i64
      %194 = llvm.mlir.addressof @CAP : !llvm.ptr
      %195 = llvm.load %194 : !llvm.ptr -> i64
      %196 = arith.cmpi slt, %193, %195 : i64
      cf.cond_br %196, ^bb25, ^bb26
      ^bb25:
        %197 = arith.constant 0 : i32
        %198 = llvm.load %165 : !llvm.ptr -> !llvm.ptr
        %199 = llvm.load %192 : !llvm.ptr -> i64
        %200 = arith.trunci %197 : i32 to i8
        %201 = llvm.getelementptr %198[%199] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %200, %201 : i8, !llvm.ptr
        %202 = llvm.load %192 : !llvm.ptr -> i64
        %203 = arith.constant 1 : i32
        %205 = arith.extsi %203 : i32 to i64
        %204 = arith.addi %202, %205 : i64
        llvm.store %204, %192 : i64, !llvm.ptr
        cf.br ^bb24
      ^bb26:
      %206 = arith.constant 0 : i32
      %207 = arith.extsi %206 : i32 to i64
      %208 = llvm.mlir.constant(1 : i64) : i64
      %209 = llvm.alloca %208 x i64 : (i64) -> !llvm.ptr
      llvm.store %207, %209 : i64, !llvm.ptr
      %210 = llvm.load %186 : !llvm.ptr -> i64
      %211 = arith.constant 0 : i32
      %213 = arith.extsi %211 : i32 to i64
      %212 = arith.cmpi eq, %210, %213 : i64
      %214 = scf.if %212 -> (i1) {
        %215 = arith.constant true
        scf.yield %215 : i1
      } else {
        %216 = llvm.load %186 : !llvm.ptr -> i64
        %217 = arith.constant 1 : i32
        %219 = arith.extsi %217 : i32 to i64
        %218 = arith.subi %arg2, %219 : i64
        %220 = arith.cmpi eq, %216, %218 : i64
        scf.yield %220 : i1
      }
      cf.cond_br %214, ^bb27, ^bb28
      ^bb27:
        %221 = arith.constant 1 : i32
        %222 = arith.extsi %221 : i32 to i64
        llvm.store %222, %209 : i64, !llvm.ptr
        cf.br ^bb29
      ^bb28:
        cf.br ^bb29
      ^bb29:
      %223 = arith.constant 0 : i32
      %224 = arith.extsi %223 : i32 to i64
      %225 = llvm.mlir.constant(1 : i64) : i64
      %226 = llvm.alloca %225 x i64 : (i64) -> !llvm.ptr
      llvm.store %224, %226 : i64, !llvm.ptr
      cf.br ^bb30
      ^bb30:
      %227 = llvm.load %226 : !llvm.ptr -> i64
      %228 = llvm.mlir.addressof @CAP : !llvm.ptr
      %229 = llvm.load %228 : !llvm.ptr -> i64
      %230 = arith.cmpi slt, %227, %229 : i64
      cf.cond_br %230, ^bb31, ^bb32
      ^bb31:
        %232 = llvm.load %159 : !llvm.ptr -> !llvm.ptr
        %233 = llvm.load %226 : !llvm.ptr -> i64
        %234 = llvm.getelementptr %232[%233] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        %231 = llvm.load %234 : !llvm.ptr -> i8
        %235 = arith.constant 0 : i32
        %237 = arith.extsi %231 : i8 to i32
        %236 = arith.cmpi ne, %237, %235 : i32
        cf.cond_br %236, ^bb33, ^bb34
        ^bb33:
          %240 = llvm.load %155 : !llvm.ptr -> !llvm.ptr
          %241 = llvm.load %226 : !llvm.ptr -> i64
          %242 = llvm.getelementptr %240[%241] : (!llvm.ptr, i64) -> !llvm.ptr, i128
          %239 = llvm.load %242 : !llvm.ptr -> i128
          func.call @decode(%239, %166, %arg1) : (i128, !llvm.ptr, i64) -> ()
          %244 = llvm.load %157 : !llvm.ptr -> !llvm.ptr
          %245 = llvm.load %226 : !llvm.ptr -> i64
          %246 = llvm.getelementptr %244[%245] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %243 = llvm.load %246 : !llvm.ptr -> i64
          %247 = llvm.load %209 : !llvm.ptr -> i64
          %248 = llvm.mlir.constant(1 : i64) : i64
          %249 = llvm.alloca %248 x i64 : (i64) -> !llvm.ptr
          llvm.store %247, %249 : i64, !llvm.ptr
          cf.br ^bb36
          ^bb36:
          %250 = llvm.load %249 : !llvm.ptr -> i64
          %251 = arith.constant 9 : i32
          %253 = arith.extsi %251 : i32 to i64
          %252 = arith.cmpi sle, %250, %253 : i64
          cf.cond_br %252, ^bb37, ^bb38
          ^bb37:
            %254 = arith.constant 1 : i1
            %255 = llvm.mlir.constant(1 : i64) : i64
            %256 = llvm.alloca %255 x i1 : (i64) -> !llvm.ptr
            llvm.store %254, %256 : i1, !llvm.ptr
            %257 = arith.constant 0 : i32
            %258 = arith.extsi %257 : i32 to i64
            %259 = llvm.mlir.constant(1 : i64) : i64
            %260 = llvm.alloca %259 x i64 : (i64) -> !llvm.ptr
            llvm.store %258, %260 : i64, !llvm.ptr
            cf.br ^bb39
            ^bb39:
            %261 = llvm.load %260 : !llvm.ptr -> i64
            %262 = arith.cmpi slt, %261, %arg1 : i64
            cf.cond_br %262, ^bb40, ^bb41
            ^bb40:
              %264 = llvm.load %260 : !llvm.ptr -> i64
              %265 = llvm.getelementptr %166[%264] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %263 = llvm.load %265 : !llvm.ptr -> i64
              %266 = llvm.load %249 : !llvm.ptr -> i64
              %267 = arith.addi %263, %266 : i64
              %269 = llvm.load %260 : !llvm.ptr -> i64
              %270 = llvm.getelementptr %arg0[%269] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %268 = llvm.load %270 : !llvm.ptr -> i64
              %271 = arith.remsi %267, %268 : i64
              %272 = arith.constant 0 : i32
              %274 = arith.extsi %272 : i32 to i64
              %273 = arith.cmpi ne, %271, %274 : i64
              cf.cond_br %273, ^bb42, ^bb43
              ^bb42:
                %275 = arith.constant 0 : i1
                llvm.store %275, %256 : i1, !llvm.ptr
                cf.br ^bb41
              ^bb43:
                cf.br ^bb44
              ^bb44:
              %276 = arith.constant 0 : i32
              %278 = llvm.load %260 : !llvm.ptr -> i64
              %279 = llvm.getelementptr %arg0[%278] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %277 = llvm.load %279 : !llvm.ptr -> i64
              %280 = arith.divsi %267, %277 : i64
              %282 = arith.extsi %276 : i32 to i64
              %281 = arith.subi %282, %280 : i64
              %283 = llvm.load %260 : !llvm.ptr -> i64
              %284 = llvm.getelementptr %171[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %281, %284 : i64, !llvm.ptr
              %285 = llvm.load %260 : !llvm.ptr -> i64
              %286 = arith.constant 1 : i32
              %288 = arith.extsi %286 : i32 to i64
              %287 = arith.addi %285, %288 : i64
              llvm.store %287, %260 : i64, !llvm.ptr
              cf.br ^bb39
            ^bb41:
            %289 = llvm.load %256 : !llvm.ptr -> i1
            cf.cond_br %289, ^bb45, ^bb46
            ^bb45:
              %290 = func.call @encode(%171, %arg1) : (!llvm.ptr, i64) -> i128
              %292 = llvm.load %161 : !llvm.ptr -> !llvm.ptr
              %293 = llvm.load %163 : !llvm.ptr -> !llvm.ptr
              %294 = llvm.load %165 : !llvm.ptr -> !llvm.ptr
              func.call @map_add(%292, %293, %294, %290, %243) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i128, i64) -> ()
              cf.br ^bb47
            ^bb46:
              cf.br ^bb47
            ^bb47:
            %295 = llvm.load %249 : !llvm.ptr -> i64
            %296 = arith.constant 1 : i32
            %298 = arith.extsi %296 : i32 to i64
            %297 = arith.addi %295, %298 : i64
            llvm.store %297, %249 : i64, !llvm.ptr
            cf.br ^bb36
          ^bb38:
          cf.br ^bb35
        ^bb34:
          cf.br ^bb35
        ^bb35:
        %299 = llvm.load %226 : !llvm.ptr -> i64
        %300 = arith.constant 1 : i32
        %302 = arith.extsi %300 : i32 to i64
        %301 = arith.addi %299, %302 : i64
        llvm.store %301, %226 : i64, !llvm.ptr
        cf.br ^bb30
      ^bb32:
      %303 = llvm.load %155 : !llvm.ptr -> !llvm.ptr
      %304 = llvm.load %161 : !llvm.ptr -> !llvm.ptr
      llvm.store %304, %155 : !llvm.ptr, !llvm.ptr
      llvm.store %303, %161 : !llvm.ptr, !llvm.ptr
      %305 = llvm.load %157 : !llvm.ptr -> !llvm.ptr
      %306 = llvm.load %163 : !llvm.ptr -> !llvm.ptr
      llvm.store %306, %157 : !llvm.ptr, !llvm.ptr
      llvm.store %305, %163 : !llvm.ptr, !llvm.ptr
      %307 = llvm.load %159 : !llvm.ptr -> !llvm.ptr
      %308 = llvm.load %165 : !llvm.ptr -> !llvm.ptr
      llvm.store %308, %159 : !llvm.ptr, !llvm.ptr
      llvm.store %307, %165 : !llvm.ptr, !llvm.ptr
      %309 = llvm.load %186 : !llvm.ptr -> i64
      %310 = arith.constant 1 : i32
      %312 = arith.extsi %310 : i32 to i64
      %311 = arith.addi %309, %312 : i64
      llvm.store %311, %186 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %314 = llvm.load %155 : !llvm.ptr -> !llvm.ptr
    %315 = llvm.load %159 : !llvm.ptr -> !llvm.ptr
    %313 = func.call @find_slot(%314, %315, %176) : (!llvm.ptr, !llvm.ptr, i128) -> i64
    %316 = arith.constant 0 : i32
    %317 = arith.extsi %316 : i32 to i64
    %318 = llvm.mlir.constant(1 : i64) : i64
    %319 = llvm.alloca %318 x i64 : (i64) -> !llvm.ptr
    llvm.store %317, %319 : i64, !llvm.ptr
    %321 = llvm.load %159 : !llvm.ptr -> !llvm.ptr
    %322 = llvm.getelementptr %321[%313] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %320 = llvm.load %322 : !llvm.ptr -> i8
    %323 = arith.constant 0 : i32
    %325 = arith.extsi %320 : i8 to i32
    %324 = arith.cmpi ne, %325, %323 : i32
    cf.cond_br %324, ^bb48, ^bb49
    ^bb48:
      %327 = llvm.load %157 : !llvm.ptr -> !llvm.ptr
      %328 = llvm.getelementptr %327[%313] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %326 = llvm.load %328 : !llvm.ptr -> i64
      llvm.store %326, %319 : i64, !llvm.ptr
      cf.br ^bb50
    ^bb49:
      cf.br ^bb50
    ^bb50:
    func.call @free(%124) : (!llvm.ptr) -> ()
    func.call @free(%129) : (!llvm.ptr) -> ()
    func.call @free(%134) : (!llvm.ptr) -> ()
    func.call @free(%139) : (!llvm.ptr) -> ()
    func.call @free(%144) : (!llvm.ptr) -> ()
    func.call @free(%149) : (!llvm.ptr) -> ()
    func.call @free(%166) : (!llvm.ptr) -> ()
    func.call @free(%171) : (!llvm.ptr) -> ()
    %337 = llvm.load %319 : !llvm.ptr -> i64
    func.return %337 : i64
  }
  func.func @main() -> i32 {
    %338 = arith.constant 999995705032704 : i32
    %339 = arith.extsi %338 : i32 to i64
    %340 = arith.constant 0 : i32
    %341 = arith.extsi %340 : i32 to i64
    %342 = llvm.mlir.constant(1 : i64) : i64
    %343 = llvm.alloca %342 x i64 : (i64) -> !llvm.ptr
    llvm.store %341, %343 : i64, !llvm.ptr
    %345 = arith.constant 9 : i32
    %346 = arith.constant 8 : i32
    %347 = arith.extsi %345 : i32 to i64
    %348 = arith.extsi %346 : i32 to i64
    %344 = func.call @calloc(%347, %348) : (i64, i64) -> !llvm.ptr
    %349 = arith.constant 1 : i32
    %350 = arith.extsi %349 : i32 to i64
    %351 = arith.constant 1 : i32
    %352 = arith.extsi %351 : i32 to i64
    %353 = llvm.mlir.constant(1 : i64) : i64
    %354 = llvm.alloca %353 x i64 : (i64) -> !llvm.ptr
    llvm.store %352, %354 : i64, !llvm.ptr
    cf.br ^bb51
    ^bb51:
    %355 = llvm.load %354 : !llvm.ptr -> i64
    %356 = arith.constant 9 : i32
    %358 = arith.extsi %356 : i32 to i64
    %357 = arith.shli %350, %358 : i64
    %359 = arith.cmpi slt, %355, %357 : i64
    cf.cond_br %359, ^bb52, ^bb53
    ^bb52:
      %360 = arith.constant 0 : i32
      %361 = arith.extsi %360 : i32 to i64
      %362 = llvm.mlir.constant(1 : i64) : i64
      %363 = llvm.alloca %362 x i64 : (i64) -> !llvm.ptr
      llvm.store %361, %363 : i64, !llvm.ptr
      %364 = arith.constant 0 : i32
      %365 = arith.extsi %364 : i32 to i64
      %366 = llvm.mlir.constant(1 : i64) : i64
      %367 = llvm.alloca %366 x i64 : (i64) -> !llvm.ptr
      llvm.store %365, %367 : i64, !llvm.ptr
      cf.br ^bb54
      ^bb54:
      %368 = llvm.load %367 : !llvm.ptr -> i64
      %369 = arith.constant 9 : i32
      %371 = arith.extsi %369 : i32 to i64
      %370 = arith.cmpi slt, %368, %371 : i64
      cf.cond_br %370, ^bb55, ^bb56
      ^bb55:
        %372 = llvm.load %354 : !llvm.ptr -> i64
        %373 = llvm.load %367 : !llvm.ptr -> i64
        %374 = arith.shli %350, %373 : i64
        %375 = arith.andi %372, %374 : i64
        %376 = arith.constant 0 : i32
        %378 = arith.extsi %376 : i32 to i64
        %377 = arith.cmpi ne, %375, %378 : i64
        cf.cond_br %377, ^bb57, ^bb58
        ^bb57:
          %379 = llvm.load %367 : !llvm.ptr -> i64
          %380 = arith.constant 1 : i32
          %382 = arith.extsi %380 : i32 to i64
          %381 = arith.addi %379, %382 : i64
          %383 = llvm.load %363 : !llvm.ptr -> i64
          %384 = llvm.getelementptr %344[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %381, %384 : i64, !llvm.ptr
          %385 = llvm.load %363 : !llvm.ptr -> i64
          %386 = arith.constant 1 : i32
          %388 = arith.extsi %386 : i32 to i64
          %387 = arith.addi %385, %388 : i64
          llvm.store %387, %363 : i64, !llvm.ptr
          cf.br ^bb59
        ^bb58:
          cf.br ^bb59
        ^bb59:
        %389 = llvm.load %367 : !llvm.ptr -> i64
        %390 = arith.constant 1 : i32
        %392 = arith.extsi %390 : i32 to i64
        %391 = arith.addi %389, %392 : i64
        llvm.store %391, %367 : i64, !llvm.ptr
        cf.br ^bb54
      ^bb56:
      %393 = arith.constant 1 : i32
      %394 = arith.extsi %393 : i32 to i64
      %395 = llvm.mlir.constant(1 : i64) : i64
      %396 = llvm.alloca %395 x i64 : (i64) -> !llvm.ptr
      llvm.store %394, %396 : i64, !llvm.ptr
      %397 = llvm.load %363 : !llvm.ptr -> i64
      %398 = arith.constant 2 : i32
      %400 = arith.extsi %398 : i32 to i64
      %399 = arith.remsi %397, %400 : i64
      %401 = arith.constant 0 : i32
      %403 = arith.extsi %401 : i32 to i64
      %402 = arith.cmpi eq, %399, %403 : i64
      cf.cond_br %402, ^bb60, ^bb61
      ^bb60:
        %404 = arith.constant 1 : i32
        %406 = arith.constant 0 : i32
        %405 = arith.subi %406, %404 : i32
        %407 = arith.extsi %405 : i32 to i64
        llvm.store %407, %396 : i64, !llvm.ptr
        cf.br ^bb62
      ^bb61:
        cf.br ^bb62
      ^bb62:
      %408 = arith.constant 0 : i32
      %409 = arith.extsi %408 : i32 to i64
      %410 = llvm.mlir.constant(1 : i64) : i64
      %411 = llvm.alloca %410 x i64 : (i64) -> !llvm.ptr
      llvm.store %409, %411 : i64, !llvm.ptr
      %412 = arith.constant 1 : i32
      %413 = arith.extsi %412 : i32 to i64
      %414 = llvm.mlir.constant(1 : i64) : i64
      %415 = llvm.alloca %414 x i64 : (i64) -> !llvm.ptr
      llvm.store %413, %415 : i64, !llvm.ptr
      cf.br ^bb63
      ^bb63:
      %416 = llvm.load %415 : !llvm.ptr -> i64
      %417 = arith.constant 16 : i32
      %419 = arith.extsi %417 : i32 to i64
      %418 = arith.cmpi sle, %416, %419 : i64
      cf.cond_br %418, ^bb64, ^bb65
      ^bb64:
        %420 = llvm.load %411 : !llvm.ptr -> i64
        %422 = llvm.load %363 : !llvm.ptr -> i64
        %423 = llvm.load %415 : !llvm.ptr -> i64
        %421 = func.call @count_for(%344, %422, %423) : (!llvm.ptr, i64, i64) -> i64
        %424 = arith.addi %420, %421 : i64
        llvm.store %424, %411 : i64, !llvm.ptr
        %425 = llvm.load %415 : !llvm.ptr -> i64
        %426 = arith.constant 1 : i32
        %428 = arith.extsi %426 : i32 to i64
        %427 = arith.addi %425, %428 : i64
        llvm.store %427, %415 : i64, !llvm.ptr
        cf.br ^bb63
      ^bb65:
      %429 = llvm.load %343 : !llvm.ptr -> i64
      %430 = llvm.load %396 : !llvm.ptr -> i64
      %431 = llvm.load %411 : !llvm.ptr -> i64
      %432 = arith.muli %430, %431 : i64
      %433 = arith.addi %429, %432 : i64
      llvm.store %433, %343 : i64, !llvm.ptr
      %434 = llvm.load %354 : !llvm.ptr -> i64
      %435 = arith.constant 1 : i32
      %437 = arith.extsi %435 : i32 to i64
      %436 = arith.addi %434, %437 : i64
      llvm.store %436, %354 : i64, !llvm.ptr
      cf.br ^bb51
    ^bb53:
    %438 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %439 = llvm.load %343 : !llvm.ptr -> i64
    %440 = arith.addi %339, %439 : i64
    %441 = llvm.call @printf(%438, %440) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%344) : (!llvm.ptr) -> ()
    %443 = arith.constant 0 : i32
    func.return %443 : i32
  }
}