Problem 735

Divisors of 2n^2: F(N) = sum over n <= N of the number of divisors of 2n^2 that are at most n, for N = 10^12. Method: F(N) counts pairs (d, n) with d <= n and d | 2n^2. Writing d = g*a, n = g*b with gcd(a, b) = 1 turns the condition into a | 2g, splitting F into two 3D lattice counts over (a, b, k) with parity and ordering constraints. Mobius inversion over odd e removes the gcd condition, and each count reduces to sums of the divisor summatory function D(x) and its partial sums via the hyperbola method, with D(x) for x <= 10^8 served from a sieved prefix table of tau. Runs in a few seconds.

Answer174848216767932
Output174848216767932
StatusPASS
Native helperno
Runtime14410 ms
Peak memory399584 KB
Time complexityO(n^2) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log log n)
Space complexityO(n)O(n)
ApproachFlow solutionMobius sieve
VerdictSuboptimal

Flow source

# Project Euler 735
# Divisors of 2n^2: F(N) = sum over n <= N of the number of divisors of
# 2n^2 that are at most n, for N = 10^12.
# Method: F(N) counts pairs (d, n) with d <= n and d | 2n^2. Writing
# d = g*a, n = g*b with gcd(a, b) = 1 turns the condition into a | 2g,
# splitting F into two 3D lattice counts over (a, b, k) with parity and
# ordering constraints. Mobius inversion over odd e removes the gcd
# condition, and each count reduces to sums of the divisor summatory
# function D(x) and its partial sums via the hyperbola method, with
# D(x) for x <= 10^8 served from a sieved prefix table of tau. Runs in
# a few seconds.

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

function isqrt(x: i64) -> i64 {
    if x <= 0 { return 0 }
    let mut r: i64 = sqrt(x as f64) as i64
    while r > 0 && r * r > x { r = r - 1 }
    while (r + 1) * (r + 1) <= x { r = r + 1 }
    return r
}

# Divisor summatory D(x) = sum_{k<=x} floor(x/k), hyperbola method.
function bigd(x: i64) -> i64 {
    if x <= 0 { return 0 }
    let r: i64 = isqrt(x)
    let mut s: i64 = 0
    for i in 1..(r + 1) { s = s + x / i }
    return 2 * s - r * r
}

function dval(x: i64, tab: ptr<i32>, y: i64) -> i64 {
    if x <= 0 { return 0 }
    if x <= y { return tab[x] as i64 }
    return bigd(x)
}

# P(x, l) = sum_{b=1..l} floor(x/b)
function pval(x: i64, l: i64, tab: ptr<i32>, y: i64) -> i64 {
    if l <= 0 || x <= 0 { return 0 }
    if l >= x { return dval(x, tab, y) }
    if l * l <= x {
        let mut s: i64 = 0
        for b in 1..(l + 1) { s = s + x / b }
        return s
    }
    let k: i64 = x / (l + 1)
    let mut s: i64 = dval(x, tab, y)
    for i in 1..(k + 1) { s = s - (x / i - l) }
    return s
}

# T1(m) = #{(a,b,k): a odd, a <= b, a*b*k <= m}
function t1(m: i64, tab: ptr<i32>, y: i64) -> i64 {
    let mut s: i64 = 0
    let mut a: i64 = 1
    while a * a <= m {
        let x: i64 = m / a
        s = s + dval(x, tab, y) - pval(x, a - 1, tab, y)
        a = a + 2
    }
    return s
}

# T2(m) = #{(c,b,k): b odd, 2c < b, c*b*k <= m}
function t2(m: i64, tab: ptr<i32>, y: i64) -> i64 {
    let mut s: i64 = 0
    let mut c: i64 = 1
    while c * (2 * c + 1) <= m {
        let x: i64 = m / c
        let x2: i64 = x / 2
        s = s + dval(x, tab, y) - dval(x2, tab, y)
        s = s - (pval(x, 2 * c, tab, y) - pval(x2, c, tab, y))
        c = c + 1
    }
    return s
}

function solve(n: i64, y: i64) -> i64 {
    # Prefix sums of tau up to y; D(1e8) < 2^31 so i32 holds each entry.
    let tab: ptr<i32> = calloc(y + 1, 4)
    if tab == null { return -1 }
    for d in 1..(y + 1) {
        let mut mm: i64 = d
        while mm <= y {
            tab[mm] = tab[mm] + 1
            mm = mm + d
        }
    }
    let mut acc: i64 = 0
    for i in 1..(y + 1) {
        acc = acc + (tab[i] as i64)
        tab[i] = acc as i32
    }

    # Mobius values up to sqrt(n).
    let lim: i64 = isqrt(n)
    let mu: ptr<i32> = calloc(lim + 1, 4)
    let comp: ptr<i32> = calloc(lim + 1, 4)
    if mu == null || comp == null { return -1 }
    for i in 1..(lim + 1) { mu[i] = 1 }
    let mut p: i64 = 2
    while p <= lim {
        if comp[p] == 0 {
            let mut m: i64 = p
            while m <= lim {
                if m > p { comp[m] = 1 }
                mu[m] = 0 - mu[m]
                m = m + p
            }
            let p2: i64 = p * p
            let mut m2: i64 = p2
            while m2 <= lim {
                mu[m2] = 0
                m2 = m2 + p2
            }
        }
        p = p + 1
    }

    let mut total: i64 = 0
    let mut e: i64 = 1
    while e * e <= n {
        let mv: i64 = mu[e] as i64
        if mv != 0 {
            let m: i64 = n / (e * e)
            total = total + mv * (t1(m, tab, y) + t2(m, tab, y))
        }
        e = e + 2
    }
    free(tab)
    free(mu)
    free(comp)
    return total
}

