Problem 919

Fortunate Triangles: |cos(A)| = 1/4 for at least one angle. S(P) = sum of perimeters of all fortunate triangles with perimeter <= P. P = 10^7.

Answer134222859969633
Output134222859969633
StatusPASS
Native helperno
Runtime1230 ms
Peak memory1088 KB
Time complexityO(n^2) (estimated)
Space complexityO(1) (estimated)

Performance comparison

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

Flow source

# Project Euler 919
# Fortunate Triangles: |cos(A)| = 1/4 for at least one angle.
# S(P) = sum of perimeters of all fortunate triangles with perimeter <= P.
# P = 10^7.

import euler.nt { gcd }

extern {
    function sqrt(x: f64) -> f64
}

let mut total: i128 = 0

function passes_d_filter(m: i64, d: i64) -> bool {
    if d == 1 { return (m % 3 != 0) && (m % 5 != 0) }
    if d == 3 { return (m % 5 != 0) }
    if d == 5 { return (m % 3 != 0) }
    return true
}

function process(raw_a: i64, raw_b: i64, raw_c: i64, P: i64) -> void {
    let mut g: i64 = gcd(raw_a, raw_b)
    g = gcd(g, raw_c)
    let a: i64 = raw_a / g
    let b: i64 = raw_b / g
    let c: i64 = raw_c / g
    if a > b { return }
    let per: i64 = a + b + c
    if per > P { return }
    let n: i64 = P / per
    total = total + (per as i128) * (n as i128) * ((n + 1) as i128) / 2
}

function main() -> i32 {
    let P: i64 = 10000000
    total = 0
    let q_max: i64 = 2 * (sqrt((P as f64)) as i64) + 10
    let ds: array<i64, 4> = [1, 3, 5, 15]

    # Family A: cos = +1/4
    #   A = 8*p*q, B = 15*q^2 - p^2 + 2*p*q, C = 15*q^2 + p^2
    #   Constraint: p < 5q, perimeter raw = 10*q*(p+3q)
    let mut q: i64 = 1
    while q <= q_max {
        let qq: i64 = q * q
        let max_p: i64 = 5 * q - 1
        let mut di: i64 = 0
        while di < 4 {
            let d: i64 = ds[di]
            let mut p_lim: i64 = (P * 8 * d) / (10 * q) - 3 * q
            if p_lim > max_p { p_lim = max_p }
            if p_lim >= d {
                let mut p: i64 = d
                while p <= p_lim {
                    let m: i64 = p / d
                    if passes_d_filter(m, d) {
                        if gcd(p, q) == 1 {
                            let a: i64 = 8 * p * q
                            let b: i64 = 15 * qq - p * p + 2 * p * q
                            let c: i64 = 15 * qq + p * p
                            if b > 0 {
                                process(a, b, c, P)
                            }
                        }
                    }
                    p = p + d
                }
            }
            di = di + 1
        }
        q = q + 1
    }

    # Family B: cos = -1/4
    #   A = 8*p*q, B = 15*q^2 - p^2 - 2*p*q, C = 15*q^2 + p^2
    #   Constraint: p < 3q, perimeter raw = 6*q*(p+5q)
    q = 1
    while q <= q_max {
        let qq: i64 = q * q
        let max_p: i64 = 3 * q - 1
        let mut di: i64 = 0
        while di < 4 {
            let d: i64 = ds[di]
            let mut p_lim: i64 = (P * 8 * d) / (6 * q) - 5 * q
            if p_lim > max_p { p_lim = max_p }
            if p_lim >= d {
                let mut p: i64 = d
                while p <= p_lim {
                    let m: i64 = p / d
                    if passes_d_filter(m, d) {
                        if gcd(p, q) == 1 {
                            let a: i64 = 8 * p * q
                            let b: i64 = 15 * qq - p * p - 2 * p * q
                            let c: i64 = 15 * qq + p * p
                            if b > 0 {
                                process(a, b, c, P)
                            }
                        }
                    }
                    p = p + d
                }
            }
            di = di + 1
        }
        q = q + 1
    }

    printf("%lld\n", total as i64)
    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);
