Problem 662

Fibonacci Paths: F(10000, 10000) mod 1e9+7. DP over grid, steps where sqrt(dx^2+dy^2) is a Fibonacci number.

Answer860873428
Output860873428
StatusPASS
Native helperno
Runtime16570 ms
Peak memory766384 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 662
# Fibonacci Paths: F(10000, 10000) mod 1e9+7.
# DP over grid, steps where sqrt(dx^2+dy^2) is a Fibonacci number.

import euler.nt { isqrt }

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

const MOD: i64 = 1000000007

function main() -> i32 {
    let W: i64 = 10000
    let H: i64 = 10000

    # Generate Fibonacci numbers up to sqrt(W^2 + H^2)
    let max_len: i64 = isqrt(W * W + H * H)
    let fibs: ptr<i64> = calloc(100, 8)
    fibs[0] = 1
    fibs[1] = 2
    let mut nfibs: i64 = 2
    while fibs[nfibs - 1] + fibs[nfibs - 2] <= max_len {
        fibs[nfibs] = fibs[nfibs - 1] + fibs[nfibs - 2]
        nfibs = nfibs + 1
    }

    # Enumerate step vectors (dx, dy) with dx^2 + dy^2 = fib^2
    # Store as flat arrays: steps_dx[], steps_dy[], nsteps
    let steps_dx: ptr<i64> = calloc(20000, 8)
    let steps_dy: ptr<i64> = calloc(20000, 8)
    let mut nsteps: i64 = 0

    # Use a simple set: just collect all and deduplicate later
    for fi in 0..nfibs {
        let f: i64 = fibs[fi]
        let ff: i64 = f * f
        let lim: i64 = f
        if lim > W { lim = W }
        for dx in 0..(lim + 1) {
            let dy2: i64 = ff - dx * dx
            if dy2 < 0 { continue }
            let dy: i64 = isqrt(dy2)
            if dy * dy == dy2 && dy <= H {
                if dx != 0 || dy != 0 {
                    # Check for duplicates
                    let mut dup: bool = false
                    for j in 0..nsteps {
                        if steps_dx[j] == dx && steps_dy[j] == dy {
                            dup = true
                            break
                        }
                    }
                    if !dup {
                        steps_dx[nsteps] = dx
                        steps_dy[nsteps] = dy
                        nsteps = nsteps + 1
                    }
                }
            }
        }
    }

    # Separate vertical (dx=0) and horizontal (dx>0) steps
    let vert_dy: ptr<i64> = calloc(nsteps, 8)
    let prev_dx: ptr<i64> = calloc(nsteps, 8)
    let prev_dy: ptr<i64> = calloc(nsteps, 8)
    let mut nvert: i64 = 0
    let mut nprev: i64 = 0
    let mut max_dx: i64 = 0

    for i in 0..nsteps {
        if steps_dx[i] == 0 {
            vert_dy[nvert] = steps_dy[i]
            nvert = nvert + 1
        } else {
            prev_dx[nprev] = steps_dx[i]
            prev_dy[nprev] = steps_dy[i]
            nprev = nprev + 1
            if steps_dx[i] > max_dx { max_dx = steps_dx[i] }
        }
    }

    # Sort vertical steps by dy (insertion sort)
    for i in 1..nvert {
        let key: i64 = vert_dy[i]
        let mut j: i64 = i
        while j > 0 && vert_dy[j - 1] > key {
            vert_dy[j] = vert_dy[j - 1]
            j = j - 1
        }
        vert_dy[j] = key
    }

    # Sort previous column steps by dx (insertion sort)
    for i in 1..nprev {
        let kdx: i64 = prev_dx[i]
        let kdy: i64 = prev_dy[i]
        let mut j: i64 = i
        while j > 0 && prev_dx[j - 1] > kdx {
            prev_dx[j] = prev_dx[j - 1]
            prev_dy[j] = prev_dy[j - 1]
            j = j - 1
        }
        prev_dx[j] = kdx
        prev_dy[j] = kdy
    }

    # DP with circular buffer of columns (flat array: buf * (H+1))
    let buf: i64 = max_dx + 1
    let col_size: i64 = H + 1
    let buffer: ptr<i64> = calloc(buf * col_size, 8)
    let incoming: ptr<i64> = calloc(H + 1, 8)

    if buffer == null || incoming == null { return 1 }

    for x in 0..(W + 1) {
        let col_off: i64 = (x % buf) * col_size

        for y in 0..(H + 1) { incoming[y] = 0 }

        for i in 0..nprev {
            let dx: i64 = prev_dx[i]
            if dx > x { break }
            let dy: i64 = prev_dy[i]
            let src_off: i64 = ((x - dx) % buf) * col_size
            if dy == 0 {
                for y in 0..(H + 1) {
                    incoming[y] = (incoming[y] + buffer[src_off + y]) % MOD
                }
            } else {
                let limit: i64 = H - dy
                for y in 0..(limit + 1) {
                    incoming[y + dy] = (incoming[y + dy] + buffer[src_off + y]) % MOD
                }
            }
        }

        if x == 0 { incoming[0] = incoming[0] + 1 }

        for y in 0..(H + 1) {
            let mut val: i64 = incoming[y]
            for vi in 0..nvert {
                let dy: i64 = vert_dy[vi]
                if dy > y { break }
                val = (val + buffer[col_off + y - dy]) % MOD
            }
            buffer[col_off + y] = val
        }
    }

    printf("%lld\n", buffer[(W % buf) * col_size + H])

    free(buffer)
    free(incoming)
    free(vert_dy)
    free(prev_dx)
    free(prev_dy)
    free(steps_dx)
    free(steps_dy)
    free(fibs)
    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_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int32_t main(void);

static const int64_t MOD = 1000000007;

int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t lcm_i64_i64(int64_t a, int64_t b) {
    if ((a == 0 || b == 0)) {
        return 0;
    }
    return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}

int64_t isqrt_i64(int64_t n) {
    if (n < 2) {
        return n;
    }
    int64_t x = n;
    int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
    while (y < x) {
        x = y;
        y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
    }
    return x;
}

int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
    int64_t a = FLOW_CHECKED_MOD((a0), (mod));
    int64_t b = FLOW_CHECKED_MOD((b0), (mod));
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result + a)), (mod));
        }
        a = FLOW_CHECKED_MOD(((a * 2)), (mod));
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    int64_t result = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            result = mulmod_i64_i64_i64(result, b, mod);
        }
        b = mulmod_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return result;
}

bool is_prime_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (n < 4) {
        return 1;
    }
    if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
        return 0;
    }
    int64_t i = 5;
    while ((i * i) <= n) {
        if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
            return 0;
        }
        i = (i + 6);
    }
    return 1;
}



