Problem 496

Incenter/circumcenter — F(10^9) via A=2B triangle parametrization.

Answer2042473533769142717
Output2042473533769142717
StatusPASS
Native helperno
Runtime10 ms
Peak memory1264 KB
Time complexityO(n^2) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n^2)
Space complexityO(n)O(n^2)
ApproachFlow solutionBottom-up DP
VerdictOptimal

Flow source

# Project Euler 496
# Incenter/circumcenter — F(10^9) via A=2B triangle parametrization.

import euler.nt { isqrt }

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

function squarefree_divs(p: i64, spf: ptr<i32>, ds: ptr<i64>, cs: ptr<i64>) -> i64 {
    let mut primes: array<i64, 16> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    let mut pc: i64 = 0
    let mut x: i64 = p
    while x > 1 {
        let pr: i64 = spf[x] as i64
        primes[pc] = pr
        pc = pc + 1
        while x % pr == 0 {
            x = x / pr
        }
    }
    ds[0] = 1
    cs[0] = 1
    let mut dcount: i64 = 1
    let mut i: i64 = 0
    while i < pc {
        let pr: i64 = primes[i]
        let m: i64 = dcount
        let mut j: i64 = 0
        while j < m {
            ds[dcount] = ds[j] * pr
            cs[dcount] = 0 - cs[j] * pr
            dcount = dcount + 1
            j = j + 1
        }
        i = i + 1
    }
    return dcount
}

function coprime_prefix_sum(ds: ptr<i64>, cs: ptr<i64>, dcount: i64, x: i64) -> i64 {
    if x <= 0 { return 0 }
    let mut total: i64 = 0
    let mut i: i64 = 0
    while i < dcount {
        let d: i64 = ds[i]
        let coef: i64 = cs[i]
        let nn: i64 = x / d
        total = total + coef * (nn * (nn + 1) / 2)
        i = i + 1
    }
    return total
}

function F(L: i64) -> i64 {
    let p_max: i64 = isqrt(L) + 1
    let spf: ptr<i32> = calloc(p_max + 1, 4)
    let ds: ptr<i64> = calloc(64, 8)
    let cs: ptr<i64> = calloc(64, 8)
    if spf == null || ds == null || cs == null { return 0 }
    let mut i: i64 = 0
    while i <= p_max {
        spf[i] = i as i32
        i = i + 1
    }
    let lim: i64 = isqrt(p_max)
    i = 2
    while i <= lim {
        if (spf[i] as i64) == i {
            let mut j: i64 = i * i
            while j <= p_max {
                if (spf[j] as i64) == j {
                    spf[j] = i as i32
                }
                j = j + i
            }
        }
        i = i + 1
    }

    let mut ans: i64 = 0
    let mut p: i64 = 1
    while p <= p_max {
        let q_low: i64 = p + 1
        let mut q_high: i64 = 2 * p - 1
        let limq: i64 = L / p
        if limq < q_high { q_high = limq }
        if q_low <= q_high {
            let M: i64 = L / p
            let dcount: i64 = squarefree_divs(p, spf, ds, cs)
            let mut q: i64 = q_low
            while q <= q_high {
                let v: i64 = M / q
                let mut q_end: i64 = M / v
                if q_end > q_high { q_end = q_high }
                let sum_q: i64 = coprime_prefix_sum(ds, cs, dcount, q_end) - coprime_prefix_sum(ds, cs, dcount, q - 1)
                if sum_q != 0 {
                    let tri: i64 = v * (v + 1) / 2
                    ans = ans + p * tri * sum_q
                }
                q = q_end + 1
            }
        }
        p = p + 1
    }

    free(spf)
    free(ds)
    free(cs)
    return ans
}

function main() -> i32 {
    if F(15) != 45 {
        printf("%lld\n", F(15))
        return 1
    }
    printf("%lld\n", F(1000000000))
    return 0
}

Generated C

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
    while (flow_temp_head) {
        flow_temp_node* n = flow_temp_head;
        flow_temp_head = n->next;
        free(n);
    }
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
    flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
    if (!node) return NULL;
    node->next = flow_temp_head;
    flow_temp_head = node;
    if (!flow_temp_atexit_set) {
        flow_temp_atexit_set = 1;
        atexit(flow_temp_free_all);
    }
    return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
    size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
    char* r = (char*)flow_temp_alloc(la + lb + 1);
    if (!r) return NULL;
    if (la) memcpy(r, a, la);
    if (lb) memcpy(r + la, b, lb);
    r[la + lb] = '\0';
    return r;
}

#define __flow_in_arr(arr, val) __extension__ ({ \
    int _found = 0; \
    size_t _n = sizeof(arr)/sizeof((arr)[0]); \
    for (size_t _i = 0; _i < _n; _i++) { \
        if ((arr)[_i] == (val)) { _found = 1; break; } \
    } _found; })

/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
    fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
    abort();
#if defined(__GNUC__) || defined(__clang__)
    __builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")

