Problem 470

Super Ramvok — expected visits by visible-count × average optimal Ramvok profit.

Answer147668794
Output147668794
StatusPASS
Native helperno
Runtime490 ms
Peak memory1328 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n * s^2)
Space complexityO(n^2)O(s^2)
ApproachFlow solutionMarkov chain or DP over states
VerdictUnknown

Flow source

# Project Euler 470
# Super Ramvok — expected visits by visible-count × average optimal Ramvok profit.

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

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

function invert(A: ptr<f64>, n: i64, out: ptr<f64>) -> i32 {
    # Gauss-Jordan invert n×n matrix A into out. Uses 2n augmented rows in-place buffer.
    let aug: ptr<f64> = calloc(n * (2 * n), 8)
    if aug == null { return 1 }
    let mut i: i64 = 0
    while i < n {
        let mut j: i64 = 0
        while j < n {
            aug[i * (2 * n) + j] = A[i * n + j]
            j = j + 1
        }
        j = 0
        while j < n {
            if i == j {
                aug[i * (2 * n) + n + j] = 1.0
            } else {
                aug[i * (2 * n) + n + j] = 0.0
            }
            j = j + 1
        }
        i = i + 1
    }
    let mut col: i64 = 0
    while col < n {
        let mut pivot: i64 = col
        let mut best: f64 = fabs(aug[pivot * (2 * n) + col])
        let mut r: i64 = col + 1
        while r < n {
            let v: f64 = fabs(aug[r * (2 * n) + col])
            if v > best {
                best = v
                pivot = r
            }
            r = r + 1
        }
        if best == 0.0 {
            free(aug)
            return 1
        }
        if pivot != col {
            let mut j2: i64 = 0
            while j2 < 2 * n {
                let tmp: f64 = aug[col * (2 * n) + j2]
                aug[col * (2 * n) + j2] = aug[pivot * (2 * n) + j2]
                aug[pivot * (2 * n) + j2] = tmp
                j2 = j2 + 1
            }
        }
        let piv: f64 = aug[col * (2 * n) + col]
        let invp: f64 = 1.0 / piv
        let mut j3: i64 = 0
        while j3 < 2 * n {
            aug[col * (2 * n) + j3] = aug[col * (2 * n) + j3] * invp
            j3 = j3 + 1
        }
        r = 0
        while r < n {
            if r != col {
                let f: f64 = aug[r * (2 * n) + col]
                if f != 0.0 {
                    j3 = 0
                    while j3 < 2 * n {
                        aug[r * (2 * n) + j3] = aug[r * (2 * n) + j3] - f * aug[col * (2 * n) + j3]
                        j3 = j3 + 1
                    }
                }
            }
            r = r + 1
        }
        col = col + 1
    }
    i = 0
    while i < n {
        let mut j: i64 = 0
        while j < n {
            out[i * n + j] = aug[i * (2 * n) + n + j]
            j = j + 1
        }
        i = i + 1
    }
    free(aug)
    return 0
}

function visit_counts(d: i64, V: ptr<f64>) -> void {
    let n: i64 = d
    let A: ptr<f64> = calloc(n * n, 8)
    let Ninv: ptr<f64> = calloc(n * n, 8)
    if A == null || Ninv == null { return }
    let mut k: i64 = 1
    while k <= d {
        let i: i64 = k - 1
        A[i * n + i] = 1.0
        if k == d {
            A[i * n + (d - 2)] = A[i * n + (d - 2)] - 1.0
        } else {
            let down: f64 = (k as f64) / (d as f64)
            let up: f64 = ((d - k) as f64) / (d as f64)
            if k > 1 {
                A[i * n + (k - 2)] = A[i * n + (k - 2)] - down
            }
            if k < d {
                A[i * n + k] = A[i * n + k] - up
            }
        }
        k = k + 1
    }
    if invert(A, n, Ninv) != 0 { return }
    let start: i64 = d - 1
    k = 1
    while k <= d {
        V[k] = Ninv[start * n + (k - 1)]
        k = k + 1
    }
    free(Ninv)
    free(A)
}

