Problem 400

Winning moves on poisoned Fibonacci tree T(10000), mod 10^18.

Answer438505383468410633
Output438505383468410633
StatusPASS
Native helperno
Runtime120 ms
Peak memory1376 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(log n)
Space complexityO(n^2)O(1)
ApproachFlow solutionMatrix exponentiation
VerdictSuboptimal

Flow source

# Project Euler 400
# Winning moves on poisoned Fibonacci tree T(10000), mod 10^18.

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

function bit_length(n0: i64) -> i32 {
    let mut n: i64 = n0
    let mut b: i32 = 0
    while n > 0 {
        b = b + 1
        n = n / 2
    }
    return b
}

function main() -> i32 {
    let MOD: i64 = 1000000000000000000
    let N: i32 = 10000
    let h: ptr<i64> = calloc((N + 1) as i64, 8)
    if h == null { return 1 }
    h[1] = 1
    h[2] = 2
    let mut k: i32 = 3
    let mut maxh: i64 = 2
    while k <= N {
        h[k] = (h[k - 1] ^ h[k - 2]) + 1
        if h[k] > maxh { maxh = h[k] }
        k = k + 1
    }
    let limit: i64 = 1 << bit_length(maxh)

    let prev2: ptr<i64> = calloc(limit, 8)
    let prev1: ptr<i64> = calloc(limit, 8)
    let cur: ptr<i64> = calloc(limit, 8)
    if prev2 == null || prev1 == null || cur == null { return 1 }
    prev1[0] = 1

    let mut result: i64 = 0
    k = 2
    while k <= N {
        result = (prev1[h[k - 2]] + prev2[h[k - 1]]) % MOD
        let mut v: i64 = 0
        while v < limit {
            cur[v] = 0
            v = v + 1
        }
        cur[0] = 1
        let h1: i64 = h[k - 2]
        let h2: i64 = h[k - 1]
        v = 1
        while v < limit {
            cur[v] = (prev1[(v - 1) ^ h1] + prev2[(v - 1) ^ h2]) % MOD
            v = v + 1
        }
        # rotate: prev2=prev1, prev1=cur
        let mut i: i64 = 0
        while i < limit {
            prev2[i] = prev1[i]
            prev1[i] = cur[i]
            i = i + 1
        }
        k = k + 1
    }

    printf("%lld\n", result)
    free(cur)
    free(prev1)
    free(prev2)
    free(h)
    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 bit_length_i64(int64_t n0);
int32_t main(void);



int32_t bit_length_i64(int64_t n0) {
    int64_t n = n0;
    int32_t b = 0;
    while (n > 0) {
        b = (b + 1);
        n = FLOW_CHECKED_DIV((n), (2));
    }
    return b;
}

int32_t main(void) {
    int64_t MOD = 1000000000000000000;
    int32_t N = 10000;
    int64_t* h = (int64_t*)(calloc(((int64_t)((N + 1))), 8));
    if (h == NULL) {
        return 1;
    }
    h[1] = 1;
    h[2] = 2;
    int32_t k = 3;
    int64_t maxh = 2;
    while (k <= N) {
        h[k] = ((h[(k - 1)] ^ h[(k - 2)]) + 1);
        if (h[k] > maxh) {
            maxh = h[k];
        }
        k = (k + 1);
    }
    int64_t limit = FLOW_CHECKED_SHL((1), (bit_length_i64(maxh)));
    int64_t* prev2 = (int64_t*)(calloc(limit, 8));
    int64_t* prev1 = (int64_t*)(calloc(limit, 8));
    int64_t* cur = (int64_t*)(calloc(limit, 8));
    if (((prev2 == NULL || prev1 == NULL) || cur == NULL)) {
        return 1;
    }
    prev1[0] = 1;
    int64_t result = 0;
    k = 2;
    while (k <= N) {
        result = FLOW_CHECKED_MOD(((prev1[h[(k - 2)]] + prev2[h[(k - 1)]])), (MOD));
        int64_t v = 0;
        while (v < limit) {
            cur[v] = 0;
            v = (v + 1);
        }
        cur[0] = 1;
        int64_t h1 = h[(k - 2)];
        int64_t h2 = h[(k - 1)];
        v = 1;
        while (v < limit) {
            cur[v] = FLOW_CHECKED_MOD(((prev1[((v - 1) ^ h1)] + prev2[((v - 1) ^ h2)])), (MOD));
            v = (v + 1);
        }
        int64_t i = 0;
        while (i < limit) {
            prev2[i] = prev1[i];
            prev1[i] = cur[i];
            i = (i + 1);
        }
        k = (k + 1);
    }
    printf("%lld\n", result);
    free(cur);
    free(prev1);
    free(prev2);
    free(h);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func @bit_length(%arg0: i64) -> i32 {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %1 : i64, !llvm.ptr
    %2 = arith.constant 0 : i32
    %3 = llvm.mlir.constant(1 : i64) : i64
    %4 = llvm.alloca %3 x i32 : (i64) -> !llvm.ptr
    llvm.store %2, %4 : i32, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %5 = llvm.load %1 : !llvm.ptr -> i64
    %6 = arith.constant 0 : i32
    %8 = arith.extsi %6 : i32 to i64
    %7 = arith.cmpi sgt, %5, %8 : i64
    cf.cond_br %7, ^bb1, ^bb2
    ^bb1:
      %9 = llvm.load %4 : !llvm.ptr -> i32
      %10 = arith.constant 1 : i32
      %11 = arith.addi %9, %10 : i32
      llvm.store %11, %4 : i32, !llvm.ptr
      %12 = llvm.load %1 : !llvm.ptr -> i64
      %13 = arith.constant 2 : i32
      %15 = arith.extsi %13 : i32 to i64
      %14 = arith.divsi %12, %15 : i64
      llvm.store %14, %1 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %16 = llvm.load %4 : !llvm.ptr -> i32
    func.return %16 : i32
  }
  func.func @main() -> i32 {
    %17 = arith.constant 999999995705032704 : i32
    %18 = arith.extsi %17 : i32 to i64
    %19 = arith.constant 10000 : i32
    %21 = arith.constant 1 : i32
    %22 = arith.addi %19, %21 : i32
    %23 = arith.extsi %22 : i32 to i64
    %24 = arith.constant 8 : i32
    %25 = arith.extsi %24 : i32 to i64
    %20 = func.call @calloc(%23, %25) : (i64, i64) -> !llvm.ptr
    %26 = llvm.mlir.zero : !llvm.ptr
    %27 = llvm.icmp "eq" %20, %26 : !llvm.ptr
    cf.cond_br %27, ^bb3, ^bb4
    ^bb3:
      %28 = arith.constant 1 : i32
      func.return %28 : i32
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %29 = arith.constant 1 : i32
    %30 = arith.constant 1 : i32
    %31 = arith.extsi %29 : i32 to i64
    %32 = arith.extsi %30 : i32 to i64
    %33 = llvm.getelementptr %20[%32] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %31, %33 : i64, !llvm.ptr
    %34 = arith.constant 2 : i32
    %35 = arith.constant 2 : i32
    %36 = arith.extsi %34 : i32 to i64
    %37 = arith.extsi %35 : i32 to i64
    %38 = llvm.getelementptr %20[%37] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %36, %38 : i64, !llvm.ptr
    %39 = arith.constant 3 : i32
    %40 = llvm.mlir.constant(1 : i64) : i64
    %41 = llvm.alloca %40 x i32 : (i64) -> !llvm.ptr
    llvm.store %39, %41 : i32, !llvm.ptr
    %42 = arith.constant 2 : i32
    %43 = arith.extsi %42 : i32 to i64
    %44 = llvm.mlir.constant(1 : i64) : i64
    %45 = llvm.alloca %44 x i64 : (i64) -> !llvm.ptr
    llvm.store %43, %45 : i64, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %46 = llvm.load %41 : !llvm.ptr -> i32
    %47 = arith.cmpi sle, %46, %19 : i32
    cf.cond_br %47, ^bb7, ^bb8
    ^bb7:
      %49 = llvm.load %41 : !llvm.ptr -> i32
      %50 = arith.constant 1 : i32
      %51 = arith.subi %49, %50 : i32
      %52 = arith.extsi %51 : i32 to i64
      %53 = llvm.getelementptr %20[%52] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %48 = llvm.load %53 : !llvm.ptr -> i64
      %55 = llvm.load %41 : !llvm.ptr -> i32
      %56 = arith.constant 2 : i32
      %57 = arith.subi %55, %56 : i32
      %58 = arith.extsi %57 : i32 to i64
      %59 = llvm.getelementptr %20[%58] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %54 = llvm.load %59 : !llvm.ptr -> i64
      %60 = arith.xori %48, %54 : i64
      %61 = arith.constant 1 : i32
      %63 = arith.extsi %61 : i32 to i64
      %62 = arith.addi %60, %63 : i64
      %64 = llvm.load %41 : !llvm.ptr -> i32
      %65 = arith.extsi %64 : i32 to i64
      %66 = llvm.getelementptr %20[%65] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %62, %66 : i64, !llvm.ptr
      %68 = llvm.load %41 : !llvm.ptr -> i32
      %69 = arith.extsi %68 : i32 to i64
      %70 = llvm.getelementptr %20[%69] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %67 = llvm.load %70 : !llvm.ptr -> i64
      %71 = llvm.load %45 : !llvm.ptr -> i64
      %72 = arith.cmpi sgt, %67, %71 : i64
      cf.cond_br %72, ^bb9, ^bb10
      ^bb9:
        %74 = llvm.load %41 : !llvm.ptr -> i32
        %75 = arith.extsi %74 : i32 to i64
        %76 = llvm.getelementptr %20[%75] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %73 = llvm.load %76 : !llvm.ptr -> i64
        llvm.store %73, %45 : i64, !llvm.ptr
        cf.br ^bb11
      ^bb10:
        cf.br ^bb11
      ^bb11:
      %77 = llvm.load %41 : !llvm.ptr -> i32
      %78 = arith.constant 1 : i32
      %79 = arith.addi %77, %78 : i32
      llvm.store %79, %41 : i32, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %80 = arith.constant 1 : i32
    %82 = llvm.load %45 : !llvm.ptr -> i64
    %81 = func.call @bit_length(%82) : (i64) -> i32
    %83 = arith.shli %80, %81 : i32
    %84 = arith.extsi %83 : i32 to i64
    %86 = arith.constant 8 : i32
    %87 = arith.extsi %86 : i32 to i64
    %85 = func.call @calloc(%84, %87) : (i64, i64) -> !llvm.ptr
    %89 = arith.constant 8 : i32
    %90 = arith.extsi %89 : i32 to i64
    %88 = func.call @calloc(%84, %90) : (i64, i64) -> !llvm.ptr
    %92 = arith.constant 8 : i32
    %93 = arith.extsi %92 : i32 to i64
    %91 = func.call @calloc(%84, %93) : (i64, i64) -> !llvm.ptr
    %94 = llvm.mlir.zero : !llvm.ptr
    %95 = llvm.icmp "eq" %85, %94 : !llvm.ptr
    %96 = scf.if %95 -> (i1) {
      %97 = arith.constant true
      scf.yield %97 : i1
    } else {
      %98 = llvm.mlir.zero : !llvm.ptr
      %99 = llvm.icmp "eq" %88, %98 : !llvm.ptr
      scf.yield %99 : i1
    }
    %100 = scf.if %96 -> (i1) {
      %101 = arith.constant true
      scf.yield %101 : i1
    } else {
      %102 = llvm.mlir.zero : !llvm.ptr
      %103 = llvm.icmp "eq" %91, %102 : !llvm.ptr
      scf.yield %103 : i1
    }
    cf.cond_br %100, ^bb12, ^bb13
    ^bb12:
      %104 = arith.constant 1 : i32
      func.return %104 : i32
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %105 = arith.constant 1 : i32
    %106 = arith.constant 0 : i32
    %107 = arith.extsi %105 : i32 to i64
    %108 = arith.extsi %106 : i32 to i64
    %109 = llvm.getelementptr %88[%108] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %107, %109 : i64, !llvm.ptr
    %110 = arith.constant 0 : i32
    %111 = arith.extsi %110 : i32 to i64
    %112 = llvm.mlir.constant(1 : i64) : i64
    %113 = llvm.alloca %112 x i64 : (i64) -> !llvm.ptr
    llvm.store %111, %113 : i64, !llvm.ptr
    %114 = arith.constant 2 : i32
    llvm.store %114, %41 : i32, !llvm.ptr
    cf.br ^bb15
    ^bb15:
    %115 = llvm.load %41 : !llvm.ptr -> i32
    %116 = arith.cmpi sle, %115, %19 : i32
    cf.cond_br %116, ^bb16, ^bb17
    ^bb16:
      %119 = llvm.load %41 : !llvm.ptr -> i32
      %120 = arith.constant 2 : i32
      %121 = arith.subi %119, %120 : i32
      %122 = arith.extsi %121 : i32 to i64
      %123 = llvm.getelementptr %20[%122] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %118 = llvm.load %123 : !llvm.ptr -> i64
      %124 = llvm.getelementptr %88[%118] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %117 = llvm.load %124 : !llvm.ptr -> i64
      %127 = llvm.load %41 : !llvm.ptr -> i32
      %128 = arith.constant 1 : i32
      %129 = arith.subi %127, %128 : i32
      %130 = arith.extsi %129 : i32 to i64
      %131 = llvm.getelementptr %20[%130] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %126 = llvm.load %131 : !llvm.ptr -> i64
      %132 = llvm.getelementptr %85[%126] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %125 = llvm.load %132 : !llvm.ptr -> i64
      %133 = arith.addi %117, %125 : i64
      %134 = arith.remsi %133, %18 : i64
      llvm.store %134, %113 : i64, !llvm.ptr
      %135 = arith.constant 0 : i32
      %136 = arith.extsi %135 : i32 to 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
      %140 = arith.cmpi slt, %139, %84 : i64
      cf.cond_br %140, ^bb19, ^bb20
      ^bb19:
        %141 = arith.constant 0 : i32
        %142 = llvm.load %138 : !llvm.ptr -> i64
        %143 = arith.extsi %141 : i32 to i64
        %144 = llvm.getelementptr %91[%142] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %143, %144 : i64, !llvm.ptr
        %145 = llvm.load %138 : !llvm.ptr -> i64
        %146 = arith.constant 1 : i32
        %148 = arith.extsi %146 : i32 to i64
        %147 = arith.addi %145, %148 : i64
        llvm.store %147, %138 : i64, !llvm.ptr
        cf.br ^bb18
      ^bb20:
      %149 = arith.constant 1 : i32
      %150 = arith.constant 0 : i32
      %151 = arith.extsi %149 : i32 to i64
      %152 = arith.extsi %150 : i32 to i64
      %153 = llvm.getelementptr %91[%152] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %151, %153 : i64, !llvm.ptr
      %155 = llvm.load %41 : !llvm.ptr -> i32
      %156 = arith.constant 2 : i32
      %157 = arith.subi %155, %156 : i32
      %158 = arith.extsi %157 : i32 to i64
      %159 = llvm.getelementptr %20[%158] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %154 = llvm.load %159 : !llvm.ptr -> i64
      %161 = llvm.load %41 : !llvm.ptr -> i32
      %162 = arith.constant 1 : i32
      %163 = arith.subi %161, %162 : i32
      %164 = arith.extsi %163 : i32 to i64
      %165 = llvm.getelementptr %20[%164] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %160 = llvm.load %165 : !llvm.ptr -> i64
      %166 = arith.constant 1 : i32
      %167 = arith.extsi %166 : i32 to i64
      llvm.store %167, %138 : i64, !llvm.ptr
      cf.br ^bb21
      ^bb21:
      %168 = llvm.load %138 : !llvm.ptr -> i64
      %169 = arith.cmpi slt, %168, %84 : i64
      cf.cond_br %169, ^bb22, ^bb23
      ^bb22:
        %171 = llvm.load %138 : !llvm.ptr -> i64
        %172 = arith.constant 1 : i32
        %174 = arith.extsi %172 : i32 to i64
        %173 = arith.subi %171, %174 : i64
        %175 = arith.xori %173, %154 : i64
        %176 = llvm.getelementptr %88[%175] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %170 = llvm.load %176 : !llvm.ptr -> i64
        %178 = llvm.load %138 : !llvm.ptr -> i64
        %179 = arith.constant 1 : i32
        %181 = arith.extsi %179 : i32 to i64
        %180 = arith.subi %178, %181 : i64
        %182 = arith.xori %180, %160 : i64
        %183 = llvm.getelementptr %85[%182] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %177 = llvm.load %183 : !llvm.ptr -> i64
        %184 = arith.addi %170, %177 : i64
        %185 = arith.remsi %184, %18 : i64
        %186 = llvm.load %138 : !llvm.ptr -> i64
        %187 = llvm.getelementptr %91[%186] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %185, %187 : i64, !llvm.ptr
        %188 = llvm.load %138 : !llvm.ptr -> i64
        %189 = arith.constant 1 : i32
        %191 = arith.extsi %189 : i32 to i64
        %190 = arith.addi %188, %191 : i64
        llvm.store %190, %138 : i64, !llvm.ptr
        cf.br ^bb21
      ^bb23:
      %192 = arith.constant 0 : i32
      %193 = arith.extsi %192 : i32 to i64
      %194 = llvm.mlir.constant(1 : i64) : i64
      %195 = llvm.alloca %194 x i64 : (i64) -> !llvm.ptr
      llvm.store %193, %195 : i64, !llvm.ptr
      cf.br ^bb24
      ^bb24:
      %196 = llvm.load %195 : !llvm.ptr -> i64
      %197 = arith.cmpi slt, %196, %84 : i64
      cf.cond_br %197, ^bb25, ^bb26
      ^bb25:
        %199 = llvm.load %195 : !llvm.ptr -> i64
        %200 = llvm.getelementptr %88[%199] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %198 = llvm.load %200 : !llvm.ptr -> i64
        %201 = llvm.load %195 : !llvm.ptr -> i64
        %202 = llvm.getelementptr %85[%201] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %198, %202 : i64, !llvm.ptr
        %204 = llvm.load %195 : !llvm.ptr -> i64
        %205 = llvm.getelementptr %91[%204] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %203 = llvm.load %205 : !llvm.ptr -> i64
        %206 = llvm.load %195 : !llvm.ptr -> i64
        %207 = llvm.getelementptr %88[%206] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %203, %207 : i64, !llvm.ptr
        %208 = llvm.load %195 : !llvm.ptr -> i64
        %209 = arith.constant 1 : i32
        %211 = arith.extsi %209 : i32 to i64
        %210 = arith.addi %208, %211 : i64
        llvm.store %210, %195 : i64, !llvm.ptr
        cf.br ^bb24
      ^bb26:
      %212 = llvm.load %41 : !llvm.ptr -> i32
      %213 = arith.constant 1 : i32
      %214 = arith.addi %212, %213 : i32
      llvm.store %214, %41 : i32, !llvm.ptr
      cf.br ^bb15
    ^bb17:
    %215 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %216 = llvm.load %113 : !llvm.ptr -> i64
    %217 = llvm.call @printf(%215, %216) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%91) : (!llvm.ptr) -> ()
    func.call @free(%88) : (!llvm.ptr) -> ()
    func.call @free(%85) : (!llvm.ptr) -> ()
    func.call @free(%20) : (!llvm.ptr) -> ()
    %222 = arith.constant 0 : i32
    func.return %222 : i32
  }
}