bool passes_d_filter_i64_i64(int64_t m, int64_t d);
void process_i64_i64_i64_i64(int64_t raw_a, int64_t raw_b, int64_t raw_c, int64_t P);
int32_t main(void);

/* Module statics */
static __int128 total = 0;

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;
}


bool passes_d_filter_i64_i64(int64_t m, int64_t d) {
    if (d == 1) {
        return (FLOW_CHECKED_MOD((m), (3)) != 0 && FLOW_CHECKED_MOD((m), (5)) != 0);
    }
    if (d == 3) {
        return FLOW_CHECKED_MOD((m), (5)) != 0;
    }
    if (d == 5) {
        return FLOW_CHECKED_MOD((m), (3)) != 0;
    }
    return 1;
}

void process_i64_i64_i64_i64(int64_t raw_a, int64_t raw_b, int64_t raw_c, int64_t P) {
    int64_t g = gcd_i64_i64(raw_a, raw_b);
    g = gcd_i64_i64(g, raw_c);
    int64_t a = FLOW_CHECKED_DIV((raw_a), (g));
    int64_t b = FLOW_CHECKED_DIV((raw_b), (g));
    int64_t c = FLOW_CHECKED_DIV((raw_c), (g));
    if (a > b) {
        return;
    }
    int64_t per = ((a + b) + c);
    if (per > P) {
        return;
    }
    int64_t n = FLOW_CHECKED_DIV((P), (per));
    total = (total + FLOW_CHECKED_DIV((((((__int128)(per)) * ((__int128)(n))) * ((__int128)((n + 1))))), (2)));
}

