Problem 438

Sum of sum|ai| over integer coefficient tuples for floor-root condition, n=7.

Answer2046409616809
Output2046409616809
StatusPASS
Native helperno
Runtime620 ms
Peak memory1184 KB
Time complexityO(n log n) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n log n)O(n log log n)
Space complexityO(n)O(n)
ApproachFlow solutionSieve or enumeration
VerdictSuboptimal

Flow source

# Project Euler 438
# Sum of sum|ai| over integer coefficient tuples for floor-root condition, n=7.

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

function comb(n: i64, k0: i64) -> i64 {
    let mut k: i64 = k0
    if k < 0 || k > n { return 0 }
    if k > n - k { k = n - k }
    let mut r: i64 = 1
    let mut i: i64 = 1
    while i <= k {
        r = r * (n - k + i) / i
        i = i + 1
    }
    return r
}

function ipow(base: i64, e: i64) -> i64 {
    let mut r: i64 = 1
    let mut i: i64 = 0
    while i < e {
        r = r * base
        i = i + 1
    }
    return r
}

function sum_abs_range(lo: i64, hi: i64) -> i64 {
    if lo > hi { return 0 }
    if hi < 0 {
        let cnt: i64 = hi - lo + 1
        return 0 - (lo + hi) * cnt / 2
    }
    if lo > 0 {
        let cnt: i64 = hi - lo + 1
        return (lo + hi) * cnt / 2
    }
    return (0 - lo) * ((0 - lo) + 1) / 2 + hi * (hi + 1) / 2
}

function floor_div(a: i64, b: i64) -> i64 {
    let mut q: i64 = a / b
    let r: i64 = a % b
    if r != 0 && ((a < 0) != (b < 0)) { q = q - 1 }
    return q
}

function first_sign(Bf: ptr<i64>, base: i64, n: i64) -> i64 {
    for dd in 1..(n + 1) {
        let v: i64 = Bf[base + dd]
        if v != 0 {
            if v > 0 { return 1 }
            return 0 - 1
        }
    }
    return 0
}

function apply_val(i: i64, val: i64, n: i64, P: ptr<i64>, Bf: ptr<i64>, MMAX: i64, IMAX: i64, DMAX: i64) -> void {
    let mut kp: i64 = i + 1
    while kp <= n {
        let mut m: i64 = 1
        while m <= kp + 1 {
            let mut d: i64 = 0
            while d <= n {
                let pidx: i64 = ((kp * MMAX + m) * IMAX + i) * DMAX + d
                let bix: i64 = (kp * MMAX + m) * DMAX + d
                Bf[bix] = Bf[bix] + val * P[pidx]
                d = d + 1
            }
            m = m + 1
        }
        kp = kp + 1
    }
}

function dfs438(k: i64, prefix: i64, n: i64, P: ptr<i64>, A0: ptr<i64>, Bf: ptr<i64>, MMAX: i64, IMAX: i64, DMAX: i64) -> i64 {
    let mut lb: i64 = 0 - 1000000000000000
    let mut ub: i64 = 1000000000000000
    let mut m: i64 = 1
    while m <= k + 1 {
        let A0v: i64 = A0[k * MMAX + m]
        let bbase: i64 = (k * MMAX + m) * DMAX
        let b0: i64 = Bf[bbase]
        if A0v > 0 {
            let num: i64 = 0 - b0
            let den: i64 = A0v
            let mut x0: i64 = floor_div(num, den)
            if num % den != 0 {
                x0 = x0 + 1
            } else {
                if first_sign(Bf, bbase, n) <= 0 { x0 = x0 + 1 }
            }
            if x0 > lb { lb = x0 }
        } else {
            let den: i64 = 0 - A0v
            let num: i64 = b0
            let mut x0: i64 = floor_div(num, den)
            if num % den == 0 {
                if first_sign(Bf, bbase, n) <= 0 { x0 = x0 - 1 }
            }
            if x0 < ub { ub = x0 }
        }
        m = m + 1
    }
    if lb > ub { return 0 }
    if k == n {
        return (ub - lb + 1) * prefix + sum_abs_range(lb, ub)
    }
    let mut total: i64 = 0
    let mut ak: i64 = lb
    while ak <= ub {
        apply_val(k, ak, n, P, Bf, MMAX, IMAX, DMAX)
        let mut ap: i64 = ak
        if ap < 0 { ap = 0 - ap }
        total = total + dfs438(k + 1, prefix + ap, n, P, A0, Bf, MMAX, IMAX, DMAX)
        apply_val(k, 0 - ak, n, P, Bf, MMAX, IMAX, DMAX)
        ak = ak + 1
    }
    return total
}