#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif

#include <math.h>

void* _ui_state = NULL;

static inline float i32_to_f32(int32_t v) { return (float)v; }

/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }

int64_t gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t squarefree_divs_i64_ptr_i32_ptr_i64_ptr_i64(int64_t p, int32_t* spf, int64_t* ds, int64_t* cs);
int64_t coprime_prefix_sum_ptr_i64_ptr_i64_i64_i64(int64_t* ds, int64_t* cs, int64_t dcount, int64_t x);
int64_t F_i64(int64_t L);
int32_t main(void);

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

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

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

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

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

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



int64_t squarefree_divs_i64_ptr_i32_ptr_i64_ptr_i64(int64_t p, int32_t* spf, int64_t* ds, int64_t* cs) {
    int64_t primes[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int64_t pc = 0;
    int64_t x = p;
    while (x > 1) {
        int64_t pr = ((int64_t)(spf[x]));
        primes[pc] = pr;
        pc = (pc + 1);
        while (FLOW_CHECKED_MOD((x), (pr)) == 0) {
            x = FLOW_CHECKED_DIV((x), (pr));
        }
    }
    ds[0] = 1;
    cs[0] = 1;
    int64_t dcount = 1;
    int64_t i = 0;
    while (i < pc) {
        int64_t pr = (((unsigned)(i) < 16) ? primes[i] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(i), 16), flow_fault_handler("array index out of bounds"), primes[0]));
        int64_t m = dcount;
        int64_t j = 0;
        while (j < m) {
            ds[dcount] = (ds[j] * pr);
            cs[dcount] = (0 - (cs[j] * pr));
            dcount = (dcount + 1);
            j = (j + 1);
        }
        i = (i + 1);
    }
    return dcount;
}

int64_t coprime_prefix_sum_ptr_i64_ptr_i64_i64_i64(int64_t* ds, int64_t* cs, int64_t dcount, int64_t x) {
    if (x <= 0) {
        return 0;
    }
    int64_t total = 0;
    int64_t i = 0;
    while (i < dcount) {
        int64_t d = ds[i];
        int64_t coef = cs[i];
        int64_t nn = FLOW_CHECKED_DIV((x), (d));
        total = (total + (coef * FLOW_CHECKED_DIV(((nn * (nn + 1))), (2))));
        i = (i + 1);
    }
    return total;
}

int64_t F_i64(int64_t L) {
    int64_t p_max = (isqrt_i64(L) + 1);
    int32_t* spf = (int32_t*)(calloc((p_max + 1), 4));
    int64_t* ds = (int64_t*)(calloc(64, 8));
    int64_t* cs = (int64_t*)(calloc(64, 8));
    if (((spf == NULL || ds == NULL) || cs == NULL)) {
        return 0;
    }
    int64_t i = 0;
    while (i <= p_max) {
        spf[i] = ((int32_t)(i));
        i = (i + 1);
    }
    int64_t lim = isqrt_i64(p_max);
    i = 2;
    while (i <= lim) {
        if (((int64_t)(spf[i])) == i) {
            int64_t j = (i * i);
            while (j <= p_max) {
                if (((int64_t)(spf[j])) == j) {
                    spf[j] = ((int32_t)(i));
                }
                j = (j + i);
            }
        }
        i = (i + 1);
    }
    int64_t ans = 0;
    int64_t p = 1;
    while (p <= p_max) {
        int64_t q_low = (p + 1);
        int64_t q_high = ((2 * p) - 1);
        int64_t limq = FLOW_CHECKED_DIV((L), (p));
        if (limq < q_high) {
            q_high = limq;
        }
        if (q_low <= q_high) {
            int64_t M = FLOW_CHECKED_DIV((L), (p));
            int64_t dcount = squarefree_divs_i64_ptr_i32_ptr_i64_ptr_i64(p, spf, ds, cs);
            int64_t q = q_low;
            while (q <= q_high) {
                int64_t v = FLOW_CHECKED_DIV((M), (q));
                int64_t q_end = FLOW_CHECKED_DIV((M), (v));
                if (q_end > q_high) {
                    q_end = q_high;
                }
                int64_t sum_q = (coprime_prefix_sum_ptr_i64_ptr_i64_i64_i64(ds, cs, dcount, q_end) - coprime_prefix_sum_ptr_i64_ptr_i64_i64_i64(ds, cs, dcount, (q - 1)));
                if (sum_q != 0) {
                    int64_t tri = FLOW_CHECKED_DIV(((v * (v + 1))), (2));
                    ans = (ans + ((p * tri) * sum_q));
                }
                q = (q_end + 1);
            }
        }
        p = (p + 1);
    }
    free(spf);
    free(ds);
    free(cs);
    return ans;
}

int32_t main(void) {
    if (F_i64(15) != 45) {
        printf("%lld\n", F_i64(15));
        return 1;
    }
    printf("%lld\n", F_i64(1000000000));
    return 0;
}

Generated MLIR

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