int32_t main(void) {
    int64_t W = 10000;
    int64_t H = 10000;
    int64_t max_len = isqrt_i64(((W * W) + (H * H)));
    int64_t* fibs = (int64_t*)(calloc(100, 8));
    fibs[0] = 1;
    fibs[1] = 2;
    int64_t nfibs = 2;
    while ((fibs[(nfibs - 1)] + fibs[(nfibs - 2)]) <= max_len) {
        fibs[nfibs] = (fibs[(nfibs - 1)] + fibs[(nfibs - 2)]);
        nfibs = (nfibs + 1);
    }
    int64_t* steps_dx = (int64_t*)(calloc(20000, 8));
    int64_t* steps_dy = (int64_t*)(calloc(20000, 8));
    int64_t nsteps = 0;
    int32_t __flow_step_1 = 1;
    for (int32_t fi = 0; (0 <= nfibs) ? fi < nfibs : fi > nfibs; fi += (0 <= nfibs) ? 1 : -1) {
        int64_t f = fibs[fi];
        int64_t ff = (f * f);
        int64_t lim = f;
        if (lim > W) {
            lim = W;
        }
        int32_t __flow_step_2 = 1;
        for (int32_t dx = 0; (0 <= (lim + 1)) ? dx < (lim + 1) : dx > (lim + 1); dx += (0 <= (lim + 1)) ? 1 : -1) {
            int64_t dy2 = (ff - (dx * dx));
            if (dy2 < 0) {
                continue;
            }
            int64_t dy = isqrt_i64(dy2);
            if (((dy * dy) == dy2 && dy <= H)) {
                if ((dx != 0 || dy != 0)) {
                    bool dup = 0;
                    int32_t __flow_step_3 = 1;
                    for (int32_t j = 0; (0 <= nsteps) ? j < nsteps : j > nsteps; j += (0 <= nsteps) ? 1 : -1) {
                        if ((steps_dx[j] == dx && steps_dy[j] == dy)) {
                            dup = 1;
                            break;
                        }
                    }
                    if ((!(dup))) {
                        steps_dx[nsteps] = dx;
                        steps_dy[nsteps] = dy;
                        nsteps = (nsteps + 1);
                    }
                }
            }
        }
    }
    int64_t* vert_dy = (int64_t*)(calloc(nsteps, 8));
    int64_t* prev_dx = (int64_t*)(calloc(nsteps, 8));
    int64_t* prev_dy = (int64_t*)(calloc(nsteps, 8));
    int64_t nvert = 0;
    int64_t nprev = 0;
    int64_t max_dx = 0;
    int32_t __flow_step_4 = 1;
    for (int32_t i = 0; (0 <= nsteps) ? i < nsteps : i > nsteps; i += (0 <= nsteps) ? 1 : -1) {
        if (steps_dx[i] == 0) {
            vert_dy[nvert] = steps_dy[i];
            nvert = (nvert + 1);
        } else {
            prev_dx[nprev] = steps_dx[i];
            prev_dy[nprev] = steps_dy[i];
            nprev = (nprev + 1);
            if (steps_dx[i] > max_dx) {
                max_dx = steps_dx[i];
            }
        }
    }
    int32_t __flow_step_5 = 1;
    for (int32_t i = 1; (1 <= nvert) ? i < nvert : i > nvert; i += (1 <= nvert) ? 1 : -1) {
        int64_t key = vert_dy[i];
        int64_t j = i;
        while ((j > 0 && vert_dy[(j - 1)] > key)) {
            vert_dy[j] = vert_dy[(j - 1)];
            j = (j - 1);
        }
        vert_dy[j] = key;
    }
    int32_t __flow_step_6 = 1;
    for (int32_t i = 1; (1 <= nprev) ? i < nprev : i > nprev; i += (1 <= nprev) ? 1 : -1) {
        int64_t kdx = prev_dx[i];
        int64_t kdy = prev_dy[i];
        int64_t j = i;
        while ((j > 0 && prev_dx[(j - 1)] > kdx)) {
            prev_dx[j] = prev_dx[(j - 1)];
            prev_dy[j] = prev_dy[(j - 1)];
            j = (j - 1);
        }
        prev_dx[j] = kdx;
        prev_dy[j] = kdy;
    }
    int64_t buf = (max_dx + 1);
    int64_t col_size = (H + 1);
    int64_t* buffer = (int64_t*)(calloc((buf * col_size), 8));
    int64_t* incoming = (int64_t*)(calloc((H + 1), 8));
    if ((buffer == NULL || incoming == NULL)) {
        return 1;
    }
    int32_t __flow_step_7 = 1;
    for (int32_t x = 0; (0 <= (W + 1)) ? x < (W + 1) : x > (W + 1); x += (0 <= (W + 1)) ? 1 : -1) {
        int64_t col_off = (FLOW_CHECKED_MOD((x), (buf)) * col_size);
        int32_t __flow_step_8 = 1;
        for (int32_t y = 0; (0 <= (H + 1)) ? y < (H + 1) : y > (H + 1); y += (0 <= (H + 1)) ? 1 : -1) {
            incoming[y] = 0;
        }
        int32_t __flow_step_9 = 1;
        for (int32_t i = 0; (0 <= nprev) ? i < nprev : i > nprev; i += (0 <= nprev) ? 1 : -1) {
            int64_t dx = prev_dx[i];
            if (dx > x) {
                break;
            }
            int64_t dy = prev_dy[i];
            int64_t src_off = (FLOW_CHECKED_MOD(((x - dx)), (buf)) * col_size);
            if (dy == 0) {
                int32_t __flow_step_10 = 1;
                for (int32_t y = 0; (0 <= (H + 1)) ? y < (H + 1) : y > (H + 1); y += (0 <= (H + 1)) ? 1 : -1) {
                    incoming[y] = FLOW_CHECKED_MOD(((incoming[y] + buffer[(src_off + y)])), (MOD));
                }
            } else {
                int64_t limit = (H - dy);
                int32_t __flow_step_11 = 1;
                for (int32_t y = 0; (0 <= (limit + 1)) ? y < (limit + 1) : y > (limit + 1); y += (0 <= (limit + 1)) ? 1 : -1) {
                    incoming[(y + dy)] = FLOW_CHECKED_MOD(((incoming[(y + dy)] + buffer[(src_off + y)])), (MOD));
                }
            }
        }
        if (x == 0) {
            incoming[0] = (incoming[0] + 1);
        }
        int32_t __flow_step_12 = 1;
        for (int32_t y = 0; (0 <= (H + 1)) ? y < (H + 1) : y > (H + 1); y += (0 <= (H + 1)) ? 1 : -1) {
            int64_t val = incoming[y];
            int32_t __flow_step_13 = 1;
            for (int32_t vi = 0; (0 <= nvert) ? vi < nvert : vi > nvert; vi += (0 <= nvert) ? 1 : -1) {
                int64_t dy = vert_dy[vi];
                if (dy > y) {
                    break;
                }
                val = FLOW_CHECKED_MOD(((val + buffer[((col_off + y) - dy)])), (MOD));
            }
            buffer[(col_off + y)] = val;
        }
    }
    printf("%lld\n", buffer[((FLOW_CHECKED_MOD((W), (buf)) * col_size) + H)]);
    free(buffer);
    free(incoming);
    free(vert_dy);
    free(prev_dx);
    free(prev_dy);
    free(steps_dx);
    free(steps_dy);
    free(fibs);
    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 @gcd(%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
    cf.br ^bb0
    ^bb0:
    %4 = llvm.load %3 : !llvm.ptr -> i64
    %5 = arith.constant 0 : i32
    %7 = arith.extsi %5 : i32 to i64
    %6 = arith.cmpi ne, %4, %7 : i64
    cf.cond_br %6, ^bb1, ^bb2
    ^bb1:
      %8 = llvm.load %1 : !llvm.ptr -> i64
      %9 = llvm.load %3 : !llvm.ptr -> i64
      %10 = arith.remsi %8, %9 : i64
      %11 = llvm.load %3 : !llvm.ptr -> i64
      llvm.store %11, %1 : i64, !llvm.ptr
      llvm.store %10, %3 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %12 = llvm.load %1 : !llvm.ptr -> i64
    func.return %12 : i64
  }
  func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
    %13 = arith.constant 0 : i32
    %15 = arith.extsi %13 : i32 to i64
    %14 = arith.cmpi eq, %arg0, %15 : i64
    %16 = scf.if %14 -> (i1) {
      %17 = arith.constant true
      scf.yield %17 : i1
    } else {
      %18 = arith.constant 0 : i32
      %20 = arith.extsi %18 : i32 to i64
      %19 = arith.cmpi eq, %arg1, %20 : i64
      scf.yield %19 : i1
    }
    cf.cond_br %16, ^bb3, ^bb4
    ^bb3:
      %21 = arith.constant 0 : i32
      %22 = arith.extsi %21 : i32 to i64
      func.return %22 : i64
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
    %24 = arith.divsi %arg0, %23 : i64
    %25 = arith.muli %24, %arg1 : i64
    func.return %25 : i64
  }
  func.func @isqrt(%arg0: i64) -> i64 {
    %26 = arith.constant 2 : i32
    %28 = arith.extsi %26 : i32 to i64
    %27 = arith.cmpi slt, %arg0, %28 : i64
    cf.cond_br %27, ^bb6, ^bb7
    ^bb6:
      func.return %arg0 : i64
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %29 = llvm.mlir.constant(1 : i64) : i64
    %30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %30 : i64, !llvm.ptr
    %31 = llvm.load %30 : !llvm.ptr -> i64
    %32 = arith.constant 1 : i32
    %34 = arith.extsi %32 : i32 to i64
    %33 = arith.addi %31, %34 : i64
    %35 = arith.constant 2 : i32
    %37 = arith.extsi %35 : i32 to i64
    %36 = arith.divsi %33, %37 : i64
    %38 = llvm.mlir.constant(1 : i64) : i64
    %39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
    llvm.store %36, %39 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %40 = llvm.load %39 : !llvm.ptr -> i64
    %41 = llvm.load %30 : !llvm.ptr -> i64
    %42 = arith.cmpi slt, %40, %41 : i64
    cf.cond_br %42, ^bb10, ^bb11
    ^bb10:
      %43 = llvm.load %39 : !llvm.ptr -> i64
      llvm.store %43, %30 : i64, !llvm.ptr
      %44 = llvm.load %30 : !llvm.ptr -> i64
      %45 = llvm.load %30 : !llvm.ptr -> i64
      %46 = arith.divsi %arg0, %45 : i64
      %47 = arith.addi %44, %46 : i64
      %48 = arith.constant 2 : i32
      %50 = arith.extsi %48 : i32 to i64
      %49 = arith.divsi %47, %50 : i64
      llvm.store %49, %39 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %51 = llvm.load %30 : !llvm.ptr -> i64
    func.return %51 : i64
  }
  func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %52 = arith.remsi %arg0, %arg2 : i64
    %53 = llvm.mlir.constant(1 : i64) : i64
    %54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
    llvm.store %52, %54 : i64, !llvm.ptr
    %55 = arith.remsi %arg1, %arg2 : i64
    %56 = llvm.mlir.constant(1 : i64) : i64
    %57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
    llvm.store %55, %57 : i64, !llvm.ptr
    %58 = arith.constant 0 : i32
    %59 = arith.extsi %58 : i32 to i64
    %60 = llvm.mlir.constant(1 : i64) : i64
    %61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
    llvm.store %59, %61 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %62 = llvm.load %57 : !llvm.ptr -> i64
    %63 = arith.constant 0 : i32
    %65 = arith.extsi %63 : i32 to i64
    %64 = arith.cmpi sgt, %62, %65 : i64
    cf.cond_br %64, ^bb13, ^bb14
    ^bb13:
      %66 = llvm.load %57 : !llvm.ptr -> i64
      %67 = arith.constant 2 : i32
      %69 = arith.extsi %67 : i32 to i64
      %68 = arith.remsi %66, %69 : i64
      %70 = arith.constant 1 : i32
      %72 = arith.extsi %70 : i32 to i64
      %71 = arith.cmpi eq, %68, %72 : i64
      cf.cond_br %71, ^bb15, ^bb16
      ^bb15:
        %73 = llvm.load %61 : !llvm.ptr -> i64
        %74 = llvm.load %54 : !llvm.ptr -> i64
        %75 = arith.addi %73, %74 : i64
        %76 = arith.remsi %75, %arg2 : i64
        llvm.store %76, %61 : i64, !llvm.ptr
        cf.br ^bb17
      ^bb16:
        cf.br ^bb17
      ^bb17:
      %77 = llvm.load %54 : !llvm.ptr -> i64
      %78 = arith.constant 2 : i32
      %80 = arith.extsi %78 : i32 to i64
      %79 = arith.muli %77, %80 : i64
      %81 = arith.remsi %79, %arg2 : i64
      llvm.store %81, %54 : i64, !llvm.ptr
      %82 = llvm.load %57 : !llvm.ptr -> i64
      %83 = arith.constant 2 : i32
      %85 = arith.extsi %83 : i32 to i64
      %84 = arith.divsi %82, %85 : i64
      llvm.store %84, %57 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %86 = llvm.load %61 : !llvm.ptr -> i64
    func.return %86 : i64
  }
  func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %87 = arith.constant 1 : i32
    %89 = arith.extsi %87 : i32 to i64
    %88 = arith.cmpi eq, %arg2, %89 : i64
    cf.cond_br %88, ^bb18, ^bb19
    ^bb18:
      %90 = arith.constant 0 : i32
      %91 = arith.extsi %90 : i32 to i64
      func.return %91 : i64
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %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
    %96 = arith.remsi %arg0, %arg2 : i64
    %97 = llvm.mlir.constant(1 : i64) : i64
    %98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
    llvm.store %96, %98 : i64, !llvm.ptr
    %99 = llvm.mlir.constant(1 : i64) : i64
    %100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %100 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %101 = llvm.load %100 : !llvm.ptr -> i64
    %102 = arith.constant 0 : i32
    %104 = arith.extsi %102 : i32 to i64
    %103 = arith.cmpi sgt, %101, %104 : i64
    cf.cond_br %103, ^bb22, ^bb23
    ^bb22:
      %105 = llvm.load %100 : !llvm.ptr -> i64
      %106 = arith.constant 2 : i32
      %108 = arith.extsi %106 : i32 to i64
      %107 = arith.remsi %105, %108 : i64
      %109 = arith.constant 1 : i32
      %111 = arith.extsi %109 : i32 to i64
      %110 = arith.cmpi eq, %107, %111 : i64
      cf.cond_br %110, ^bb24, ^bb25
      ^bb24:
        %113 = llvm.load %95 : !llvm.ptr -> i64
        %114 = llvm.load %98 : !llvm.ptr -> i64
        %112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
        llvm.store %112, %95 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        cf.br ^bb26
      ^bb26:
      %116 = llvm.load %98 : !llvm.ptr -> i64
      %117 = llvm.load %98 : !llvm.ptr -> i64
      %115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
      llvm.store %115, %98 : i64, !llvm.ptr
      %118 = llvm.load %100 : !llvm.ptr -> i64
      %119 = arith.constant 2 : i32
      %121 = arith.extsi %119 : i32 to i64
      %120 = arith.divsi %118, %121 : i64
      llvm.store %120, %100 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %122 = llvm.load %95 : !llvm.ptr -> i64
    func.return %122 : i64
  }
  func.func @is_prime(%arg0: i64) -> i1 {
    %123 = arith.constant 2 : i32
    %125 = arith.extsi %123 : i32 to i64
    %124 = arith.cmpi slt, %arg0, %125 : i64
    cf.cond_br %124, ^bb27, ^bb28
    ^bb27:
      %126 = arith.constant 0 : i1
      func.return %126 : i1
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %127 = arith.constant 4 : i32
    %129 = arith.extsi %127 : i32 to i64
    %128 = arith.cmpi slt, %arg0, %129 : i64
    cf.cond_br %128, ^bb30, ^bb31
    ^bb30:
      %130 = arith.constant 1 : i1
      func.return %130 : i1
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %131 = arith.constant 2 : i32
    %133 = arith.extsi %131 : i32 to i64
    %132 = arith.remsi %arg0, %133 : i64
    %134 = arith.constant 0 : i32
    %136 = arith.extsi %134 : i32 to i64
    %135 = arith.cmpi eq, %132, %136 : i64
    %137 = scf.if %135 -> (i1) {
      %138 = arith.constant true
      scf.yield %138 : i1
    } else {
      %139 = arith.constant 3 : i32
      %141 = arith.extsi %139 : i32 to i64
      %140 = arith.remsi %arg0, %141 : i64
      %142 = arith.constant 0 : i32
      %144 = arith.extsi %142 : i32 to i64
      %143 = arith.cmpi eq, %140, %144 : i64
      scf.yield %143 : i1
    }
    cf.cond_br %137, ^bb33, ^bb34
    ^bb33:
      %145 = arith.constant 0 : i1
      func.return %145 : i1
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %146 = arith.constant 5 : i32
    %147 = arith.extsi %146 : i32 to i64
    %148 = llvm.mlir.constant(1 : i64) : i64
    %149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
    llvm.store %147, %149 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %150 = llvm.load %149 : !llvm.ptr -> i64
    %151 = llvm.load %149 : !llvm.ptr -> i64
    %152 = arith.muli %150, %151 : i64
    %153 = arith.cmpi sle, %152, %arg0 : i64
    cf.cond_br %153, ^bb37, ^bb38
    ^bb37:
      %154 = llvm.load %149 : !llvm.ptr -> i64
      %155 = arith.remsi %arg0, %154 : i64
      %156 = arith.constant 0 : i32
      %158 = arith.extsi %156 : i32 to i64
      %157 = arith.cmpi eq, %155, %158 : i64
      %159 = scf.if %157 -> (i1) {
        %160 = arith.constant true
        scf.yield %160 : i1
      } else {
        %161 = llvm.load %149 : !llvm.ptr -> i64
        %162 = arith.constant 2 : i32
        %164 = arith.extsi %162 : i32 to i64
        %163 = arith.addi %161, %164 : i64
        %165 = arith.remsi %arg0, %163 : i64
        %166 = arith.constant 0 : i32
        %168 = arith.extsi %166 : i32 to i64
        %167 = arith.cmpi eq, %165, %168 : i64
        scf.yield %167 : i1
      }
      cf.cond_br %159, ^bb39, ^bb40
      ^bb39:
        %169 = arith.constant 0 : i1
        func.return %169 : i1
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %170 = llvm.load %149 : !llvm.ptr -> i64
      %171 = arith.constant 6 : i32
      %173 = arith.extsi %171 : i32 to i64
      %172 = arith.addi %170, %173 : i64
      llvm.store %172, %149 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %174 = arith.constant 1 : i1
    func.return %174 : i1
  }
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  func.func @main() -> i32 {
    %175 = arith.constant 10000 : i32
    %176 = arith.extsi %175 : i32 to i64
    %177 = arith.constant 10000 : i32
    %178 = arith.extsi %177 : i32 to i64
    %180 = arith.muli %176, %176 : i64
    %181 = arith.muli %178, %178 : i64
    %182 = arith.addi %180, %181 : i64
    %179 = func.call @isqrt(%182) : (i64) -> i64
    %184 = arith.constant 100 : i32
    %185 = arith.constant 8 : i32
    %186 = arith.extsi %184 : i32 to i64
    %187 = arith.extsi %185 : i32 to i64
    %183 = func.call @calloc(%186, %187) : (i64, i64) -> !llvm.ptr
    %188 = arith.constant 1 : i32
    %189 = arith.constant 0 : i32
    %190 = arith.extsi %188 : i32 to i64
    %191 = arith.extsi %189 : i32 to i64
    %192 = llvm.getelementptr %183[%191] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %190, %192 : i64, !llvm.ptr
    %193 = arith.constant 2 : i32
    %194 = arith.constant 1 : i32
    %195 = arith.extsi %193 : i32 to i64
    %196 = arith.extsi %194 : i32 to i64
    %197 = llvm.getelementptr %183[%196] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %195, %197 : i64, !llvm.ptr
    %198 = arith.constant 2 : i32
    %199 = arith.extsi %198 : i32 to i64
    %200 = llvm.mlir.constant(1 : i64) : i64
    %201 = llvm.alloca %200 x i64 : (i64) -> !llvm.ptr
    llvm.store %199, %201 : i64, !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %203 = llvm.load %201 : !llvm.ptr -> i64
    %204 = arith.constant 1 : i32
    %206 = arith.extsi %204 : i32 to i64
    %205 = arith.subi %203, %206 : i64
    %207 = llvm.getelementptr %183[%205] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %202 = llvm.load %207 : !llvm.ptr -> i64
    %209 = llvm.load %201 : !llvm.ptr -> i64
    %210 = arith.constant 2 : i32
    %212 = arith.extsi %210 : i32 to i64
    %211 = arith.subi %209, %212 : i64
    %213 = llvm.getelementptr %183[%211] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %208 = llvm.load %213 : !llvm.ptr -> i64
    %214 = arith.addi %202, %208 : i64
    %215 = arith.cmpi sle, %214, %179 : i64
    cf.cond_br %215, ^bb43, ^bb44
    ^bb43:
      %217 = llvm.load %201 : !llvm.ptr -> i64
      %218 = arith.constant 1 : i32
      %220 = arith.extsi %218 : i32 to i64
      %219 = arith.subi %217, %220 : i64
      %221 = llvm.getelementptr %183[%219] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %216 = llvm.load %221 : !llvm.ptr -> i64
      %223 = llvm.load %201 : !llvm.ptr -> i64
      %224 = arith.constant 2 : i32
      %226 = arith.extsi %224 : i32 to i64
      %225 = arith.subi %223, %226 : i64
      %227 = llvm.getelementptr %183[%225] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %222 = llvm.load %227 : !llvm.ptr -> i64
      %228 = arith.addi %216, %222 : i64
      %229 = llvm.load %201 : !llvm.ptr -> i64
      %230 = llvm.getelementptr %183[%229] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %228, %230 : i64, !llvm.ptr
      %231 = llvm.load %201 : !llvm.ptr -> i64
      %232 = arith.constant 1 : i32
      %234 = arith.extsi %232 : i32 to i64
      %233 = arith.addi %231, %234 : i64
      llvm.store %233, %201 : i64, !llvm.ptr
      cf.br ^bb42
    ^bb44:
    %236 = arith.constant 20000 : i32
    %237 = arith.constant 8 : i32
    %238 = arith.extsi %236 : i32 to i64
    %239 = arith.extsi %237 : i32 to i64
    %235 = func.call @calloc(%238, %239) : (i64, i64) -> !llvm.ptr
    %241 = arith.constant 20000 : i32
    %242 = arith.constant 8 : i32
    %243 = arith.extsi %241 : i32 to i64
    %244 = arith.extsi %242 : i32 to i64
    %240 = func.call @calloc(%243, %244) : (i64, i64) -> !llvm.ptr
    %245 = arith.constant 0 : i32
    %246 = arith.extsi %245 : i32 to i64
    %247 = llvm.mlir.constant(1 : i64) : i64
    %248 = llvm.alloca %247 x i64 : (i64) -> !llvm.ptr
    llvm.store %246, %248 : i64, !llvm.ptr
    %249 = arith.constant 0 : i32
    %250 = llvm.load %201 : !llvm.ptr -> i64
    %251 = arith.index_cast %249 : i32 to index
    %252 = arith.index_cast %250 : i32 to index
    %254 = arith.constant 1 : index
    %255 = arith.constant -1 : index
    %256 = arith.cmpi sle, %251, %252 : index
    %253 = arith.select %256, %254, %255 : index
    cf.br ^bb45(%251 : index)
    ^bb45(%257: index):
    %258 = arith.cmpi slt, %257, %252 : index
    %259 = arith.cmpi sgt, %257, %252 : index
    %260 = arith.select %256, %258, %259 : i1
    cf.cond_br %260, ^bb46(%257 : index), ^bb47(%257 : index)
    ^bb46(%261: index):
      %263 = arith.index_cast %261 : index to i64
      %264 = llvm.getelementptr %183[%263] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %262 = llvm.load %264 : !llvm.ptr -> i64
      %265 = arith.muli %262, %262 : i64
      %266 = arith.cmpi sgt, %262, %176 : i64
      %267 = scf.if %266 -> (i64) {
        scf.yield %176 : i64
      } else {
        scf.yield %262 : i64
      }
      %268 = arith.constant 0 : i32
      %269 = arith.constant 1 : i32
      %271 = arith.extsi %269 : i32 to i64
      %270 = arith.addi %267, %271 : i64
      %272 = arith.index_cast %268 : i32 to index
      %273 = arith.index_cast %270 : i32 to index
      %275 = arith.constant 1 : index
      %276 = arith.constant -1 : index
      %277 = arith.cmpi sle, %272, %273 : index
      %274 = arith.select %277, %275, %276 : index
      cf.br ^bb48(%272 : index)
      ^bb48(%278: index):
      %279 = arith.cmpi slt, %278, %273 : index
      %280 = arith.cmpi sgt, %278, %273 : index
      %281 = arith.select %277, %279, %280 : i1
      cf.cond_br %281, ^bb49(%278 : index), ^bb50(%278 : index)
      ^bb49(%282: index):
        %283 = arith.muli %282, %282 : index
        %285 = arith.trunci %265 : i64 to i32
        %286 = arith.index_cast %283 : index to i32
        %284 = arith.subi %285, %286 : i32
        %287 = arith.extsi %284 : i32 to i64
        %288 = arith.constant 0 : i32
        %290 = arith.extsi %288 : i32 to i64
        %289 = arith.cmpi slt, %287, %290 : i64
        cf.cond_br %289, ^bb51, ^bb52
        ^bb51:
          %291 = arith.addi %282, %274 : index
          cf.br ^bb48(%291 : index)
        ^bb52:
          cf.br ^bb53
        ^bb53:
        %292 = func.call @isqrt(%287) : (i64) -> i64
        %293 = arith.muli %292, %292 : i64
        %294 = arith.cmpi eq, %293, %287 : i64
        %295 = scf.if %294 -> (i1) {
          %296 = arith.cmpi sle, %292, %178 : i64
          scf.yield %296 : i1
        } else {
          %297 = arith.constant false
          scf.yield %297 : i1
        }
        cf.cond_br %295, ^bb54, ^bb55
        ^bb54:
          %298 = arith.constant 0 : i32
          %300 = arith.index_cast %282 : index to i32
          %299 = arith.cmpi ne, %300, %298 : i32
          %301 = scf.if %299 -> (i1) {
            %302 = arith.constant true
            scf.yield %302 : i1
          } else {
            %303 = arith.constant 0 : i32
            %305 = arith.extsi %303 : i32 to i64
            %304 = arith.cmpi ne, %292, %305 : i64
            scf.yield %304 : i1
          }
          cf.cond_br %301, ^bb57, ^bb58
          ^bb57:
            %306 = arith.constant 0 : i1
            %307 = llvm.mlir.constant(1 : i64) : i64
            %308 = llvm.alloca %307 x i1 : (i64) -> !llvm.ptr
            llvm.store %306, %308 : i1, !llvm.ptr
            %309 = arith.constant 0 : i32
            %310 = llvm.load %248 : !llvm.ptr -> i64
            %311 = arith.index_cast %309 : i32 to index
            %312 = arith.index_cast %310 : i32 to index
            %314 = arith.constant 1 : index
            %315 = arith.constant -1 : index
            %316 = arith.cmpi sle, %311, %312 : index
            %313 = arith.select %316, %314, %315 : index
            cf.br ^bb60(%311 : index)
            ^bb60(%317: index):
            %318 = arith.cmpi slt, %317, %312 : index
            %319 = arith.cmpi sgt, %317, %312 : index
            %320 = arith.select %316, %318, %319 : i1
            cf.cond_br %320, ^bb61(%317 : index), ^bb62(%317 : index)
            ^bb61(%321: index):
              %323 = arith.index_cast %321 : index to i64
              %324 = llvm.getelementptr %235[%323] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %322 = llvm.load %324 : !llvm.ptr -> i64
              %326 = arith.trunci %322 : i64 to i32
              %327 = arith.index_cast %282 : index to i32
              %325 = arith.cmpi eq, %326, %327 : i32
              %328 = scf.if %325 -> (i1) {
                %330 = arith.index_cast %321 : index to i64
                %331 = llvm.getelementptr %240[%330] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %329 = llvm.load %331 : !llvm.ptr -> i64
                %332 = arith.cmpi eq, %329, %292 : i64
                scf.yield %332 : i1
              } else {
                %333 = arith.constant false
                scf.yield %333 : i1
              }
              cf.cond_br %328, ^bb63, ^bb64
              ^bb63:
                %334 = arith.constant 1 : i1
                llvm.store %334, %308 : i1, !llvm.ptr
                cf.br ^bb62(%321 : index)
              ^bb64:
                cf.br ^bb65
              ^bb65:
              %335 = arith.addi %321, %313 : index
              cf.br ^bb60(%335 : index)
            ^bb62(%336: index):
            %337 = llvm.load %308 : !llvm.ptr -> i1
            %339 = arith.constant 1 : i1
            %338 = arith.xori %337, %339 : i1
            cf.cond_br %338, ^bb66, ^bb67
            ^bb66:
              %341 = llvm.load %248 : !llvm.ptr -> i64
              %342 = arith.index_cast %282 : index to i64
              %343 = llvm.getelementptr %235[%341] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %342, %343 : i64, !llvm.ptr
              %344 = llvm.load %248 : !llvm.ptr -> i64
              %345 = llvm.getelementptr %240[%344] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %292, %345 : i64, !llvm.ptr
              %346 = llvm.load %248 : !llvm.ptr -> i64
              %347 = arith.constant 1 : i32
              %349 = arith.extsi %347 : i32 to i64
              %348 = arith.addi %346, %349 : i64
              llvm.store %348, %248 : i64, !llvm.ptr
              cf.br ^bb68
            ^bb67:
              cf.br ^bb68
            ^bb68:
            cf.br ^bb59
          ^bb58:
            cf.br ^bb59
          ^bb59:
          cf.br ^bb56
        ^bb55:
          cf.br ^bb56
        ^bb56:
        %350 = arith.addi %282, %274 : index
        cf.br ^bb48(%350 : index)
      ^bb50(%351: index):
      %352 = arith.addi %261, %253 : index
      cf.br ^bb45(%352 : index)
    ^bb47(%353: index):
    %355 = llvm.load %248 : !llvm.ptr -> i64
    %356 = arith.constant 8 : i32
    %357 = arith.extsi %356 : i32 to i64
    %354 = func.call @calloc(%355, %357) : (i64, i64) -> !llvm.ptr
    %359 = llvm.load %248 : !llvm.ptr -> i64
    %360 = arith.constant 8 : i32
    %361 = arith.extsi %360 : i32 to i64
    %358 = func.call @calloc(%359, %361) : (i64, i64) -> !llvm.ptr
    %363 = llvm.load %248 : !llvm.ptr -> i64
    %364 = arith.constant 8 : i32
    %365 = arith.extsi %364 : i32 to i64
    %362 = func.call @calloc(%363, %365) : (i64, i64) -> !llvm.ptr
    %366 = arith.constant 0 : i32
    %367 = arith.extsi %366 : i32 to i64
    %368 = llvm.mlir.constant(1 : i64) : i64
    %369 = llvm.alloca %368 x i64 : (i64) -> !llvm.ptr
    llvm.store %367, %369 : i64, !llvm.ptr
    %370 = arith.constant 0 : i32
    %371 = arith.extsi %370 : i32 to i64
    %372 = llvm.mlir.constant(1 : i64) : i64
    %373 = llvm.alloca %372 x i64 : (i64) -> !llvm.ptr
    llvm.store %371, %373 : i64, !llvm.ptr
    %374 = arith.constant 0 : i32
    %375 = arith.extsi %374 : i32 to i64
    %376 = llvm.mlir.constant(1 : i64) : i64
    %377 = llvm.alloca %376 x i64 : (i64) -> !llvm.ptr
    llvm.store %375, %377 : i64, !llvm.ptr
    %378 = arith.constant 0 : i32
    %379 = llvm.load %248 : !llvm.ptr -> i64
    %380 = arith.index_cast %378 : i32 to index
    %381 = arith.index_cast %379 : i32 to index
    %383 = arith.constant 1 : index
    %384 = arith.constant -1 : index
    %385 = arith.cmpi sle, %380, %381 : index
    %382 = arith.select %385, %383, %384 : index
    cf.br ^bb69(%380 : index)
    ^bb69(%386: index):
    %387 = arith.cmpi slt, %386, %381 : index
    %388 = arith.cmpi sgt, %386, %381 : index
    %389 = arith.select %385, %387, %388 : i1
    cf.cond_br %389, ^bb70(%386 : index), ^bb71(%386 : index)
    ^bb70(%390: index):
      %392 = arith.index_cast %390 : index to i64
      %393 = llvm.getelementptr %235[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %391 = llvm.load %393 : !llvm.ptr -> i64
      %394 = arith.constant 0 : i32
      %396 = arith.extsi %394 : i32 to i64
      %395 = arith.cmpi eq, %391, %396 : i64
      cf.cond_br %395, ^bb72, ^bb73
      ^bb72:
        %398 = arith.index_cast %390 : index to i64
        %399 = llvm.getelementptr %240[%398] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %397 = llvm.load %399 : !llvm.ptr -> i64
        %400 = llvm.load %369 : !llvm.ptr -> i64
        %401 = llvm.getelementptr %354[%400] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %397, %401 : i64, !llvm.ptr
        %402 = llvm.load %369 : !llvm.ptr -> i64
        %403 = arith.constant 1 : i32
        %405 = arith.extsi %403 : i32 to i64
        %404 = arith.addi %402, %405 : i64
        llvm.store %404, %369 : i64, !llvm.ptr
        cf.br ^bb74
      ^bb73:
        %407 = arith.index_cast %390 : index to i64
        %408 = llvm.getelementptr %235[%407] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %406 = llvm.load %408 : !llvm.ptr -> i64
        %409 = llvm.load %373 : !llvm.ptr -> i64
        %410 = llvm.getelementptr %358[%409] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %406, %410 : i64, !llvm.ptr
        %412 = arith.index_cast %390 : index to i64
        %413 = llvm.getelementptr %240[%412] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %411 = llvm.load %413 : !llvm.ptr -> i64
        %414 = llvm.load %373 : !llvm.ptr -> i64
        %415 = llvm.getelementptr %362[%414] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %411, %415 : i64, !llvm.ptr
        %416 = llvm.load %373 : !llvm.ptr -> i64
        %417 = arith.constant 1 : i32
        %419 = arith.extsi %417 : i32 to i64
        %418 = arith.addi %416, %419 : i64
        llvm.store %418, %373 : i64, !llvm.ptr
        %421 = arith.index_cast %390 : index to i64
        %422 = llvm.getelementptr %235[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %420 = llvm.load %422 : !llvm.ptr -> i64
        %423 = llvm.load %377 : !llvm.ptr -> i64
        %424 = arith.cmpi sgt, %420, %423 : i64
        cf.cond_br %424, ^bb75, ^bb76
        ^bb75:
          %426 = arith.index_cast %390 : index to i64
          %427 = llvm.getelementptr %235[%426] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %425 = llvm.load %427 : !llvm.ptr -> i64
          llvm.store %425, %377 : i64, !llvm.ptr
          cf.br ^bb77
        ^bb76:
          cf.br ^bb77
        ^bb77:
        cf.br ^bb74
      ^bb74:
      %428 = arith.addi %390, %382 : index
      cf.br ^bb69(%428 : index)
    ^bb71(%429: index):
    %430 = arith.constant 1 : i32
    %431 = llvm.load %369 : !llvm.ptr -> i64
    %432 = arith.index_cast %430 : i32 to index
    %433 = arith.index_cast %431 : i32 to index
    %435 = arith.constant 1 : index
    %436 = arith.constant -1 : index
    %437 = arith.cmpi sle, %432, %433 : index
    %434 = arith.select %437, %435, %436 : index
    cf.br ^bb78(%432 : index)
    ^bb78(%438: index):
    %439 = arith.cmpi slt, %438, %433 : index
    %440 = arith.cmpi sgt, %438, %433 : index
    %441 = arith.select %437, %439, %440 : i1
    cf.cond_br %441, ^bb79(%438 : index), ^bb80(%438 : index)
    ^bb79(%442: index):
      %444 = arith.index_cast %442 : index to i64
      %445 = llvm.getelementptr %354[%444] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %443 = llvm.load %445 : !llvm.ptr -> i64
      %446 = arith.index_cast %442 : index to i64
      %447 = llvm.mlir.constant(1 : i64) : i64
      %448 = llvm.alloca %447 x i64 : (i64) -> !llvm.ptr
      llvm.store %446, %448 : i64, !llvm.ptr
      cf.br ^bb81
      ^bb81:
      %449 = llvm.load %448 : !llvm.ptr -> i64
      %450 = arith.constant 0 : i32
      %452 = arith.extsi %450 : i32 to i64
      %451 = arith.cmpi sgt, %449, %452 : i64
      %453 = scf.if %451 -> (i1) {
        %455 = llvm.load %448 : !llvm.ptr -> i64
        %456 = arith.constant 1 : i32
        %458 = arith.extsi %456 : i32 to i64
        %457 = arith.subi %455, %458 : i64
        %459 = llvm.getelementptr %354[%457] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %454 = llvm.load %459 : !llvm.ptr -> i64
        %460 = arith.cmpi sgt, %454, %443 : i64
        scf.yield %460 : i1
      } else {
        %461 = arith.constant false
        scf.yield %461 : i1
      }
      cf.cond_br %453, ^bb82, ^bb83
      ^bb82:
        %463 = llvm.load %448 : !llvm.ptr -> i64
        %464 = arith.constant 1 : i32
        %466 = arith.extsi %464 : i32 to i64
        %465 = arith.subi %463, %466 : i64
        %467 = llvm.getelementptr %354[%465] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %462 = llvm.load %467 : !llvm.ptr -> i64
        %468 = llvm.load %448 : !llvm.ptr -> i64
        %469 = llvm.getelementptr %354[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %462, %469 : i64, !llvm.ptr
        %470 = llvm.load %448 : !llvm.ptr -> i64
        %471 = arith.constant 1 : i32
        %473 = arith.extsi %471 : i32 to i64
        %472 = arith.subi %470, %473 : i64
        llvm.store %472, %448 : i64, !llvm.ptr
        cf.br ^bb81
      ^bb83:
      %474 = llvm.load %448 : !llvm.ptr -> i64
      %475 = llvm.getelementptr %354[%474] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %443, %475 : i64, !llvm.ptr
      %476 = arith.addi %442, %434 : index
      cf.br ^bb78(%476 : index)
    ^bb80(%477: index):
    %478 = arith.constant 1 : i32
    %479 = llvm.load %373 : !llvm.ptr -> i64
    %480 = arith.index_cast %478 : i32 to index
    %481 = arith.index_cast %479 : i32 to index
    %483 = arith.constant 1 : index
    %484 = arith.constant -1 : index
    %485 = arith.cmpi sle, %480, %481 : index
    %482 = arith.select %485, %483, %484 : index
    cf.br ^bb84(%480 : index)
    ^bb84(%486: index):
    %487 = arith.cmpi slt, %486, %481 : index
    %488 = arith.cmpi sgt, %486, %481 : index
    %489 = arith.select %485, %487, %488 : i1
    cf.cond_br %489, ^bb85(%486 : index), ^bb86(%486 : index)
    ^bb85(%490: index):
      %492 = arith.index_cast %490 : index to i64
      %493 = llvm.getelementptr %358[%492] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %491 = llvm.load %493 : !llvm.ptr -> i64
      %495 = arith.index_cast %490 : index to i64
      %496 = llvm.getelementptr %362[%495] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %494 = llvm.load %496 : !llvm.ptr -> i64
      %497 = arith.index_cast %490 : index to i64
      %498 = llvm.mlir.constant(1 : i64) : i64
      %499 = llvm.alloca %498 x i64 : (i64) -> !llvm.ptr
      llvm.store %497, %499 : i64, !llvm.ptr
      cf.br ^bb87
      ^bb87:
      %500 = llvm.load %499 : !llvm.ptr -> i64
      %501 = arith.constant 0 : i32
      %503 = arith.extsi %501 : i32 to i64
      %502 = arith.cmpi sgt, %500, %503 : i64
      %504 = scf.if %502 -> (i1) {
        %506 = llvm.load %499 : !llvm.ptr -> i64
        %507 = arith.constant 1 : i32
        %509 = arith.extsi %507 : i32 to i64
        %508 = arith.subi %506, %509 : i64
        %510 = llvm.getelementptr %358[%508] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %505 = llvm.load %510 : !llvm.ptr -> i64
        %511 = arith.cmpi sgt, %505, %491 : i64
        scf.yield %511 : i1
      } else {
        %512 = arith.constant false
        scf.yield %512 : i1
      }
      cf.cond_br %504, ^bb88, ^bb89
      ^bb88:
        %514 = llvm.load %499 : !llvm.ptr -> i64
        %515 = arith.constant 1 : i32
        %517 = arith.extsi %515 : i32 to i64
        %516 = arith.subi %514, %517 : i64
        %518 = llvm.getelementptr %358[%516] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %513 = llvm.load %518 : !llvm.ptr -> i64
        %519 = llvm.load %499 : !llvm.ptr -> i64
        %520 = llvm.getelementptr %358[%519] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %513, %520 : i64, !llvm.ptr
        %522 = llvm.load %499 : !llvm.ptr -> i64
        %523 = arith.constant 1 : i32
        %525 = arith.extsi %523 : i32 to i64
        %524 = arith.subi %522, %525 : i64
        %526 = llvm.getelementptr %362[%524] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %521 = llvm.load %526 : !llvm.ptr -> i64
        %527 = llvm.load %499 : !llvm.ptr -> i64
        %528 = llvm.getelementptr %362[%527] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %521, %528 : i64, !llvm.ptr
        %529 = llvm.load %499 : !llvm.ptr -> i64
        %530 = arith.constant 1 : i32
        %532 = arith.extsi %530 : i32 to i64
        %531 = arith.subi %529, %532 : i64
        llvm.store %531, %499 : i64, !llvm.ptr
        cf.br ^bb87
      ^bb89:
      %533 = llvm.load %499 : !llvm.ptr -> i64
      %534 = llvm.getelementptr %358[%533] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %491, %534 : i64, !llvm.ptr
      %535 = llvm.load %499 : !llvm.ptr -> i64
      %536 = llvm.getelementptr %362[%535] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %494, %536 : i64, !llvm.ptr
      %537 = arith.addi %490, %482 : index
      cf.br ^bb84(%537 : index)
    ^bb86(%538: index):
    %539 = llvm.load %377 : !llvm.ptr -> i64
    %540 = arith.constant 1 : i32
    %542 = arith.extsi %540 : i32 to i64
    %541 = arith.addi %539, %542 : i64
    %543 = arith.constant 1 : i32
    %545 = arith.extsi %543 : i32 to i64
    %544 = arith.addi %178, %545 : i64
    %547 = arith.muli %541, %544 : i64
    %548 = arith.constant 8 : i32
    %549 = arith.extsi %548 : i32 to i64
    %546 = func.call @calloc(%547, %549) : (i64, i64) -> !llvm.ptr
    %551 = arith.constant 1 : i32
    %553 = arith.extsi %551 : i32 to i64
    %552 = arith.addi %178, %553 : i64
    %554 = arith.constant 8 : i32
    %555 = arith.extsi %554 : i32 to i64
    %550 = func.call @calloc(%552, %555) : (i64, i64) -> !llvm.ptr
    %556 = llvm.mlir.zero : !llvm.ptr
    %557 = llvm.icmp "eq" %546, %556 : !llvm.ptr
    %558 = scf.if %557 -> (i1) {
      %559 = arith.constant true
      scf.yield %559 : i1
    } else {
      %560 = llvm.mlir.zero : !llvm.ptr
      %561 = llvm.icmp "eq" %550, %560 : !llvm.ptr
      scf.yield %561 : i1
    }
    cf.cond_br %558, ^bb90, ^bb91
    ^bb90:
      %562 = arith.constant 1 : i32
      func.return %562 : i32
    ^bb91:
      cf.br ^bb92
    ^bb92:
    %563 = arith.constant 0 : i32
    %564 = arith.constant 1 : i32
    %566 = arith.extsi %564 : i32 to i64
    %565 = arith.addi %176, %566 : i64
    %567 = arith.index_cast %563 : i32 to index
    %568 = arith.index_cast %565 : i32 to index
    %570 = arith.constant 1 : index
    %571 = arith.constant -1 : index
    %572 = arith.cmpi sle, %567, %568 : index
    %569 = arith.select %572, %570, %571 : index
    cf.br ^bb93(%567 : index)
    ^bb93(%573: index):
    %574 = arith.cmpi slt, %573, %568 : index
    %575 = arith.cmpi sgt, %573, %568 : index
    %576 = arith.select %572, %574, %575 : i1
    cf.cond_br %576, ^bb94(%573 : index), ^bb95(%573 : index)
    ^bb94(%577: index):
      %579 = arith.index_cast %577 : index to i32
      %580 = arith.trunci %541 : i64 to i32
      %578 = arith.remsi %579, %580 : i32
      %582 = arith.extsi %578 : i32 to i64
      %581 = arith.muli %582, %544 : i64
      %583 = arith.constant 0 : i32
      %584 = arith.constant 1 : i32
      %586 = arith.extsi %584 : i32 to i64
      %585 = arith.addi %178, %586 : i64
      %587 = arith.index_cast %583 : i32 to index
      %588 = arith.index_cast %585 : i32 to index
      %590 = arith.constant 1 : index
      %591 = arith.constant -1 : index
      %592 = arith.cmpi sle, %587, %588 : index
      %589 = arith.select %592, %590, %591 : index
      cf.br ^bb96(%587 : index)
      ^bb96(%593: index):
      %594 = arith.cmpi slt, %593, %588 : index
      %595 = arith.cmpi sgt, %593, %588 : index
      %596 = arith.select %592, %594, %595 : i1
      cf.cond_br %596, ^bb97(%593 : index), ^bb98(%593 : index)
      ^bb97(%597: index):
        %598 = arith.constant 0 : i32
        %599 = arith.extsi %598 : i32 to i64
        %600 = arith.index_cast %597 : index to i64
        %601 = llvm.getelementptr %550[%600] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %599, %601 : i64, !llvm.ptr
        %602 = arith.addi %597, %589 : index
        cf.br ^bb96(%602 : index)
      ^bb98(%603: index):
      %604 = arith.constant 0 : i32
      %605 = llvm.load %373 : !llvm.ptr -> i64
      %606 = arith.index_cast %604 : i32 to index
      %607 = arith.index_cast %605 : i32 to index
      %609 = arith.constant 1 : index
      %610 = arith.constant -1 : index
      %611 = arith.cmpi sle, %606, %607 : index
      %608 = arith.select %611, %609, %610 : index
      cf.br ^bb99(%606 : index)
      ^bb99(%612: index):
      %613 = arith.cmpi slt, %612, %607 : index
      %614 = arith.cmpi sgt, %612, %607 : index
      %615 = arith.select %611, %613, %614 : i1
      cf.cond_br %615, ^bb100(%612 : index), ^bb101(%612 : index)
      ^bb100(%616: index):
        %618 = arith.index_cast %616 : index to i64
        %619 = llvm.getelementptr %358[%618] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %617 = llvm.load %619 : !llvm.ptr -> i64
        %621 = arith.trunci %617 : i64 to i32
        %622 = arith.index_cast %577 : index to i32
        %620 = arith.cmpi sgt, %621, %622 : i32
        cf.cond_br %620, ^bb102, ^bb103
        ^bb102:
          cf.br ^bb101(%616 : index)
        ^bb103:
          cf.br ^bb104
        ^bb104:
        %624 = arith.index_cast %616 : index to i64
        %625 = llvm.getelementptr %362[%624] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %623 = llvm.load %625 : !llvm.ptr -> i64
        %627 = arith.index_cast %577 : index to i32
        %628 = arith.trunci %617 : i64 to i32
        %626 = arith.subi %627, %628 : i32
        %630 = arith.extsi %626 : i32 to i64
        %629 = arith.remsi %630, %541 : i64
        %631 = arith.muli %629, %544 : i64
        %632 = arith.constant 0 : i32
        %634 = arith.extsi %632 : i32 to i64
        %633 = arith.cmpi eq, %623, %634 : i64
        cf.cond_br %633, ^bb105, ^bb106
        ^bb105:
          %635 = arith.constant 0 : i32
          %636 = arith.constant 1 : i32
          %638 = arith.extsi %636 : i32 to i64
          %637 = arith.addi %178, %638 : i64
          %639 = arith.index_cast %635 : i32 to index
          %640 = arith.index_cast %637 : i32 to index
          %642 = arith.constant 1 : index
          %643 = arith.constant -1 : index
          %644 = arith.cmpi sle, %639, %640 : index
          %641 = arith.select %644, %642, %643 : index
          cf.br ^bb108(%639 : index)
          ^bb108(%645: index):
          %646 = arith.cmpi slt, %645, %640 : index
          %647 = arith.cmpi sgt, %645, %640 : index
          %648 = arith.select %644, %646, %647 : i1
          cf.cond_br %648, ^bb109(%645 : index), ^bb110(%645 : index)
          ^bb109(%649: index):
            %651 = arith.index_cast %649 : index to i64
            %652 = llvm.getelementptr %550[%651] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %650 = llvm.load %652 : !llvm.ptr -> i64
            %655 = arith.trunci %631 : i64 to i32
            %656 = arith.index_cast %649 : index to i32
            %654 = arith.addi %655, %656 : i32
            %657 = arith.extsi %654 : i32 to i64
            %658 = llvm.getelementptr %546[%657] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %653 = llvm.load %658 : !llvm.ptr -> i64
            %659 = arith.addi %650, %653 : i64
            %660 = llvm.mlir.addressof @MOD : !llvm.ptr
            %661 = llvm.load %660 : !llvm.ptr -> i64
            %662 = arith.remsi %659, %661 : i64
            %663 = arith.index_cast %649 : index to i64
            %664 = llvm.getelementptr %550[%663] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %662, %664 : i64, !llvm.ptr
            %665 = arith.addi %649, %641 : index
            cf.br ^bb108(%665 : index)
          ^bb110(%666: index):
          cf.br ^bb107
        ^bb106:
          %667 = arith.subi %178, %623 : i64
          %668 = arith.constant 0 : i32
          %669 = arith.constant 1 : i32
          %671 = arith.extsi %669 : i32 to i64
          %670 = arith.addi %667, %671 : i64
          %672 = arith.index_cast %668 : i32 to index
          %673 = arith.index_cast %670 : i32 to index
          %675 = arith.constant 1 : index
          %676 = arith.constant -1 : index
          %677 = arith.cmpi sle, %672, %673 : index
          %674 = arith.select %677, %675, %676 : index
          cf.br ^bb111(%672 : index)
          ^bb111(%678: index):
          %679 = arith.cmpi slt, %678, %673 : index
          %680 = arith.cmpi sgt, %678, %673 : index
          %681 = arith.select %677, %679, %680 : i1
          cf.cond_br %681, ^bb112(%678 : index), ^bb113(%678 : index)
          ^bb112(%682: index):
            %685 = arith.index_cast %682 : index to i32
            %686 = arith.trunci %623 : i64 to i32
            %684 = arith.addi %685, %686 : i32
            %687 = arith.extsi %684 : i32 to i64
            %688 = llvm.getelementptr %550[%687] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %683 = llvm.load %688 : !llvm.ptr -> i64
            %691 = arith.trunci %631 : i64 to i32
            %692 = arith.index_cast %682 : index to i32
            %690 = arith.addi %691, %692 : i32
            %693 = arith.extsi %690 : i32 to i64
            %694 = llvm.getelementptr %546[%693] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %689 = llvm.load %694 : !llvm.ptr -> i64
            %695 = arith.addi %683, %689 : i64
            %696 = llvm.mlir.addressof @MOD : !llvm.ptr
            %697 = llvm.load %696 : !llvm.ptr -> i64
            %698 = arith.remsi %695, %697 : i64
            %700 = arith.index_cast %682 : index to i32
            %701 = arith.trunci %623 : i64 to i32
            %699 = arith.addi %700, %701 : i32
            %702 = arith.extsi %699 : i32 to i64
            %703 = llvm.getelementptr %550[%702] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %698, %703 : i64, !llvm.ptr
            %704 = arith.addi %682, %674 : index
            cf.br ^bb111(%704 : index)
          ^bb113(%705: index):
          cf.br ^bb107
        ^bb107:
        %706 = arith.addi %616, %608 : index
        cf.br ^bb99(%706 : index)
      ^bb101(%707: index):
      %708 = arith.constant 0 : i32
      %710 = arith.index_cast %577 : index to i32
      %709 = arith.cmpi eq, %710, %708 : i32
      cf.cond_br %709, ^bb114, ^bb115
      ^bb114:
        %712 = arith.constant 0 : i32
        %713 = arith.extsi %712 : i32 to i64
        %714 = llvm.getelementptr %550[%713] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %711 = llvm.load %714 : !llvm.ptr -> i64
        %715 = arith.constant 1 : i32
        %717 = arith.extsi %715 : i32 to i64
        %716 = arith.addi %711, %717 : i64
        %718 = arith.constant 0 : i32
        %719 = arith.extsi %718 : i32 to i64
        %720 = llvm.getelementptr %550[%719] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %716, %720 : i64, !llvm.ptr
        cf.br ^bb116
      ^bb115:
        cf.br ^bb116
      ^bb116:
      %721 = arith.constant 0 : i32
      %722 = arith.constant 1 : i32
      %724 = arith.extsi %722 : i32 to i64
      %723 = arith.addi %178, %724 : i64
      %725 = arith.index_cast %721 : i32 to index
      %726 = arith.index_cast %723 : i32 to index
      %728 = arith.constant 1 : index
      %729 = arith.constant -1 : index
      %730 = arith.cmpi sle, %725, %726 : index
      %727 = arith.select %730, %728, %729 : index
      cf.br ^bb117(%725 : index)
      ^bb117(%731: index):
      %732 = arith.cmpi slt, %731, %726 : index
      %733 = arith.cmpi sgt, %731, %726 : index
      %734 = arith.select %730, %732, %733 : i1
      cf.cond_br %734, ^bb118(%731 : index), ^bb119(%731 : index)
      ^bb118(%735: index):
        %737 = arith.index_cast %735 : index to i64
        %738 = llvm.getelementptr %550[%737] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %736 = llvm.load %738 : !llvm.ptr -> i64
        %739 = llvm.mlir.constant(1 : i64) : i64
        %740 = llvm.alloca %739 x i64 : (i64) -> !llvm.ptr
        llvm.store %736, %740 : i64, !llvm.ptr
        %741 = arith.constant 0 : i32
        %742 = llvm.load %369 : !llvm.ptr -> i64
        %743 = arith.index_cast %741 : i32 to index
        %744 = arith.index_cast %742 : i32 to index
        %746 = arith.constant 1 : index
        %747 = arith.constant -1 : index
        %748 = arith.cmpi sle, %743, %744 : index
        %745 = arith.select %748, %746, %747 : index
        cf.br ^bb120(%743 : index)
        ^bb120(%749: index):
        %750 = arith.cmpi slt, %749, %744 : index
        %751 = arith.cmpi sgt, %749, %744 : index
        %752 = arith.select %748, %750, %751 : i1
        cf.cond_br %752, ^bb121(%749 : index), ^bb122(%749 : index)
        ^bb121(%753: index):
          %755 = arith.index_cast %753 : index to i64
          %756 = llvm.getelementptr %354[%755] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %754 = llvm.load %756 : !llvm.ptr -> i64
          %758 = arith.trunci %754 : i64 to i32
          %759 = arith.index_cast %735 : index to i32
          %757 = arith.cmpi sgt, %758, %759 : i32
          cf.cond_br %757, ^bb123, ^bb124
          ^bb123:
            cf.br ^bb122(%753 : index)
          ^bb124:
            cf.br ^bb125
          ^bb125:
          %760 = llvm.load %740 : !llvm.ptr -> i64
          %763 = arith.trunci %581 : i64 to i32
          %764 = arith.index_cast %735 : index to i32
          %762 = arith.addi %763, %764 : i32
          %766 = arith.extsi %762 : i32 to i64
          %765 = arith.subi %766, %754 : i64
          %767 = llvm.getelementptr %546[%765] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %761 = llvm.load %767 : !llvm.ptr -> i64
          %768 = arith.addi %760, %761 : i64
          %769 = llvm.mlir.addressof @MOD : !llvm.ptr
          %770 = llvm.load %769 : !llvm.ptr -> i64
          %771 = arith.remsi %768, %770 : i64
          llvm.store %771, %740 : i64, !llvm.ptr
          %772 = arith.addi %753, %745 : index
          cf.br ^bb120(%772 : index)
        ^bb122(%773: index):
        %774 = llvm.load %740 : !llvm.ptr -> i64
        %776 = arith.trunci %581 : i64 to i32
        %777 = arith.index_cast %735 : index to i32
        %775 = arith.addi %776, %777 : i32
        %778 = arith.extsi %775 : i32 to i64
        %779 = llvm.getelementptr %546[%778] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %774, %779 : i64, !llvm.ptr
        %780 = arith.addi %735, %727 : index
        cf.br ^bb117(%780 : index)
      ^bb119(%781: index):
      %782 = arith.addi %577, %569 : index
      cf.br ^bb93(%782 : index)
    ^bb95(%783: index):
    %784 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %786 = arith.remsi %176, %541 : i64
    %787 = arith.muli %786, %544 : i64
    %788 = arith.addi %787, %178 : i64
    %789 = llvm.getelementptr %546[%788] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %785 = llvm.load %789 : !llvm.ptr -> i64
    %790 = llvm.call @printf(%784, %785) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%546) : (!llvm.ptr) -> ()
    func.call @free(%550) : (!llvm.ptr) -> ()
    func.call @free(%354) : (!llvm.ptr) -> ()
    func.call @free(%358) : (!llvm.ptr) -> ()
    func.call @free(%362) : (!llvm.ptr) -> ()
    func.call @free(%235) : (!llvm.ptr) -> ()
    func.call @free(%240) : (!llvm.ptr) -> ()
    func.call @free(%183) : (!llvm.ptr) -> ()
    %799 = arith.constant 0 : i32
    func.return %799 : i32
  }
}