Problem 859

Cookie Game: count unordered pile partitions of 300 where Even wins. Each pile is a cold combinatorial game whose value g(n) is an integer. Even (Right) wins iff total value <= 0.

Answer1527162658488196
Output1527162658488196
StatusPASS
Native helperno
Runtime0 ms
Peak memory2176 KB
Time complexityO(n^3) (estimated)
Space complexityO(n) (estimated)

Performance comparison

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

Flow source

# Project Euler 859
# Cookie Game: count unordered pile partitions of 300 where Even wins.
# Each pile is a cold combinatorial game whose value g(n) is an integer.
# Even (Right) wins iff total value <= 0.

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

function main() -> i32 {
    let n: i64 = 300

    # g[k]: combinatorial game value of a single pile of size k.
    let g: ptr<i64> = calloc(n + 1, 8)
    g[0] = 0
    let mut k: i64 = 1
    while k <= n {
        if (k & 1) != 0 {
            # k = 2m + 1: Left moves to two piles of size m.
            let m: i64 = k >> 1
            let option: i64 = 2 * g[m]
            if option < 0 {
                g[k] = 0
            } else {
                g[k] = option + 1
            }
        } else {
            # k = 2m: Right moves to two piles of size m - 1.
            let m: i64 = k >> 1
            let option: i64 = 2 * g[m - 1]
            if option > 0 {
                g[k] = 0
            } else {
                g[k] = option - 1
            }
        }
        k = k + 1
    }

    # Value range for the full position: [-n/2, n].
    let v_min: i64 = 0 - (n / 2)
    let v_max: i64 = n
    let width: i64 = v_max - v_min + 1
    let offset: i64 = 0 - v_min

    # dp[cookies * width + vi] = #partitions of `cookies` with total value
    # mapped to index vi.
    let dp: ptr<i64> = calloc((n + 1) * width, 8)
    dp[offset] = 1

    let mut size: i64 = 1
    while size <= n {
        let dv: i64 = g[size]
        if dv >= 0 {
            let d: i64 = dv
            let mut cookies: i64 = size
            while cookies <= n {
                let src_base: i64 = (cookies - size) * width
                let dst_base: i64 = cookies * width
                let mut vi: i64 = d
                while vi < width {
                    dp[dst_base + vi] = dp[dst_base + vi] + dp[src_base + vi - d]
                    vi = vi + 1
                }
                cookies = cookies + 1
            }
        } else {
            let shift: i64 = 0 - dv
            let limit: i64 = width - shift
            let mut cookies: i64 = size
            while cookies <= n {
                let src_base: i64 = (cookies - size) * width
                let dst_base: i64 = cookies * width
                let mut vi: i64 = 0
                while vi < limit {
                    dp[dst_base + vi] = dp[dst_base + vi] + dp[src_base + vi + shift]
                    vi = vi + 1
                }
                cookies = cookies + 1
            }
        }
        size = size + 1
    }

    # Sum counts with total value <= 0 (indices 0..offset).
    let mut total: i64 = 0
    let row_base: i64 = n * width
    let mut vi: i64 = 0
    while vi <= offset {
        total = total + dp[row_base + vi]
        vi = vi + 1
    }

    printf("%lld\n", total)
    free(g)
    free(dp)
    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 main(void);



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