function best_profits_mask(mask0: i64, d: i64, max_c: i64, best: ptr<f64>) -> void {
    let vals: ptr<i64> = calloc(d + 1, 8)
    let cum: ptr<i64> = calloc(d + 1, 8)
    if vals == null || cum == null { return }
    let mut m: i64 = mask0
    let mut k: i64 = 0
    let mut total: i64 = 0
    while m != 0 {
        let lsb: i64 = m & -m
        let mut v: i64 = 0
        let mut t: i64 = lsb
        while t > 0 {
            v = v + 1
            t = t / 2
        }
        vals[k] = v
        total = total + v
        cum[k] = total
        k = k + 1
        m = m ^ lsb
    }
    let maxv: i64 = vals[k - 1]
    let mut c: i64 = 0
    while c <= max_c {
        best[c] = 0.0
        c = c + 1
    }
    best[0] = maxv as f64
    let mut prev: f64 = 0.0
    let mut p: i64 = 0
    let mut tt: i64 = 1
    while tt <= maxv {
        while p < k && (vals[p] as f64) < prev {
            p = p + 1
        }
        let mut low_sum: i64 = 0
        if p > 0 { low_sum = cum[p - 1] }
        let sum_ge: f64 = (total - low_sum) as f64
        prev = (prev * (p as f64) + sum_ge) / (k as f64)
        let mut lim: i64 = (prev / (tt as f64)) as i64
        if lim > max_c { lim = max_c }
        c = 1
        while c <= lim {
            let prof: f64 = prev - (c as f64) * (tt as f64)
            if prof > best[c] { best[c] = prof }
            c = c + 1
        }
        tt = tt + 1
    }
    free(cum)
    free(vals)
}

function popcount(x0: i64) -> i64 {
    let mut x: i64 = x0
    let mut c: i64 = 0
    while x > 0 {
        c = c + (x & 1)
        x = x / 2
    }
    return c
}

function compute_S_sum(d: i64) -> f64 {
    let V: ptr<f64> = calloc(d + 1, 8)
    let sum_R: ptr<f64> = calloc((d + 1) * (d + 1), 8)
    let best: ptr<f64> = calloc(d + 1, 8)
    if V == null || sum_R == null || best == null { return 0.0 }
    visit_counts(d, V)
    let mut mask: i64 = 1
    let lim: i64 = 1 << d
    while mask < lim {
        let kk: i64 = popcount(mask)
        best_profits_mask(mask, d, d, best)
        let mut c: i64 = 0
        while c <= d {
            sum_R[kk * (d + 1) + c] = sum_R[kk * (d + 1) + c] + best[c]
            c = c + 1
        }
        mask = mask + 1
    }
    let mut total: f64 = 0.0
    let mut c2: i64 = 0
    while c2 <= d {
        let mut s: f64 = 0.0
        let mut kk: i64 = 1
        while kk <= d {
            let avg: f64 = sum_R[kk * (d + 1) + c2] / comb(d, kk)
            s = s + V[kk] * avg
            kk = kk + 1
        }
        total = total + s
        c2 = c2 + 1
    }
    free(best)
    free(sum_R)
    free(V)
    return total
}

function main() -> i32 {
    let mut F: f64 = 0.0
    let mut d: i64 = 4
    while d <= 20 {
        F = F + compute_S_sum(d)
        d = d + 1
    }
    let ans: i64 = (F + 0.5) as i64
    printf("%lld\n", ans)
    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; }

double comb_i64_i64(int64_t n, int64_t k0);
int32_t invert_ptr_f64_i64_ptr_f64(double* A, int64_t n, double* out);
void visit_counts_i64_ptr_f64(int64_t d, double* V);
void best_profits_mask_i64_i64_i64_ptr_f64(int64_t mask0, int64_t d, int64_t max_c, double* best);
int64_t popcount_i64(int64_t x0);
double compute_S_sum_i64(int64_t d);
int32_t main(void);




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

