Problem 259

Sum of positive reachable integers from digits 1..9.

Answer20101196798
Output20101196798
StatusPASS
Native helperno
Runtime1020 ms
Peak memory211008 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(n * d)
Space complexityO(n^2)O(n)
ApproachFlow solutionExpression enumeration
VerdictUnknown

Flow source

# Project Euler 259
# Sum of positive reachable integers from digits 1..9.

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

function gcd_abs(a0: i64, b0: i64) -> i64 {
    let mut a: i64 = a0
    let mut b: i64 = b0
    if a < 0 { a = -a }
    if b < 0 { b = -b }
    while b != 0 {
        let t: i64 = a % b
        a = b
        b = t
    }
    return a
}

function concat_val(l: i64, r: i64) -> i64 {
    let mut v: i64 = 0
    let mut i: i64 = l
    while i <= r {
        v = v * 10 + i
        i = i + 1
    }
    return v
}

function pack(num: i64, den: i64) -> i64 {
    # mix into one key for hash; store separately
    return num * 1000003 + den
}

function main() -> i32 {
    # 10x10 ranges; for each range a hashset
    let R: i64 = 10
    let CAP: i64 = 8000009
    # Too big for all ranges - use one working set built bottom-up by span
    # Store results in jagged: offsets[100], nums/dens big arrays
    let max_total: i64 = 6000000
    let all_num: ptr<i64> = calloc(max_total, 8)
    let all_den: ptr<i64> = calloc(max_total, 8)
    let off: ptr<i32> = calloc(101, 4)
    let cnt: ptr<i32> = calloc(100, 4)
    let ready: ptr<i8> = calloc(100, 1)
    let mut total: i64 = 0

    # hash helpers for building one range
    let HCAP: i64 = 8388608
    let hused: ptr<i8> = calloc(HCAP, 1)
    let hnum: ptr<i64> = calloc(HCAP, 8)
    let hden: ptr<i64> = calloc(HCAP, 8)

    let mut span: i64 = 1
    while span <= 9 {
        let mut l: i64 = 1
        while l + span - 1 <= 9 {
            let r: i64 = l + span - 1
            let idx: i64 = l * 10 + r
            # clear hash
            let mut hi: i64 = 0
            while hi < HCAP {
                hused[hi] = 0
                hi = hi + 1
            }
            let mut nlocal: i64 = 0

            # insert helper via inline
            # concat
            let cv: i64 = concat_val(l, r)
            let mut hn: i64 = cv % HCAP
            if hn < 0 { hn = -hn }
            while hused[hn] != 0 {
                if hnum[hn] == cv && hden[hn] == 1 { break }
                hn = hn + 1
                if hn == HCAP { hn = 0 }
            }
            if hused[hn] == 0 {
                hused[hn] = 1
                hnum[hn] = cv
                hden[hn] = 1
                nlocal = nlocal + 1
            }

            if span > 1 {
                let mut mid: i64 = l
                while mid < r {
                    let li: i64 = l * 10 + mid
                    let ri: i64 = (mid + 1) * 10 + r
                    let l0: i64 = off[li] as i64
                    let lc: i64 = cnt[li] as i64
                    let r0: i64 = off[ri] as i64
                    let rc: i64 = cnt[ri] as i64
                    let mut i: i64 = 0
                    while i < lc {
                        let an: i64 = all_num[l0 + i]
                        let ad: i64 = all_den[l0 + i]
                        let mut j: i64 = 0
                        while j < rc {
                            let bn: i64 = all_num[r0 + j]
                            let bd: i64 = all_den[r0 + j]
                            # four ops
                            let mut op: i64 = 0
                            while op < 4 {
                                let mut num: i64 = 0
                                let mut den: i64 = 1
                                let mut ok: bool = true
                                if op == 0 {
                                    num = an * bd + bn * ad
                                    den = ad * bd
                                } elif op == 1 {
                                    num = an * bd - bn * ad
                                    den = ad * bd
                                } elif op == 2 {
                                    num = an * bn
                                    den = ad * bd
                                } else {
                                    if bn == 0 { ok = false }
                                    else {
                                        num = an * bd
                                        den = ad * bn
                                    }
                                }
                                if ok {
                                    if den < 0 {
                                        num = 0 - num
                                        den = 0 - den
                                    }
                                    if den != 0 {
                                        let g: i64 = gcd_abs(num, den)
                                        num = num / g
                                        den = den / g
                                        hn = (num * 1000003 + den) % HCAP
                                        if hn < 0 { hn = -hn }
                                        while hused[hn] != 0 {
                                            if hnum[hn] == num && hden[hn] == den { break }
                                            hn = hn + 1
                                            if hn == HCAP { hn = 0 }
                                        }
                                        if hused[hn] == 0 {
                                            hused[hn] = 1
                                            hnum[hn] = num
                                            hden[hn] = den
                                            nlocal = nlocal + 1
                                        }
                                    }
                                }
                                op = op + 1
                            }
                            j = j + 1
                        }
                        i = i + 1
                    }
                    mid = mid + 1
                }
            }

            off[idx] = total as i32
            cnt[idx] = nlocal as i32
            # dump hash to all_*
            hi = 0
            while hi < HCAP {
                if hused[hi] != 0 {
                    all_num[total] = hnum[hi]
                    all_den[total] = hden[hi]
                    total = total + 1
                }
                hi = hi + 1
            }
            ready[idx] = 1
            l = l + 1
        }
        span = span + 1
    }

    let idx: i64 = 19
    let base: i64 = off[idx] as i64
    let n: i64 = cnt[idx] as i64
    let mut sum: i64 = 0
    let mut i: i64 = 0
    while i < n {
        if all_den[base + i] == 1 && all_num[base + i] > 0 {
            sum = sum + all_num[base + i]
        }
        i = i + 1
    }
    printf("%lld\n", sum)
    free(all_num); free(all_den); free(off); free(cnt); free(ready); free(hused); free(hnum); free(hden)
    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 gcd_abs_i64_i64(int64_t a0, int64_t b0);
int64_t concat_val_i64_i64(int64_t l, int64_t r);
int64_t pack_i64_i64(int64_t num, int64_t den);
int32_t main(void);



int64_t gcd_abs_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    if (a < 0) {
        a = (-a);
    }
    if (b < 0) {
        b = (-b);
    }
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t concat_val_i64_i64(int64_t l, int64_t r) {
    int64_t v = 0;
    int64_t i = l;
    while (i <= r) {
        v = ((v * 10) + i);
        i = (i + 1);
    }
    return v;
}

int64_t pack_i64_i64(int64_t num, int64_t den) {
    return ((num * 1000003) + den);
}

int32_t main(void) {
    int64_t R = 10;
    int64_t CAP = 8000009;
    int64_t max_total = 6000000;
    int64_t* all_num = (int64_t*)(calloc(max_total, 8));
    int64_t* all_den = (int64_t*)(calloc(max_total, 8));
    int32_t* off = (int32_t*)(calloc(101, 4));
    int32_t* cnt = (int32_t*)(calloc(100, 4));
    int8_t* ready = (int8_t*)(calloc(100, 1));
    int64_t total = 0;
    int64_t HCAP = 8388608;
    int8_t* hused = (int8_t*)(calloc(HCAP, 1));
    int64_t* hnum = (int64_t*)(calloc(HCAP, 8));
    int64_t* hden = (int64_t*)(calloc(HCAP, 8));
    int64_t span = 1;
    while (span <= 9) {
        int64_t l = 1;
        while (((l + span) - 1) <= 9) {
            int64_t r = ((l + span) - 1);
            int64_t idx = ((l * 10) + r);
            int64_t hi = 0;
            while (hi < HCAP) {
                hused[hi] = 0;
                hi = (hi + 1);
            }
            int64_t nlocal = 0;
            int64_t cv = concat_val_i64_i64(l, r);
            int64_t hn = FLOW_CHECKED_MOD((cv), (HCAP));
            if (hn < 0) {
                hn = (-hn);
            }
            while (hused[hn] != 0) {
                if ((hnum[hn] == cv && hden[hn] == 1)) {
                    break;
                }
                hn = (hn + 1);
                if (hn == HCAP) {
                    hn = 0;
                }
            }
            if (hused[hn] == 0) {
                hused[hn] = 1;
                hnum[hn] = cv;
                hden[hn] = 1;
                nlocal = (nlocal + 1);
            }
            if (span > 1) {
                int64_t mid = l;
                while (mid < r) {
                    int64_t li = ((l * 10) + mid);
                    int64_t ri = (((mid + 1) * 10) + r);
                    int64_t l0 = ((int64_t)(off[li]));
                    int64_t lc = ((int64_t)(cnt[li]));
                    int64_t r0 = ((int64_t)(off[ri]));
                    int64_t rc = ((int64_t)(cnt[ri]));
                    int64_t i = 0;
                    while (i < lc) {
                        int64_t an = all_num[(l0 + i)];
                        int64_t ad = all_den[(l0 + i)];
                        int64_t j = 0;
                        while (j < rc) {
                            int64_t bn = all_num[(r0 + j)];
                            int64_t bd = all_den[(r0 + j)];
                            int64_t op = 0;
                            while (op < 4) {
                                int64_t num = 0;
                                int64_t den = 1;
                                bool ok = 1;
                                if (op == 0) {
                                    num = ((an * bd) + (bn * ad));
                                    den = (ad * bd);
                                } else if (op == 1) {
                                    num = ((an * bd) - (bn * ad));
                                    den = (ad * bd);
                                } else if (op == 2) {
                                    num = (an * bn);
                                    den = (ad * bd);
                                } else {
                                    if (bn == 0) {
                                        ok = 0;
                                    } else {
                                        num = (an * bd);
                                        den = (ad * bn);
                                    }
                                }
                                if (ok) {
                                    if (den < 0) {
                                        num = (0 - num);
                                        den = (0 - den);
                                    }
                                    if (den != 0) {
                                        int64_t g = gcd_abs_i64_i64(num, den);
                                        num = FLOW_CHECKED_DIV((num), (g));
                                        den = FLOW_CHECKED_DIV((den), (g));
                                        hn = FLOW_CHECKED_MOD((((num * 1000003) + den)), (HCAP));
                                        if (hn < 0) {
                                            hn = (-hn);
                                        }
                                        while (hused[hn] != 0) {
                                            if ((hnum[hn] == num && hden[hn] == den)) {
                                                break;
                                            }
                                            hn = (hn + 1);
                                            if (hn == HCAP) {
                                                hn = 0;
                                            }
                                        }
                                        if (hused[hn] == 0) {
                                            hused[hn] = 1;
                                            hnum[hn] = num;
                                            hden[hn] = den;
                                            nlocal = (nlocal + 1);
                                        }
                                    }
                                }
                                op = (op + 1);
                            }
                            j = (j + 1);
                        }
                        i = (i + 1);
                    }
                    mid = (mid + 1);
                }
            }
            off[idx] = ((int32_t)(total));
            cnt[idx] = ((int32_t)(nlocal));
            hi = 0;
            while (hi < HCAP) {
                if (hused[hi] != 0) {
                    all_num[total] = hnum[hi];
                    all_den[total] = hden[hi];
                    total = (total + 1);
                }
                hi = (hi + 1);
            }
            ready[idx] = 1;
            l = (l + 1);
        }
        span = (span + 1);
    }
    int64_t idx = 19;
    int64_t base = ((int64_t)(off[idx]));
    int64_t n = ((int64_t)(cnt[idx]));
    int64_t sum = 0;
    int64_t i = 0;
    while (i < n) {
        if ((all_den[(base + i)] == 1 && all_num[(base + i)] > 0)) {
            sum = (sum + all_num[(base + i)]);
        }
        i = (i + 1);
    }
    printf("%lld\n", sum);
    free(all_num);
    free(all_den);
    free(off);
    free(cnt);
    free(ready);
    free(hused);
    free(hnum);
    free(hden);
    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 @gcd_abs(%arg0: i64, %arg1: i64) -> i64 {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %1 : i64, !llvm.ptr
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %3 : i64, !llvm.ptr
    %4 = llvm.load %1 : !llvm.ptr -> i64
    %5 = arith.constant 0 : i32
    %7 = arith.extsi %5 : i32 to i64
    %6 = arith.cmpi slt, %4, %7 : i64
    cf.cond_br %6, ^bb0, ^bb1
    ^bb0:
      %8 = llvm.load %1 : !llvm.ptr -> i64
      %10 = arith.constant 0 : i64
      %9 = arith.subi %10, %8 : i64
      llvm.store %9, %1 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %11 = llvm.load %3 : !llvm.ptr -> i64
    %12 = arith.constant 0 : i32
    %14 = arith.extsi %12 : i32 to i64
    %13 = arith.cmpi slt, %11, %14 : i64
    cf.cond_br %13, ^bb3, ^bb4
    ^bb3:
      %15 = llvm.load %3 : !llvm.ptr -> i64
      %17 = arith.constant 0 : i64
      %16 = arith.subi %17, %15 : i64
      llvm.store %16, %3 : i64, !llvm.ptr
      cf.br ^bb5
    ^bb4:
      cf.br ^bb5
    ^bb5:
    cf.br ^bb6
    ^bb6:
    %18 = llvm.load %3 : !llvm.ptr -> i64
    %19 = arith.constant 0 : i32
    %21 = arith.extsi %19 : i32 to i64
    %20 = arith.cmpi ne, %18, %21 : i64
    cf.cond_br %20, ^bb7, ^bb8
    ^bb7:
      %22 = llvm.load %1 : !llvm.ptr -> i64
      %23 = llvm.load %3 : !llvm.ptr -> i64
      %24 = arith.remsi %22, %23 : i64
      %25 = llvm.load %3 : !llvm.ptr -> i64
      llvm.store %25, %1 : i64, !llvm.ptr
      llvm.store %24, %3 : i64, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %26 = llvm.load %1 : !llvm.ptr -> i64
    func.return %26 : i64
  }
  func.func @concat_val(%arg0: i64, %arg1: i64) -> i64 {
    %27 = arith.constant 0 : i32
    %28 = arith.extsi %27 : i32 to i64
    %29 = llvm.mlir.constant(1 : i64) : i64
    %30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
    llvm.store %28, %30 : i64, !llvm.ptr
    %31 = llvm.mlir.constant(1 : i64) : i64
    %32 = llvm.alloca %31 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %32 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %33 = llvm.load %32 : !llvm.ptr -> i64
    %34 = arith.cmpi sle, %33, %arg1 : i64
    cf.cond_br %34, ^bb10, ^bb11
    ^bb10:
      %35 = llvm.load %30 : !llvm.ptr -> i64
      %36 = arith.constant 10 : i32
      %38 = arith.extsi %36 : i32 to i64
      %37 = arith.muli %35, %38 : i64
      %39 = llvm.load %32 : !llvm.ptr -> i64
      %40 = arith.addi %37, %39 : i64
      llvm.store %40, %30 : i64, !llvm.ptr
      %41 = llvm.load %32 : !llvm.ptr -> i64
      %42 = arith.constant 1 : i32
      %44 = arith.extsi %42 : i32 to i64
      %43 = arith.addi %41, %44 : i64
      llvm.store %43, %32 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %45 = llvm.load %30 : !llvm.ptr -> i64
    func.return %45 : i64
  }
  func.func @pack(%arg0: i64, %arg1: i64) -> i64 {
    %46 = arith.constant 1000003 : i32
    %48 = arith.extsi %46 : i32 to i64
    %47 = arith.muli %arg0, %48 : i64
    %49 = arith.addi %47, %arg1 : i64
    func.return %49 : i64
  }
  func.func @main() -> i32 {
    %50 = arith.constant 10 : i32
    %51 = arith.extsi %50 : i32 to i64
    %52 = arith.constant 8000009 : i32
    %53 = arith.extsi %52 : i32 to i64
    %54 = arith.constant 6000000 : i32
    %55 = arith.extsi %54 : i32 to i64
    %57 = arith.constant 8 : i32
    %58 = arith.extsi %57 : i32 to i64
    %56 = func.call @calloc(%55, %58) : (i64, i64) -> !llvm.ptr
    %60 = arith.constant 8 : i32
    %61 = arith.extsi %60 : i32 to i64
    %59 = func.call @calloc(%55, %61) : (i64, i64) -> !llvm.ptr
    %63 = arith.constant 101 : i32
    %64 = arith.constant 4 : i32
    %65 = arith.extsi %63 : i32 to i64
    %66 = arith.extsi %64 : i32 to i64
    %62 = func.call @calloc(%65, %66) : (i64, i64) -> !llvm.ptr
    %68 = arith.constant 100 : i32
    %69 = arith.constant 4 : i32
    %70 = arith.extsi %68 : i32 to i64
    %71 = arith.extsi %69 : i32 to i64
    %67 = func.call @calloc(%70, %71) : (i64, i64) -> !llvm.ptr
    %73 = arith.constant 100 : i32
    %74 = arith.constant 1 : i32
    %75 = arith.extsi %73 : i32 to i64
    %76 = arith.extsi %74 : i32 to i64
    %72 = func.call @calloc(%75, %76) : (i64, i64) -> !llvm.ptr
    %77 = arith.constant 0 : i32
    %78 = arith.extsi %77 : i32 to i64
    %79 = llvm.mlir.constant(1 : i64) : i64
    %80 = llvm.alloca %79 x i64 : (i64) -> !llvm.ptr
    llvm.store %78, %80 : i64, !llvm.ptr
    %81 = arith.constant 8388608 : i32
    %82 = arith.extsi %81 : i32 to i64
    %84 = arith.constant 1 : i32
    %85 = arith.extsi %84 : i32 to i64
    %83 = func.call @calloc(%82, %85) : (i64, i64) -> !llvm.ptr
    %87 = arith.constant 8 : i32
    %88 = arith.extsi %87 : i32 to i64
    %86 = func.call @calloc(%82, %88) : (i64, i64) -> !llvm.ptr
    %90 = arith.constant 8 : i32
    %91 = arith.extsi %90 : i32 to i64
    %89 = func.call @calloc(%82, %91) : (i64, i64) -> !llvm.ptr
    %92 = arith.constant 1 : i32
    %93 = arith.extsi %92 : i32 to i64
    %94 = llvm.mlir.constant(1 : i64) : i64
    %95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
    llvm.store %93, %95 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %96 = llvm.load %95 : !llvm.ptr -> i64
    %97 = arith.constant 9 : i32
    %99 = arith.extsi %97 : i32 to i64
    %98 = arith.cmpi sle, %96, %99 : i64
    cf.cond_br %98, ^bb13, ^bb14
    ^bb13:
      %100 = arith.constant 1 : i32
      %101 = arith.extsi %100 : i32 to i64
      %102 = llvm.mlir.constant(1 : i64) : i64
      %103 = llvm.alloca %102 x i64 : (i64) -> !llvm.ptr
      llvm.store %101, %103 : i64, !llvm.ptr
      cf.br ^bb15
      ^bb15:
      %104 = llvm.load %103 : !llvm.ptr -> i64
      %105 = llvm.load %95 : !llvm.ptr -> i64
      %106 = arith.addi %104, %105 : i64
      %107 = arith.constant 1 : i32
      %109 = arith.extsi %107 : i32 to i64
      %108 = arith.subi %106, %109 : i64
      %110 = arith.constant 9 : i32
      %112 = arith.extsi %110 : i32 to i64
      %111 = arith.cmpi sle, %108, %112 : i64
      cf.cond_br %111, ^bb16, ^bb17
      ^bb16:
        %113 = llvm.load %103 : !llvm.ptr -> i64
        %114 = llvm.load %95 : !llvm.ptr -> i64
        %115 = arith.addi %113, %114 : i64
        %116 = arith.constant 1 : i32
        %118 = arith.extsi %116 : i32 to i64
        %117 = arith.subi %115, %118 : i64
        %119 = llvm.load %103 : !llvm.ptr -> i64
        %120 = arith.constant 10 : i32
        %122 = arith.extsi %120 : i32 to i64
        %121 = arith.muli %119, %122 : i64
        %123 = arith.addi %121, %117 : i64
        %124 = arith.constant 0 : i32
        %125 = arith.extsi %124 : i32 to i64
        %126 = llvm.mlir.constant(1 : i64) : i64
        %127 = llvm.alloca %126 x i64 : (i64) -> !llvm.ptr
        llvm.store %125, %127 : i64, !llvm.ptr
        cf.br ^bb18
        ^bb18:
        %128 = llvm.load %127 : !llvm.ptr -> i64
        %129 = arith.cmpi slt, %128, %82 : i64
        cf.cond_br %129, ^bb19, ^bb20
        ^bb19:
          %130 = arith.constant 0 : i32
          %131 = llvm.load %127 : !llvm.ptr -> i64
          %132 = arith.trunci %130 : i32 to i8
          %133 = llvm.getelementptr %83[%131] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %132, %133 : i8, !llvm.ptr
          %134 = llvm.load %127 : !llvm.ptr -> i64
          %135 = arith.constant 1 : i32
          %137 = arith.extsi %135 : i32 to i64
          %136 = arith.addi %134, %137 : i64
          llvm.store %136, %127 : i64, !llvm.ptr
          cf.br ^bb18
        ^bb20:
        %138 = arith.constant 0 : i32
        %139 = arith.extsi %138 : i32 to i64
        %140 = llvm.mlir.constant(1 : i64) : i64
        %141 = llvm.alloca %140 x i64 : (i64) -> !llvm.ptr
        llvm.store %139, %141 : i64, !llvm.ptr
        %143 = llvm.load %103 : !llvm.ptr -> i64
        %142 = func.call @concat_val(%143, %117) : (i64, i64) -> i64
        %144 = arith.remsi %142, %82 : i64
        %145 = llvm.mlir.constant(1 : i64) : i64
        %146 = llvm.alloca %145 x i64 : (i64) -> !llvm.ptr
        llvm.store %144, %146 : i64, !llvm.ptr
        %147 = llvm.load %146 : !llvm.ptr -> i64
        %148 = arith.constant 0 : i32
        %150 = arith.extsi %148 : i32 to i64
        %149 = arith.cmpi slt, %147, %150 : i64
        cf.cond_br %149, ^bb21, ^bb22
        ^bb21:
          %151 = llvm.load %146 : !llvm.ptr -> i64
          %153 = arith.constant 0 : i64
          %152 = arith.subi %153, %151 : i64
          llvm.store %152, %146 : i64, !llvm.ptr
          cf.br ^bb23
        ^bb22:
          cf.br ^bb23
        ^bb23:
        cf.br ^bb24
        ^bb24:
        %155 = llvm.load %146 : !llvm.ptr -> i64
        %156 = llvm.getelementptr %83[%155] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        %154 = llvm.load %156 : !llvm.ptr -> i8
        %157 = arith.constant 0 : i32
        %159 = arith.extsi %154 : i8 to i32
        %158 = arith.cmpi ne, %159, %157 : i32
        cf.cond_br %158, ^bb25, ^bb26
        ^bb25:
          %161 = llvm.load %146 : !llvm.ptr -> i64
          %162 = llvm.getelementptr %86[%161] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %160 = llvm.load %162 : !llvm.ptr -> i64
          %163 = arith.cmpi eq, %160, %142 : i64
          %164 = scf.if %163 -> (i1) {
            %166 = llvm.load %146 : !llvm.ptr -> i64
            %167 = llvm.getelementptr %89[%166] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %165 = llvm.load %167 : !llvm.ptr -> i64
            %168 = arith.constant 1 : i32
            %170 = arith.extsi %168 : i32 to i64
            %169 = arith.cmpi eq, %165, %170 : i64
            scf.yield %169 : i1
          } else {
            %171 = arith.constant false
            scf.yield %171 : i1
          }
          cf.cond_br %164, ^bb27, ^bb28
          ^bb27:
            cf.br ^bb26
          ^bb28:
            cf.br ^bb29
          ^bb29:
          %172 = llvm.load %146 : !llvm.ptr -> i64
          %173 = arith.constant 1 : i32
          %175 = arith.extsi %173 : i32 to i64
          %174 = arith.addi %172, %175 : i64
          llvm.store %174, %146 : i64, !llvm.ptr
          %176 = llvm.load %146 : !llvm.ptr -> i64
          %177 = arith.cmpi eq, %176, %82 : i64
          cf.cond_br %177, ^bb30, ^bb31
          ^bb30:
            %178 = arith.constant 0 : i32
            %179 = arith.extsi %178 : i32 to i64
            llvm.store %179, %146 : i64, !llvm.ptr
            cf.br ^bb32
          ^bb31:
            cf.br ^bb32
          ^bb32:
          cf.br ^bb24
        ^bb26:
        %181 = llvm.load %146 : !llvm.ptr -> i64
        %182 = llvm.getelementptr %83[%181] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        %180 = llvm.load %182 : !llvm.ptr -> i8
        %183 = arith.constant 0 : i32
        %185 = arith.extsi %180 : i8 to i32
        %184 = arith.cmpi eq, %185, %183 : i32
        cf.cond_br %184, ^bb33, ^bb34
        ^bb33:
          %186 = arith.constant 1 : i32
          %187 = llvm.load %146 : !llvm.ptr -> i64
          %188 = arith.trunci %186 : i32 to i8
          %189 = llvm.getelementptr %83[%187] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %188, %189 : i8, !llvm.ptr
          %190 = llvm.load %146 : !llvm.ptr -> i64
          %191 = llvm.getelementptr %86[%190] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %142, %191 : i64, !llvm.ptr
          %192 = arith.constant 1 : i32
          %193 = llvm.load %146 : !llvm.ptr -> i64
          %194 = arith.extsi %192 : i32 to i64
          %195 = llvm.getelementptr %89[%193] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %194, %195 : i64, !llvm.ptr
          %196 = llvm.load %141 : !llvm.ptr -> i64
          %197 = arith.constant 1 : i32
          %199 = arith.extsi %197 : i32 to i64
          %198 = arith.addi %196, %199 : i64
          llvm.store %198, %141 : i64, !llvm.ptr
          cf.br ^bb35
        ^bb34:
          cf.br ^bb35
        ^bb35:
        %200 = llvm.load %95 : !llvm.ptr -> i64
        %201 = arith.constant 1 : i32
        %203 = arith.extsi %201 : i32 to i64
        %202 = arith.cmpi sgt, %200, %203 : i64
        cf.cond_br %202, ^bb36, ^bb37
        ^bb36:
          %204 = llvm.load %103 : !llvm.ptr -> i64
          %205 = llvm.mlir.constant(1 : i64) : i64
          %206 = llvm.alloca %205 x i64 : (i64) -> !llvm.ptr
          llvm.store %204, %206 : i64, !llvm.ptr
          cf.br ^bb39
          ^bb39:
          %207 = llvm.load %206 : !llvm.ptr -> i64
          %208 = arith.cmpi slt, %207, %117 : i64
          cf.cond_br %208, ^bb40, ^bb41
          ^bb40:
            %209 = llvm.load %103 : !llvm.ptr -> i64
            %210 = arith.constant 10 : i32
            %212 = arith.extsi %210 : i32 to i64
            %211 = arith.muli %209, %212 : i64
            %213 = llvm.load %206 : !llvm.ptr -> i64
            %214 = arith.addi %211, %213 : i64
            %215 = llvm.load %206 : !llvm.ptr -> i64
            %216 = arith.constant 1 : i32
            %218 = arith.extsi %216 : i32 to i64
            %217 = arith.addi %215, %218 : i64
            %219 = arith.constant 10 : i32
            %221 = arith.extsi %219 : i32 to i64
            %220 = arith.muli %217, %221 : i64
            %222 = arith.addi %220, %117 : i64
            %224 = llvm.getelementptr %62[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            %223 = llvm.load %224 : !llvm.ptr -> i32
            %225 = arith.extsi %223 : i32 to i64
            %227 = llvm.getelementptr %67[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            %226 = llvm.load %227 : !llvm.ptr -> i32
            %228 = arith.extsi %226 : i32 to i64
            %230 = llvm.getelementptr %62[%222] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            %229 = llvm.load %230 : !llvm.ptr -> i32
            %231 = arith.extsi %229 : i32 to i64
            %233 = llvm.getelementptr %67[%222] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            %232 = llvm.load %233 : !llvm.ptr -> i32
            %234 = arith.extsi %232 : i32 to i64
            %235 = arith.constant 0 : i32
            %236 = arith.extsi %235 : i32 to i64
            %237 = llvm.mlir.constant(1 : i64) : i64
            %238 = llvm.alloca %237 x i64 : (i64) -> !llvm.ptr
            llvm.store %236, %238 : i64, !llvm.ptr
            cf.br ^bb42
            ^bb42:
            %239 = llvm.load %238 : !llvm.ptr -> i64
            %240 = arith.cmpi slt, %239, %228 : i64
            cf.cond_br %240, ^bb43, ^bb44
            ^bb43:
              %242 = llvm.load %238 : !llvm.ptr -> i64
              %243 = arith.addi %225, %242 : i64
              %244 = llvm.getelementptr %56[%243] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %241 = llvm.load %244 : !llvm.ptr -> i64
              %246 = llvm.load %238 : !llvm.ptr -> i64
              %247 = arith.addi %225, %246 : i64
              %248 = llvm.getelementptr %59[%247] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %245 = llvm.load %248 : !llvm.ptr -> i64
              %249 = arith.constant 0 : i32
              %250 = arith.extsi %249 : i32 to i64
              %251 = llvm.mlir.constant(1 : i64) : i64
              %252 = llvm.alloca %251 x i64 : (i64) -> !llvm.ptr
              llvm.store %250, %252 : i64, !llvm.ptr
              cf.br ^bb45
              ^bb45:
              %253 = llvm.load %252 : !llvm.ptr -> i64
              %254 = arith.cmpi slt, %253, %234 : i64
              cf.cond_br %254, ^bb46, ^bb47
              ^bb46:
                %256 = llvm.load %252 : !llvm.ptr -> i64
                %257 = arith.addi %231, %256 : i64
                %258 = llvm.getelementptr %56[%257] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %255 = llvm.load %258 : !llvm.ptr -> i64
                %260 = llvm.load %252 : !llvm.ptr -> i64
                %261 = arith.addi %231, %260 : i64
                %262 = llvm.getelementptr %59[%261] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %259 = llvm.load %262 : !llvm.ptr -> i64
                %263 = arith.constant 0 : i32
                %264 = arith.extsi %263 : i32 to i64
                %265 = llvm.mlir.constant(1 : i64) : i64
                %266 = llvm.alloca %265 x i64 : (i64) -> !llvm.ptr
                llvm.store %264, %266 : i64, !llvm.ptr
                cf.br ^bb48
                ^bb48:
                %267 = llvm.load %266 : !llvm.ptr -> i64
                %268 = arith.constant 4 : i32
                %270 = arith.extsi %268 : i32 to i64
                %269 = arith.cmpi slt, %267, %270 : i64
                cf.cond_br %269, ^bb49, ^bb50
                ^bb49:
                  %271 = arith.constant 0 : i32
                  %272 = arith.extsi %271 : i32 to i64
                  %273 = llvm.mlir.constant(1 : i64) : i64
                  %274 = llvm.alloca %273 x i64 : (i64) -> !llvm.ptr
                  llvm.store %272, %274 : i64, !llvm.ptr
                  %275 = arith.constant 1 : i32
                  %276 = arith.extsi %275 : i32 to i64
                  %277 = llvm.mlir.constant(1 : i64) : i64
                  %278 = llvm.alloca %277 x i64 : (i64) -> !llvm.ptr
                  llvm.store %276, %278 : i64, !llvm.ptr
                  %279 = arith.constant 1 : i1
                  %280 = llvm.mlir.constant(1 : i64) : i64
                  %281 = llvm.alloca %280 x i1 : (i64) -> !llvm.ptr
                  llvm.store %279, %281 : i1, !llvm.ptr
                  %282 = llvm.load %266 : !llvm.ptr -> i64
                  %283 = arith.constant 0 : i32
                  %285 = arith.extsi %283 : i32 to i64
                  %284 = arith.cmpi eq, %282, %285 : i64
                  cf.cond_br %284, ^bb51, ^bb52
                  ^bb51:
                    %286 = arith.muli %241, %259 : i64
                    %287 = arith.muli %255, %245 : i64
                    %288 = arith.addi %286, %287 : i64
                    llvm.store %288, %274 : i64, !llvm.ptr
                    %289 = arith.muli %245, %259 : i64
                    llvm.store %289, %278 : i64, !llvm.ptr
                    cf.br ^bb53
                  ^bb52:
                    %290 = llvm.load %266 : !llvm.ptr -> i64
                    %291 = arith.constant 1 : i32
                    %293 = arith.extsi %291 : i32 to i64
                    %292 = arith.cmpi eq, %290, %293 : i64
                    cf.cond_br %292, ^bb55, ^bb54
                  ^bb55:
                    %294 = arith.muli %241, %259 : i64
                    %295 = arith.muli %255, %245 : i64
                    %296 = arith.subi %294, %295 : i64
                    llvm.store %296, %274 : i64, !llvm.ptr
                    %297 = arith.muli %245, %259 : i64
                    llvm.store %297, %278 : i64, !llvm.ptr
                    cf.br ^bb53
                  ^bb54:
                    %298 = llvm.load %266 : !llvm.ptr -> i64
                    %299 = arith.constant 2 : i32
                    %301 = arith.extsi %299 : i32 to i64
                    %300 = arith.cmpi eq, %298, %301 : i64
                    cf.cond_br %300, ^bb57, ^bb56
                  ^bb57:
                    %302 = arith.muli %241, %255 : i64
                    llvm.store %302, %274 : i64, !llvm.ptr
                    %303 = arith.muli %245, %259 : i64
                    llvm.store %303, %278 : i64, !llvm.ptr
                    cf.br ^bb53
                  ^bb56:
                    %304 = arith.constant 0 : i32
                    %306 = arith.extsi %304 : i32 to i64
                    %305 = arith.cmpi eq, %255, %306 : i64
                    cf.cond_br %305, ^bb58, ^bb59
                    ^bb58:
                      %307 = arith.constant 0 : i1
                      llvm.store %307, %281 : i1, !llvm.ptr
                      cf.br ^bb60
                    ^bb59:
                      %308 = arith.muli %241, %259 : i64
                      llvm.store %308, %274 : i64, !llvm.ptr
                      %309 = arith.muli %245, %255 : i64
                      llvm.store %309, %278 : i64, !llvm.ptr
                      cf.br ^bb60
                    ^bb60:
                    cf.br ^bb53
                  ^bb53:
                  %310 = llvm.load %281 : !llvm.ptr -> i1
                  cf.cond_br %310, ^bb61, ^bb62
                  ^bb61:
                    %311 = llvm.load %278 : !llvm.ptr -> i64
                    %312 = arith.constant 0 : i32
                    %314 = arith.extsi %312 : i32 to i64
                    %313 = arith.cmpi slt, %311, %314 : i64
                    cf.cond_br %313, ^bb64, ^bb65
                    ^bb64:
                      %315 = arith.constant 0 : i32
                      %316 = llvm.load %274 : !llvm.ptr -> i64
                      %318 = arith.extsi %315 : i32 to i64
                      %317 = arith.subi %318, %316 : i64
                      llvm.store %317, %274 : i64, !llvm.ptr
                      %319 = arith.constant 0 : i32
                      %320 = llvm.load %278 : !llvm.ptr -> i64
                      %322 = arith.extsi %319 : i32 to i64
                      %321 = arith.subi %322, %320 : i64
                      llvm.store %321, %278 : i64, !llvm.ptr
                      cf.br ^bb66
                    ^bb65:
                      cf.br ^bb66
                    ^bb66:
                    %323 = llvm.load %278 : !llvm.ptr -> i64
                    %324 = arith.constant 0 : i32
                    %326 = arith.extsi %324 : i32 to i64
                    %325 = arith.cmpi ne, %323, %326 : i64
                    cf.cond_br %325, ^bb67, ^bb68
                    ^bb67:
                      %328 = llvm.load %274 : !llvm.ptr -> i64
                      %329 = llvm.load %278 : !llvm.ptr -> i64
                      %327 = func.call @gcd_abs(%328, %329) : (i64, i64) -> i64
                      %330 = llvm.load %274 : !llvm.ptr -> i64
                      %331 = arith.divsi %330, %327 : i64
                      llvm.store %331, %274 : i64, !llvm.ptr
                      %332 = llvm.load %278 : !llvm.ptr -> i64
                      %333 = arith.divsi %332, %327 : i64
                      llvm.store %333, %278 : i64, !llvm.ptr
                      %334 = llvm.load %274 : !llvm.ptr -> i64
                      %335 = arith.constant 1000003 : i32
                      %337 = arith.extsi %335 : i32 to i64
                      %336 = arith.muli %334, %337 : i64
                      %338 = llvm.load %278 : !llvm.ptr -> i64
                      %339 = arith.addi %336, %338 : i64
                      %340 = arith.remsi %339, %82 : i64
                      llvm.store %340, %146 : i64, !llvm.ptr
                      %341 = llvm.load %146 : !llvm.ptr -> i64
                      %342 = arith.constant 0 : i32
                      %344 = arith.extsi %342 : i32 to i64
                      %343 = arith.cmpi slt, %341, %344 : i64
                      cf.cond_br %343, ^bb70, ^bb71
                      ^bb70:
                        %345 = llvm.load %146 : !llvm.ptr -> i64
                        %347 = arith.constant 0 : i64
                        %346 = arith.subi %347, %345 : i64
                        llvm.store %346, %146 : i64, !llvm.ptr
                        cf.br ^bb72
                      ^bb71:
                        cf.br ^bb72
                      ^bb72:
                      cf.br ^bb73
                      ^bb73:
                      %349 = llvm.load %146 : !llvm.ptr -> i64
                      %350 = llvm.getelementptr %83[%349] : (!llvm.ptr, i64) -> !llvm.ptr, i8
                      %348 = llvm.load %350 : !llvm.ptr -> i8
                      %351 = arith.constant 0 : i32
                      %353 = arith.extsi %348 : i8 to i32
                      %352 = arith.cmpi ne, %353, %351 : i32
                      cf.cond_br %352, ^bb74, ^bb75
                      ^bb74:
                        %355 = llvm.load %146 : !llvm.ptr -> i64
                        %356 = llvm.getelementptr %86[%355] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                        %354 = llvm.load %356 : !llvm.ptr -> i64
                        %357 = llvm.load %274 : !llvm.ptr -> i64
                        %358 = arith.cmpi eq, %354, %357 : i64
                        %359 = scf.if %358 -> (i1) {
                          %361 = llvm.load %146 : !llvm.ptr -> i64
                          %362 = llvm.getelementptr %89[%361] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                          %360 = llvm.load %362 : !llvm.ptr -> i64
                          %363 = llvm.load %278 : !llvm.ptr -> i64
                          %364 = arith.cmpi eq, %360, %363 : i64
                          scf.yield %364 : i1
                        } else {
                          %365 = arith.constant false
                          scf.yield %365 : i1
                        }
                        cf.cond_br %359, ^bb76, ^bb77
                        ^bb76:
                          cf.br ^bb75
                        ^bb77:
                          cf.br ^bb78
                        ^bb78:
                        %366 = llvm.load %146 : !llvm.ptr -> i64
                        %367 = arith.constant 1 : i32
                        %369 = arith.extsi %367 : i32 to i64
                        %368 = arith.addi %366, %369 : i64
                        llvm.store %368, %146 : i64, !llvm.ptr
                        %370 = llvm.load %146 : !llvm.ptr -> i64
                        %371 = arith.cmpi eq, %370, %82 : i64
                        cf.cond_br %371, ^bb79, ^bb80
                        ^bb79:
                          %372 = arith.constant 0 : i32
                          %373 = arith.extsi %372 : i32 to i64
                          llvm.store %373, %146 : i64, !llvm.ptr
                          cf.br ^bb81
                        ^bb80:
                          cf.br ^bb81
                        ^bb81:
                        cf.br ^bb73
                      ^bb75:
                      %375 = llvm.load %146 : !llvm.ptr -> i64
                      %376 = llvm.getelementptr %83[%375] : (!llvm.ptr, i64) -> !llvm.ptr, i8
                      %374 = llvm.load %376 : !llvm.ptr -> i8
                      %377 = arith.constant 0 : i32
                      %379 = arith.extsi %374 : i8 to i32
                      %378 = arith.cmpi eq, %379, %377 : i32
                      cf.cond_br %378, ^bb82, ^bb83
                      ^bb82:
                        %380 = arith.constant 1 : i32
                        %381 = llvm.load %146 : !llvm.ptr -> i64
                        %382 = arith.trunci %380 : i32 to i8
                        %383 = llvm.getelementptr %83[%381] : (!llvm.ptr, i64) -> !llvm.ptr, i8
                        llvm.store %382, %383 : i8, !llvm.ptr
                        %384 = llvm.load %274 : !llvm.ptr -> i64
                        %385 = llvm.load %146 : !llvm.ptr -> i64
                        %386 = llvm.getelementptr %86[%385] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                        llvm.store %384, %386 : i64, !llvm.ptr
                        %387 = llvm.load %278 : !llvm.ptr -> i64
                        %388 = llvm.load %146 : !llvm.ptr -> i64
                        %389 = llvm.getelementptr %89[%388] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                        llvm.store %387, %389 : i64, !llvm.ptr
                        %390 = llvm.load %141 : !llvm.ptr -> i64
                        %391 = arith.constant 1 : i32
                        %393 = arith.extsi %391 : i32 to i64
                        %392 = arith.addi %390, %393 : i64
                        llvm.store %392, %141 : i64, !llvm.ptr
                        cf.br ^bb84
                      ^bb83:
                        cf.br ^bb84
                      ^bb84:
                      cf.br ^bb69
                    ^bb68:
                      cf.br ^bb69
                    ^bb69:
                    cf.br ^bb63
                  ^bb62:
                    cf.br ^bb63
                  ^bb63:
                  %394 = llvm.load %266 : !llvm.ptr -> i64
                  %395 = arith.constant 1 : i32
                  %397 = arith.extsi %395 : i32 to i64
                  %396 = arith.addi %394, %397 : i64
                  llvm.store %396, %266 : i64, !llvm.ptr
                  cf.br ^bb48
                ^bb50:
                %398 = llvm.load %252 : !llvm.ptr -> i64
                %399 = arith.constant 1 : i32
                %401 = arith.extsi %399 : i32 to i64
                %400 = arith.addi %398, %401 : i64
                llvm.store %400, %252 : i64, !llvm.ptr
                cf.br ^bb45
              ^bb47:
              %402 = llvm.load %238 : !llvm.ptr -> i64
              %403 = arith.constant 1 : i32
              %405 = arith.extsi %403 : i32 to i64
              %404 = arith.addi %402, %405 : i64
              llvm.store %404, %238 : i64, !llvm.ptr
              cf.br ^bb42
            ^bb44:
            %406 = llvm.load %206 : !llvm.ptr -> i64
            %407 = arith.constant 1 : i32
            %409 = arith.extsi %407 : i32 to i64
            %408 = arith.addi %406, %409 : i64
            llvm.store %408, %206 : i64, !llvm.ptr
            cf.br ^bb39
          ^bb41:
          cf.br ^bb38
        ^bb37:
          cf.br ^bb38
        ^bb38:
        %410 = llvm.load %80 : !llvm.ptr -> i64
        %411 = arith.trunci %410 : i64 to i32
        %412 = llvm.getelementptr %62[%123] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %411, %412 : i32, !llvm.ptr
        %413 = llvm.load %141 : !llvm.ptr -> i64
        %414 = arith.trunci %413 : i64 to i32
        %415 = llvm.getelementptr %67[%123] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %414, %415 : i32, !llvm.ptr
        %416 = arith.constant 0 : i32
        %417 = arith.extsi %416 : i32 to i64
        llvm.store %417, %127 : i64, !llvm.ptr
        cf.br ^bb85
        ^bb85:
        %418 = llvm.load %127 : !llvm.ptr -> i64
        %419 = arith.cmpi slt, %418, %82 : i64
        cf.cond_br %419, ^bb86, ^bb87
        ^bb86:
          %421 = llvm.load %127 : !llvm.ptr -> i64
          %422 = llvm.getelementptr %83[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          %420 = llvm.load %422 : !llvm.ptr -> i8
          %423 = arith.constant 0 : i32
          %425 = arith.extsi %420 : i8 to i32
          %424 = arith.cmpi ne, %425, %423 : i32
          cf.cond_br %424, ^bb88, ^bb89
          ^bb88:
            %427 = llvm.load %127 : !llvm.ptr -> i64
            %428 = llvm.getelementptr %86[%427] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %426 = llvm.load %428 : !llvm.ptr -> i64
            %429 = llvm.load %80 : !llvm.ptr -> i64
            %430 = llvm.getelementptr %56[%429] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %426, %430 : i64, !llvm.ptr
            %432 = llvm.load %127 : !llvm.ptr -> i64
            %433 = llvm.getelementptr %89[%432] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %431 = llvm.load %433 : !llvm.ptr -> i64
            %434 = llvm.load %80 : !llvm.ptr -> i64
            %435 = llvm.getelementptr %59[%434] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %431, %435 : i64, !llvm.ptr
            %436 = llvm.load %80 : !llvm.ptr -> i64
            %437 = arith.constant 1 : i32
            %439 = arith.extsi %437 : i32 to i64
            %438 = arith.addi %436, %439 : i64
            llvm.store %438, %80 : i64, !llvm.ptr
            cf.br ^bb90
          ^bb89:
            cf.br ^bb90
          ^bb90:
          %440 = llvm.load %127 : !llvm.ptr -> i64
          %441 = arith.constant 1 : i32
          %443 = arith.extsi %441 : i32 to i64
          %442 = arith.addi %440, %443 : i64
          llvm.store %442, %127 : i64, !llvm.ptr
          cf.br ^bb85
        ^bb87:
        %444 = arith.constant 1 : i32
        %445 = arith.trunci %444 : i32 to i8
        %446 = llvm.getelementptr %72[%123] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %445, %446 : i8, !llvm.ptr
        %447 = llvm.load %103 : !llvm.ptr -> i64
        %448 = arith.constant 1 : i32
        %450 = arith.extsi %448 : i32 to i64
        %449 = arith.addi %447, %450 : i64
        llvm.store %449, %103 : i64, !llvm.ptr
        cf.br ^bb15
      ^bb17:
      %451 = llvm.load %95 : !llvm.ptr -> i64
      %452 = arith.constant 1 : i32
      %454 = arith.extsi %452 : i32 to i64
      %453 = arith.addi %451, %454 : i64
      llvm.store %453, %95 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %455 = arith.constant 19 : i32
    %456 = arith.extsi %455 : i32 to i64
    %458 = llvm.getelementptr %62[%456] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %457 = llvm.load %458 : !llvm.ptr -> i32
    %459 = arith.extsi %457 : i32 to i64
    %461 = llvm.getelementptr %67[%456] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %460 = llvm.load %461 : !llvm.ptr -> i32
    %462 = arith.extsi %460 : i32 to i64
    %463 = arith.constant 0 : i32
    %464 = arith.extsi %463 : i32 to i64
    %465 = llvm.mlir.constant(1 : i64) : i64
    %466 = llvm.alloca %465 x i64 : (i64) -> !llvm.ptr
    llvm.store %464, %466 : i64, !llvm.ptr
    %467 = arith.constant 0 : i32
    %468 = arith.extsi %467 : i32 to i64
    %469 = llvm.mlir.constant(1 : i64) : i64
    %470 = llvm.alloca %469 x i64 : (i64) -> !llvm.ptr
    llvm.store %468, %470 : i64, !llvm.ptr
    cf.br ^bb91
    ^bb91:
    %471 = llvm.load %470 : !llvm.ptr -> i64
    %472 = arith.cmpi slt, %471, %462 : i64
    cf.cond_br %472, ^bb92, ^bb93
    ^bb92:
      %474 = llvm.load %470 : !llvm.ptr -> i64
      %475 = arith.addi %459, %474 : i64
      %476 = llvm.getelementptr %59[%475] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %473 = llvm.load %476 : !llvm.ptr -> i64
      %477 = arith.constant 1 : i32
      %479 = arith.extsi %477 : i32 to i64
      %478 = arith.cmpi eq, %473, %479 : i64
      %480 = scf.if %478 -> (i1) {
        %482 = llvm.load %470 : !llvm.ptr -> i64
        %483 = arith.addi %459, %482 : i64
        %484 = llvm.getelementptr %56[%483] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %481 = llvm.load %484 : !llvm.ptr -> i64
        %485 = arith.constant 0 : i32
        %487 = arith.extsi %485 : i32 to i64
        %486 = arith.cmpi sgt, %481, %487 : i64
        scf.yield %486 : i1
      } else {
        %488 = arith.constant false
        scf.yield %488 : i1
      }
      cf.cond_br %480, ^bb94, ^bb95
      ^bb94:
        %489 = llvm.load %466 : !llvm.ptr -> i64
        %491 = llvm.load %470 : !llvm.ptr -> i64
        %492 = arith.addi %459, %491 : i64
        %493 = llvm.getelementptr %56[%492] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %490 = llvm.load %493 : !llvm.ptr -> i64
        %494 = arith.addi %489, %490 : i64
        llvm.store %494, %466 : i64, !llvm.ptr
        cf.br ^bb96
      ^bb95:
        cf.br ^bb96
      ^bb96:
      %495 = llvm.load %470 : !llvm.ptr -> i64
      %496 = arith.constant 1 : i32
      %498 = arith.extsi %496 : i32 to i64
      %497 = arith.addi %495, %498 : i64
      llvm.store %497, %470 : i64, !llvm.ptr
      cf.br ^bb91
    ^bb93:
    %499 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %500 = llvm.load %466 : !llvm.ptr -> i64
    %501 = llvm.call @printf(%499, %500) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%56) : (!llvm.ptr) -> ()
    func.call @free(%59) : (!llvm.ptr) -> ()
    func.call @free(%62) : (!llvm.ptr) -> ()
    func.call @free(%67) : (!llvm.ptr) -> ()
    func.call @free(%72) : (!llvm.ptr) -> ()
    func.call @free(%83) : (!llvm.ptr) -> ()
    func.call @free(%86) : (!llvm.ptr) -> ()
    func.call @free(%89) : (!llvm.ptr) -> ()
    %510 = arith.constant 0 : i32
    func.return %510 : i32
  }
}