function main() -> i32 {
    printf("%lld\n", solve(1000000000000, 100000000))
    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 isqrt_i64(int64_t x);
int64_t bigd_i64(int64_t x);
int64_t dval_i64_ptr_i32_i64(int64_t x, int32_t* tab, int64_t y);
int64_t pval_i64_i64_ptr_i32_i64(int64_t x, int64_t l, int32_t* tab, int64_t y);
int64_t t1_i64_ptr_i32_i64(int64_t m, int32_t* tab, int64_t y);
int64_t t2_i64_ptr_i32_i64(int64_t m, int32_t* tab, int64_t y);
int64_t solve_i64_i64(int64_t n, int64_t y);
int32_t main(void);




int64_t isqrt_i64(int64_t x) {
    if (x <= 0) {
        return 0;
    }
    int64_t r = ((int64_t)(sqrt(((double)(x)))));
    while ((r > 0 && (r * r) > x)) {
        r = (r - 1);
    }
    while (((r + 1) * (r + 1)) <= x) {
        r = (r + 1);
    }
    return r;
}

int64_t bigd_i64(int64_t x) {
    if (x <= 0) {
        return 0;
    }
    int64_t r = isqrt_i64(x);
    int64_t s = 0;
    int32_t __flow_step_1 = 1;
    for (int32_t i = 1; (1 <= (r + 1)) ? i < (r + 1) : i > (r + 1); i += (1 <= (r + 1)) ? 1 : -1) {
        s = (s + FLOW_CHECKED_DIV((x), (i)));
    }
    return ((2 * s) - (r * r));
}

int64_t dval_i64_ptr_i32_i64(int64_t x, int32_t* tab, int64_t y) {
    if (x <= 0) {
        return 0;
    }
    if (x <= y) {
        return ((int64_t)(tab[x]));
    }
    return bigd_i64(x);
}

int64_t pval_i64_i64_ptr_i32_i64(int64_t x, int64_t l, int32_t* tab, int64_t y) {
    if ((l <= 0 || x <= 0)) {
        return 0;
    }
    if (l >= x) {
        return dval_i64_ptr_i32_i64(x, tab, y);
    }
    if ((l * l) <= x) {
        int64_t s = 0;
        int32_t __flow_step_2 = 1;
        for (int32_t b = 1; (1 <= (l + 1)) ? b < (l + 1) : b > (l + 1); b += (1 <= (l + 1)) ? 1 : -1) {
            s = (s + FLOW_CHECKED_DIV((x), (b)));
        }
        return s;
    }
    int64_t k = FLOW_CHECKED_DIV((x), ((l + 1)));
    int64_t s = dval_i64_ptr_i32_i64(x, tab, y);
    int32_t __flow_step_3 = 1;
    for (int32_t i = 1; (1 <= (k + 1)) ? i < (k + 1) : i > (k + 1); i += (1 <= (k + 1)) ? 1 : -1) {
        s = (s - (FLOW_CHECKED_DIV((x), (i)) - l));
    }
    return s;
}

int64_t t1_i64_ptr_i32_i64(int64_t m, int32_t* tab, int64_t y) {
    int64_t s = 0;
    int64_t a = 1;
    while ((a * a) <= m) {
        int64_t x = FLOW_CHECKED_DIV((m), (a));
        s = ((s + dval_i64_ptr_i32_i64(x, tab, y)) - pval_i64_i64_ptr_i32_i64(x, (a - 1), tab, y));
        a = (a + 2);
    }
    return s;
}

int64_t t2_i64_ptr_i32_i64(int64_t m, int32_t* tab, int64_t y) {
    int64_t s = 0;
    int64_t c = 1;
    while ((c * ((2 * c) + 1)) <= m) {
        int64_t x = FLOW_CHECKED_DIV((m), (c));
        int64_t x2 = FLOW_CHECKED_DIV((x), (2));
        s = ((s + dval_i64_ptr_i32_i64(x, tab, y)) - dval_i64_ptr_i32_i64(x2, tab, y));
        s = (s - (pval_i64_i64_ptr_i32_i64(x, (2 * c), tab, y) - pval_i64_i64_ptr_i32_i64(x2, c, tab, y)));
        c = (c + 1);
    }
    return s;
}

int64_t solve_i64_i64(int64_t n, int64_t y) {
    int32_t* tab = (int32_t*)(calloc((y + 1), 4));
    if (tab == NULL) {
        return (-1);
    }
    int32_t __flow_step_4 = 1;
    for (int32_t d = 1; (1 <= (y + 1)) ? d < (y + 1) : d > (y + 1); d += (1 <= (y + 1)) ? 1 : -1) {
        int64_t mm = d;
        while (mm <= y) {
            tab[mm] = (tab[mm] + 1);
            mm = (mm + d);
        }
    }
    int64_t acc = 0;
    int32_t __flow_step_5 = 1;
    for (int32_t i = 1; (1 <= (y + 1)) ? i < (y + 1) : i > (y + 1); i += (1 <= (y + 1)) ? 1 : -1) {
        acc = (acc + ((int64_t)(tab[i])));
        tab[i] = ((int32_t)(acc));
    }
    int64_t lim = isqrt_i64(n);
    int32_t* mu = (int32_t*)(calloc((lim + 1), 4));
    int32_t* comp = (int32_t*)(calloc((lim + 1), 4));
    if ((mu == NULL || comp == NULL)) {
        return (-1);
    }
    int32_t __flow_step_6 = 1;
    for (int32_t i = 1; (1 <= (lim + 1)) ? i < (lim + 1) : i > (lim + 1); i += (1 <= (lim + 1)) ? 1 : -1) {
        mu[i] = 1;
    }
    int64_t p = 2;
    while (p <= lim) {
        if (comp[p] == 0) {
            int64_t m = p;
            while (m <= lim) {
                if (m > p) {
                    comp[m] = 1;
                }
                mu[m] = (0 - mu[m]);
                m = (m + p);
            }
            int64_t p2 = (p * p);
            int64_t m2 = p2;
            while (m2 <= lim) {
                mu[m2] = 0;
                m2 = (m2 + p2);
            }
        }
        p = (p + 1);
    }
    int64_t total = 0;
    int64_t e = 1;
    while ((e * e) <= n) {
        int64_t mv = ((int64_t)(mu[e]));
        if (mv != 0) {
            int64_t m = FLOW_CHECKED_DIV((n), ((e * e)));
            total = (total + (mv * (t1_i64_ptr_i32_i64(m, tab, y) + t2_i64_ptr_i32_i64(m, tab, y))));
        }
        e = (e + 2);
    }
    free(tab);
    free(mu);
    free(comp);
    return total;
}

int32_t main(void) {
    printf("%lld\n", solve_i64_i64(1000000000000, 100000000));
    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 private @sqrt(f64) -> f64
  func.func @isqrt(%arg0: i64) -> i64 {
    %0 = arith.constant 0 : i32
    %2 = arith.extsi %0 : i32 to i64
    %1 = arith.cmpi sle, %arg0, %2 : i64
    cf.cond_br %1, ^bb0, ^bb1
    ^bb0:
      %3 = arith.constant 0 : i32
      %4 = arith.extsi %3 : i32 to i64
      func.return %4 : i64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %5 = arith.sitofp %arg0 : i64 to f64
    %6 = math.sqrt %5 : f64
    %7 = arith.fptosi %6 : f64 to i64
    %8 = llvm.mlir.constant(1 : i64) : i64
    %9 = llvm.alloca %8 x i64 : (i64) -> !llvm.ptr
    llvm.store %7, %9 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %10 = llvm.load %9 : !llvm.ptr -> i64
    %11 = arith.constant 0 : i32
    %13 = arith.extsi %11 : i32 to i64
    %12 = arith.cmpi sgt, %10, %13 : i64
    %14 = scf.if %12 -> (i1) {
      %15 = llvm.load %9 : !llvm.ptr -> i64
      %16 = llvm.load %9 : !llvm.ptr -> i64
      %17 = arith.muli %15, %16 : i64
      %18 = arith.cmpi sgt, %17, %arg0 : i64
      scf.yield %18 : i1
    } else {
      %19 = arith.constant false
      scf.yield %19 : i1
    }
    cf.cond_br %14, ^bb4, ^bb5
    ^bb4:
      %20 = llvm.load %9 : !llvm.ptr -> i64
      %21 = arith.constant 1 : i32
      %23 = arith.extsi %21 : i32 to i64
      %22 = arith.subi %20, %23 : i64
      llvm.store %22, %9 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    cf.br ^bb6
    ^bb6:
    %24 = llvm.load %9 : !llvm.ptr -> i64
    %25 = arith.constant 1 : i32
    %27 = arith.extsi %25 : i32 to i64
    %26 = arith.addi %24, %27 : i64
    %28 = llvm.load %9 : !llvm.ptr -> i64
    %29 = arith.constant 1 : i32
    %31 = arith.extsi %29 : i32 to i64
    %30 = arith.addi %28, %31 : i64
    %32 = arith.muli %26, %30 : i64
    %33 = arith.cmpi sle, %32, %arg0 : i64
    cf.cond_br %33, ^bb7, ^bb8
    ^bb7:
      %34 = llvm.load %9 : !llvm.ptr -> i64
      %35 = arith.constant 1 : i32
      %37 = arith.extsi %35 : i32 to i64
      %36 = arith.addi %34, %37 : i64
      llvm.store %36, %9 : i64, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %38 = llvm.load %9 : !llvm.ptr -> i64
    func.return %38 : i64
  }
  func.func @bigd(%arg0: i64) -> i64 {
    %39 = arith.constant 0 : i32
    %41 = arith.extsi %39 : i32 to i64
    %40 = arith.cmpi sle, %arg0, %41 : i64
    cf.cond_br %40, ^bb9, ^bb10
    ^bb9:
      %42 = arith.constant 0 : i32
      %43 = arith.extsi %42 : i32 to i64
      func.return %43 : i64
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %44 = func.call @isqrt(%arg0) : (i64) -> i64
    %45 = arith.constant 0 : i32
    %46 = arith.extsi %45 : i32 to i64
    %47 = llvm.mlir.constant(1 : i64) : i64
    %48 = llvm.alloca %47 x i64 : (i64) -> !llvm.ptr
    llvm.store %46, %48 : i64, !llvm.ptr
    %49 = arith.constant 1 : i32
    %50 = arith.constant 1 : i32
    %52 = arith.extsi %50 : i32 to i64
    %51 = arith.addi %44, %52 : i64
    %53 = arith.index_cast %49 : i32 to index
    %54 = arith.index_cast %51 : i32 to index
    %56 = arith.constant 1 : index
    %57 = arith.constant -1 : index
    %58 = arith.cmpi sle, %53, %54 : index
    %55 = arith.select %58, %56, %57 : index
    cf.br ^bb12(%53 : index)
    ^bb12(%59: index):
    %60 = arith.cmpi slt, %59, %54 : index
    %61 = arith.cmpi sgt, %59, %54 : index
    %62 = arith.select %58, %60, %61 : i1
    cf.cond_br %62, ^bb13(%59 : index), ^bb14(%59 : index)
    ^bb13(%63: index):
      %64 = llvm.load %48 : !llvm.ptr -> i64
      %66 = arith.trunci %arg0 : i64 to i32
      %67 = arith.index_cast %63 : index to i32
      %65 = arith.divsi %66, %67 : i32
      %69 = arith.extsi %65 : i32 to i64
      %68 = arith.addi %64, %69 : i64
      llvm.store %68, %48 : i64, !llvm.ptr
      %70 = arith.addi %63, %55 : index
      cf.br ^bb12(%70 : index)
    ^bb14(%71: index):
    %72 = arith.constant 2 : i32
    %73 = llvm.load %48 : !llvm.ptr -> i64
    %75 = arith.extsi %72 : i32 to i64
    %74 = arith.muli %75, %73 : i64
    %76 = arith.muli %44, %44 : i64
    %77 = arith.subi %74, %76 : i64
    func.return %77 : i64
  }
  func.func @dval(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64) -> i64 {
    %78 = arith.constant 0 : i32
    %80 = arith.extsi %78 : i32 to i64
    %79 = arith.cmpi sle, %arg0, %80 : i64
    cf.cond_br %79, ^bb15, ^bb16
    ^bb15:
      %81 = arith.constant 0 : i32
      %82 = arith.extsi %81 : i32 to i64
      func.return %82 : i64
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %83 = arith.cmpi sle, %arg0, %arg2 : i64
    cf.cond_br %83, ^bb18, ^bb19
    ^bb18:
      %85 = llvm.getelementptr %arg1[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %84 = llvm.load %85 : !llvm.ptr -> i32
      %86 = arith.extsi %84 : i32 to i64
      func.return %86 : i64
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %87 = func.call @bigd(%arg0) : (i64) -> i64
    func.return %87 : i64
  }
  func.func @pval(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: i64) -> i64 {
    %88 = arith.constant 0 : i32
    %90 = arith.extsi %88 : i32 to i64
    %89 = arith.cmpi sle, %arg1, %90 : i64
    %91 = scf.if %89 -> (i1) {
      %92 = arith.constant true
      scf.yield %92 : i1
    } else {
      %93 = arith.constant 0 : i32
      %95 = arith.extsi %93 : i32 to i64
      %94 = arith.cmpi sle, %arg0, %95 : i64
      scf.yield %94 : i1
    }
    cf.cond_br %91, ^bb21, ^bb22
    ^bb21:
      %96 = arith.constant 0 : i32
      %97 = arith.extsi %96 : i32 to i64
      func.return %97 : i64
    ^bb22:
      cf.br ^bb23
    ^bb23:
    %98 = arith.cmpi sge, %arg1, %arg0 : i64
    cf.cond_br %98, ^bb24, ^bb25
    ^bb24:
      %99 = func.call @dval(%arg0, %arg2, %arg3) : (i64, !llvm.ptr, i64) -> i64
      func.return %99 : i64
    ^bb25:
      cf.br ^bb26
    ^bb26:
    %100 = arith.muli %arg1, %arg1 : i64
    %101 = arith.cmpi sle, %100, %arg0 : i64
    cf.cond_br %101, ^bb27, ^bb28
    ^bb27:
      %102 = arith.constant 0 : i32
      %103 = arith.extsi %102 : i32 to i64
      %104 = llvm.mlir.constant(1 : i64) : i64
      %105 = llvm.alloca %104 x i64 : (i64) -> !llvm.ptr
      llvm.store %103, %105 : i64, !llvm.ptr
      %106 = arith.constant 1 : i32
      %107 = arith.constant 1 : i32
      %109 = arith.extsi %107 : i32 to i64
      %108 = arith.addi %arg1, %109 : i64
      %110 = arith.index_cast %106 : i32 to index
      %111 = arith.index_cast %108 : i32 to index
      %113 = arith.constant 1 : index
      %114 = arith.constant -1 : index
      %115 = arith.cmpi sle, %110, %111 : index
      %112 = arith.select %115, %113, %114 : index
      cf.br ^bb30(%110 : index)
      ^bb30(%116: index):
      %117 = arith.cmpi slt, %116, %111 : index
      %118 = arith.cmpi sgt, %116, %111 : index
      %119 = arith.select %115, %117, %118 : i1
      cf.cond_br %119, ^bb31(%116 : index), ^bb32(%116 : index)
      ^bb31(%120: index):
        %121 = llvm.load %105 : !llvm.ptr -> i64
        %123 = arith.trunci %arg0 : i64 to i32
        %124 = arith.index_cast %120 : index to i32
        %122 = arith.divsi %123, %124 : i32
        %126 = arith.extsi %122 : i32 to i64
        %125 = arith.addi %121, %126 : i64
        llvm.store %125, %105 : i64, !llvm.ptr
        %127 = arith.addi %120, %112 : index
        cf.br ^bb30(%127 : index)
      ^bb32(%128: index):
      %129 = llvm.load %105 : !llvm.ptr -> i64
      func.return %129 : i64
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %130 = arith.constant 1 : i32
    %132 = arith.extsi %130 : i32 to i64
    %131 = arith.addi %arg1, %132 : i64
    %133 = arith.divsi %arg0, %131 : i64
    %134 = func.call @dval(%arg0, %arg2, %arg3) : (i64, !llvm.ptr, i64) -> i64
    %135 = llvm.mlir.constant(1 : i64) : i64
    %136 = llvm.alloca %135 x i64 : (i64) -> !llvm.ptr
    llvm.store %134, %136 : i64, !llvm.ptr
    %137 = arith.constant 1 : i32
    %138 = arith.constant 1 : i32
    %140 = arith.extsi %138 : i32 to i64
    %139 = arith.addi %133, %140 : i64
    %141 = arith.index_cast %137 : i32 to index
    %142 = arith.index_cast %139 : i32 to index
    %144 = arith.constant 1 : index
    %145 = arith.constant -1 : index
    %146 = arith.cmpi sle, %141, %142 : index
    %143 = arith.select %146, %144, %145 : index
    cf.br ^bb33(%141 : index)
    ^bb33(%147: index):
    %148 = arith.cmpi slt, %147, %142 : index
    %149 = arith.cmpi sgt, %147, %142 : index
    %150 = arith.select %146, %148, %149 : i1
    cf.cond_br %150, ^bb34(%147 : index), ^bb35(%147 : index)
    ^bb34(%151: index):
      %152 = llvm.load %136 : !llvm.ptr -> i64
      %154 = arith.trunci %arg0 : i64 to i32
      %155 = arith.index_cast %151 : index to i32
      %153 = arith.divsi %154, %155 : i32
      %157 = arith.extsi %153 : i32 to i64
      %156 = arith.subi %157, %arg1 : i64
      %158 = arith.subi %152, %156 : i64
      llvm.store %158, %136 : i64, !llvm.ptr
      %159 = arith.addi %151, %143 : index
      cf.br ^bb33(%159 : index)
    ^bb35(%160: index):
    %161 = llvm.load %136 : !llvm.ptr -> i64
    func.return %161 : i64
  }
  func.func @t1(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64) -> i64 {
    %162 = arith.constant 0 : i32
    %163 = arith.extsi %162 : i32 to i64
    %164 = llvm.mlir.constant(1 : i64) : i64
    %165 = llvm.alloca %164 x i64 : (i64) -> !llvm.ptr
    llvm.store %163, %165 : i64, !llvm.ptr
    %166 = arith.constant 1 : i32
    %167 = arith.extsi %166 : i32 to i64
    %168 = llvm.mlir.constant(1 : i64) : i64
    %169 = llvm.alloca %168 x i64 : (i64) -> !llvm.ptr
    llvm.store %167, %169 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %170 = llvm.load %169 : !llvm.ptr -> i64
    %171 = llvm.load %169 : !llvm.ptr -> i64
    %172 = arith.muli %170, %171 : i64
    %173 = arith.cmpi sle, %172, %arg0 : i64
    cf.cond_br %173, ^bb37, ^bb38
    ^bb37:
      %174 = llvm.load %169 : !llvm.ptr -> i64
      %175 = arith.divsi %arg0, %174 : i64
      %176 = llvm.load %165 : !llvm.ptr -> i64
      %177 = func.call @dval(%175, %arg1, %arg2) : (i64, !llvm.ptr, i64) -> i64
      %178 = arith.addi %176, %177 : i64
      %180 = llvm.load %169 : !llvm.ptr -> i64
      %181 = arith.constant 1 : i32
      %183 = arith.extsi %181 : i32 to i64
      %182 = arith.subi %180, %183 : i64
      %179 = func.call @pval(%175, %182, %arg1, %arg2) : (i64, i64, !llvm.ptr, i64) -> i64
      %184 = arith.subi %178, %179 : i64
      llvm.store %184, %165 : i64, !llvm.ptr
      %185 = llvm.load %169 : !llvm.ptr -> i64
      %186 = arith.constant 2 : i32
      %188 = arith.extsi %186 : i32 to i64
      %187 = arith.addi %185, %188 : i64
      llvm.store %187, %169 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %189 = llvm.load %165 : !llvm.ptr -> i64
    func.return %189 : i64
  }
  func.func @t2(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64) -> i64 {
    %190 = arith.constant 0 : i32
    %191 = arith.extsi %190 : i32 to i64
    %192 = llvm.mlir.constant(1 : i64) : i64
    %193 = llvm.alloca %192 x i64 : (i64) -> !llvm.ptr
    llvm.store %191, %193 : i64, !llvm.ptr
    %194 = arith.constant 1 : i32
    %195 = arith.extsi %194 : i32 to i64
    %196 = llvm.mlir.constant(1 : i64) : i64
    %197 = llvm.alloca %196 x i64 : (i64) -> !llvm.ptr
    llvm.store %195, %197 : i64, !llvm.ptr
    cf.br ^bb39
    ^bb39:
    %198 = llvm.load %197 : !llvm.ptr -> i64
    %199 = arith.constant 2 : i32
    %200 = llvm.load %197 : !llvm.ptr -> i64
    %202 = arith.extsi %199 : i32 to i64
    %201 = arith.muli %202, %200 : i64
    %203 = arith.constant 1 : i32
    %205 = arith.extsi %203 : i32 to i64
    %204 = arith.addi %201, %205 : i64
    %206 = arith.muli %198, %204 : i64
    %207 = arith.cmpi sle, %206, %arg0 : i64
    cf.cond_br %207, ^bb40, ^bb41
    ^bb40:
      %208 = llvm.load %197 : !llvm.ptr -> i64
      %209 = arith.divsi %arg0, %208 : i64
      %210 = arith.constant 2 : i32
      %212 = arith.extsi %210 : i32 to i64
      %211 = arith.divsi %209, %212 : i64
      %213 = llvm.load %193 : !llvm.ptr -> i64
      %214 = func.call @dval(%209, %arg1, %arg2) : (i64, !llvm.ptr, i64) -> i64
      %215 = arith.addi %213, %214 : i64
      %216 = func.call @dval(%211, %arg1, %arg2) : (i64, !llvm.ptr, i64) -> i64
      %217 = arith.subi %215, %216 : i64
      llvm.store %217, %193 : i64, !llvm.ptr
      %218 = llvm.load %193 : !llvm.ptr -> i64
      %220 = arith.constant 2 : i32
      %221 = llvm.load %197 : !llvm.ptr -> i64
      %223 = arith.extsi %220 : i32 to i64
      %222 = arith.muli %223, %221 : i64
      %219 = func.call @pval(%209, %222, %arg1, %arg2) : (i64, i64, !llvm.ptr, i64) -> i64
      %225 = llvm.load %197 : !llvm.ptr -> i64
      %224 = func.call @pval(%211, %225, %arg1, %arg2) : (i64, i64, !llvm.ptr, i64) -> i64
      %226 = arith.subi %219, %224 : i64
      %227 = arith.subi %218, %226 : i64
      llvm.store %227, %193 : i64, !llvm.ptr
      %228 = llvm.load %197 : !llvm.ptr -> i64
      %229 = arith.constant 1 : i32
      %231 = arith.extsi %229 : i32 to i64
      %230 = arith.addi %228, %231 : i64
      llvm.store %230, %197 : i64, !llvm.ptr
      cf.br ^bb39
    ^bb41:
    %232 = llvm.load %193 : !llvm.ptr -> i64
    func.return %232 : i64
  }
  func.func @solve(%arg0: i64, %arg1: i64) -> i64 {
    %234 = arith.constant 1 : i32
    %236 = arith.extsi %234 : i32 to i64
    %235 = arith.addi %arg1, %236 : i64
    %237 = arith.constant 4 : i32
    %238 = arith.extsi %237 : i32 to i64
    %233 = func.call @calloc(%235, %238) : (i64, i64) -> !llvm.ptr
    %239 = llvm.mlir.zero : !llvm.ptr
    %240 = llvm.icmp "eq" %233, %239 : !llvm.ptr
    cf.cond_br %240, ^bb42, ^bb43
    ^bb42:
      %241 = arith.constant 1 : i32
      %243 = arith.constant 0 : i32
      %242 = arith.subi %243, %241 : i32
      %244 = arith.extsi %242 : i32 to i64
      func.return %244 : i64
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %245 = arith.constant 1 : i32
    %246 = arith.constant 1 : i32
    %248 = arith.extsi %246 : i32 to i64
    %247 = arith.addi %arg1, %248 : i64
    %249 = arith.index_cast %245 : i32 to index
    %250 = arith.index_cast %247 : i32 to index
    %252 = arith.constant 1 : index
    %253 = arith.constant -1 : index
    %254 = arith.cmpi sle, %249, %250 : index
    %251 = arith.select %254, %252, %253 : index
    cf.br ^bb45(%249 : index)
    ^bb45(%255: index):
    %256 = arith.cmpi slt, %255, %250 : index
    %257 = arith.cmpi sgt, %255, %250 : index
    %258 = arith.select %254, %256, %257 : i1
    cf.cond_br %258, ^bb46(%255 : index), ^bb47(%255 : index)
    ^bb46(%259: index):
      %260 = arith.index_cast %259 : index to i64
      %261 = llvm.mlir.constant(1 : i64) : i64
      %262 = llvm.alloca %261 x i64 : (i64) -> !llvm.ptr
      llvm.store %260, %262 : i64, !llvm.ptr
      cf.br ^bb48
      ^bb48:
      %263 = llvm.load %262 : !llvm.ptr -> i64
      %264 = arith.cmpi sle, %263, %arg1 : i64
      cf.cond_br %264, ^bb49, ^bb50
      ^bb49:
        %266 = llvm.load %262 : !llvm.ptr -> i64
        %267 = llvm.getelementptr %233[%266] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %265 = llvm.load %267 : !llvm.ptr -> i32
        %268 = arith.constant 1 : i32
        %269 = arith.addi %265, %268 : i32
        %270 = llvm.load %262 : !llvm.ptr -> i64
        %271 = llvm.getelementptr %233[%270] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %269, %271 : i32, !llvm.ptr
        %272 = llvm.load %262 : !llvm.ptr -> i64
        %274 = arith.trunci %272 : i64 to i32
        %275 = arith.index_cast %259 : index to i32
        %273 = arith.addi %274, %275 : i32
        %276 = arith.extsi %273 : i32 to i64
        llvm.store %276, %262 : i64, !llvm.ptr
        cf.br ^bb48
      ^bb50:
      %277 = arith.addi %259, %251 : index
      cf.br ^bb45(%277 : index)
    ^bb47(%278: index):
    %279 = arith.constant 0 : i32
    %280 = arith.extsi %279 : i32 to i64
    %281 = llvm.mlir.constant(1 : i64) : i64
    %282 = llvm.alloca %281 x i64 : (i64) -> !llvm.ptr
    llvm.store %280, %282 : i64, !llvm.ptr
    %283 = arith.constant 1 : i32
    %284 = arith.constant 1 : i32
    %286 = arith.extsi %284 : i32 to i64
    %285 = arith.addi %arg1, %286 : i64
    %287 = arith.index_cast %283 : i32 to index
    %288 = arith.index_cast %285 : i32 to index
    %290 = arith.constant 1 : index
    %291 = arith.constant -1 : index
    %292 = arith.cmpi sle, %287, %288 : index
    %289 = arith.select %292, %290, %291 : index
    cf.br ^bb51(%287 : index)
    ^bb51(%293: index):
    %294 = arith.cmpi slt, %293, %288 : index
    %295 = arith.cmpi sgt, %293, %288 : index
    %296 = arith.select %292, %294, %295 : i1
    cf.cond_br %296, ^bb52(%293 : index), ^bb53(%293 : index)
    ^bb52(%297: index):
      %298 = llvm.load %282 : !llvm.ptr -> i64
      %300 = arith.index_cast %297 : index to i64
      %301 = llvm.getelementptr %233[%300] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %299 = llvm.load %301 : !llvm.ptr -> i32
      %302 = arith.extsi %299 : i32 to i64
      %303 = arith.addi %298, %302 : i64
      llvm.store %303, %282 : i64, !llvm.ptr
      %304 = llvm.load %282 : !llvm.ptr -> i64
      %305 = arith.trunci %304 : i64 to i32
      %306 = arith.index_cast %297 : index to i64
      %307 = llvm.getelementptr %233[%306] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %305, %307 : i32, !llvm.ptr
      %308 = arith.addi %297, %289 : index
      cf.br ^bb51(%308 : index)
    ^bb53(%309: index):
    %310 = func.call @isqrt(%arg0) : (i64) -> i64
    %312 = arith.constant 1 : i32
    %314 = arith.extsi %312 : i32 to i64
    %313 = arith.addi %310, %314 : i64
    %315 = arith.constant 4 : i32
    %316 = arith.extsi %315 : i32 to i64
    %311 = func.call @calloc(%313, %316) : (i64, i64) -> !llvm.ptr
    %318 = arith.constant 1 : i32
    %320 = arith.extsi %318 : i32 to i64
    %319 = arith.addi %310, %320 : i64
    %321 = arith.constant 4 : i32
    %322 = arith.extsi %321 : i32 to i64
    %317 = func.call @calloc(%319, %322) : (i64, i64) -> !llvm.ptr
    %323 = llvm.mlir.zero : !llvm.ptr
    %324 = llvm.icmp "eq" %311, %323 : !llvm.ptr
    %325 = scf.if %324 -> (i1) {
      %326 = arith.constant true
      scf.yield %326 : i1
    } else {
      %327 = llvm.mlir.zero : !llvm.ptr
      %328 = llvm.icmp "eq" %317, %327 : !llvm.ptr
      scf.yield %328 : i1
    }
    cf.cond_br %325, ^bb54, ^bb55
    ^bb54:
      %329 = arith.constant 1 : i32
      %331 = arith.constant 0 : i32
      %330 = arith.subi %331, %329 : i32
      %332 = arith.extsi %330 : i32 to i64
      func.return %332 : i64
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %333 = arith.constant 1 : i32
    %334 = arith.constant 1 : i32
    %336 = arith.extsi %334 : i32 to i64
    %335 = arith.addi %310, %336 : i64
    %337 = arith.index_cast %333 : i32 to index
    %338 = arith.index_cast %335 : i32 to index
    %340 = arith.constant 1 : index
    %341 = arith.constant -1 : index
    %342 = arith.cmpi sle, %337, %338 : index
    %339 = arith.select %342, %340, %341 : index
    cf.br ^bb57(%337 : index)
    ^bb57(%343: index):
    %344 = arith.cmpi slt, %343, %338 : index
    %345 = arith.cmpi sgt, %343, %338 : index
    %346 = arith.select %342, %344, %345 : i1
    cf.cond_br %346, ^bb58(%343 : index), ^bb59(%343 : index)
    ^bb58(%347: index):
      %348 = arith.constant 1 : i32
      %349 = arith.index_cast %347 : index to i64
      %350 = llvm.getelementptr %311[%349] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %348, %350 : i32, !llvm.ptr
      %351 = arith.addi %347, %339 : index
      cf.br ^bb57(%351 : index)
    ^bb59(%352: index):
    %353 = arith.constant 2 : i32
    %354 = arith.extsi %353 : i32 to i64
    %355 = llvm.mlir.constant(1 : i64) : i64
    %356 = llvm.alloca %355 x i64 : (i64) -> !llvm.ptr
    llvm.store %354, %356 : i64, !llvm.ptr
    cf.br ^bb60
    ^bb60:
    %357 = llvm.load %356 : !llvm.ptr -> i64
    %358 = arith.cmpi sle, %357, %310 : i64
    cf.cond_br %358, ^bb61, ^bb62
    ^bb61:
      %360 = llvm.load %356 : !llvm.ptr -> i64
      %361 = llvm.getelementptr %317[%360] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %359 = llvm.load %361 : !llvm.ptr -> i32
      %362 = arith.constant 0 : i32
      %363 = arith.cmpi eq, %359, %362 : i32
      cf.cond_br %363, ^bb63, ^bb64
      ^bb63:
        %364 = llvm.load %356 : !llvm.ptr -> i64
        %365 = llvm.mlir.constant(1 : i64) : i64
        %366 = llvm.alloca %365 x i64 : (i64) -> !llvm.ptr
        llvm.store %364, %366 : i64, !llvm.ptr
        cf.br ^bb66
        ^bb66:
        %367 = llvm.load %366 : !llvm.ptr -> i64
        %368 = arith.cmpi sle, %367, %310 : i64
        cf.cond_br %368, ^bb67, ^bb68
        ^bb67:
          %369 = llvm.load %366 : !llvm.ptr -> i64
          %370 = llvm.load %356 : !llvm.ptr -> i64
          %371 = arith.cmpi sgt, %369, %370 : i64
          cf.cond_br %371, ^bb69, ^bb70
          ^bb69:
            %372 = arith.constant 1 : i32
            %373 = llvm.load %366 : !llvm.ptr -> i64
            %374 = llvm.getelementptr %317[%373] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            llvm.store %372, %374 : i32, !llvm.ptr
            cf.br ^bb71
          ^bb70:
            cf.br ^bb71
          ^bb71:
          %375 = arith.constant 0 : i32
          %377 = llvm.load %366 : !llvm.ptr -> i64
          %378 = llvm.getelementptr %311[%377] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %376 = llvm.load %378 : !llvm.ptr -> i32
          %379 = arith.subi %375, %376 : i32
          %380 = llvm.load %366 : !llvm.ptr -> i64
          %381 = llvm.getelementptr %311[%380] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %379, %381 : i32, !llvm.ptr
          %382 = llvm.load %366 : !llvm.ptr -> i64
          %383 = llvm.load %356 : !llvm.ptr -> i64
          %384 = arith.addi %382, %383 : i64
          llvm.store %384, %366 : i64, !llvm.ptr
          cf.br ^bb66
        ^bb68:
        %385 = llvm.load %356 : !llvm.ptr -> i64
        %386 = llvm.load %356 : !llvm.ptr -> i64
        %387 = arith.muli %385, %386 : i64
        %388 = llvm.mlir.constant(1 : i64) : i64
        %389 = llvm.alloca %388 x i64 : (i64) -> !llvm.ptr
        llvm.store %387, %389 : i64, !llvm.ptr
        cf.br ^bb72
        ^bb72:
        %390 = llvm.load %389 : !llvm.ptr -> i64
        %391 = arith.cmpi sle, %390, %310 : i64
        cf.cond_br %391, ^bb73, ^bb74
        ^bb73:
          %392 = arith.constant 0 : i32
          %393 = llvm.load %389 : !llvm.ptr -> i64
          %394 = llvm.getelementptr %311[%393] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %392, %394 : i32, !llvm.ptr
          %395 = llvm.load %389 : !llvm.ptr -> i64
          %396 = arith.addi %395, %387 : i64
          llvm.store %396, %389 : i64, !llvm.ptr
          cf.br ^bb72
        ^bb74:
        cf.br ^bb65
      ^bb64:
        cf.br ^bb65
      ^bb65:
      %397 = llvm.load %356 : !llvm.ptr -> i64
      %398 = arith.constant 1 : i32
      %400 = arith.extsi %398 : i32 to i64
      %399 = arith.addi %397, %400 : i64
      llvm.store %399, %356 : i64, !llvm.ptr
      cf.br ^bb60
    ^bb62:
    %401 = arith.constant 0 : i32
    %402 = arith.extsi %401 : i32 to i64
    %403 = llvm.mlir.constant(1 : i64) : i64
    %404 = llvm.alloca %403 x i64 : (i64) -> !llvm.ptr
    llvm.store %402, %404 : i64, !llvm.ptr
    %405 = arith.constant 1 : i32
    %406 = arith.extsi %405 : i32 to i64
    %407 = llvm.mlir.constant(1 : i64) : i64
    %408 = llvm.alloca %407 x i64 : (i64) -> !llvm.ptr
    llvm.store %406, %408 : i64, !llvm.ptr
    cf.br ^bb75
    ^bb75:
    %409 = llvm.load %408 : !llvm.ptr -> i64
    %410 = llvm.load %408 : !llvm.ptr -> i64
    %411 = arith.muli %409, %410 : i64
    %412 = arith.cmpi sle, %411, %arg0 : i64
    cf.cond_br %412, ^bb76, ^bb77
    ^bb76:
      %414 = llvm.load %408 : !llvm.ptr -> i64
      %415 = llvm.getelementptr %311[%414] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %413 = llvm.load %415 : !llvm.ptr -> i32
      %416 = arith.extsi %413 : i32 to i64
      %417 = arith.constant 0 : i32
      %419 = arith.extsi %417 : i32 to i64
      %418 = arith.cmpi ne, %416, %419 : i64
      cf.cond_br %418, ^bb78, ^bb79
      ^bb78:
        %420 = llvm.load %408 : !llvm.ptr -> i64
        %421 = llvm.load %408 : !llvm.ptr -> i64
        %422 = arith.muli %420, %421 : i64
        %423 = arith.divsi %arg0, %422 : i64
        %424 = llvm.load %404 : !llvm.ptr -> i64
        %425 = func.call @t1(%423, %233, %arg1) : (i64, !llvm.ptr, i64) -> i64
        %426 = func.call @t2(%423, %233, %arg1) : (i64, !llvm.ptr, i64) -> i64
        %427 = arith.addi %425, %426 : i64
        %428 = arith.muli %416, %427 : i64
        %429 = arith.addi %424, %428 : i64
        llvm.store %429, %404 : i64, !llvm.ptr
        cf.br ^bb80
      ^bb79:
        cf.br ^bb80
      ^bb80:
      %430 = llvm.load %408 : !llvm.ptr -> i64
      %431 = arith.constant 2 : i32
      %433 = arith.extsi %431 : i32 to i64
      %432 = arith.addi %430, %433 : i64
      llvm.store %432, %408 : i64, !llvm.ptr
      cf.br ^bb75
    ^bb77:
    func.call @free(%233) : (!llvm.ptr) -> ()
    func.call @free(%311) : (!llvm.ptr) -> ()
    func.call @free(%317) : (!llvm.ptr) -> ()
    %437 = llvm.load %404 : !llvm.ptr -> i64
    func.return %437 : i64
  }
  func.func @main() -> i32 {
    %438 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %440 = arith.constant 995705032704 : i32
    %441 = arith.constant 100000000 : i32
    %442 = arith.extsi %440 : i32 to i64
    %443 = arith.extsi %441 : i32 to i64
    %439 = func.call @solve(%442, %443) : (i64, i64) -> i64
    %444 = llvm.call @printf(%438, %439) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %445 = arith.constant 0 : i32
    func.return %445 : i32
  }
}