int32_t invert_ptr_f64_i64_ptr_f64(double* A, int64_t n, double* out) {
    double* aug = (double*)(calloc((n * (2 * n)), 8));
    if (aug == NULL) {
        return 1;
    }
    int64_t i = 0;
    while (i < n) {
        int64_t j = 0;
        while (j < n) {
            aug[((i * (2 * n)) + j)] = A[((i * n) + j)];
            j = (j + 1);
        }
        j = 0;
        while (j < n) {
            if (i == j) {
                aug[(((i * (2 * n)) + n) + j)] = 1.0;
            } else {
                aug[(((i * (2 * n)) + n) + j)] = 0.0;
            }
            j = (j + 1);
        }
        i = (i + 1);
    }
    int64_t col = 0;
    while (col < n) {
        int64_t pivot = col;
        double best = fabs(aug[((pivot * (2 * n)) + col)]);
        int64_t r = (col + 1);
        while (r < n) {
            double v = fabs(aug[((r * (2 * n)) + col)]);
            if (v > best) {
                best = v;
                pivot = r;
            }
            r = (r + 1);
        }
        if (best == 0.0) {
            free(aug);
            return 1;
        }
        if (pivot != col) {
            int64_t j2 = 0;
            while (j2 < (2 * n)) {
                double tmp = aug[((col * (2 * n)) + j2)];
                aug[((col * (2 * n)) + j2)] = aug[((pivot * (2 * n)) + j2)];
                aug[((pivot * (2 * n)) + j2)] = tmp;
                j2 = (j2 + 1);
            }
        }
        double piv = aug[((col * (2 * n)) + col)];
        double invp = (1.0 / piv);
        int64_t j3 = 0;
        while (j3 < (2 * n)) {
            aug[((col * (2 * n)) + j3)] = (aug[((col * (2 * n)) + j3)] * invp);
            j3 = (j3 + 1);
        }
        r = 0;
        while (r < n) {
            if (r != col) {
                double f = aug[((r * (2 * n)) + col)];
                if (f != 0.0) {
                    j3 = 0;
                    while (j3 < (2 * n)) {
                        aug[((r * (2 * n)) + j3)] = (aug[((r * (2 * n)) + j3)] - (f * aug[((col * (2 * n)) + j3)]));
                        j3 = (j3 + 1);
                    }
                }
            }
            r = (r + 1);
        }
        col = (col + 1);
    }
    i = 0;
    while (i < n) {
        int64_t j = 0;
        while (j < n) {
            out[((i * n) + j)] = aug[(((i * (2 * n)) + n) + j)];
            j = (j + 1);
        }
        i = (i + 1);
    }
    free(aug);
    return 0;
}

void visit_counts_i64_ptr_f64(int64_t d, double* V) {
    int64_t n = d;
    double* A = (double*)(calloc((n * n), 8));
    double* Ninv = (double*)(calloc((n * n), 8));
    if ((A == NULL || Ninv == NULL)) {
        return;
    }
    int64_t k = 1;
    while (k <= d) {
        int64_t i = (k - 1);
        A[((i * n) + i)] = 1.0;
        if (k == d) {
            A[((i * n) + (d - 2))] = (A[((i * n) + (d - 2))] - 1.0);
        } else {
            double down = (((double)(k)) / ((double)(d)));
            double up = (((double)((d - k))) / ((double)(d)));
            if (k > 1) {
                A[((i * n) + (k - 2))] = (A[((i * n) + (k - 2))] - down);
            }
            if (k < d) {
                A[((i * n) + k)] = (A[((i * n) + k)] - up);
            }
        }
        k = (k + 1);
    }
    if (invert_ptr_f64_i64_ptr_f64(A, n, Ninv) != 0) {
        return;
    }
    int64_t start = (d - 1);
    k = 1;
    while (k <= d) {
        V[k] = Ninv[((start * n) + (k - 1))];
        k = (k + 1);
    }
    free(Ninv);
    free(A);
}