int32_t main(void) {
    int64_t P = 10000000;
    total = 0;
    int64_t q_max = ((2 * ((int64_t)(sqrt(((double)(P)))))) + 10);
    int64_t ds[4] = { 1, 3, 5, 15 };
    int64_t q = 1;
    while (q <= q_max) {
        int64_t qq = (q * q);
        int64_t max_p = ((5 * q) - 1);
        int64_t di = 0;
        while (di < 4) {
            int64_t d = (((unsigned)(di) < 4) ? ds[di] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(di), 4), flow_fault_handler("array index out of bounds"), ds[0]));
            int64_t p_lim = (FLOW_CHECKED_DIV((((P * 8) * d)), ((10 * q))) - (3 * q));
            if (p_lim > max_p) {
                p_lim = max_p;
            }
            if (p_lim >= d) {
                int64_t p = d;
                while (p <= p_lim) {
                    int64_t m = FLOW_CHECKED_DIV((p), (d));
                    if (passes_d_filter_i64_i64(m, d)) {
                        if (gcd_i64_i64(p, q) == 1) {
                            int64_t a = ((8 * p) * q);
                            int64_t b = (((15 * qq) - (p * p)) + ((2 * p) * q));
                            int64_t c = ((15 * qq) + (p * p));
                            if (b > 0) {
                                process_i64_i64_i64_i64(a, b, c, P);
                            }
                        }
                    }
                    p = (p + d);
                }
            }
            di = (di + 1);
        }
        q = (q + 1);
    }
    q = 1;
    while (q <= q_max) {
        int64_t qq = (q * q);
        int64_t max_p = ((3 * q) - 1);
        int64_t di = 0;
        while (di < 4) {
            int64_t d = (((unsigned)(di) < 4) ? ds[di] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(di), 4), flow_fault_handler("array index out of bounds"), ds[0]));
            int64_t p_lim = (FLOW_CHECKED_DIV((((P * 8) * d)), ((6 * q))) - (5 * q));
            if (p_lim > max_p) {
                p_lim = max_p;
            }
            if (p_lim >= d) {
                int64_t p = d;
                while (p <= p_lim) {
                    int64_t m = FLOW_CHECKED_DIV((p), (d));
                    if (passes_d_filter_i64_i64(m, d)) {
                        if (gcd_i64_i64(p, q) == 1) {
                            int64_t a = ((8 * p) * q);
                            int64_t b = (((15 * qq) - (p * p)) - ((2 * p) * q));
                            int64_t c = ((15 * qq) + (p * p));
                            if (b > 0) {
                                process_i64_i64_i64_i64(a, b, c, P);
                            }
                        }
                    }
                    p = (p + d);
                }
            }
            di = (di + 1);
        }
        q = (q + 1);
    }
    printf("%lld\n", ((int64_t)(total)));
    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 @sqrt(f64) -> f64
  // Module static: total
  llvm.mlir.global internal @total(0 : i128) : i128
  func.func @passes_d_filter(%arg0: i64, %arg1: i64) -> i1 {
    %175 = arith.constant 1 : i32
    %177 = arith.extsi %175 : i32 to i64
    %176 = arith.cmpi eq, %arg1, %177 : i64
    cf.cond_br %176, ^bb42, ^bb43
    ^bb42:
      %178 = arith.constant 3 : i32
      %180 = arith.extsi %178 : i32 to i64
      %179 = arith.remsi %arg0, %180 : i64
      %181 = arith.constant 0 : i32
      %183 = arith.extsi %181 : i32 to i64
      %182 = arith.cmpi ne, %179, %183 : i64
      %184 = scf.if %182 -> (i1) {
        %185 = arith.constant 5 : i32
        %187 = arith.extsi %185 : i32 to i64
        %186 = arith.remsi %arg0, %187 : i64
        %188 = arith.constant 0 : i32
        %190 = arith.extsi %188 : i32 to i64
        %189 = arith.cmpi ne, %186, %190 : i64
        scf.yield %189 : i1
      } else {
        %191 = arith.constant false
        scf.yield %191 : i1
      }
      func.return %184 : i1
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %192 = arith.constant 3 : i32
    %194 = arith.extsi %192 : i32 to i64
    %193 = arith.cmpi eq, %arg1, %194 : i64
    cf.cond_br %193, ^bb45, ^bb46
    ^bb45:
      %195 = arith.constant 5 : i32
      %197 = arith.extsi %195 : i32 to i64
      %196 = arith.remsi %arg0, %197 : i64
      %198 = arith.constant 0 : i32
      %200 = arith.extsi %198 : i32 to i64
      %199 = arith.cmpi ne, %196, %200 : i64
      func.return %199 : i1
    ^bb46:
      cf.br ^bb47
    ^bb47:
    %201 = arith.constant 5 : i32
    %203 = arith.extsi %201 : i32 to i64
    %202 = arith.cmpi eq, %arg1, %203 : i64
    cf.cond_br %202, ^bb48, ^bb49
    ^bb48:
      %204 = arith.constant 3 : i32
      %206 = arith.extsi %204 : i32 to i64
      %205 = arith.remsi %arg0, %206 : i64
      %207 = arith.constant 0 : i32
      %209 = arith.extsi %207 : i32 to i64
      %208 = arith.cmpi ne, %205, %209 : i64
      func.return %208 : i1
    ^bb49:
      cf.br ^bb50
    ^bb50:
    %210 = arith.constant 1 : i1
    func.return %210 : i1
  }
  func.func @process(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> () {
    %211 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
    %212 = llvm.mlir.constant(1 : i64) : i64
    %213 = llvm.alloca %212 x i64 : (i64) -> !llvm.ptr
    llvm.store %211, %213 : i64, !llvm.ptr
    %215 = llvm.load %213 : !llvm.ptr -> i64
    %214 = func.call @gcd(%215, %arg2) : (i64, i64) -> i64
    llvm.store %214, %213 : i64, !llvm.ptr
    %216 = llvm.load %213 : !llvm.ptr -> i64
    %217 = arith.divsi %arg0, %216 : i64
    %218 = llvm.load %213 : !llvm.ptr -> i64
    %219 = arith.divsi %arg1, %218 : i64
    %220 = llvm.load %213 : !llvm.ptr -> i64
    %221 = arith.divsi %arg2, %220 : i64
    %222 = arith.cmpi sgt, %217, %219 : i64
    cf.cond_br %222, ^bb51, ^bb52
    ^bb51:
      func.return
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %223 = arith.addi %217, %219 : i64
    %224 = arith.addi %223, %221 : i64
    %225 = arith.cmpi sgt, %224, %arg3 : i64
    cf.cond_br %225, ^bb54, ^bb55
    ^bb54:
      func.return
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %226 = arith.divsi %arg3, %224 : i64
    %227 = llvm.mlir.addressof @total : !llvm.ptr
    %228 = llvm.load %227 : !llvm.ptr -> i128
    %229 = arith.extsi %224 : i64 to i128
    %230 = arith.extsi %226 : i64 to i128
    %232 = arith.trunci %229 : i128 to i64
    %233 = arith.trunci %230 : i128 to i64
    %231 = arith.muli %232, %233 : i64
    %234 = arith.constant 1 : i32
    %236 = arith.extsi %234 : i32 to i64
    %235 = arith.addi %226, %236 : i64
    %237 = arith.extsi %235 : i64 to i128
    %239 = arith.trunci %237 : i128 to i64
    %238 = arith.muli %231, %239 : i64
    %240 = arith.constant 2 : i32
    %242 = arith.extsi %240 : i32 to i64
    %241 = arith.divsi %238, %242 : i64
    %244 = arith.trunci %228 : i128 to i64
    %243 = arith.addi %244, %241 : i64
    %245 = arith.extsi %243 : i64 to i128
    %246 = llvm.mlir.addressof @total : !llvm.ptr
    llvm.store %245, %246 : i128, !llvm.ptr
    func.return
  }
  func.func @main() -> i32 {
    %247 = arith.constant 10000000 : i32
    %248 = arith.extsi %247 : i32 to i64
    %249 = arith.constant 0 : i32
    %250 = arith.extsi %249 : i32 to i128
    %251 = llvm.mlir.addressof @total : !llvm.ptr
    llvm.store %250, %251 : i128, !llvm.ptr
    %252 = arith.constant 2 : i32
    %253 = arith.sitofp %248 : i64 to f64
    %254 = math.sqrt %253 : f64
    %255 = arith.fptosi %254 : f64 to i64
    %257 = arith.extsi %252 : i32 to i64
    %256 = arith.muli %257, %255 : i64
    %258 = arith.constant 10 : i32
    %260 = arith.extsi %258 : i32 to i64
    %259 = arith.addi %256, %260 : i64
    %262 = arith.constant 1 : i32
    %263 = arith.constant 3 : i32
    %264 = arith.constant 5 : i32
    %265 = arith.constant 15 : i32
    %266 = llvm.mlir.constant(1 : i64) : i64
    %267 = llvm.alloca %266 x !llvm.array<4 x i64> : (i64) -> !llvm.ptr
    %268 = llvm.mlir.zero : !llvm.array<4 x i64>
    llvm.store %268, %267 : !llvm.array<4 x i64>, !llvm.ptr
    %269 = arith.extsi %262 : i32 to i64
    %270 = arith.extsi %263 : i32 to i64
    %271 = arith.extsi %264 : i32 to i64
    %272 = arith.extsi %265 : i32 to i64
    %273 = llvm.mlir.constant(0 : i64) : i64
    %274 = llvm.getelementptr %267[0, %273] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64>
    llvm.store %269, %274 : i64, !llvm.ptr
    %275 = llvm.mlir.constant(1 : i64) : i64
    %276 = llvm.getelementptr %267[0, %275] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64>
    llvm.store %270, %276 : i64, !llvm.ptr
    %277 = llvm.mlir.constant(2 : i64) : i64
    %278 = llvm.getelementptr %267[0, %277] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64>
    llvm.store %271, %278 : i64, !llvm.ptr
    %279 = llvm.mlir.constant(3 : i64) : i64
    %280 = llvm.getelementptr %267[0, %279] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64>
    llvm.store %272, %280 : i64, !llvm.ptr
    %281 = arith.constant 1 : i32
    %282 = arith.extsi %281 : i32 to i64
    %283 = llvm.mlir.constant(1 : i64) : i64
    %284 = llvm.alloca %283 x i64 : (i64) -> !llvm.ptr
    llvm.store %282, %284 : i64, !llvm.ptr
    cf.br ^bb57
    ^bb57:
    %285 = llvm.load %284 : !llvm.ptr -> i64
    %286 = arith.cmpi sle, %285, %259 : i64
    cf.cond_br %286, ^bb58, ^bb59
    ^bb58:
      %287 = llvm.load %284 : !llvm.ptr -> i64
      %288 = llvm.load %284 : !llvm.ptr -> i64
      %289 = arith.muli %287, %288 : i64
      %290 = arith.constant 5 : i32
      %291 = llvm.load %284 : !llvm.ptr -> i64
      %293 = arith.extsi %290 : i32 to i64
      %292 = arith.muli %293, %291 : i64
      %294 = arith.constant 1 : i32
      %296 = arith.extsi %294 : i32 to i64
      %295 = arith.subi %292, %296 : i64
      %297 = arith.constant 0 : i32
      %298 = arith.extsi %297 : i32 to i64
      %299 = llvm.mlir.constant(1 : i64) : i64
      %300 = llvm.alloca %299 x i64 : (i64) -> !llvm.ptr
      llvm.store %298, %300 : i64, !llvm.ptr
      cf.br ^bb60
      ^bb60:
      %301 = llvm.load %300 : !llvm.ptr -> i64
      %302 = arith.constant 4 : i32
      %304 = arith.extsi %302 : i32 to i64
      %303 = arith.cmpi slt, %301, %304 : i64
      cf.cond_br %303, ^bb61, ^bb62
      ^bb61:
        %306 = llvm.load %300 : !llvm.ptr -> i64
        %307 = llvm.getelementptr %267[0, %306] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64>
        %305 = llvm.load %307 : !llvm.ptr -> i64
        %308 = arith.constant 8 : i32
        %310 = arith.extsi %308 : i32 to i64
        %309 = arith.muli %248, %310 : i64
        %311 = arith.muli %309, %305 : i64
        %312 = arith.constant 10 : i32
        %313 = llvm.load %284 : !llvm.ptr -> i64
        %315 = arith.extsi %312 : i32 to i64
        %314 = arith.muli %315, %313 : i64
        %316 = arith.divsi %311, %314 : i64
        %317 = arith.constant 3 : i32
        %318 = llvm.load %284 : !llvm.ptr -> i64
        %320 = arith.extsi %317 : i32 to i64
        %319 = arith.muli %320, %318 : i64
        %321 = arith.subi %316, %319 : i64
        %322 = llvm.mlir.constant(1 : i64) : i64
        %323 = llvm.alloca %322 x i64 : (i64) -> !llvm.ptr
        llvm.store %321, %323 : i64, !llvm.ptr
        %324 = llvm.load %323 : !llvm.ptr -> i64
        %325 = arith.cmpi sgt, %324, %295 : i64
        cf.cond_br %325, ^bb63, ^bb64
        ^bb63:
          llvm.store %295, %323 : i64, !llvm.ptr
          cf.br ^bb65
        ^bb64:
          cf.br ^bb65
        ^bb65:
        %326 = llvm.load %323 : !llvm.ptr -> i64
        %327 = arith.cmpi sge, %326, %305 : i64
        cf.cond_br %327, ^bb66, ^bb67
        ^bb66:
          %328 = llvm.mlir.constant(1 : i64) : i64
          %329 = llvm.alloca %328 x i64 : (i64) -> !llvm.ptr
          llvm.store %305, %329 : i64, !llvm.ptr
          cf.br ^bb69
          ^bb69:
          %330 = llvm.load %329 : !llvm.ptr -> i64
          %331 = llvm.load %323 : !llvm.ptr -> i64
          %332 = arith.cmpi sle, %330, %331 : i64
          cf.cond_br %332, ^bb70, ^bb71
          ^bb70:
            %333 = llvm.load %329 : !llvm.ptr -> i64
            %334 = arith.divsi %333, %305 : i64
            %335 = func.call @passes_d_filter(%334, %305) : (i64, i64) -> i1
            cf.cond_br %335, ^bb72, ^bb73
            ^bb72:
              %337 = llvm.load %329 : !llvm.ptr -> i64
              %338 = llvm.load %284 : !llvm.ptr -> i64
              %336 = func.call @gcd(%337, %338) : (i64, i64) -> i64
              %339 = arith.constant 1 : i32
              %341 = arith.extsi %339 : i32 to i64
              %340 = arith.cmpi eq, %336, %341 : i64
              cf.cond_br %340, ^bb75, ^bb76
              ^bb75:
                %342 = arith.constant 8 : i32
                %343 = llvm.load %329 : !llvm.ptr -> i64
                %345 = arith.extsi %342 : i32 to i64
                %344 = arith.muli %345, %343 : i64
                %346 = llvm.load %284 : !llvm.ptr -> i64
                %347 = arith.muli %344, %346 : i64
                %348 = arith.constant 15 : i32
                %350 = arith.extsi %348 : i32 to i64
                %349 = arith.muli %350, %289 : i64
                %351 = llvm.load %329 : !llvm.ptr -> i64
                %352 = llvm.load %329 : !llvm.ptr -> i64
                %353 = arith.muli %351, %352 : i64
                %354 = arith.subi %349, %353 : i64
                %355 = arith.constant 2 : i32
                %356 = llvm.load %329 : !llvm.ptr -> i64
                %358 = arith.extsi %355 : i32 to i64
                %357 = arith.muli %358, %356 : i64
                %359 = llvm.load %284 : !llvm.ptr -> i64
                %360 = arith.muli %357, %359 : i64
                %361 = arith.addi %354, %360 : i64
                %362 = arith.constant 15 : i32
                %364 = arith.extsi %362 : i32 to i64
                %363 = arith.muli %364, %289 : i64
                %365 = llvm.load %329 : !llvm.ptr -> i64
                %366 = llvm.load %329 : !llvm.ptr -> i64
                %367 = arith.muli %365, %366 : i64
                %368 = arith.addi %363, %367 : i64
                %369 = arith.constant 0 : i32
                %371 = arith.extsi %369 : i32 to i64
                %370 = arith.cmpi sgt, %361, %371 : i64
                cf.cond_br %370, ^bb78, ^bb79
                ^bb78:
                  func.call @process(%347, %361, %368, %248) : (i64, i64, i64, i64) -> ()
                  cf.br ^bb80
                ^bb79:
                  cf.br ^bb80
                ^bb80:
                cf.br ^bb77
              ^bb76:
                cf.br ^bb77
              ^bb77:
              cf.br ^bb74
            ^bb73:
              cf.br ^bb74
            ^bb74:
            %373 = llvm.load %329 : !llvm.ptr -> i64
            %374 = arith.addi %373, %305 : i64
            llvm.store %374, %329 : i64, !llvm.ptr
            cf.br ^bb69
          ^bb71:
          cf.br ^bb68
        ^bb67:
          cf.br ^bb68
        ^bb68:
        %375 = llvm.load %300 : !llvm.ptr -> i64
        %376 = arith.constant 1 : i32
        %378 = arith.extsi %376 : i32 to i64
        %377 = arith.addi %375, %378 : i64
        llvm.store %377, %300 : i64, !llvm.ptr
        cf.br ^bb60
      ^bb62:
      %379 = llvm.load %284 : !llvm.ptr -> i64
      %380 = arith.constant 1 : i32
      %382 = arith.extsi %380 : i32 to i64
      %381 = arith.addi %379, %382 : i64
      llvm.store %381, %284 : i64, !llvm.ptr
      cf.br ^bb57
    ^bb59:
    %383 = arith.constant 1 : i32
    %384 = arith.extsi %383 : i32 to i64
    llvm.store %384, %284 : i64, !llvm.ptr
    cf.br ^bb81
    ^bb81:
    %385 = llvm.load %284 : !llvm.ptr -> i64
    %386 = arith.cmpi sle, %385, %259 : i64
    cf.cond_br %386, ^bb82, ^bb83
    ^bb82:
      %387 = llvm.load %284 : !llvm.ptr -> i64
      %388 = llvm.load %284 : !llvm.ptr -> i64
      %389 = arith.muli %387, %388 : i64
      %390 = arith.constant 3 : i32
      %391 = llvm.load %284 : !llvm.ptr -> i64
      %393 = arith.extsi %390 : i32 to i64
      %392 = arith.muli %393, %391 : i64
      %394 = arith.constant 1 : i32
      %396 = arith.extsi %394 : i32 to i64
      %395 = arith.subi %392, %396 : i64
      %397 = arith.constant 0 : i32
      %398 = arith.extsi %397 : i32 to i64
      %399 = llvm.mlir.constant(1 : i64) : i64
      %400 = llvm.alloca %399 x i64 : (i64) -> !llvm.ptr
      llvm.store %398, %400 : i64, !llvm.ptr
      cf.br ^bb84
      ^bb84:
      %401 = llvm.load %400 : !llvm.ptr -> i64
      %402 = arith.constant 4 : i32
      %404 = arith.extsi %402 : i32 to i64
      %403 = arith.cmpi slt, %401, %404 : i64
      cf.cond_br %403, ^bb85, ^bb86
      ^bb85:
        %406 = llvm.load %400 : !llvm.ptr -> i64
        %407 = llvm.getelementptr %267[0, %406] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64>
        %405 = llvm.load %407 : !llvm.ptr -> i64
        %408 = arith.constant 8 : i32
        %410 = arith.extsi %408 : i32 to i64
        %409 = arith.muli %248, %410 : i64
        %411 = arith.muli %409, %405 : i64
        %412 = arith.constant 6 : i32
        %413 = llvm.load %284 : !llvm.ptr -> i64
        %415 = arith.extsi %412 : i32 to i64
        %414 = arith.muli %415, %413 : i64
        %416 = arith.divsi %411, %414 : i64
        %417 = arith.constant 5 : i32
        %418 = llvm.load %284 : !llvm.ptr -> i64
        %420 = arith.extsi %417 : i32 to i64
        %419 = arith.muli %420, %418 : i64
        %421 = arith.subi %416, %419 : i64
        %422 = llvm.mlir.constant(1 : i64) : i64
        %423 = llvm.alloca %422 x i64 : (i64) -> !llvm.ptr
        llvm.store %421, %423 : i64, !llvm.ptr
        %424 = llvm.load %423 : !llvm.ptr -> i64
        %425 = arith.cmpi sgt, %424, %395 : i64
        cf.cond_br %425, ^bb87, ^bb88
        ^bb87:
          llvm.store %395, %423 : i64, !llvm.ptr
          cf.br ^bb89
        ^bb88:
          cf.br ^bb89
        ^bb89:
        %426 = llvm.load %423 : !llvm.ptr -> i64
        %427 = arith.cmpi sge, %426, %405 : i64
        cf.cond_br %427, ^bb90, ^bb91
        ^bb90:
          %428 = llvm.mlir.constant(1 : i64) : i64
          %429 = llvm.alloca %428 x i64 : (i64) -> !llvm.ptr
          llvm.store %405, %429 : i64, !llvm.ptr
          cf.br ^bb93
          ^bb93:
          %430 = llvm.load %429 : !llvm.ptr -> i64
          %431 = llvm.load %423 : !llvm.ptr -> i64
          %432 = arith.cmpi sle, %430, %431 : i64
          cf.cond_br %432, ^bb94, ^bb95
          ^bb94:
            %433 = llvm.load %429 : !llvm.ptr -> i64
            %434 = arith.divsi %433, %405 : i64
            %435 = func.call @passes_d_filter(%434, %405) : (i64, i64) -> i1
            cf.cond_br %435, ^bb96, ^bb97
            ^bb96:
              %437 = llvm.load %429 : !llvm.ptr -> i64
              %438 = llvm.load %284 : !llvm.ptr -> i64
              %436 = func.call @gcd(%437, %438) : (i64, i64) -> i64
              %439 = arith.constant 1 : i32
              %441 = arith.extsi %439 : i32 to i64
              %440 = arith.cmpi eq, %436, %441 : i64
              cf.cond_br %440, ^bb99, ^bb100
              ^bb99:
                %442 = arith.constant 8 : i32
                %443 = llvm.load %429 : !llvm.ptr -> i64
                %445 = arith.extsi %442 : i32 to i64
                %444 = arith.muli %445, %443 : i64
                %446 = llvm.load %284 : !llvm.ptr -> i64
                %447 = arith.muli %444, %446 : i64
                %448 = arith.constant 15 : i32
                %450 = arith.extsi %448 : i32 to i64
                %449 = arith.muli %450, %389 : i64
                %451 = llvm.load %429 : !llvm.ptr -> i64
                %452 = llvm.load %429 : !llvm.ptr -> i64
                %453 = arith.muli %451, %452 : i64
                %454 = arith.subi %449, %453 : i64
                %455 = arith.constant 2 : i32
                %456 = llvm.load %429 : !llvm.ptr -> i64
                %458 = arith.extsi %455 : i32 to i64
                %457 = arith.muli %458, %456 : i64
                %459 = llvm.load %284 : !llvm.ptr -> i64
                %460 = arith.muli %457, %459 : i64
                %461 = arith.subi %454, %460 : i64
                %462 = arith.constant 15 : i32
                %464 = arith.extsi %462 : i32 to i64
                %463 = arith.muli %464, %389 : i64
                %465 = llvm.load %429 : !llvm.ptr -> i64
                %466 = llvm.load %429 : !llvm.ptr -> i64
                %467 = arith.muli %465, %466 : i64
                %468 = arith.addi %463, %467 : i64
                %469 = arith.constant 0 : i32
                %471 = arith.extsi %469 : i32 to i64
                %470 = arith.cmpi sgt, %461, %471 : i64
                cf.cond_br %470, ^bb102, ^bb103
                ^bb102:
                  func.call @process(%447, %461, %468, %248) : (i64, i64, i64, i64) -> ()
                  cf.br ^bb104
                ^bb103:
                  cf.br ^bb104
                ^bb104:
                cf.br ^bb101
              ^bb100:
                cf.br ^bb101
              ^bb101:
              cf.br ^bb98
            ^bb97:
              cf.br ^bb98
            ^bb98:
            %473 = llvm.load %429 : !llvm.ptr -> i64
            %474 = arith.addi %473, %405 : i64
            llvm.store %474, %429 : i64, !llvm.ptr
            cf.br ^bb93
          ^bb95:
          cf.br ^bb92
        ^bb91:
          cf.br ^bb92
        ^bb92:
        %475 = llvm.load %400 : !llvm.ptr -> i64
        %476 = arith.constant 1 : i32
        %478 = arith.extsi %476 : i32 to i64
        %477 = arith.addi %475, %478 : i64
        llvm.store %477, %400 : i64, !llvm.ptr
        cf.br ^bb84
      ^bb86:
      %479 = llvm.load %284 : !llvm.ptr -> i64
      %480 = arith.constant 1 : i32
      %482 = arith.extsi %480 : i32 to i64
      %481 = arith.addi %479, %482 : i64
      llvm.store %481, %284 : i64, !llvm.ptr
      cf.br ^bb81
    ^bb83:
    %483 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %484 = llvm.mlir.addressof @total : !llvm.ptr
    %485 = llvm.load %484 : !llvm.ptr -> i128
    %486 = arith.trunci %485 : i128 to i64
    %487 = llvm.call @printf(%483, %486) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %488 = arith.constant 0 : i32
    func.return %488 : i32
  }
}