function main() -> i32 {
    let n: i64 = 7
    let MMAX: i64 = n + 2
    let IMAX: i64 = n + 1
    let DMAX: i64 = n + 1
    let P: ptr<i64> = calloc((n + 1) * MMAX * IMAX * DMAX, 8)
    let A0: ptr<i64> = calloc((n + 1) * MMAX, 8)
    let Bf: ptr<i64> = calloc((n + 1) * MMAX * DMAX, 8)
    if P == null || A0 == null || Bf == null { return 1 }

    let mut k: i64 = 1
    while k <= n {
        let r: i64 = n - k
        let mut fact: i64 = 1
        let mut t: i64 = 2
        while t <= r {
            fact = fact * t
            t = t + 1
        }
        let mut m: i64 = 1
        while m <= k + 1 {
            let mut s: i64 = 1
            if ((k + 1 - m) & 1) != 0 { s = 0 - 1 }
            A0[k * MMAX + m] = s * fact
            let mut i: i64 = 0
            while i <= k {
                let p: i64 = n - i
                let mut d: i64 = 0
                while d <= n {
                    let mut acc: i64 = 0
                    let mut j: i64 = 0
                    while j <= r {
                        let mut cjj: i64 = comb(r, j)
                        if ((r - j) & 1) != 0 { cjj = 0 - cjj }
                        if d <= p {
                            let mut cd: i64 = comb(p, d) * ipow(m + j, p - d)
                            if (d & 1) != 0 { cd = 0 - cd }
                            acc = acc + cjj * cd
                        }
                        j = j + 1
                    }
                    P[((k * MMAX + m) * IMAX + i) * DMAX + d] = s * acc
                    d = d + 1
                }
                i = i + 1
            }
            m = m + 1
        }
        k = k + 1
    }

    k = 1
    while k <= n {
        let mut m: i64 = 1
        while m <= k + 1 {
            let mut d: i64 = 0
            while d <= n {
                Bf[(k * MMAX + m) * DMAX + d] = P[((k * MMAX + m) * IMAX + 0) * DMAX + d]
                d = d + 1
            }
            m = m + 1
        }
        k = k + 1
    }

    let ans: i64 = dfs438(1, 0, n, P, A0, Bf, MMAX, IMAX, DMAX)
    printf("%lld\n", ans)
    free(Bf)
    free(A0)
    free(P)
    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 comb_i64_i64(int64_t n, int64_t k0);
int64_t ipow_i64_i64(int64_t base, int64_t e);
int64_t sum_abs_range_i64_i64(int64_t lo, int64_t hi);
int64_t floor_div_i64_i64(int64_t a, int64_t b);
int64_t first_sign_ptr_i64_i64_i64(int64_t* Bf, int64_t base, int64_t n);
void apply_val_i64_i64_i64_ptr_i64_ptr_i64_i64_i64_i64(int64_t i, int64_t val, int64_t n, int64_t* P, int64_t* Bf, int64_t MMAX, int64_t IMAX, int64_t DMAX);
int64_t dfs438_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_i64_i64_i64(int64_t k, int64_t prefix, int64_t n, int64_t* P, int64_t* A0, int64_t* Bf, int64_t MMAX, int64_t IMAX, int64_t DMAX);
int32_t main(void);



int64_t comb_i64_i64(int64_t n, int64_t k0) {
    int64_t k = k0;
    if ((k < 0 || k > n)) {
        return 0;
    }
    if (k > (n - k)) {
        k = (n - k);
    }
    int64_t r = 1;
    int64_t i = 1;
    while (i <= k) {
        r = FLOW_CHECKED_DIV(((r * ((n - k) + i))), (i));
        i = (i + 1);
    }
    return r;
}

int64_t ipow_i64_i64(int64_t base, int64_t e) {
    int64_t r = 1;
    int64_t i = 0;
    while (i < e) {
        r = (r * base);
        i = (i + 1);
    }
    return r;
}

int64_t sum_abs_range_i64_i64(int64_t lo, int64_t hi) {
    if (lo > hi) {
        return 0;
    }
    if (hi < 0) {
        int64_t cnt = ((hi - lo) + 1);
        return (0 - FLOW_CHECKED_DIV((((lo + hi) * cnt)), (2)));
    }
    if (lo > 0) {
        int64_t cnt = ((hi - lo) + 1);
        return FLOW_CHECKED_DIV((((lo + hi) * cnt)), (2));
    }
    return (FLOW_CHECKED_DIV((((0 - lo) * ((0 - lo) + 1))), (2)) + FLOW_CHECKED_DIV(((hi * (hi + 1))), (2)));
}

int64_t floor_div_i64_i64(int64_t a, int64_t b) {
    int64_t q = FLOW_CHECKED_DIV((a), (b));
    int64_t r = FLOW_CHECKED_MOD((a), (b));
    if ((r != 0 && a < 0 != b < 0)) {
        q = (q - 1);
    }
    return q;
}

int64_t first_sign_ptr_i64_i64_i64(int64_t* Bf, int64_t base, int64_t n) {
    int32_t __flow_step_1 = 1;
    for (int32_t dd = 1; (1 <= (n + 1)) ? dd < (n + 1) : dd > (n + 1); dd += (1 <= (n + 1)) ? 1 : -1) {
        int64_t v = Bf[(base + dd)];
        if (v != 0) {
            if (v > 0) {
                return 1;
            }
            return (0 - 1);
        }
    }
    return 0;
}

void apply_val_i64_i64_i64_ptr_i64_ptr_i64_i64_i64_i64(int64_t i, int64_t val, int64_t n, int64_t* P, int64_t* Bf, int64_t MMAX, int64_t IMAX, int64_t DMAX) {
    int64_t kp = (i + 1);
    while (kp <= n) {
        int64_t m = 1;
        while (m <= (kp + 1)) {
            int64_t d = 0;
            while (d <= n) {
                int64_t pidx = ((((((kp * MMAX) + m) * IMAX) + i) * DMAX) + d);
                int64_t bix = ((((kp * MMAX) + m) * DMAX) + d);
                Bf[bix] = (Bf[bix] + (val * P[pidx]));
                d = (d + 1);
            }
            m = (m + 1);
        }
        kp = (kp + 1);
    }
}

int64_t dfs438_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_i64_i64_i64(int64_t k, int64_t prefix, int64_t n, int64_t* P, int64_t* A0, int64_t* Bf, int64_t MMAX, int64_t IMAX, int64_t DMAX) {
    int64_t lb = (0 - 1000000000000000);
    int64_t ub = 1000000000000000;
    int64_t m = 1;
    while (m <= (k + 1)) {
        int64_t A0v = A0[((k * MMAX) + m)];
        int64_t bbase = (((k * MMAX) + m) * DMAX);
        int64_t b0 = Bf[bbase];
        if (A0v > 0) {
            int64_t num = (0 - b0);
            int64_t den = A0v;
            int64_t x0 = floor_div_i64_i64(num, den);
            if (FLOW_CHECKED_MOD((num), (den)) != 0) {
                x0 = (x0 + 1);
            } else {
                if (first_sign_ptr_i64_i64_i64(Bf, bbase, n) <= 0) {
                    x0 = (x0 + 1);
                }
            }
            if (x0 > lb) {
                lb = x0;
            }
        } else {
            int64_t den = (0 - A0v);
            int64_t num = b0;
            int64_t x0 = floor_div_i64_i64(num, den);
            if (FLOW_CHECKED_MOD((num), (den)) == 0) {
                if (first_sign_ptr_i64_i64_i64(Bf, bbase, n) <= 0) {
                    x0 = (x0 - 1);
                }
            }
            if (x0 < ub) {
                ub = x0;
            }
        }
        m = (m + 1);
    }
    if (lb > ub) {
        return 0;
    }
    if (k == n) {
        return ((((ub - lb) + 1) * prefix) + sum_abs_range_i64_i64(lb, ub));
    }
    int64_t total = 0;
    int64_t ak = lb;
    while (ak <= ub) {
        apply_val_i64_i64_i64_ptr_i64_ptr_i64_i64_i64_i64(k, ak, n, P, Bf, MMAX, IMAX, DMAX);
        int64_t ap = ak;
        if (ap < 0) {
            ap = (0 - ap);
        }
        total = (total + dfs438_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_i64_i64_i64((k + 1), (prefix + ap), n, P, A0, Bf, MMAX, IMAX, DMAX));
        apply_val_i64_i64_i64_ptr_i64_ptr_i64_i64_i64_i64(k, (0 - ak), n, P, Bf, MMAX, IMAX, DMAX);
        ak = (ak + 1);
    }
    return total;
}

int32_t main(void) {
    int64_t n = 7;
    int64_t MMAX = (n + 2);
    int64_t IMAX = (n + 1);
    int64_t DMAX = (n + 1);
    int64_t* P = (int64_t*)(calloc(((((n + 1) * MMAX) * IMAX) * DMAX), 8));
    int64_t* A0 = (int64_t*)(calloc(((n + 1) * MMAX), 8));
    int64_t* Bf = (int64_t*)(calloc((((n + 1) * MMAX) * DMAX), 8));
    if (((P == NULL || A0 == NULL) || Bf == NULL)) {
        return 1;
    }
    int64_t k = 1;
    while (k <= n) {
        int64_t r = (n - k);
        int64_t fact = 1;
        int64_t t = 2;
        while (t <= r) {
            fact = (fact * t);
            t = (t + 1);
        }
        int64_t m = 1;
        while (m <= (k + 1)) {
            int64_t s = 1;
            if ((((k + 1) - m) & 1) != 0) {
                s = (0 - 1);
            }
            A0[((k * MMAX) + m)] = (s * fact);
            int64_t i = 0;
            while (i <= k) {
                int64_t p = (n - i);
                int64_t d = 0;
                while (d <= n) {
                    int64_t acc = 0;
                    int64_t j = 0;
                    while (j <= r) {
                        int64_t cjj = comb_i64_i64(r, j);
                        if (((r - j) & 1) != 0) {
                            cjj = (0 - cjj);
                        }
                        if (d <= p) {
                            int64_t cd = (comb_i64_i64(p, d) * ipow_i64_i64((m + j), (p - d)));
                            if ((d & 1) != 0) {
                                cd = (0 - cd);
                            }
                            acc = (acc + (cjj * cd));
                        }
                        j = (j + 1);
                    }
                    P[((((((k * MMAX) + m) * IMAX) + i) * DMAX) + d)] = (s * acc);
                    d = (d + 1);
                }
                i = (i + 1);
            }
            m = (m + 1);
        }
        k = (k + 1);
    }
    k = 1;
    while (k <= n) {
        int64_t m = 1;
        while (m <= (k + 1)) {
            int64_t d = 0;
            while (d <= n) {
                Bf[((((k * MMAX) + m) * DMAX) + d)] = P[((((((k * MMAX) + m) * IMAX) + 0) * DMAX) + d)];
                d = (d + 1);
            }
            m = (m + 1);
        }
        k = (k + 1);
    }
    int64_t ans = dfs438_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_i64_i64_i64(1, 0, n, P, A0, Bf, MMAX, IMAX, DMAX);
    printf("%lld\n", ans);
    free(Bf);
    free(A0);
    free(P);
    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 @comb(%arg0: i64, %arg1: i64) -> i64 {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %1 : i64, !llvm.ptr
    %2 = llvm.load %1 : !llvm.ptr -> i64
    %3 = arith.constant 0 : i32
    %5 = arith.extsi %3 : i32 to i64
    %4 = arith.cmpi slt, %2, %5 : i64
    %6 = scf.if %4 -> (i1) {
      %7 = arith.constant true
      scf.yield %7 : i1
    } else {
      %8 = llvm.load %1 : !llvm.ptr -> i64
      %9 = arith.cmpi sgt, %8, %arg0 : i64
      scf.yield %9 : i1
    }
    cf.cond_br %6, ^bb0, ^bb1
    ^bb0:
      %10 = arith.constant 0 : i32
      %11 = arith.extsi %10 : i32 to i64
      func.return %11 : i64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %12 = llvm.load %1 : !llvm.ptr -> i64
    %13 = llvm.load %1 : !llvm.ptr -> i64
    %14 = arith.subi %arg0, %13 : i64
    %15 = arith.cmpi sgt, %12, %14 : i64
    cf.cond_br %15, ^bb3, ^bb4
    ^bb3:
      %16 = llvm.load %1 : !llvm.ptr -> i64
      %17 = arith.subi %arg0, %16 : i64
      llvm.store %17, %1 : i64, !llvm.ptr
      cf.br ^bb5
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %18 = arith.constant 1 : i32
    %19 = arith.extsi %18 : i32 to i64
    %20 = llvm.mlir.constant(1 : i64) : i64
    %21 = llvm.alloca %20 x i64 : (i64) -> !llvm.ptr
    llvm.store %19, %21 : i64, !llvm.ptr
    %22 = arith.constant 1 : i32
    %23 = arith.extsi %22 : i32 to i64
    %24 = llvm.mlir.constant(1 : i64) : i64
    %25 = llvm.alloca %24 x i64 : (i64) -> !llvm.ptr
    llvm.store %23, %25 : i64, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %26 = llvm.load %25 : !llvm.ptr -> i64
    %27 = llvm.load %1 : !llvm.ptr -> i64
    %28 = arith.cmpi sle, %26, %27 : i64
    cf.cond_br %28, ^bb7, ^bb8
    ^bb7:
      %29 = llvm.load %21 : !llvm.ptr -> i64
      %30 = llvm.load %1 : !llvm.ptr -> i64
      %31 = arith.subi %arg0, %30 : i64
      %32 = llvm.load %25 : !llvm.ptr -> i64
      %33 = arith.addi %31, %32 : i64
      %34 = arith.muli %29, %33 : i64
      %35 = llvm.load %25 : !llvm.ptr -> i64
      %36 = arith.divsi %34, %35 : i64
      llvm.store %36, %21 : i64, !llvm.ptr
      %37 = llvm.load %25 : !llvm.ptr -> i64
      %38 = arith.constant 1 : i32
      %40 = arith.extsi %38 : i32 to i64
      %39 = arith.addi %37, %40 : i64
      llvm.store %39, %25 : i64, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %41 = llvm.load %21 : !llvm.ptr -> i64
    func.return %41 : i64
  }
  func.func @ipow(%arg0: i64, %arg1: i64) -> i64 {
    %42 = arith.constant 1 : i32
    %43 = arith.extsi %42 : i32 to i64
    %44 = llvm.mlir.constant(1 : i64) : i64
    %45 = llvm.alloca %44 x i64 : (i64) -> !llvm.ptr
    llvm.store %43, %45 : i64, !llvm.ptr
    %46 = arith.constant 0 : i32
    %47 = arith.extsi %46 : i32 to i64
    %48 = llvm.mlir.constant(1 : i64) : i64
    %49 = llvm.alloca %48 x i64 : (i64) -> !llvm.ptr
    llvm.store %47, %49 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %50 = llvm.load %49 : !llvm.ptr -> i64
    %51 = arith.cmpi slt, %50, %arg1 : i64
    cf.cond_br %51, ^bb10, ^bb11
    ^bb10:
      %52 = llvm.load %45 : !llvm.ptr -> i64
      %53 = arith.muli %52, %arg0 : i64
      llvm.store %53, %45 : i64, !llvm.ptr
      %54 = llvm.load %49 : !llvm.ptr -> i64
      %55 = arith.constant 1 : i32
      %57 = arith.extsi %55 : i32 to i64
      %56 = arith.addi %54, %57 : i64
      llvm.store %56, %49 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %58 = llvm.load %45 : !llvm.ptr -> i64
    func.return %58 : i64
  }
  func.func @sum_abs_range(%arg0: i64, %arg1: i64) -> i64 {
    %59 = arith.cmpi sgt, %arg0, %arg1 : i64
    cf.cond_br %59, ^bb12, ^bb13
    ^bb12:
      %60 = arith.constant 0 : i32
      %61 = arith.extsi %60 : i32 to i64
      func.return %61 : i64
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %62 = arith.constant 0 : i32
    %64 = arith.extsi %62 : i32 to i64
    %63 = arith.cmpi slt, %arg1, %64 : i64
    cf.cond_br %63, ^bb15, ^bb16
    ^bb15:
      %65 = arith.subi %arg1, %arg0 : i64
      %66 = arith.constant 1 : i32
      %68 = arith.extsi %66 : i32 to i64
      %67 = arith.addi %65, %68 : i64
      %69 = arith.constant 0 : i32
      %70 = arith.addi %arg0, %arg1 : i64
      %71 = arith.muli %70, %67 : i64
      %72 = arith.constant 2 : i32
      %74 = arith.extsi %72 : i32 to i64
      %73 = arith.divsi %71, %74 : i64
      %76 = arith.extsi %69 : i32 to i64
      %75 = arith.subi %76, %73 : i64
      func.return %75 : i64
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %77 = arith.constant 0 : i32
    %79 = arith.extsi %77 : i32 to i64
    %78 = arith.cmpi sgt, %arg0, %79 : i64
    cf.cond_br %78, ^bb18, ^bb19
    ^bb18:
      %80 = arith.subi %arg1, %arg0 : i64
      %81 = arith.constant 1 : i32
      %83 = arith.extsi %81 : i32 to i64
      %82 = arith.addi %80, %83 : i64
      %84 = arith.addi %arg0, %arg1 : i64
      %85 = arith.muli %84, %82 : i64
      %86 = arith.constant 2 : i32
      %88 = arith.extsi %86 : i32 to i64
      %87 = arith.divsi %85, %88 : i64
      func.return %87 : i64
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %89 = arith.constant 0 : i32
    %91 = arith.extsi %89 : i32 to i64
    %90 = arith.subi %91, %arg0 : i64
    %92 = arith.constant 0 : i32
    %94 = arith.extsi %92 : i32 to i64
    %93 = arith.subi %94, %arg0 : i64
    %95 = arith.constant 1 : i32
    %97 = arith.extsi %95 : i32 to i64
    %96 = arith.addi %93, %97 : i64
    %98 = arith.muli %90, %96 : i64
    %99 = arith.constant 2 : i32
    %101 = arith.extsi %99 : i32 to i64
    %100 = arith.divsi %98, %101 : i64
    %102 = arith.constant 1 : i32
    %104 = arith.extsi %102 : i32 to i64
    %103 = arith.addi %arg1, %104 : i64
    %105 = arith.muli %arg1, %103 : i64
    %106 = arith.constant 2 : i32
    %108 = arith.extsi %106 : i32 to i64
    %107 = arith.divsi %105, %108 : i64
    %109 = arith.addi %100, %107 : i64
    func.return %109 : i64
  }
  func.func @floor_div(%arg0: i64, %arg1: i64) -> i64 {
    %110 = arith.divsi %arg0, %arg1 : i64
    %111 = llvm.mlir.constant(1 : i64) : i64
    %112 = llvm.alloca %111 x i64 : (i64) -> !llvm.ptr
    llvm.store %110, %112 : i64, !llvm.ptr
    %113 = arith.remsi %arg0, %arg1 : i64
    %114 = arith.constant 0 : i32
    %116 = arith.extsi %114 : i32 to i64
    %115 = arith.cmpi ne, %113, %116 : i64
    %117 = scf.if %115 -> (i1) {
      %118 = arith.constant 0 : i32
      %120 = arith.extsi %118 : i32 to i64
      %119 = arith.cmpi slt, %arg0, %120 : i64
      %121 = arith.constant 0 : i32
      %123 = arith.extsi %121 : i32 to i64
      %122 = arith.cmpi slt, %arg1, %123 : i64
      %124 = arith.cmpi ne, %119, %122 : i1
      scf.yield %124 : i1
    } else {
      %125 = arith.constant false
      scf.yield %125 : i1
    }
    cf.cond_br %117, ^bb21, ^bb22
    ^bb21:
      %126 = llvm.load %112 : !llvm.ptr -> i64
      %127 = arith.constant 1 : i32
      %129 = arith.extsi %127 : i32 to i64
      %128 = arith.subi %126, %129 : i64
      llvm.store %128, %112 : i64, !llvm.ptr
      cf.br ^bb23
    ^bb22:
      cf.br ^bb23
    ^bb23:
    %130 = llvm.load %112 : !llvm.ptr -> i64
    func.return %130 : i64
  }
  func.func @first_sign(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 {
    %131 = arith.constant 1 : i32
    %132 = arith.constant 1 : i32
    %134 = arith.extsi %132 : i32 to i64
    %133 = arith.addi %arg2, %134 : i64
    %135 = arith.index_cast %131 : i32 to index
    %136 = arith.index_cast %133 : i32 to index
    %138 = arith.constant 1 : index
    %139 = arith.constant -1 : index
    %140 = arith.cmpi sle, %135, %136 : index
    %137 = arith.select %140, %138, %139 : index
    cf.br ^bb24(%135 : index)
    ^bb24(%141: index):
    %142 = arith.cmpi slt, %141, %136 : index
    %143 = arith.cmpi sgt, %141, %136 : index
    %144 = arith.select %140, %142, %143 : i1
    cf.cond_br %144, ^bb25(%141 : index), ^bb26(%141 : index)
    ^bb25(%145: index):
      %148 = arith.trunci %arg1 : i64 to i32
      %149 = arith.index_cast %145 : index to i32
      %147 = arith.addi %148, %149 : i32
      %150 = arith.extsi %147 : i32 to i64
      %151 = llvm.getelementptr %arg0[%150] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %146 = llvm.load %151 : !llvm.ptr -> i64
      %152 = arith.constant 0 : i32
      %154 = arith.extsi %152 : i32 to i64
      %153 = arith.cmpi ne, %146, %154 : i64
      cf.cond_br %153, ^bb27, ^bb28
      ^bb27:
        %155 = arith.constant 0 : i32
        %157 = arith.extsi %155 : i32 to i64
        %156 = arith.cmpi sgt, %146, %157 : i64
        cf.cond_br %156, ^bb30, ^bb31
        ^bb30:
          %158 = arith.constant 1 : i32
          %159 = arith.extsi %158 : i32 to i64
          func.return %159 : i64
        ^bb31:
          cf.br ^bb32
        ^bb32:
        %160 = arith.constant 0 : i32
        %161 = arith.constant 1 : i32
        %162 = arith.subi %160, %161 : i32
        %163 = arith.extsi %162 : i32 to i64
        func.return %163 : i64
      ^bb28:
        cf.br ^bb29
      ^bb29:
      %164 = arith.addi %145, %137 : index
      cf.br ^bb24(%164 : index)
    ^bb26(%165: index):
    %166 = arith.constant 0 : i32
    %167 = arith.extsi %166 : i32 to i64
    func.return %167 : i64
  }
  func.func @apply_val(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: i64, %arg6: i64, %arg7: i64) -> () {
    %168 = arith.constant 1 : i32
    %170 = arith.extsi %168 : i32 to i64
    %169 = arith.addi %arg0, %170 : i64
    %171 = llvm.mlir.constant(1 : i64) : i64
    %172 = llvm.alloca %171 x i64 : (i64) -> !llvm.ptr
    llvm.store %169, %172 : i64, !llvm.ptr
    cf.br ^bb33
    ^bb33:
    %173 = llvm.load %172 : !llvm.ptr -> i64
    %174 = arith.cmpi sle, %173, %arg2 : i64
    cf.cond_br %174, ^bb34, ^bb35
    ^bb34:
      %175 = arith.constant 1 : i32
      %176 = arith.extsi %175 : i32 to i64
      %177 = llvm.mlir.constant(1 : i64) : i64
      %178 = llvm.alloca %177 x i64 : (i64) -> !llvm.ptr
      llvm.store %176, %178 : i64, !llvm.ptr
      cf.br ^bb36
      ^bb36:
      %179 = llvm.load %178 : !llvm.ptr -> i64
      %180 = llvm.load %172 : !llvm.ptr -> i64
      %181 = arith.constant 1 : i32
      %183 = arith.extsi %181 : i32 to i64
      %182 = arith.addi %180, %183 : i64
      %184 = arith.cmpi sle, %179, %182 : i64
      cf.cond_br %184, ^bb37, ^bb38
      ^bb37:
        %185 = arith.constant 0 : i32
        %186 = arith.extsi %185 : i32 to i64
        %187 = llvm.mlir.constant(1 : i64) : i64
        %188 = llvm.alloca %187 x i64 : (i64) -> !llvm.ptr
        llvm.store %186, %188 : i64, !llvm.ptr
        cf.br ^bb39
        ^bb39:
        %189 = llvm.load %188 : !llvm.ptr -> i64
        %190 = arith.cmpi sle, %189, %arg2 : i64
        cf.cond_br %190, ^bb40, ^bb41
        ^bb40:
          %191 = llvm.load %172 : !llvm.ptr -> i64
          %192 = arith.muli %191, %arg5 : i64
          %193 = llvm.load %178 : !llvm.ptr -> i64
          %194 = arith.addi %192, %193 : i64
          %195 = arith.muli %194, %arg6 : i64
          %196 = arith.addi %195, %arg0 : i64
          %197 = arith.muli %196, %arg7 : i64
          %198 = llvm.load %188 : !llvm.ptr -> i64
          %199 = arith.addi %197, %198 : i64
          %200 = llvm.load %172 : !llvm.ptr -> i64
          %201 = arith.muli %200, %arg5 : i64
          %202 = llvm.load %178 : !llvm.ptr -> i64
          %203 = arith.addi %201, %202 : i64
          %204 = arith.muli %203, %arg7 : i64
          %205 = llvm.load %188 : !llvm.ptr -> i64
          %206 = arith.addi %204, %205 : i64
          %208 = llvm.getelementptr %arg4[%206] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %207 = llvm.load %208 : !llvm.ptr -> i64
          %210 = llvm.getelementptr %arg3[%199] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %209 = llvm.load %210 : !llvm.ptr -> i64
          %211 = arith.muli %arg1, %209 : i64
          %212 = arith.addi %207, %211 : i64
          %213 = llvm.getelementptr %arg4[%206] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %212, %213 : i64, !llvm.ptr
          %214 = llvm.load %188 : !llvm.ptr -> i64
          %215 = arith.constant 1 : i32
          %217 = arith.extsi %215 : i32 to i64
          %216 = arith.addi %214, %217 : i64
          llvm.store %216, %188 : i64, !llvm.ptr
          cf.br ^bb39
        ^bb41:
        %218 = llvm.load %178 : !llvm.ptr -> i64
        %219 = arith.constant 1 : i32
        %221 = arith.extsi %219 : i32 to i64
        %220 = arith.addi %218, %221 : i64
        llvm.store %220, %178 : i64, !llvm.ptr
        cf.br ^bb36
      ^bb38:
      %222 = llvm.load %172 : !llvm.ptr -> i64
      %223 = arith.constant 1 : i32
      %225 = arith.extsi %223 : i32 to i64
      %224 = arith.addi %222, %225 : i64
      llvm.store %224, %172 : i64, !llvm.ptr
      cf.br ^bb33
    ^bb35:
    func.return
  }
  func.func @dfs438(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i64, %arg7: i64, %arg8: i64) -> i64 {
    %226 = arith.constant 0 : i32
    %227 = arith.constant 999995705032704 : i32
    %228 = arith.subi %226, %227 : i32
    %229 = arith.extsi %228 : i32 to i64
    %230 = llvm.mlir.constant(1 : i64) : i64
    %231 = llvm.alloca %230 x i64 : (i64) -> !llvm.ptr
    llvm.store %229, %231 : i64, !llvm.ptr
    %232 = arith.constant 999995705032704 : i32
    %233 = arith.extsi %232 : i32 to i64
    %234 = llvm.mlir.constant(1 : i64) : i64
    %235 = llvm.alloca %234 x i64 : (i64) -> !llvm.ptr
    llvm.store %233, %235 : i64, !llvm.ptr
    %236 = arith.constant 1 : i32
    %237 = arith.extsi %236 : i32 to i64
    %238 = llvm.mlir.constant(1 : i64) : i64
    %239 = llvm.alloca %238 x i64 : (i64) -> !llvm.ptr
    llvm.store %237, %239 : i64, !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %240 = llvm.load %239 : !llvm.ptr -> i64
    %241 = arith.constant 1 : i32
    %243 = arith.extsi %241 : i32 to i64
    %242 = arith.addi %arg0, %243 : i64
    %244 = arith.cmpi sle, %240, %242 : i64
    cf.cond_br %244, ^bb43, ^bb44
    ^bb43:
      %246 = arith.muli %arg0, %arg6 : i64
      %247 = llvm.load %239 : !llvm.ptr -> i64
      %248 = arith.addi %246, %247 : i64
      %249 = llvm.getelementptr %arg4[%248] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %245 = llvm.load %249 : !llvm.ptr -> i64
      %250 = arith.muli %arg0, %arg6 : i64
      %251 = llvm.load %239 : !llvm.ptr -> i64
      %252 = arith.addi %250, %251 : i64
      %253 = arith.muli %252, %arg8 : i64
      %255 = llvm.getelementptr %arg5[%253] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %254 = llvm.load %255 : !llvm.ptr -> i64
      %256 = arith.constant 0 : i32
      %258 = arith.extsi %256 : i32 to i64
      %257 = arith.cmpi sgt, %245, %258 : i64
      cf.cond_br %257, ^bb45, ^bb46
      ^bb45:
        %259 = arith.constant 0 : i32
        %261 = arith.extsi %259 : i32 to i64
        %260 = arith.subi %261, %254 : i64
        %262 = func.call @floor_div(%260, %245) : (i64, i64) -> i64
        %263 = llvm.mlir.constant(1 : i64) : i64
        %264 = llvm.alloca %263 x i64 : (i64) -> !llvm.ptr
        llvm.store %262, %264 : i64, !llvm.ptr
        %265 = arith.remsi %260, %245 : i64
        %266 = arith.constant 0 : i32
        %268 = arith.extsi %266 : i32 to i64
        %267 = arith.cmpi ne, %265, %268 : i64
        cf.cond_br %267, ^bb48, ^bb49
        ^bb48:
          %269 = llvm.load %264 : !llvm.ptr -> i64
          %270 = arith.constant 1 : i32
          %272 = arith.extsi %270 : i32 to i64
          %271 = arith.addi %269, %272 : i64
          llvm.store %271, %264 : i64, !llvm.ptr
          cf.br ^bb50
        ^bb49:
          %273 = func.call @first_sign(%arg5, %253, %arg2) : (!llvm.ptr, i64, i64) -> i64
          %274 = arith.constant 0 : i32
          %276 = arith.extsi %274 : i32 to i64
          %275 = arith.cmpi sle, %273, %276 : i64
          cf.cond_br %275, ^bb51, ^bb52
          ^bb51:
            %277 = llvm.load %264 : !llvm.ptr -> i64
            %278 = arith.constant 1 : i32
            %280 = arith.extsi %278 : i32 to i64
            %279 = arith.addi %277, %280 : i64
            llvm.store %279, %264 : i64, !llvm.ptr
            cf.br ^bb53
          ^bb52:
            cf.br ^bb53
          ^bb53:
          cf.br ^bb50
        ^bb50:
        %281 = llvm.load %264 : !llvm.ptr -> i64
        %282 = llvm.load %231 : !llvm.ptr -> i64
        %283 = arith.cmpi sgt, %281, %282 : i64
        cf.cond_br %283, ^bb54, ^bb55
        ^bb54:
          %284 = llvm.load %264 : !llvm.ptr -> i64
          llvm.store %284, %231 : i64, !llvm.ptr
          cf.br ^bb56
        ^bb55:
          cf.br ^bb56
        ^bb56:
        cf.br ^bb47
      ^bb46:
        %285 = arith.constant 0 : i32
        %287 = arith.extsi %285 : i32 to i64
        %286 = arith.subi %287, %245 : i64
        %288 = func.call @floor_div(%254, %286) : (i64, i64) -> i64
        %289 = llvm.mlir.constant(1 : i64) : i64
        %290 = llvm.alloca %289 x i64 : (i64) -> !llvm.ptr
        llvm.store %288, %290 : i64, !llvm.ptr
        %291 = arith.remsi %254, %286 : i64
        %292 = arith.constant 0 : i32
        %294 = arith.extsi %292 : i32 to i64
        %293 = arith.cmpi eq, %291, %294 : i64
        cf.cond_br %293, ^bb57, ^bb58
        ^bb57:
          %295 = func.call @first_sign(%arg5, %253, %arg2) : (!llvm.ptr, i64, i64) -> i64
          %296 = arith.constant 0 : i32
          %298 = arith.extsi %296 : i32 to i64
          %297 = arith.cmpi sle, %295, %298 : i64
          cf.cond_br %297, ^bb60, ^bb61
          ^bb60:
            %299 = llvm.load %290 : !llvm.ptr -> i64
            %300 = arith.constant 1 : i32
            %302 = arith.extsi %300 : i32 to i64
            %301 = arith.subi %299, %302 : i64
            llvm.store %301, %290 : i64, !llvm.ptr
            cf.br ^bb62
          ^bb61:
            cf.br ^bb62
          ^bb62:
          cf.br ^bb59
        ^bb58:
          cf.br ^bb59
        ^bb59:
        %303 = llvm.load %290 : !llvm.ptr -> i64
        %304 = llvm.load %235 : !llvm.ptr -> i64
        %305 = arith.cmpi slt, %303, %304 : i64
        cf.cond_br %305, ^bb63, ^bb64
        ^bb63:
          %306 = llvm.load %290 : !llvm.ptr -> i64
          llvm.store %306, %235 : i64, !llvm.ptr
          cf.br ^bb65
        ^bb64:
          cf.br ^bb65
        ^bb65:
        cf.br ^bb47
      ^bb47:
      %307 = llvm.load %239 : !llvm.ptr -> i64
      %308 = arith.constant 1 : i32
      %310 = arith.extsi %308 : i32 to i64
      %309 = arith.addi %307, %310 : i64
      llvm.store %309, %239 : i64, !llvm.ptr
      cf.br ^bb42
    ^bb44:
    %311 = llvm.load %231 : !llvm.ptr -> i64
    %312 = llvm.load %235 : !llvm.ptr -> i64
    %313 = arith.cmpi sgt, %311, %312 : i64
    cf.cond_br %313, ^bb66, ^bb67
    ^bb66:
      %314 = arith.constant 0 : i32
      %315 = arith.extsi %314 : i32 to i64
      func.return %315 : i64
    ^bb67:
      cf.br ^bb68
    ^bb68:
    %316 = arith.cmpi eq, %arg0, %arg2 : i64
    cf.cond_br %316, ^bb69, ^bb70
    ^bb69:
      %317 = llvm.load %235 : !llvm.ptr -> i64
      %318 = llvm.load %231 : !llvm.ptr -> i64
      %319 = arith.subi %317, %318 : i64
      %320 = arith.constant 1 : i32
      %322 = arith.extsi %320 : i32 to i64
      %321 = arith.addi %319, %322 : i64
      %323 = arith.muli %321, %arg1 : i64
      %325 = llvm.load %231 : !llvm.ptr -> i64
      %326 = llvm.load %235 : !llvm.ptr -> i64
      %324 = func.call @sum_abs_range(%325, %326) : (i64, i64) -> i64
      %327 = arith.addi %323, %324 : i64
      func.return %327 : i64
    ^bb70:
      cf.br ^bb71
    ^bb71:
    %328 = arith.constant 0 : i32
    %329 = arith.extsi %328 : i32 to i64
    %330 = llvm.mlir.constant(1 : i64) : i64
    %331 = llvm.alloca %330 x i64 : (i64) -> !llvm.ptr
    llvm.store %329, %331 : i64, !llvm.ptr
    %332 = llvm.load %231 : !llvm.ptr -> i64
    %333 = llvm.mlir.constant(1 : i64) : i64
    %334 = llvm.alloca %333 x i64 : (i64) -> !llvm.ptr
    llvm.store %332, %334 : i64, !llvm.ptr
    cf.br ^bb72
    ^bb72:
    %335 = llvm.load %334 : !llvm.ptr -> i64
    %336 = llvm.load %235 : !llvm.ptr -> i64
    %337 = arith.cmpi sle, %335, %336 : i64
    cf.cond_br %337, ^bb73, ^bb74
    ^bb73:
      %339 = llvm.load %334 : !llvm.ptr -> i64
      func.call @apply_val(%arg0, %339, %arg2, %arg3, %arg5, %arg6, %arg7, %arg8) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
      %340 = llvm.load %334 : !llvm.ptr -> i64
      %341 = llvm.mlir.constant(1 : i64) : i64
      %342 = llvm.alloca %341 x i64 : (i64) -> !llvm.ptr
      llvm.store %340, %342 : i64, !llvm.ptr
      %343 = llvm.load %342 : !llvm.ptr -> i64
      %344 = arith.constant 0 : i32
      %346 = arith.extsi %344 : i32 to i64
      %345 = arith.cmpi slt, %343, %346 : i64
      cf.cond_br %345, ^bb75, ^bb76
      ^bb75:
        %347 = arith.constant 0 : i32
        %348 = llvm.load %342 : !llvm.ptr -> i64
        %350 = arith.extsi %347 : i32 to i64
        %349 = arith.subi %350, %348 : i64
        llvm.store %349, %342 : i64, !llvm.ptr
        cf.br ^bb77
      ^bb76:
        cf.br ^bb77
      ^bb77:
      %351 = llvm.load %331 : !llvm.ptr -> i64
      %353 = arith.constant 1 : i32
      %355 = arith.extsi %353 : i32 to i64
      %354 = arith.addi %arg0, %355 : i64
      %356 = llvm.load %342 : !llvm.ptr -> i64
      %357 = arith.addi %arg1, %356 : i64
      %352 = func.call @dfs438(%354, %357, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> i64
      %358 = arith.addi %351, %352 : i64
      llvm.store %358, %331 : i64, !llvm.ptr
      %360 = arith.constant 0 : i32
      %361 = llvm.load %334 : !llvm.ptr -> i64
      %363 = arith.extsi %360 : i32 to i64
      %362 = arith.subi %363, %361 : i64
      func.call @apply_val(%arg0, %362, %arg2, %arg3, %arg5, %arg6, %arg7, %arg8) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
      %364 = llvm.load %334 : !llvm.ptr -> i64
      %365 = arith.constant 1 : i32
      %367 = arith.extsi %365 : i32 to i64
      %366 = arith.addi %364, %367 : i64
      llvm.store %366, %334 : i64, !llvm.ptr
      cf.br ^bb72
    ^bb74:
    %368 = llvm.load %331 : !llvm.ptr -> i64
    func.return %368 : i64
  }
  func.func @main() -> i32 {
    %369 = arith.constant 7 : i32
    %370 = arith.extsi %369 : i32 to i64
    %371 = arith.constant 2 : i32
    %373 = arith.extsi %371 : i32 to i64
    %372 = arith.addi %370, %373 : i64
    %374 = arith.constant 1 : i32
    %376 = arith.extsi %374 : i32 to i64
    %375 = arith.addi %370, %376 : i64
    %377 = arith.constant 1 : i32
    %379 = arith.extsi %377 : i32 to i64
    %378 = arith.addi %370, %379 : i64
    %381 = arith.constant 1 : i32
    %383 = arith.extsi %381 : i32 to i64
    %382 = arith.addi %370, %383 : i64
    %384 = arith.muli %382, %372 : i64
    %385 = arith.muli %384, %375 : i64
    %386 = arith.muli %385, %378 : i64
    %387 = arith.constant 8 : i32
    %388 = arith.extsi %387 : i32 to i64
    %380 = func.call @calloc(%386, %388) : (i64, i64) -> !llvm.ptr
    %390 = arith.constant 1 : i32
    %392 = arith.extsi %390 : i32 to i64
    %391 = arith.addi %370, %392 : i64
    %393 = arith.muli %391, %372 : i64
    %394 = arith.constant 8 : i32
    %395 = arith.extsi %394 : i32 to i64
    %389 = func.call @calloc(%393, %395) : (i64, i64) -> !llvm.ptr
    %397 = arith.constant 1 : i32
    %399 = arith.extsi %397 : i32 to i64
    %398 = arith.addi %370, %399 : i64
    %400 = arith.muli %398, %372 : i64
    %401 = arith.muli %400, %378 : i64
    %402 = arith.constant 8 : i32
    %403 = arith.extsi %402 : i32 to i64
    %396 = func.call @calloc(%401, %403) : (i64, i64) -> !llvm.ptr
    %404 = llvm.mlir.zero : !llvm.ptr
    %405 = llvm.icmp "eq" %380, %404 : !llvm.ptr
    %406 = scf.if %405 -> (i1) {
      %407 = arith.constant true
      scf.yield %407 : i1
    } else {
      %408 = llvm.mlir.zero : !llvm.ptr
      %409 = llvm.icmp "eq" %389, %408 : !llvm.ptr
      scf.yield %409 : i1
    }
    %410 = scf.if %406 -> (i1) {
      %411 = arith.constant true
      scf.yield %411 : i1
    } else {
      %412 = llvm.mlir.zero : !llvm.ptr
      %413 = llvm.icmp "eq" %396, %412 : !llvm.ptr
      scf.yield %413 : i1
    }
    cf.cond_br %410, ^bb78, ^bb79
    ^bb78:
      %414 = arith.constant 1 : i32
      func.return %414 : i32
    ^bb79:
      cf.br ^bb80
    ^bb80:
    %415 = arith.constant 1 : i32
    %416 = arith.extsi %415 : i32 to i64
    %417 = llvm.mlir.constant(1 : i64) : i64
    %418 = llvm.alloca %417 x i64 : (i64) -> !llvm.ptr
    llvm.store %416, %418 : i64, !llvm.ptr
    cf.br ^bb81
    ^bb81:
    %419 = llvm.load %418 : !llvm.ptr -> i64
    %420 = arith.cmpi sle, %419, %370 : i64
    cf.cond_br %420, ^bb82, ^bb83
    ^bb82:
      %421 = llvm.load %418 : !llvm.ptr -> i64
      %422 = arith.subi %370, %421 : i64
      %423 = arith.constant 1 : i32
      %424 = arith.extsi %423 : i32 to i64
      %425 = llvm.mlir.constant(1 : i64) : i64
      %426 = llvm.alloca %425 x i64 : (i64) -> !llvm.ptr
      llvm.store %424, %426 : i64, !llvm.ptr
      %427 = arith.constant 2 : i32
      %428 = arith.extsi %427 : i32 to i64
      %429 = llvm.mlir.constant(1 : i64) : i64
      %430 = llvm.alloca %429 x i64 : (i64) -> !llvm.ptr
      llvm.store %428, %430 : i64, !llvm.ptr
      cf.br ^bb84
      ^bb84:
      %431 = llvm.load %430 : !llvm.ptr -> i64
      %432 = arith.cmpi sle, %431, %422 : i64
      cf.cond_br %432, ^bb85, ^bb86
      ^bb85:
        %433 = llvm.load %426 : !llvm.ptr -> i64
        %434 = llvm.load %430 : !llvm.ptr -> i64
        %435 = arith.muli %433, %434 : i64
        llvm.store %435, %426 : i64, !llvm.ptr
        %436 = llvm.load %430 : !llvm.ptr -> i64
        %437 = arith.constant 1 : i32
        %439 = arith.extsi %437 : i32 to i64
        %438 = arith.addi %436, %439 : i64
        llvm.store %438, %430 : i64, !llvm.ptr
        cf.br ^bb84
      ^bb86:
      %440 = arith.constant 1 : i32
      %441 = arith.extsi %440 : i32 to i64
      %442 = llvm.mlir.constant(1 : i64) : i64
      %443 = llvm.alloca %442 x i64 : (i64) -> !llvm.ptr
      llvm.store %441, %443 : i64, !llvm.ptr
      cf.br ^bb87
      ^bb87:
      %444 = llvm.load %443 : !llvm.ptr -> i64
      %445 = llvm.load %418 : !llvm.ptr -> i64
      %446 = arith.constant 1 : i32
      %448 = arith.extsi %446 : i32 to i64
      %447 = arith.addi %445, %448 : i64
      %449 = arith.cmpi sle, %444, %447 : i64
      cf.cond_br %449, ^bb88, ^bb89
      ^bb88:
        %450 = arith.constant 1 : i32
        %451 = arith.extsi %450 : i32 to i64
        %452 = llvm.mlir.constant(1 : i64) : i64
        %453 = llvm.alloca %452 x i64 : (i64) -> !llvm.ptr
        llvm.store %451, %453 : i64, !llvm.ptr
        %454 = llvm.load %418 : !llvm.ptr -> i64
        %455 = arith.constant 1 : i32
        %457 = arith.extsi %455 : i32 to i64
        %456 = arith.addi %454, %457 : i64
        %458 = llvm.load %443 : !llvm.ptr -> i64
        %459 = arith.subi %456, %458 : i64
        %460 = arith.constant 1 : i32
        %462 = arith.extsi %460 : i32 to i64
        %461 = arith.andi %459, %462 : i64
        %463 = arith.constant 0 : i32
        %465 = arith.extsi %463 : i32 to i64
        %464 = arith.cmpi ne, %461, %465 : i64
        cf.cond_br %464, ^bb90, ^bb91
        ^bb90:
          %466 = arith.constant 0 : i32
          %467 = arith.constant 1 : i32
          %468 = arith.subi %466, %467 : i32
          %469 = arith.extsi %468 : i32 to i64
          llvm.store %469, %453 : i64, !llvm.ptr
          cf.br ^bb92
        ^bb91:
          cf.br ^bb92
        ^bb92:
        %470 = llvm.load %453 : !llvm.ptr -> i64
        %471 = llvm.load %426 : !llvm.ptr -> i64
        %472 = arith.muli %470, %471 : i64
        %473 = llvm.load %418 : !llvm.ptr -> i64
        %474 = arith.muli %473, %372 : i64
        %475 = llvm.load %443 : !llvm.ptr -> i64
        %476 = arith.addi %474, %475 : i64
        %477 = llvm.getelementptr %389[%476] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %472, %477 : i64, !llvm.ptr
        %478 = arith.constant 0 : i32
        %479 = arith.extsi %478 : i32 to i64
        %480 = llvm.mlir.constant(1 : i64) : i64
        %481 = llvm.alloca %480 x i64 : (i64) -> !llvm.ptr
        llvm.store %479, %481 : i64, !llvm.ptr
        cf.br ^bb93
        ^bb93:
        %482 = llvm.load %481 : !llvm.ptr -> i64
        %483 = llvm.load %418 : !llvm.ptr -> i64
        %484 = arith.cmpi sle, %482, %483 : i64
        cf.cond_br %484, ^bb94, ^bb95
        ^bb94:
          %485 = llvm.load %481 : !llvm.ptr -> i64
          %486 = arith.subi %370, %485 : i64
          %487 = arith.constant 0 : i32
          %488 = arith.extsi %487 : i32 to i64
          %489 = llvm.mlir.constant(1 : i64) : i64
          %490 = llvm.alloca %489 x i64 : (i64) -> !llvm.ptr
          llvm.store %488, %490 : i64, !llvm.ptr
          cf.br ^bb96
          ^bb96:
          %491 = llvm.load %490 : !llvm.ptr -> i64
          %492 = arith.cmpi sle, %491, %370 : i64
          cf.cond_br %492, ^bb97, ^bb98
          ^bb97:
            %493 = arith.constant 0 : i32
            %494 = arith.extsi %493 : i32 to i64
            %495 = llvm.mlir.constant(1 : i64) : i64
            %496 = llvm.alloca %495 x i64 : (i64) -> !llvm.ptr
            llvm.store %494, %496 : i64, !llvm.ptr
            %497 = arith.constant 0 : i32
            %498 = arith.extsi %497 : i32 to i64
            %499 = llvm.mlir.constant(1 : i64) : i64
            %500 = llvm.alloca %499 x i64 : (i64) -> !llvm.ptr
            llvm.store %498, %500 : i64, !llvm.ptr
            cf.br ^bb99
            ^bb99:
            %501 = llvm.load %500 : !llvm.ptr -> i64
            %502 = arith.cmpi sle, %501, %422 : i64
            cf.cond_br %502, ^bb100, ^bb101
            ^bb100:
              %504 = llvm.load %500 : !llvm.ptr -> i64
              %503 = func.call @comb(%422, %504) : (i64, i64) -> i64
              %505 = llvm.mlir.constant(1 : i64) : i64
              %506 = llvm.alloca %505 x i64 : (i64) -> !llvm.ptr
              llvm.store %503, %506 : i64, !llvm.ptr
              %507 = llvm.load %500 : !llvm.ptr -> i64
              %508 = arith.subi %422, %507 : i64
              %509 = arith.constant 1 : i32
              %511 = arith.extsi %509 : i32 to i64
              %510 = arith.andi %508, %511 : i64
              %512 = arith.constant 0 : i32
              %514 = arith.extsi %512 : i32 to i64
              %513 = arith.cmpi ne, %510, %514 : i64
              cf.cond_br %513, ^bb102, ^bb103
              ^bb102:
                %515 = arith.constant 0 : i32
                %516 = llvm.load %506 : !llvm.ptr -> i64
                %518 = arith.extsi %515 : i32 to i64
                %517 = arith.subi %518, %516 : i64
                llvm.store %517, %506 : i64, !llvm.ptr
                cf.br ^bb104
              ^bb103:
                cf.br ^bb104
              ^bb104:
              %519 = llvm.load %490 : !llvm.ptr -> i64
              %520 = arith.cmpi sle, %519, %486 : i64
              cf.cond_br %520, ^bb105, ^bb106
              ^bb105:
                %522 = llvm.load %490 : !llvm.ptr -> i64
                %521 = func.call @comb(%486, %522) : (i64, i64) -> i64
                %524 = llvm.load %443 : !llvm.ptr -> i64
                %525 = llvm.load %500 : !llvm.ptr -> i64
                %526 = arith.addi %524, %525 : i64
                %527 = llvm.load %490 : !llvm.ptr -> i64
                %528 = arith.subi %486, %527 : i64
                %523 = func.call @ipow(%526, %528) : (i64, i64) -> i64
                %529 = arith.muli %521, %523 : i64
                %530 = llvm.mlir.constant(1 : i64) : i64
                %531 = llvm.alloca %530 x i64 : (i64) -> !llvm.ptr
                llvm.store %529, %531 : i64, !llvm.ptr
                %532 = llvm.load %490 : !llvm.ptr -> i64
                %533 = arith.constant 1 : i32
                %535 = arith.extsi %533 : i32 to i64
                %534 = arith.andi %532, %535 : i64
                %536 = arith.constant 0 : i32
                %538 = arith.extsi %536 : i32 to i64
                %537 = arith.cmpi ne, %534, %538 : i64
                cf.cond_br %537, ^bb108, ^bb109
                ^bb108:
                  %539 = arith.constant 0 : i32
                  %540 = llvm.load %531 : !llvm.ptr -> i64
                  %542 = arith.extsi %539 : i32 to i64
                  %541 = arith.subi %542, %540 : i64
                  llvm.store %541, %531 : i64, !llvm.ptr
                  cf.br ^bb110
                ^bb109:
                  cf.br ^bb110
                ^bb110:
                %543 = llvm.load %496 : !llvm.ptr -> i64
                %544 = llvm.load %506 : !llvm.ptr -> i64
                %545 = llvm.load %531 : !llvm.ptr -> i64
                %546 = arith.muli %544, %545 : i64
                %547 = arith.addi %543, %546 : i64
                llvm.store %547, %496 : i64, !llvm.ptr
                cf.br ^bb107
              ^bb106:
                cf.br ^bb107
              ^bb107:
              %548 = llvm.load %500 : !llvm.ptr -> i64
              %549 = arith.constant 1 : i32
              %551 = arith.extsi %549 : i32 to i64
              %550 = arith.addi %548, %551 : i64
              llvm.store %550, %500 : i64, !llvm.ptr
              cf.br ^bb99
            ^bb101:
            %552 = llvm.load %453 : !llvm.ptr -> i64
            %553 = llvm.load %496 : !llvm.ptr -> i64
            %554 = arith.muli %552, %553 : i64
            %555 = llvm.load %418 : !llvm.ptr -> i64
            %556 = arith.muli %555, %372 : i64
            %557 = llvm.load %443 : !llvm.ptr -> i64
            %558 = arith.addi %556, %557 : i64
            %559 = arith.muli %558, %375 : i64
            %560 = llvm.load %481 : !llvm.ptr -> i64
            %561 = arith.addi %559, %560 : i64
            %562 = arith.muli %561, %378 : i64
            %563 = llvm.load %490 : !llvm.ptr -> i64
            %564 = arith.addi %562, %563 : i64
            %565 = llvm.getelementptr %380[%564] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %554, %565 : i64, !llvm.ptr
            %566 = llvm.load %490 : !llvm.ptr -> i64
            %567 = arith.constant 1 : i32
            %569 = arith.extsi %567 : i32 to i64
            %568 = arith.addi %566, %569 : i64
            llvm.store %568, %490 : i64, !llvm.ptr
            cf.br ^bb96
          ^bb98:
          %570 = llvm.load %481 : !llvm.ptr -> i64
          %571 = arith.constant 1 : i32
          %573 = arith.extsi %571 : i32 to i64
          %572 = arith.addi %570, %573 : i64
          llvm.store %572, %481 : i64, !llvm.ptr
          cf.br ^bb93
        ^bb95:
        %574 = llvm.load %443 : !llvm.ptr -> i64
        %575 = arith.constant 1 : i32
        %577 = arith.extsi %575 : i32 to i64
        %576 = arith.addi %574, %577 : i64
        llvm.store %576, %443 : i64, !llvm.ptr
        cf.br ^bb87
      ^bb89:
      %578 = llvm.load %418 : !llvm.ptr -> i64
      %579 = arith.constant 1 : i32
      %581 = arith.extsi %579 : i32 to i64
      %580 = arith.addi %578, %581 : i64
      llvm.store %580, %418 : i64, !llvm.ptr
      cf.br ^bb81
    ^bb83:
    %582 = arith.constant 1 : i32
    %583 = arith.extsi %582 : i32 to i64
    llvm.store %583, %418 : i64, !llvm.ptr
    cf.br ^bb111
    ^bb111:
    %584 = llvm.load %418 : !llvm.ptr -> i64
    %585 = arith.cmpi sle, %584, %370 : i64
    cf.cond_br %585, ^bb112, ^bb113
    ^bb112:
      %586 = arith.constant 1 : i32
      %587 = arith.extsi %586 : i32 to i64
      %588 = llvm.mlir.constant(1 : i64) : i64
      %589 = llvm.alloca %588 x i64 : (i64) -> !llvm.ptr
      llvm.store %587, %589 : i64, !llvm.ptr
      cf.br ^bb114
      ^bb114:
      %590 = llvm.load %589 : !llvm.ptr -> i64
      %591 = llvm.load %418 : !llvm.ptr -> i64
      %592 = arith.constant 1 : i32
      %594 = arith.extsi %592 : i32 to i64
      %593 = arith.addi %591, %594 : i64
      %595 = arith.cmpi sle, %590, %593 : i64
      cf.cond_br %595, ^bb115, ^bb116
      ^bb115:
        %596 = arith.constant 0 : i32
        %597 = arith.extsi %596 : i32 to i64
        %598 = llvm.mlir.constant(1 : i64) : i64
        %599 = llvm.alloca %598 x i64 : (i64) -> !llvm.ptr
        llvm.store %597, %599 : i64, !llvm.ptr
        cf.br ^bb117
        ^bb117:
        %600 = llvm.load %599 : !llvm.ptr -> i64
        %601 = arith.cmpi sle, %600, %370 : i64
        cf.cond_br %601, ^bb118, ^bb119
        ^bb118:
          %603 = llvm.load %418 : !llvm.ptr -> i64
          %604 = arith.muli %603, %372 : i64
          %605 = llvm.load %589 : !llvm.ptr -> i64
          %606 = arith.addi %604, %605 : i64
          %607 = arith.muli %606, %375 : i64
          %608 = arith.constant 0 : i32
          %610 = arith.extsi %608 : i32 to i64
          %609 = arith.addi %607, %610 : i64
          %611 = arith.muli %609, %378 : i64
          %612 = llvm.load %599 : !llvm.ptr -> i64
          %613 = arith.addi %611, %612 : i64
          %614 = llvm.getelementptr %380[%613] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %602 = llvm.load %614 : !llvm.ptr -> i64
          %615 = llvm.load %418 : !llvm.ptr -> i64
          %616 = arith.muli %615, %372 : i64
          %617 = llvm.load %589 : !llvm.ptr -> i64
          %618 = arith.addi %616, %617 : i64
          %619 = arith.muli %618, %378 : i64
          %620 = llvm.load %599 : !llvm.ptr -> i64
          %621 = arith.addi %619, %620 : i64
          %622 = llvm.getelementptr %396[%621] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %602, %622 : i64, !llvm.ptr
          %623 = llvm.load %599 : !llvm.ptr -> i64
          %624 = arith.constant 1 : i32
          %626 = arith.extsi %624 : i32 to i64
          %625 = arith.addi %623, %626 : i64
          llvm.store %625, %599 : i64, !llvm.ptr
          cf.br ^bb117
        ^bb119:
        %627 = llvm.load %589 : !llvm.ptr -> i64
        %628 = arith.constant 1 : i32
        %630 = arith.extsi %628 : i32 to i64
        %629 = arith.addi %627, %630 : i64
        llvm.store %629, %589 : i64, !llvm.ptr
        cf.br ^bb114
      ^bb116:
      %631 = llvm.load %418 : !llvm.ptr -> i64
      %632 = arith.constant 1 : i32
      %634 = arith.extsi %632 : i32 to i64
      %633 = arith.addi %631, %634 : i64
      llvm.store %633, %418 : i64, !llvm.ptr
      cf.br ^bb111
    ^bb113:
    %636 = arith.constant 1 : i32
    %637 = arith.constant 0 : i32
    %638 = arith.extsi %636 : i32 to i64
    %639 = arith.extsi %637 : i32 to i64
    %635 = func.call @dfs438(%638, %639, %370, %380, %389, %396, %372, %375, %378) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> i64
    %640 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %641 = llvm.call @printf(%640, %635) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%396) : (!llvm.ptr) -> ()
    func.call @free(%389) : (!llvm.ptr) -> ()
    func.call @free(%380) : (!llvm.ptr) -> ()
    %645 = arith.constant 0 : i32
    func.return %645 : i32
  }
}