void best_profits_mask_i64_i64_i64_ptr_f64(int64_t mask0, int64_t d, int64_t max_c, double* best) {
    int64_t* vals = (int64_t*)(calloc((d + 1), 8));
    int64_t* cum = (int64_t*)(calloc((d + 1), 8));
    if ((vals == NULL || cum == NULL)) {
        return;
    }
    int64_t m = mask0;
    int64_t k = 0;
    int64_t total = 0;
    while (m != 0) {
        int64_t lsb = (m & (-m));
        int64_t v = 0;
        int64_t t = lsb;
        while (t > 0) {
            v = (v + 1);
            t = FLOW_CHECKED_DIV((t), (2));
        }
        vals[k] = v;
        total = (total + v);
        cum[k] = total;
        k = (k + 1);
        m = (m ^ lsb);
    }
    int64_t maxv = vals[(k - 1)];
    int64_t c = 0;
    while (c <= max_c) {
        best[c] = 0.0;
        c = (c + 1);
    }
    best[0] = ((double)(maxv));
    double prev = 0.0;
    int64_t p = 0;
    int64_t tt = 1;
    while (tt <= maxv) {
        while ((p < k && ((double)(vals[p])) < prev)) {
            p = (p + 1);
        }
        int64_t low_sum = 0;
        if (p > 0) {
            low_sum = cum[(p - 1)];
        }
        double sum_ge = ((double)((total - low_sum)));
        prev = (((prev * ((double)(p))) + sum_ge) / ((double)(k)));
        int64_t lim = ((int64_t)((prev / ((double)(tt)))));
        if (lim > max_c) {
            lim = max_c;
        }
        c = 1;
        while (c <= lim) {
            double prof = (prev - (((double)(c)) * ((double)(tt))));
            if (prof > best[c]) {
                best[c] = prof;
            }
            c = (c + 1);
        }
        tt = (tt + 1);
    }
    free(cum);
    free(vals);
}

int64_t popcount_i64(int64_t x0) {
    int64_t x = x0;
    int64_t c = 0;
    while (x > 0) {
        c = (c + (x & 1));
        x = FLOW_CHECKED_DIV((x), (2));
    }
    return c;
}

double compute_S_sum_i64(int64_t d) {
    double* V = (double*)(calloc((d + 1), 8));
    double* sum_R = (double*)(calloc(((d + 1) * (d + 1)), 8));
    double* best = (double*)(calloc((d + 1), 8));
    if (((V == NULL || sum_R == NULL) || best == NULL)) {
        return 0.0;
    }
    visit_counts_i64_ptr_f64(d, V);
    int64_t mask = 1;
    int64_t lim = FLOW_CHECKED_SHL((1), (d));
    while (mask < lim) {
        int64_t kk = popcount_i64(mask);
        best_profits_mask_i64_i64_i64_ptr_f64(mask, d, d, best);
        int64_t c = 0;
        while (c <= d) {
            sum_R[((kk * (d + 1)) + c)] = (sum_R[((kk * (d + 1)) + c)] + best[c]);
            c = (c + 1);
        }
        mask = (mask + 1);
    }
    double total = 0.0;
    int64_t c2 = 0;
    while (c2 <= d) {
        double s = 0.0;
        int64_t kk = 1;
        while (kk <= d) {
            double avg = (sum_R[((kk * (d + 1)) + c2)] / comb_i64_i64(d, kk));
            s = (s + (V[kk] * avg));
            kk = (kk + 1);
        }
        total = (total + s);
        c2 = (c2 + 1);
    }
    free(best);
    free(sum_R);
    free(V);
    return total;
}

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