Problem 547

Distance of Random Points Within Hollow Square Laminae — S(40).

Answer11730879.0023
Output11730879.0023
StatusPASS
Native helperno
Runtime10 ms
Peak memory1216 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(n)
Space complexityO(n^2)O(1)
ApproachFlow solutionEnumerative counting
VerdictSuboptimal

Flow source

# Project Euler 547
# Distance of Random Points Within Hollow Square Laminae — S(40).

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

const N: i64 = 40

function iabs(x: i64) -> i64 {
    if x < 0 { return -x }
    return x
}

function asinh_f(x: f64) -> f64 {
    return log(x + sqrt(x * x + 1.0))
}

function A_pos(a: f64, b: f64) -> f64 {
    if a == 0.0 || b == 0.0 { return 0.0 }
    let r: f64 = sqrt(a * a + b * b)
    return (2.0 * a * b * r + a * a * a * asinh_f(b / a) + b * b * b * asinh_f(a / b)) / 6.0
}

function build_tables(max_n: i64, A: ptr<f64>, F3: ptr<f64>, P5: ptr<f64>, off: i64) -> void {
    let size: i64 = 2 * max_n + 1
    let mut x: i64 = -max_n
    while x <= max_n {
        let mut sx: f64 = 1.0
        if x < 0 { sx = -1.0 }
        let ax: f64 = iabs(x) as f64
        let mut y: i64 = -max_n
        while y <= max_n {
            if x == 0 || y == 0 {
                A[x + off + (y + off) * size] = 0.0
            } else {
                let mut sy: f64 = 1.0
                if y < 0 { sy = -1.0 }
                let by: f64 = iabs(y) as f64
                A[x + off + (y + off) * size] = sx * sy * A_pos(ax, by)
            }
            y = y + 1
        }
        x = x + 1
    }
    let mut a: i64 = 0
    while a <= max_n {
        let a2: f64 = (a * a) as f64
        let a4: f64 = a2 * a2
        let mut y: i64 = -max_n
        while y <= max_n {
            if a == 0 {
                let yf: f64 = y as f64
                let ay: f64 = iabs(y) as f64
                F3[a * size + (y + off)] = yf * ay * ay * ay / 4.0
            } else {
                let yf: f64 = y as f64
                let r: f64 = sqrt(a2 + yf * yf)
                let yy: f64 = yf * yf
                F3[a * size + (y + off)] = (yf * r * (2.0 * yy + 5.0 * a2) + 3.0 * a4 * asinh_f(yf / (a as f64))) / 8.0
            }
            y = y + 1
        }
        a = a + 1
    }
    a = 0
    while a <= max_n {
        let aa: f64 = (a * a) as f64
        let mut b: i64 = 0
        while b <= max_n {
            let bb: f64 = (b * b) as f64
            P5[a * (max_n + 1) + b] = (aa + bb) * (aa + bb) * sqrt(aa + bb)
            b = b + 1
        }
        a = a + 1
    }
}

function I0(x0: i64, x1: i64, y0: i64, y1: i64, A: ptr<f64>, off: i64, size: i64) -> f64 {
    return A[x1 + off + (y1 + off) * size] - A[x0 + off + (y1 + off) * size]
        - A[x1 + off + (y0 + off) * size] + A[x0 + off + (y0 + off) * size]
}

function Ix(x0: i64, x1: i64, y0: i64, y1: i64, F3: ptr<f64>, off: i64, size: i64) -> f64 {
    let a1: i64 = iabs(x1)
    let a0: i64 = iabs(x0)
    return ((F3[a1 * size + (y1 + off)] - F3[a1 * size + (y0 + off)])
        - (F3[a0 * size + (y1 + off)] - F3[a0 * size + (y0 + off)])) / 3.0
}

function Iy(x0: i64, x1: i64, y0: i64, y1: i64, F3: ptr<f64>, off: i64, size: i64) -> f64 {
    return Ix(y0, y1, x0, x1, F3, off, size)
}

function Ixy(x0: i64, x1: i64, y0: i64, y1: i64, P5: ptr<f64>, max_n: i64) -> f64 {
    let ax1: i64 = iabs(x1)
    let ax0: i64 = iabs(x0)
    let ay1: i64 = iabs(y1)
    let ay0: i64 = iabs(y0)
    return (P5[ax1 * (max_n + 1) + ay1] - P5[ax0 * (max_n + 1) + ay1]
        - P5[ax1 * (max_n + 1) + ay0] + P5[ax0 * (max_n + 1) + ay0]) / 15.0
}

function seg_term(x0: i64, x1: i64, mx: f64, cx: f64,
                  y0: i64, y1: i64, my: f64, cy: f64,
                  A: ptr<f64>, F3: ptr<f64>, P5: ptr<f64>, off: i64, size: i64, max_n: i64) -> f64 {
    let i0: f64 = I0(x0, x1, y0, y1, A, off, size)
    let mut term: f64 = cx * cy * i0
    if mx != 0.0 { term = term + mx * cy * Ix(x0, x1, y0, y1, F3, off, size) }
    if my != 0.0 { term = term + cx * my * Iy(x0, x1, y0, y1, F3, off, size) }
    if mx != 0.0 && my != 0.0 { term = term + mx * my * Ixy(x0, x1, y0, y1, P5, max_n) }
    return term
}

function cross_integral(outer_w: i64, outer_h: i64, inner_w: i64, inner_h: i64, left: i64, bottom: i64,
                        A: ptr<f64>, F3: ptr<f64>, P5: ptr<f64>, off: i64, size: i64, max_n: i64) -> f64 {
    let right: i64 = outer_w - left - inner_w
    let top: i64 = outer_h - bottom - inner_h
    let mut total: f64 = 0.0
    let a0: i64 = -(left + inner_w)
    let a1: i64 = -left
    if a0 != a1 {
        total = total + seg_term(a0, a1, 1.0, (left + inner_w) as f64, -(bottom + inner_h), -bottom, 1.0, (bottom + inner_h) as f64, A, F3, P5, off, size, max_n)
        total = total + seg_term(a0, a1, 1.0, (left + inner_w) as f64, -bottom, top, 0.0, inner_h as f64, A, F3, P5, off, size, max_n)
        total = total + seg_term(a0, a1, 1.0, (left + inner_w) as f64, top, outer_h - bottom, -1.0, (outer_h - bottom) as f64, A, F3, P5, off, size, max_n)
    }
    total = total + seg_term(-left, right, 0.0, inner_w as f64, -(bottom + inner_h), -bottom, 1.0, (bottom + inner_h) as f64, A, F3, P5, off, size, max_n)
    total = total + seg_term(-left, right, 0.0, inner_w as f64, -bottom, top, 0.0, inner_h as f64, A, F3, P5, off, size, max_n)
    total = total + seg_term(-left, right, 0.0, inner_w as f64, top, outer_h - bottom, -1.0, (outer_h - bottom) as f64, A, F3, P5, off, size, max_n)
    total = total + seg_term(right, outer_w - left, -1.0, (outer_w - left) as f64, -(bottom + inner_h), -bottom, 1.0, (bottom + inner_h) as f64, A, F3, P5, off, size, max_n)
    total = total + seg_term(right, outer_w - left, -1.0, (outer_w - left) as f64, -bottom, top, 0.0, inner_h as f64, A, F3, P5, off, size, max_n)
    total = total + seg_term(right, outer_w - left, -1.0, (outer_w - left) as f64, top, outer_h - bottom, -1.0, (outer_h - bottom) as f64, A, F3, P5, off, size, max_n)
    return total
}

function solve_S(n: i64) -> f64 {
    let off: i64 = n
    let size: i64 = 2 * n + 1
    let A: ptr<f64> = calloc(size * size, 8)
    let F3: ptr<f64> = calloc((n + 1) * size, 8)
    let P5: ptr<f64> = calloc((n + 1) * (n + 1), 8)
    if A == null || F3 == null || P5 == null { return 0.0 }
    build_tables(n, A, F3, P5, off)
    let I_outer: f64 = cross_integral(n, n, n, n, 0, 0, A, F3, P5, off, size, n)
    let I_hole: ptr<f64> = calloc(n * n, 8)
    if I_hole == null { free(A); free(F3); free(P5); return 0.0 }
    let mut w: i64 = 1
    while w < n - 1 {
        let mut h: i64 = 1
        while h < n - 1 {
            I_hole[w * n + h] = cross_integral(w, h, w, h, 0, 0, A, F3, P5, off, size, n)
            h = h + 1
        }
        w = w + 1
    }
    let mut S_total: f64 = 0.0
    w = 1
    while w < n - 1 {
        let mut h: i64 = 1
        while h < n - 1 {
            let area: f64 = (n * n - w * h) as f64
            let inv_area2: f64 = 1.0 / (area * area)
            let Ih: f64 = I_hole[w * n + h]
            let mut left: i64 = 1
            while left < n - w {
                let mut bottom: i64 = 1
                while bottom < n - h {
                    let I_cross: f64 = cross_integral(n, n, w, h, left, bottom, A, F3, P5, off, size, n)
                    let I_region: f64 = I_outer - 2.0 * I_cross + Ih
                    S_total = S_total + I_region * inv_area2
                    bottom = bottom + 1
                }
                left = left + 1
            }
            h = h + 1
        }
        w = w + 1
    }
    free(A); free(F3); free(P5); free(I_hole)
    return S_total
}

function main() -> i32 {
    let ans: f64 = solve_S(N)
    printf("%.4f\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; }

int64_t iabs_i64(int64_t x);
double asinh_f_f64(double x);
double A_pos_f64_f64(double a, double b);
void build_tables_i64_ptr_f64_ptr_f64_ptr_f64_i64(int64_t max_n, double* A, double* F3, double* P5, int64_t off);
double I0_i64_i64_i64_i64_ptr_f64_i64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* A, int64_t off, int64_t size);
double Ix_i64_i64_i64_i64_ptr_f64_i64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* F3, int64_t off, int64_t size);
double Iy_i64_i64_i64_i64_ptr_f64_i64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* F3, int64_t off, int64_t size);
double Ixy_i64_i64_i64_i64_ptr_f64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* P5, int64_t max_n);
double seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(int64_t x0, int64_t x1, double mx, double cx, int64_t y0, int64_t y1, double my, double cy, double* A, double* F3, double* P5, int64_t off, int64_t size, int64_t max_n);
double cross_integral_i64_i64_i64_i64_i64_i64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(int64_t outer_w, int64_t outer_h, int64_t inner_w, int64_t inner_h, int64_t left, int64_t bottom, double* A, double* F3, double* P5, int64_t off, int64_t size, int64_t max_n);
double solve_S_i64(int64_t n);
int32_t main(void);

static const int64_t N = 40;





int64_t iabs_i64(int64_t x) {
    if (x < 0) {
        return (-x);
    }
    return x;
}

double asinh_f_f64(double x) {
    return log((x + sqrt(((x * x) + 1.0))));
}

double A_pos_f64_f64(double a, double b) {
    if ((a == 0.0 || b == 0.0)) {
        return 0.0;
    }
    double r = sqrt(((a * a) + (b * b)));
    return ((((((2.0 * a) * b) * r) + (((a * a) * a) * asinh_f_f64((b / a)))) + (((b * b) * b) * asinh_f_f64((a / b)))) / 6.0);
}

void build_tables_i64_ptr_f64_ptr_f64_ptr_f64_i64(int64_t max_n, double* A, double* F3, double* P5, int64_t off) {
    int64_t size = ((2 * max_n) + 1);
    int64_t x = (-max_n);
    while (x <= max_n) {
        double sx = 1.0;
        if (x < 0) {
            sx = (-1.0);
        }
        double ax = ((double)(iabs_i64(x)));
        int64_t y = (-max_n);
        while (y <= max_n) {
            if ((x == 0 || y == 0)) {
                A[((x + off) + ((y + off) * size))] = 0.0;
            } else {
                double sy = 1.0;
                if (y < 0) {
                    sy = (-1.0);
                }
                double by = ((double)(iabs_i64(y)));
                A[((x + off) + ((y + off) * size))] = ((sx * sy) * A_pos_f64_f64(ax, by));
            }
            y = (y + 1);
        }
        x = (x + 1);
    }
    int64_t a = 0;
    while (a <= max_n) {
        double a2 = ((double)((a * a)));
        double a4 = (a2 * a2);
        int64_t y = (-max_n);
        while (y <= max_n) {
            if (a == 0) {
                double yf = ((double)(y));
                double ay = ((double)(iabs_i64(y)));
                F3[((a * size) + (y + off))] = ((((yf * ay) * ay) * ay) / 4.0);
            } else {
                double yf = ((double)(y));
                double r = sqrt((a2 + (yf * yf)));
                double yy = (yf * yf);
                F3[((a * size) + (y + off))] = ((((yf * r) * ((2.0 * yy) + (5.0 * a2))) + ((3.0 * a4) * asinh_f_f64((yf / ((double)(a)))))) / 8.0);
            }
            y = (y + 1);
        }
        a = (a + 1);
    }
    a = 0;
    while (a <= max_n) {
        double aa = ((double)((a * a)));
        int64_t b = 0;
        while (b <= max_n) {
            double bb = ((double)((b * b)));
            P5[((a * (max_n + 1)) + b)] = (((aa + bb) * (aa + bb)) * sqrt((aa + bb)));
            b = (b + 1);
        }
        a = (a + 1);
    }
}

double I0_i64_i64_i64_i64_ptr_f64_i64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* A, int64_t off, int64_t size) {
    return (((A[((x1 + off) + ((y1 + off) * size))] - A[((x0 + off) + ((y1 + off) * size))]) - A[((x1 + off) + ((y0 + off) * size))]) + A[((x0 + off) + ((y0 + off) * size))]);
}

double Ix_i64_i64_i64_i64_ptr_f64_i64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* F3, int64_t off, int64_t size) {
    int64_t a1 = iabs_i64(x1);
    int64_t a0 = iabs_i64(x0);
    return (((F3[((a1 * size) + (y1 + off))] - F3[((a1 * size) + (y0 + off))]) - (F3[((a0 * size) + (y1 + off))] - F3[((a0 * size) + (y0 + off))])) / 3.0);
}

double Iy_i64_i64_i64_i64_ptr_f64_i64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* F3, int64_t off, int64_t size) {
    return Ix_i64_i64_i64_i64_ptr_f64_i64_i64(y0, y1, x0, x1, F3, off, size);
}

double Ixy_i64_i64_i64_i64_ptr_f64_i64(int64_t x0, int64_t x1, int64_t y0, int64_t y1, double* P5, int64_t max_n) {
    int64_t ax1 = iabs_i64(x1);
    int64_t ax0 = iabs_i64(x0);
    int64_t ay1 = iabs_i64(y1);
    int64_t ay0 = iabs_i64(y0);
    return ((((P5[((ax1 * (max_n + 1)) + ay1)] - P5[((ax0 * (max_n + 1)) + ay1)]) - P5[((ax1 * (max_n + 1)) + ay0)]) + P5[((ax0 * (max_n + 1)) + ay0)]) / 15.0);
}

double seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(int64_t x0, int64_t x1, double mx, double cx, int64_t y0, int64_t y1, double my, double cy, double* A, double* F3, double* P5, int64_t off, int64_t size, int64_t max_n) {
    double i0 = I0_i64_i64_i64_i64_ptr_f64_i64_i64(x0, x1, y0, y1, A, off, size);
    double term = ((cx * cy) * i0);
    if (mx != 0.0) {
        term = (term + ((mx * cy) * Ix_i64_i64_i64_i64_ptr_f64_i64_i64(x0, x1, y0, y1, F3, off, size)));
    }
    if (my != 0.0) {
        term = (term + ((cx * my) * Iy_i64_i64_i64_i64_ptr_f64_i64_i64(x0, x1, y0, y1, F3, off, size)));
    }
    if ((mx != 0.0 && my != 0.0)) {
        term = (term + ((mx * my) * Ixy_i64_i64_i64_i64_ptr_f64_i64(x0, x1, y0, y1, P5, max_n)));
    }
    return term;
}

double cross_integral_i64_i64_i64_i64_i64_i64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(int64_t outer_w, int64_t outer_h, int64_t inner_w, int64_t inner_h, int64_t left, int64_t bottom, double* A, double* F3, double* P5, int64_t off, int64_t size, int64_t max_n) {
    int64_t right = ((outer_w - left) - inner_w);
    int64_t top = ((outer_h - bottom) - inner_h);
    double total = 0.0;
    int64_t a0 = (-(left + inner_w));
    int64_t a1 = (-left);
    if (a0 != a1) {
        total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(a0, a1, 1.0, ((double)((left + inner_w))), (-(bottom + inner_h)), (-bottom), 1.0, ((double)((bottom + inner_h))), A, F3, P5, off, size, max_n));
        total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(a0, a1, 1.0, ((double)((left + inner_w))), (-bottom), top, 0.0, ((double)(inner_h)), A, F3, P5, off, size, max_n));
        total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(a0, a1, 1.0, ((double)((left + inner_w))), top, (outer_h - bottom), (-1.0), ((double)((outer_h - bottom))), A, F3, P5, off, size, max_n));
    }
    total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64((-left), right, 0.0, ((double)(inner_w)), (-(bottom + inner_h)), (-bottom), 1.0, ((double)((bottom + inner_h))), A, F3, P5, off, size, max_n));
    total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64((-left), right, 0.0, ((double)(inner_w)), (-bottom), top, 0.0, ((double)(inner_h)), A, F3, P5, off, size, max_n));
    total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64((-left), right, 0.0, ((double)(inner_w)), top, (outer_h - bottom), (-1.0), ((double)((outer_h - bottom))), A, F3, P5, off, size, max_n));
    total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(right, (outer_w - left), (-1.0), ((double)((outer_w - left))), (-(bottom + inner_h)), (-bottom), 1.0, ((double)((bottom + inner_h))), A, F3, P5, off, size, max_n));
    total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(right, (outer_w - left), (-1.0), ((double)((outer_w - left))), (-bottom), top, 0.0, ((double)(inner_h)), A, F3, P5, off, size, max_n));
    total = (total + seg_term_i64_i64_f64_f64_i64_i64_f64_f64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(right, (outer_w - left), (-1.0), ((double)((outer_w - left))), top, (outer_h - bottom), (-1.0), ((double)((outer_h - bottom))), A, F3, P5, off, size, max_n));
    return total;
}

double solve_S_i64(int64_t n) {
    int64_t off = n;
    int64_t size = ((2 * n) + 1);
    double* A = (double*)(calloc((size * size), 8));
    double* F3 = (double*)(calloc(((n + 1) * size), 8));
    double* P5 = (double*)(calloc(((n + 1) * (n + 1)), 8));
    if (((A == NULL || F3 == NULL) || P5 == NULL)) {
        return 0.0;
    }
    build_tables_i64_ptr_f64_ptr_f64_ptr_f64_i64(n, A, F3, P5, off);
    double I_outer = cross_integral_i64_i64_i64_i64_i64_i64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(n, n, n, n, 0, 0, A, F3, P5, off, size, n);
    double* I_hole = (double*)(calloc((n * n), 8));
    if (I_hole == NULL) {
        free(A);
        free(F3);
        free(P5);
        return 0.0;
    }
    int64_t w = 1;
    while (w < (n - 1)) {
        int64_t h = 1;
        while (h < (n - 1)) {
            I_hole[((w * n) + h)] = cross_integral_i64_i64_i64_i64_i64_i64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(w, h, w, h, 0, 0, A, F3, P5, off, size, n);
            h = (h + 1);
        }
        w = (w + 1);
    }
    double S_total = 0.0;
    w = 1;
    while (w < (n - 1)) {
        int64_t h = 1;
        while (h < (n - 1)) {
            double area = ((double)(((n * n) - (w * h))));
            double inv_area2 = (1.0 / (area * area));
            double Ih = I_hole[((w * n) + h)];
            int64_t left = 1;
            while (left < (n - w)) {
                int64_t bottom = 1;
                while (bottom < (n - h)) {
                    double I_cross = cross_integral_i64_i64_i64_i64_i64_i64_ptr_f64_ptr_f64_ptr_f64_i64_i64_i64(n, n, w, h, left, bottom, A, F3, P5, off, size, n);
                    double I_region = ((I_outer - (2.0 * I_cross)) + Ih);
                    S_total = (S_total + (I_region * inv_area2));
                    bottom = (bottom + 1);
                }
                left = (left + 1);
            }
            h = (h + 1);
        }
        w = (w + 1);
    }
    free(A);
    free(F3);
    free(P5);
    free(I_hole);
    return S_total;
}

int32_t main(void) {
    double ans = solve_S_i64(N);
    printf("%.4f\n", ans);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%.4f\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @sqrt(f64) -> f64
  func.func private @log(f64) -> f64
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  // Constant: N
  llvm.mlir.global internal constant @N(40 : i64) : i64
  func.func @iabs(%arg0: i64) -> i64 {
    %0 = arith.constant 0 : i32
    %2 = arith.extsi %0 : i32 to i64
    %1 = arith.cmpi slt, %arg0, %2 : i64
    cf.cond_br %1, ^bb0, ^bb1
    ^bb0:
      %4 = arith.constant 0 : i64
      %3 = arith.subi %4, %arg0 : i64
      func.return %3 : i64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    func.return %arg0 : i64
  }
  func.func @asinh_f(%arg0: f64) -> f64 {
    %5 = arith.mulf %arg0, %arg0 : f64
    %6 = arith.constant 1.0 : f32
    %8 = arith.extf %6 : f32 to f64
    %7 = arith.addf %5, %8 : f64
    %9 = math.sqrt %7 : f64
    %10 = arith.addf %arg0, %9 : f64
    %11 = math.log %10 : f64
    func.return %11 : f64
  }
  func.func @A_pos(%arg0: f64, %arg1: f64) -> f64 {
    %12 = arith.constant 0.0 : f32
    %14 = arith.extf %12 : f32 to f64
    %13 = arith.cmpf oeq, %arg0, %14 : f64
    %15 = scf.if %13 -> (i1) {
      %16 = arith.constant true
      scf.yield %16 : i1
    } else {
      %17 = arith.constant 0.0 : f32
      %19 = arith.extf %17 : f32 to f64
      %18 = arith.cmpf oeq, %arg1, %19 : f64
      scf.yield %18 : i1
    }
    cf.cond_br %15, ^bb3, ^bb4
    ^bb3:
      %20 = arith.constant 0.0 : f32
      %21 = arith.extf %20 : f32 to f64
      func.return %21 : f64
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %22 = arith.mulf %arg0, %arg0 : f64
    %23 = arith.mulf %arg1, %arg1 : f64
    %24 = arith.addf %22, %23 : f64
    %25 = math.sqrt %24 : f64
    %26 = arith.constant 2.0 : f32
    %28 = arith.extf %26 : f32 to f64
    %27 = arith.mulf %28, %arg0 : f64
    %29 = arith.mulf %27, %arg1 : f64
    %30 = arith.mulf %29, %25 : f64
    %31 = arith.mulf %arg0, %arg0 : f64
    %32 = arith.mulf %31, %arg0 : f64
    %34 = arith.divf %arg1, %arg0 : f64
    %33 = func.call @asinh_f(%34) : (f64) -> f64
    %35 = arith.mulf %32, %33 : f64
    %36 = arith.addf %30, %35 : f64
    %37 = arith.mulf %arg1, %arg1 : f64
    %38 = arith.mulf %37, %arg1 : f64
    %40 = arith.divf %arg0, %arg1 : f64
    %39 = func.call @asinh_f(%40) : (f64) -> f64
    %41 = arith.mulf %38, %39 : f64
    %42 = arith.addf %36, %41 : f64
    %43 = arith.constant 6.0 : f32
    %45 = arith.extf %43 : f32 to f64
    %44 = arith.divf %42, %45 : f64
    func.return %44 : f64
  }
  func.func @build_tables(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i64) -> () {
    %46 = arith.constant 2 : i32
    %48 = arith.extsi %46 : i32 to i64
    %47 = arith.muli %48, %arg0 : i64
    %49 = arith.constant 1 : i32
    %51 = arith.extsi %49 : i32 to i64
    %50 = arith.addi %47, %51 : i64
    %53 = arith.constant 0 : i64
    %52 = arith.subi %53, %arg0 : i64
    %54 = llvm.mlir.constant(1 : i64) : i64
    %55 = llvm.alloca %54 x i64 : (i64) -> !llvm.ptr
    llvm.store %52, %55 : i64, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %56 = llvm.load %55 : !llvm.ptr -> i64
    %57 = arith.cmpi sle, %56, %arg0 : i64
    cf.cond_br %57, ^bb7, ^bb8
    ^bb7:
      %58 = arith.constant 1.0 : f32
      %59 = arith.extf %58 : f32 to f64
      %60 = llvm.mlir.constant(1 : i64) : i64
      %61 = llvm.alloca %60 x f64 : (i64) -> !llvm.ptr
      llvm.store %59, %61 : f64, !llvm.ptr
      %62 = llvm.load %55 : !llvm.ptr -> i64
      %63 = arith.constant 0 : i32
      %65 = arith.extsi %63 : i32 to i64
      %64 = arith.cmpi slt, %62, %65 : i64
      cf.cond_br %64, ^bb9, ^bb10
      ^bb9:
        %66 = arith.constant 1.0 : f32
        %67 = arith.negf %66 : f32
        %68 = arith.extf %67 : f32 to f64
        llvm.store %68, %61 : f64, !llvm.ptr
        cf.br ^bb11
      ^bb10:
        cf.br ^bb11
      ^bb11:
      %70 = llvm.load %55 : !llvm.ptr -> i64
      %69 = func.call @iabs(%70) : (i64) -> i64
      %71 = arith.sitofp %69 : i64 to f64
      %73 = arith.constant 0 : i64
      %72 = arith.subi %73, %arg0 : i64
      %74 = llvm.mlir.constant(1 : i64) : i64
      %75 = llvm.alloca %74 x i64 : (i64) -> !llvm.ptr
      llvm.store %72, %75 : i64, !llvm.ptr
      cf.br ^bb12
      ^bb12:
      %76 = llvm.load %75 : !llvm.ptr -> i64
      %77 = arith.cmpi sle, %76, %arg0 : i64
      cf.cond_br %77, ^bb13, ^bb14
      ^bb13:
        %78 = llvm.load %55 : !llvm.ptr -> i64
        %79 = arith.constant 0 : i32
        %81 = arith.extsi %79 : i32 to i64
        %80 = arith.cmpi eq, %78, %81 : i64
        %82 = scf.if %80 -> (i1) {
          %83 = arith.constant true
          scf.yield %83 : i1
        } else {
          %84 = llvm.load %75 : !llvm.ptr -> i64
          %85 = arith.constant 0 : i32
          %87 = arith.extsi %85 : i32 to i64
          %86 = arith.cmpi eq, %84, %87 : i64
          scf.yield %86 : i1
        }
        cf.cond_br %82, ^bb15, ^bb16
        ^bb15:
          %88 = arith.constant 0.0 : f32
          %89 = llvm.load %55 : !llvm.ptr -> i64
          %90 = arith.addi %89, %arg4 : i64
          %91 = llvm.load %75 : !llvm.ptr -> i64
          %92 = arith.addi %91, %arg4 : i64
          %93 = arith.muli %92, %50 : i64
          %94 = arith.addi %90, %93 : i64
          %95 = arith.extf %88 : f32 to f64
          %96 = llvm.getelementptr %arg1[%94] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          llvm.store %95, %96 : f64, !llvm.ptr
          cf.br ^bb17
        ^bb16:
          %97 = arith.constant 1.0 : f32
          %98 = arith.extf %97 : f32 to f64
          %99 = llvm.mlir.constant(1 : i64) : i64
          %100 = llvm.alloca %99 x f64 : (i64) -> !llvm.ptr
          llvm.store %98, %100 : f64, !llvm.ptr
          %101 = llvm.load %75 : !llvm.ptr -> i64
          %102 = arith.constant 0 : i32
          %104 = arith.extsi %102 : i32 to i64
          %103 = arith.cmpi slt, %101, %104 : i64
          cf.cond_br %103, ^bb18, ^bb19
          ^bb18:
            %105 = arith.constant 1.0 : f32
            %106 = arith.negf %105 : f32
            %107 = arith.extf %106 : f32 to f64
            llvm.store %107, %100 : f64, !llvm.ptr
            cf.br ^bb20
          ^bb19:
            cf.br ^bb20
          ^bb20:
          %109 = llvm.load %75 : !llvm.ptr -> i64
          %108 = func.call @iabs(%109) : (i64) -> i64
          %110 = arith.sitofp %108 : i64 to f64
          %111 = llvm.load %61 : !llvm.ptr -> f64
          %112 = llvm.load %100 : !llvm.ptr -> f64
          %113 = arith.mulf %111, %112 : f64
          %114 = func.call @A_pos(%71, %110) : (f64, f64) -> f64
          %115 = arith.mulf %113, %114 : f64
          %116 = llvm.load %55 : !llvm.ptr -> i64
          %117 = arith.addi %116, %arg4 : i64
          %118 = llvm.load %75 : !llvm.ptr -> i64
          %119 = arith.addi %118, %arg4 : i64
          %120 = arith.muli %119, %50 : i64
          %121 = arith.addi %117, %120 : i64
          %122 = llvm.getelementptr %arg1[%121] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          llvm.store %115, %122 : f64, !llvm.ptr
          cf.br ^bb17
        ^bb17:
        %123 = llvm.load %75 : !llvm.ptr -> i64
        %124 = arith.constant 1 : i32
        %126 = arith.extsi %124 : i32 to i64
        %125 = arith.addi %123, %126 : i64
        llvm.store %125, %75 : i64, !llvm.ptr
        cf.br ^bb12
      ^bb14:
      %127 = llvm.load %55 : !llvm.ptr -> i64
      %128 = arith.constant 1 : i32
      %130 = arith.extsi %128 : i32 to i64
      %129 = arith.addi %127, %130 : i64
      llvm.store %129, %55 : i64, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %131 = arith.constant 0 : i32
    %132 = arith.extsi %131 : i32 to i64
    %133 = llvm.mlir.constant(1 : i64) : i64
    %134 = llvm.alloca %133 x i64 : (i64) -> !llvm.ptr
    llvm.store %132, %134 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %135 = llvm.load %134 : !llvm.ptr -> i64
    %136 = arith.cmpi sle, %135, %arg0 : i64
    cf.cond_br %136, ^bb22, ^bb23
    ^bb22:
      %137 = llvm.load %134 : !llvm.ptr -> i64
      %138 = llvm.load %134 : !llvm.ptr -> i64
      %139 = arith.muli %137, %138 : i64
      %140 = arith.sitofp %139 : i64 to f64
      %141 = arith.mulf %140, %140 : f64
      %143 = arith.constant 0 : i64
      %142 = arith.subi %143, %arg0 : 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 ^bb24
      ^bb24:
      %146 = llvm.load %145 : !llvm.ptr -> i64
      %147 = arith.cmpi sle, %146, %arg0 : i64
      cf.cond_br %147, ^bb25, ^bb26
      ^bb25:
        %148 = llvm.load %134 : !llvm.ptr -> i64
        %149 = arith.constant 0 : i32
        %151 = arith.extsi %149 : i32 to i64
        %150 = arith.cmpi eq, %148, %151 : i64
        cf.cond_br %150, ^bb27, ^bb28
        ^bb27:
          %152 = llvm.load %145 : !llvm.ptr -> i64
          %153 = arith.sitofp %152 : i64 to f64
          %155 = llvm.load %145 : !llvm.ptr -> i64
          %154 = func.call @iabs(%155) : (i64) -> i64
          %156 = arith.sitofp %154 : i64 to f64
          %157 = arith.mulf %153, %156 : f64
          %158 = arith.mulf %157, %156 : f64
          %159 = arith.mulf %158, %156 : f64
          %160 = arith.constant 4.0 : f32
          %162 = arith.extf %160 : f32 to f64
          %161 = arith.divf %159, %162 : f64
          %163 = llvm.load %134 : !llvm.ptr -> i64
          %164 = arith.muli %163, %50 : i64
          %165 = llvm.load %145 : !llvm.ptr -> i64
          %166 = arith.addi %165, %arg4 : i64
          %167 = arith.addi %164, %166 : i64
          %168 = llvm.getelementptr %arg2[%167] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          llvm.store %161, %168 : f64, !llvm.ptr
          cf.br ^bb29
        ^bb28:
          %169 = llvm.load %145 : !llvm.ptr -> i64
          %170 = arith.sitofp %169 : i64 to f64
          %171 = arith.mulf %170, %170 : f64
          %172 = arith.addf %140, %171 : f64
          %173 = math.sqrt %172 : f64
          %174 = arith.mulf %170, %170 : f64
          %175 = arith.mulf %170, %173 : f64
          %176 = arith.constant 2.0 : f32
          %178 = arith.extf %176 : f32 to f64
          %177 = arith.mulf %178, %174 : f64
          %179 = arith.constant 5.0 : f32
          %181 = arith.extf %179 : f32 to f64
          %180 = arith.mulf %181, %140 : f64
          %182 = arith.addf %177, %180 : f64
          %183 = arith.mulf %175, %182 : f64
          %184 = arith.constant 3.0 : f32
          %186 = arith.extf %184 : f32 to f64
          %185 = arith.mulf %186, %141 : f64
          %188 = llvm.load %134 : !llvm.ptr -> i64
          %189 = arith.sitofp %188 : i64 to f64
          %190 = arith.divf %170, %189 : f64
          %187 = func.call @asinh_f(%190) : (f64) -> f64
          %191 = arith.mulf %185, %187 : f64
          %192 = arith.addf %183, %191 : f64
          %193 = arith.constant 8.0 : f32
          %195 = arith.extf %193 : f32 to f64
          %194 = arith.divf %192, %195 : f64
          %196 = llvm.load %134 : !llvm.ptr -> i64
          %197 = arith.muli %196, %50 : i64
          %198 = llvm.load %145 : !llvm.ptr -> i64
          %199 = arith.addi %198, %arg4 : i64
          %200 = arith.addi %197, %199 : i64
          %201 = llvm.getelementptr %arg2[%200] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          llvm.store %194, %201 : f64, !llvm.ptr
          cf.br ^bb29
        ^bb29:
        %202 = llvm.load %145 : !llvm.ptr -> i64
        %203 = arith.constant 1 : i32
        %205 = arith.extsi %203 : i32 to i64
        %204 = arith.addi %202, %205 : i64
        llvm.store %204, %145 : i64, !llvm.ptr
        cf.br ^bb24
      ^bb26:
      %206 = llvm.load %134 : !llvm.ptr -> i64
      %207 = arith.constant 1 : i32
      %209 = arith.extsi %207 : i32 to i64
      %208 = arith.addi %206, %209 : i64
      llvm.store %208, %134 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %210 = arith.constant 0 : i32
    %211 = arith.extsi %210 : i32 to i64
    llvm.store %211, %134 : i64, !llvm.ptr
    cf.br ^bb30
    ^bb30:
    %212 = llvm.load %134 : !llvm.ptr -> i64
    %213 = arith.cmpi sle, %212, %arg0 : i64
    cf.cond_br %213, ^bb31, ^bb32
    ^bb31:
      %214 = llvm.load %134 : !llvm.ptr -> i64
      %215 = llvm.load %134 : !llvm.ptr -> i64
      %216 = arith.muli %214, %215 : i64
      %217 = arith.sitofp %216 : i64 to f64
      %218 = arith.constant 0 : i32
      %219 = arith.extsi %218 : i32 to i64
      %220 = llvm.mlir.constant(1 : i64) : i64
      %221 = llvm.alloca %220 x i64 : (i64) -> !llvm.ptr
      llvm.store %219, %221 : i64, !llvm.ptr
      cf.br ^bb33
      ^bb33:
      %222 = llvm.load %221 : !llvm.ptr -> i64
      %223 = arith.cmpi sle, %222, %arg0 : i64
      cf.cond_br %223, ^bb34, ^bb35
      ^bb34:
        %224 = llvm.load %221 : !llvm.ptr -> i64
        %225 = llvm.load %221 : !llvm.ptr -> i64
        %226 = arith.muli %224, %225 : i64
        %227 = arith.sitofp %226 : i64 to f64
        %228 = arith.addf %217, %227 : f64
        %229 = arith.addf %217, %227 : f64
        %230 = arith.mulf %228, %229 : f64
        %231 = arith.addf %217, %227 : f64
        %232 = math.sqrt %231 : f64
        %233 = arith.mulf %230, %232 : f64
        %234 = llvm.load %134 : !llvm.ptr -> i64
        %235 = arith.constant 1 : i32
        %237 = arith.extsi %235 : i32 to i64
        %236 = arith.addi %arg0, %237 : i64
        %238 = arith.muli %234, %236 : i64
        %239 = llvm.load %221 : !llvm.ptr -> i64
        %240 = arith.addi %238, %239 : i64
        %241 = llvm.getelementptr %arg3[%240] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %233, %241 : f64, !llvm.ptr
        %242 = llvm.load %221 : !llvm.ptr -> i64
        %243 = arith.constant 1 : i32
        %245 = arith.extsi %243 : i32 to i64
        %244 = arith.addi %242, %245 : i64
        llvm.store %244, %221 : i64, !llvm.ptr
        cf.br ^bb33
      ^bb35:
      %246 = llvm.load %134 : !llvm.ptr -> i64
      %247 = arith.constant 1 : i32
      %249 = arith.extsi %247 : i32 to i64
      %248 = arith.addi %246, %249 : i64
      llvm.store %248, %134 : i64, !llvm.ptr
      cf.br ^bb30
    ^bb32:
    func.return
  }
  func.func @I0(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: i64, %arg6: i64) -> f64 {
    %251 = arith.addi %arg1, %arg5 : i64
    %252 = arith.addi %arg3, %arg5 : i64
    %253 = arith.muli %252, %arg6 : i64
    %254 = arith.addi %251, %253 : i64
    %255 = llvm.getelementptr %arg4[%254] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %250 = llvm.load %255 : !llvm.ptr -> f64
    %257 = arith.addi %arg0, %arg5 : i64
    %258 = arith.addi %arg3, %arg5 : i64
    %259 = arith.muli %258, %arg6 : i64
    %260 = arith.addi %257, %259 : i64
    %261 = llvm.getelementptr %arg4[%260] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %256 = llvm.load %261 : !llvm.ptr -> f64
    %262 = arith.subf %250, %256 : f64
    %264 = arith.addi %arg1, %arg5 : i64
    %265 = arith.addi %arg2, %arg5 : i64
    %266 = arith.muli %265, %arg6 : i64
    %267 = arith.addi %264, %266 : i64
    %268 = llvm.getelementptr %arg4[%267] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %263 = llvm.load %268 : !llvm.ptr -> f64
    %269 = arith.subf %262, %263 : f64
    %271 = arith.addi %arg0, %arg5 : i64
    %272 = arith.addi %arg2, %arg5 : i64
    %273 = arith.muli %272, %arg6 : i64
    %274 = arith.addi %271, %273 : i64
    %275 = llvm.getelementptr %arg4[%274] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %270 = llvm.load %275 : !llvm.ptr -> f64
    %276 = arith.addf %269, %270 : f64
    func.return %276 : f64
  }
  func.func @Ix(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: i64, %arg6: i64) -> f64 {
    %277 = func.call @iabs(%arg1) : (i64) -> i64
    %278 = func.call @iabs(%arg0) : (i64) -> i64
    %280 = arith.muli %277, %arg6 : i64
    %281 = arith.addi %arg3, %arg5 : i64
    %282 = arith.addi %280, %281 : i64
    %283 = llvm.getelementptr %arg4[%282] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %279 = llvm.load %283 : !llvm.ptr -> f64
    %285 = arith.muli %277, %arg6 : i64
    %286 = arith.addi %arg2, %arg5 : i64
    %287 = arith.addi %285, %286 : i64
    %288 = llvm.getelementptr %arg4[%287] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %284 = llvm.load %288 : !llvm.ptr -> f64
    %289 = arith.subf %279, %284 : f64
    %291 = arith.muli %278, %arg6 : i64
    %292 = arith.addi %arg3, %arg5 : i64
    %293 = arith.addi %291, %292 : i64
    %294 = llvm.getelementptr %arg4[%293] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %290 = llvm.load %294 : !llvm.ptr -> f64
    %296 = arith.muli %278, %arg6 : i64
    %297 = arith.addi %arg2, %arg5 : i64
    %298 = arith.addi %296, %297 : i64
    %299 = llvm.getelementptr %arg4[%298] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %295 = llvm.load %299 : !llvm.ptr -> f64
    %300 = arith.subf %290, %295 : f64
    %301 = arith.subf %289, %300 : f64
    %302 = arith.constant 3.0 : f32
    %304 = arith.extf %302 : f32 to f64
    %303 = arith.divf %301, %304 : f64
    func.return %303 : f64
  }
  func.func @Iy(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: i64, %arg6: i64) -> f64 {
    %305 = func.call @Ix(%arg2, %arg3, %arg0, %arg1, %arg4, %arg5, %arg6) : (i64, i64, i64, i64, !llvm.ptr, i64, i64) -> f64
    func.return %305 : f64
  }
  func.func @Ixy(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: i64) -> f64 {
    %306 = func.call @iabs(%arg1) : (i64) -> i64
    %307 = func.call @iabs(%arg0) : (i64) -> i64
    %308 = func.call @iabs(%arg3) : (i64) -> i64
    %309 = func.call @iabs(%arg2) : (i64) -> i64
    %311 = arith.constant 1 : i32
    %313 = arith.extsi %311 : i32 to i64
    %312 = arith.addi %arg5, %313 : i64
    %314 = arith.muli %306, %312 : i64
    %315 = arith.addi %314, %308 : i64
    %316 = llvm.getelementptr %arg4[%315] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %310 = llvm.load %316 : !llvm.ptr -> f64
    %318 = arith.constant 1 : i32
    %320 = arith.extsi %318 : i32 to i64
    %319 = arith.addi %arg5, %320 : i64
    %321 = arith.muli %307, %319 : i64
    %322 = arith.addi %321, %308 : i64
    %323 = llvm.getelementptr %arg4[%322] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %317 = llvm.load %323 : !llvm.ptr -> f64
    %324 = arith.subf %310, %317 : f64
    %326 = arith.constant 1 : i32
    %328 = arith.extsi %326 : i32 to i64
    %327 = arith.addi %arg5, %328 : i64
    %329 = arith.muli %306, %327 : i64
    %330 = arith.addi %329, %309 : i64
    %331 = llvm.getelementptr %arg4[%330] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %325 = llvm.load %331 : !llvm.ptr -> f64
    %332 = arith.subf %324, %325 : f64
    %334 = arith.constant 1 : i32
    %336 = arith.extsi %334 : i32 to i64
    %335 = arith.addi %arg5, %336 : i64
    %337 = arith.muli %307, %335 : i64
    %338 = arith.addi %337, %309 : i64
    %339 = llvm.getelementptr %arg4[%338] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %333 = llvm.load %339 : !llvm.ptr -> f64
    %340 = arith.addf %332, %333 : f64
    %341 = arith.constant 15.0 : f32
    %343 = arith.extf %341 : f32 to f64
    %342 = arith.divf %340, %343 : f64
    func.return %342 : f64
  }
  func.func @seg_term(%arg0: i64, %arg1: i64, %arg2: f64, %arg3: f64, %arg4: i64, %arg5: i64, %arg6: f64, %arg7: f64, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: i64, %arg12: i64, %arg13: i64) -> f64 {
    %344 = func.call @I0(%arg0, %arg1, %arg4, %arg5, %arg8, %arg11, %arg12) : (i64, i64, i64, i64, !llvm.ptr, i64, i64) -> f64
    %345 = arith.mulf %arg3, %arg7 : f64
    %346 = arith.mulf %345, %344 : f64
    %347 = llvm.mlir.constant(1 : i64) : i64
    %348 = llvm.alloca %347 x f64 : (i64) -> !llvm.ptr
    llvm.store %346, %348 : f64, !llvm.ptr
    %349 = arith.constant 0.0 : f32
    %351 = arith.extf %349 : f32 to f64
    %350 = arith.cmpf one, %arg2, %351 : f64
    cf.cond_br %350, ^bb36, ^bb37
    ^bb36:
      %352 = llvm.load %348 : !llvm.ptr -> f64
      %353 = arith.mulf %arg2, %arg7 : f64
      %354 = func.call @Ix(%arg0, %arg1, %arg4, %arg5, %arg9, %arg11, %arg12) : (i64, i64, i64, i64, !llvm.ptr, i64, i64) -> f64
      %355 = arith.mulf %353, %354 : f64
      %356 = arith.addf %352, %355 : f64
      llvm.store %356, %348 : f64, !llvm.ptr
      cf.br ^bb38
    ^bb37:
      cf.br ^bb38
    ^bb38:
    %357 = arith.constant 0.0 : f32
    %359 = arith.extf %357 : f32 to f64
    %358 = arith.cmpf one, %arg6, %359 : f64
    cf.cond_br %358, ^bb39, ^bb40
    ^bb39:
      %360 = llvm.load %348 : !llvm.ptr -> f64
      %361 = arith.mulf %arg3, %arg6 : f64
      %362 = func.call @Iy(%arg0, %arg1, %arg4, %arg5, %arg9, %arg11, %arg12) : (i64, i64, i64, i64, !llvm.ptr, i64, i64) -> f64
      %363 = arith.mulf %361, %362 : f64
      %364 = arith.addf %360, %363 : f64
      llvm.store %364, %348 : f64, !llvm.ptr
      cf.br ^bb41
    ^bb40:
      cf.br ^bb41
    ^bb41:
    %365 = arith.constant 0.0 : f32
    %367 = arith.extf %365 : f32 to f64
    %366 = arith.cmpf one, %arg2, %367 : f64
    %368 = scf.if %366 -> (i1) {
      %369 = arith.constant 0.0 : f32
      %371 = arith.extf %369 : f32 to f64
      %370 = arith.cmpf one, %arg6, %371 : f64
      scf.yield %370 : i1
    } else {
      %372 = arith.constant false
      scf.yield %372 : i1
    }
    cf.cond_br %368, ^bb42, ^bb43
    ^bb42:
      %373 = llvm.load %348 : !llvm.ptr -> f64
      %374 = arith.mulf %arg2, %arg6 : f64
      %375 = func.call @Ixy(%arg0, %arg1, %arg4, %arg5, %arg10, %arg13) : (i64, i64, i64, i64, !llvm.ptr, i64) -> f64
      %376 = arith.mulf %374, %375 : f64
      %377 = arith.addf %373, %376 : f64
      llvm.store %377, %348 : f64, !llvm.ptr
      cf.br ^bb44
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %378 = llvm.load %348 : !llvm.ptr -> f64
    func.return %378 : f64
  }
  func.func @cross_integral(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: i64, %arg10: i64, %arg11: i64) -> f64 {
    %379 = arith.subi %arg0, %arg4 : i64
    %380 = arith.subi %379, %arg2 : i64
    %381 = arith.subi %arg1, %arg5 : i64
    %382 = arith.subi %381, %arg3 : i64
    %383 = arith.constant 0.0 : f32
    %384 = arith.extf %383 : f32 to f64
    %385 = llvm.mlir.constant(1 : i64) : i64
    %386 = llvm.alloca %385 x f64 : (i64) -> !llvm.ptr
    llvm.store %384, %386 : f64, !llvm.ptr
    %387 = arith.addi %arg4, %arg2 : i64
    %389 = arith.constant 0 : i64
    %388 = arith.subi %389, %387 : i64
    %391 = arith.constant 0 : i64
    %390 = arith.subi %391, %arg4 : i64
    %392 = arith.cmpi ne, %388, %390 : i64
    cf.cond_br %392, ^bb45, ^bb46
    ^bb45:
      %393 = llvm.load %386 : !llvm.ptr -> f64
      %395 = arith.constant 1.0 : f32
      %396 = arith.addi %arg4, %arg2 : i64
      %397 = arith.sitofp %396 : i64 to f64
      %398 = arith.addi %arg5, %arg3 : i64
      %400 = arith.constant 0 : i64
      %399 = arith.subi %400, %398 : i64
      %402 = arith.constant 0 : i64
      %401 = arith.subi %402, %arg5 : i64
      %403 = arith.constant 1.0 : f32
      %404 = arith.addi %arg5, %arg3 : i64
      %405 = arith.sitofp %404 : i64 to f64
      %406 = arith.extf %395 : f32 to f64
      %407 = arith.extf %403 : f32 to f64
      %394 = func.call @seg_term(%388, %390, %406, %397, %399, %401, %407, %405, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
      %408 = arith.addf %393, %394 : f64
      llvm.store %408, %386 : f64, !llvm.ptr
      %409 = llvm.load %386 : !llvm.ptr -> f64
      %411 = arith.constant 1.0 : f32
      %412 = arith.addi %arg4, %arg2 : i64
      %413 = arith.sitofp %412 : i64 to f64
      %415 = arith.constant 0 : i64
      %414 = arith.subi %415, %arg5 : i64
      %416 = arith.constant 0.0 : f32
      %417 = arith.sitofp %arg3 : i64 to f64
      %418 = arith.extf %411 : f32 to f64
      %419 = arith.extf %416 : f32 to f64
      %410 = func.call @seg_term(%388, %390, %418, %413, %414, %382, %419, %417, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
      %420 = arith.addf %409, %410 : f64
      llvm.store %420, %386 : f64, !llvm.ptr
      %421 = llvm.load %386 : !llvm.ptr -> f64
      %423 = arith.constant 1.0 : f32
      %424 = arith.addi %arg4, %arg2 : i64
      %425 = arith.sitofp %424 : i64 to f64
      %426 = arith.subi %arg1, %arg5 : i64
      %427 = arith.constant 1.0 : f32
      %428 = arith.negf %427 : f32
      %429 = arith.subi %arg1, %arg5 : i64
      %430 = arith.sitofp %429 : i64 to f64
      %431 = arith.extf %423 : f32 to f64
      %432 = arith.extf %428 : f32 to f64
      %422 = func.call @seg_term(%388, %390, %431, %425, %382, %426, %432, %430, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
      %433 = arith.addf %421, %422 : f64
      llvm.store %433, %386 : f64, !llvm.ptr
      cf.br ^bb47
    ^bb46:
      cf.br ^bb47
    ^bb47:
    %434 = llvm.load %386 : !llvm.ptr -> f64
    %437 = arith.constant 0 : i64
    %436 = arith.subi %437, %arg4 : i64
    %438 = arith.constant 0.0 : f32
    %439 = arith.sitofp %arg2 : i64 to f64
    %440 = arith.addi %arg5, %arg3 : i64
    %442 = arith.constant 0 : i64
    %441 = arith.subi %442, %440 : i64
    %444 = arith.constant 0 : i64
    %443 = arith.subi %444, %arg5 : i64
    %445 = arith.constant 1.0 : f32
    %446 = arith.addi %arg5, %arg3 : i64
    %447 = arith.sitofp %446 : i64 to f64
    %448 = arith.extf %438 : f32 to f64
    %449 = arith.extf %445 : f32 to f64
    %435 = func.call @seg_term(%436, %380, %448, %439, %441, %443, %449, %447, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %450 = arith.addf %434, %435 : f64
    llvm.store %450, %386 : f64, !llvm.ptr
    %451 = llvm.load %386 : !llvm.ptr -> f64
    %454 = arith.constant 0 : i64
    %453 = arith.subi %454, %arg4 : i64
    %455 = arith.constant 0.0 : f32
    %456 = arith.sitofp %arg2 : i64 to f64
    %458 = arith.constant 0 : i64
    %457 = arith.subi %458, %arg5 : i64
    %459 = arith.constant 0.0 : f32
    %460 = arith.sitofp %arg3 : i64 to f64
    %461 = arith.extf %455 : f32 to f64
    %462 = arith.extf %459 : f32 to f64
    %452 = func.call @seg_term(%453, %380, %461, %456, %457, %382, %462, %460, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %463 = arith.addf %451, %452 : f64
    llvm.store %463, %386 : f64, !llvm.ptr
    %464 = llvm.load %386 : !llvm.ptr -> f64
    %467 = arith.constant 0 : i64
    %466 = arith.subi %467, %arg4 : i64
    %468 = arith.constant 0.0 : f32
    %469 = arith.sitofp %arg2 : i64 to f64
    %470 = arith.subi %arg1, %arg5 : i64
    %471 = arith.constant 1.0 : f32
    %472 = arith.negf %471 : f32
    %473 = arith.subi %arg1, %arg5 : i64
    %474 = arith.sitofp %473 : i64 to f64
    %475 = arith.extf %468 : f32 to f64
    %476 = arith.extf %472 : f32 to f64
    %465 = func.call @seg_term(%466, %380, %475, %469, %382, %470, %476, %474, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %477 = arith.addf %464, %465 : f64
    llvm.store %477, %386 : f64, !llvm.ptr
    %478 = llvm.load %386 : !llvm.ptr -> f64
    %480 = arith.subi %arg0, %arg4 : i64
    %481 = arith.constant 1.0 : f32
    %482 = arith.negf %481 : f32
    %483 = arith.subi %arg0, %arg4 : i64
    %484 = arith.sitofp %483 : i64 to f64
    %485 = arith.addi %arg5, %arg3 : i64
    %487 = arith.constant 0 : i64
    %486 = arith.subi %487, %485 : i64
    %489 = arith.constant 0 : i64
    %488 = arith.subi %489, %arg5 : i64
    %490 = arith.constant 1.0 : f32
    %491 = arith.addi %arg5, %arg3 : i64
    %492 = arith.sitofp %491 : i64 to f64
    %493 = arith.extf %482 : f32 to f64
    %494 = arith.extf %490 : f32 to f64
    %479 = func.call @seg_term(%380, %480, %493, %484, %486, %488, %494, %492, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %495 = arith.addf %478, %479 : f64
    llvm.store %495, %386 : f64, !llvm.ptr
    %496 = llvm.load %386 : !llvm.ptr -> f64
    %498 = arith.subi %arg0, %arg4 : i64
    %499 = arith.constant 1.0 : f32
    %500 = arith.negf %499 : f32
    %501 = arith.subi %arg0, %arg4 : i64
    %502 = arith.sitofp %501 : i64 to f64
    %504 = arith.constant 0 : i64
    %503 = arith.subi %504, %arg5 : i64
    %505 = arith.constant 0.0 : f32
    %506 = arith.sitofp %arg3 : i64 to f64
    %507 = arith.extf %500 : f32 to f64
    %508 = arith.extf %505 : f32 to f64
    %497 = func.call @seg_term(%380, %498, %507, %502, %503, %382, %508, %506, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %509 = arith.addf %496, %497 : f64
    llvm.store %509, %386 : f64, !llvm.ptr
    %510 = llvm.load %386 : !llvm.ptr -> f64
    %512 = arith.subi %arg0, %arg4 : i64
    %513 = arith.constant 1.0 : f32
    %514 = arith.negf %513 : f32
    %515 = arith.subi %arg0, %arg4 : i64
    %516 = arith.sitofp %515 : i64 to f64
    %517 = arith.subi %arg1, %arg5 : i64
    %518 = arith.constant 1.0 : f32
    %519 = arith.negf %518 : f32
    %520 = arith.subi %arg1, %arg5 : i64
    %521 = arith.sitofp %520 : i64 to f64
    %522 = arith.extf %514 : f32 to f64
    %523 = arith.extf %519 : f32 to f64
    %511 = func.call @seg_term(%380, %512, %522, %516, %382, %517, %523, %521, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, f64, f64, i64, i64, f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %524 = arith.addf %510, %511 : f64
    llvm.store %524, %386 : f64, !llvm.ptr
    %525 = llvm.load %386 : !llvm.ptr -> f64
    func.return %525 : f64
  }
  func.func @solve_S(%arg0: i64) -> f64 {
    %526 = arith.constant 2 : i32
    %528 = arith.extsi %526 : i32 to i64
    %527 = arith.muli %528, %arg0 : i64
    %529 = arith.constant 1 : i32
    %531 = arith.extsi %529 : i32 to i64
    %530 = arith.addi %527, %531 : i64
    %533 = arith.muli %530, %530 : i64
    %534 = arith.constant 8 : i32
    %535 = arith.extsi %534 : i32 to i64
    %532 = func.call @calloc(%533, %535) : (i64, i64) -> !llvm.ptr
    %537 = arith.constant 1 : i32
    %539 = arith.extsi %537 : i32 to i64
    %538 = arith.addi %arg0, %539 : i64
    %540 = arith.muli %538, %530 : i64
    %541 = arith.constant 8 : i32
    %542 = arith.extsi %541 : i32 to i64
    %536 = func.call @calloc(%540, %542) : (i64, i64) -> !llvm.ptr
    %544 = arith.constant 1 : i32
    %546 = arith.extsi %544 : i32 to i64
    %545 = arith.addi %arg0, %546 : i64
    %547 = arith.constant 1 : i32
    %549 = arith.extsi %547 : i32 to i64
    %548 = arith.addi %arg0, %549 : i64
    %550 = arith.muli %545, %548 : i64
    %551 = arith.constant 8 : i32
    %552 = arith.extsi %551 : i32 to i64
    %543 = func.call @calloc(%550, %552) : (i64, i64) -> !llvm.ptr
    %553 = llvm.mlir.zero : !llvm.ptr
    %554 = llvm.icmp "eq" %532, %553 : !llvm.ptr
    %555 = scf.if %554 -> (i1) {
      %556 = arith.constant true
      scf.yield %556 : i1
    } else {
      %557 = llvm.mlir.zero : !llvm.ptr
      %558 = llvm.icmp "eq" %536, %557 : !llvm.ptr
      scf.yield %558 : i1
    }
    %559 = scf.if %555 -> (i1) {
      %560 = arith.constant true
      scf.yield %560 : i1
    } else {
      %561 = llvm.mlir.zero : !llvm.ptr
      %562 = llvm.icmp "eq" %543, %561 : !llvm.ptr
      scf.yield %562 : i1
    }
    cf.cond_br %559, ^bb48, ^bb49
    ^bb48:
      %563 = arith.constant 0.0 : f32
      %564 = arith.extf %563 : f32 to f64
      func.return %564 : f64
    ^bb49:
      cf.br ^bb50
    ^bb50:
    func.call @build_tables(%arg0, %532, %536, %543, %arg0) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
    %567 = arith.constant 0 : i32
    %568 = arith.constant 0 : i32
    %569 = arith.extsi %567 : i32 to i64
    %570 = arith.extsi %568 : i32 to i64
    %566 = func.call @cross_integral(%arg0, %arg0, %arg0, %arg0, %569, %570, %532, %536, %543, %arg0, %530, %arg0) : (i64, i64, i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
    %572 = arith.muli %arg0, %arg0 : i64
    %573 = arith.constant 8 : i32
    %574 = arith.extsi %573 : i32 to i64
    %571 = func.call @calloc(%572, %574) : (i64, i64) -> !llvm.ptr
    %575 = llvm.mlir.zero : !llvm.ptr
    %576 = llvm.icmp "eq" %571, %575 : !llvm.ptr
    cf.cond_br %576, ^bb51, ^bb52
    ^bb51:
      func.call @free(%532) : (!llvm.ptr) -> ()
      func.call @free(%536) : (!llvm.ptr) -> ()
      func.call @free(%543) : (!llvm.ptr) -> ()
      %580 = arith.constant 0.0 : f32
      %581 = arith.extf %580 : f32 to f64
      func.return %581 : f64
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %582 = arith.constant 1 : i32
    %583 = arith.extsi %582 : i32 to i64
    %584 = llvm.mlir.constant(1 : i64) : i64
    %585 = llvm.alloca %584 x i64 : (i64) -> !llvm.ptr
    llvm.store %583, %585 : i64, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %586 = llvm.load %585 : !llvm.ptr -> i64
    %587 = arith.constant 1 : i32
    %589 = arith.extsi %587 : i32 to i64
    %588 = arith.subi %arg0, %589 : i64
    %590 = arith.cmpi slt, %586, %588 : i64
    cf.cond_br %590, ^bb55, ^bb56
    ^bb55:
      %591 = arith.constant 1 : i32
      %592 = arith.extsi %591 : i32 to i64
      %593 = llvm.mlir.constant(1 : i64) : i64
      %594 = llvm.alloca %593 x i64 : (i64) -> !llvm.ptr
      llvm.store %592, %594 : i64, !llvm.ptr
      cf.br ^bb57
      ^bb57:
      %595 = llvm.load %594 : !llvm.ptr -> i64
      %596 = arith.constant 1 : i32
      %598 = arith.extsi %596 : i32 to i64
      %597 = arith.subi %arg0, %598 : i64
      %599 = arith.cmpi slt, %595, %597 : i64
      cf.cond_br %599, ^bb58, ^bb59
      ^bb58:
        %601 = llvm.load %585 : !llvm.ptr -> i64
        %602 = llvm.load %594 : !llvm.ptr -> i64
        %603 = llvm.load %585 : !llvm.ptr -> i64
        %604 = llvm.load %594 : !llvm.ptr -> i64
        %605 = arith.constant 0 : i32
        %606 = arith.constant 0 : i32
        %607 = arith.extsi %605 : i32 to i64
        %608 = arith.extsi %606 : i32 to i64
        %600 = func.call @cross_integral(%601, %602, %603, %604, %607, %608, %532, %536, %543, %arg0, %530, %arg0) : (i64, i64, i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
        %609 = llvm.load %585 : !llvm.ptr -> i64
        %610 = arith.muli %609, %arg0 : i64
        %611 = llvm.load %594 : !llvm.ptr -> i64
        %612 = arith.addi %610, %611 : i64
        %613 = llvm.getelementptr %571[%612] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %600, %613 : f64, !llvm.ptr
        %614 = llvm.load %594 : !llvm.ptr -> i64
        %615 = arith.constant 1 : i32
        %617 = arith.extsi %615 : i32 to i64
        %616 = arith.addi %614, %617 : i64
        llvm.store %616, %594 : i64, !llvm.ptr
        cf.br ^bb57
      ^bb59:
      %618 = llvm.load %585 : !llvm.ptr -> i64
      %619 = arith.constant 1 : i32
      %621 = arith.extsi %619 : i32 to i64
      %620 = arith.addi %618, %621 : i64
      llvm.store %620, %585 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %622 = arith.constant 0.0 : f32
    %623 = arith.extf %622 : f32 to f64
    %624 = llvm.mlir.constant(1 : i64) : i64
    %625 = llvm.alloca %624 x f64 : (i64) -> !llvm.ptr
    llvm.store %623, %625 : f64, !llvm.ptr
    %626 = arith.constant 1 : i32
    %627 = arith.extsi %626 : i32 to i64
    llvm.store %627, %585 : i64, !llvm.ptr
    cf.br ^bb60
    ^bb60:
    %628 = llvm.load %585 : !llvm.ptr -> i64
    %629 = arith.constant 1 : i32
    %631 = arith.extsi %629 : i32 to i64
    %630 = arith.subi %arg0, %631 : i64
    %632 = arith.cmpi slt, %628, %630 : i64
    cf.cond_br %632, ^bb61, ^bb62
    ^bb61:
      %633 = arith.constant 1 : i32
      %634 = arith.extsi %633 : i32 to i64
      %635 = llvm.mlir.constant(1 : i64) : i64
      %636 = llvm.alloca %635 x i64 : (i64) -> !llvm.ptr
      llvm.store %634, %636 : i64, !llvm.ptr
      cf.br ^bb63
      ^bb63:
      %637 = llvm.load %636 : !llvm.ptr -> i64
      %638 = arith.constant 1 : i32
      %640 = arith.extsi %638 : i32 to i64
      %639 = arith.subi %arg0, %640 : i64
      %641 = arith.cmpi slt, %637, %639 : i64
      cf.cond_br %641, ^bb64, ^bb65
      ^bb64:
        %642 = arith.muli %arg0, %arg0 : i64
        %643 = llvm.load %585 : !llvm.ptr -> i64
        %644 = llvm.load %636 : !llvm.ptr -> i64
        %645 = arith.muli %643, %644 : i64
        %646 = arith.subi %642, %645 : i64
        %647 = arith.sitofp %646 : i64 to f64
        %648 = arith.constant 1.0 : f32
        %649 = arith.mulf %647, %647 : f64
        %651 = arith.extf %648 : f32 to f64
        %650 = arith.divf %651, %649 : f64
        %653 = llvm.load %585 : !llvm.ptr -> i64
        %654 = arith.muli %653, %arg0 : i64
        %655 = llvm.load %636 : !llvm.ptr -> i64
        %656 = arith.addi %654, %655 : i64
        %657 = llvm.getelementptr %571[%656] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %652 = llvm.load %657 : !llvm.ptr -> f64
        %658 = arith.constant 1 : i32
        %659 = arith.extsi %658 : i32 to i64
        %660 = llvm.mlir.constant(1 : i64) : i64
        %661 = llvm.alloca %660 x i64 : (i64) -> !llvm.ptr
        llvm.store %659, %661 : i64, !llvm.ptr
        cf.br ^bb66
        ^bb66:
        %662 = llvm.load %661 : !llvm.ptr -> i64
        %663 = llvm.load %585 : !llvm.ptr -> i64
        %664 = arith.subi %arg0, %663 : i64
        %665 = arith.cmpi slt, %662, %664 : i64
        cf.cond_br %665, ^bb67, ^bb68
        ^bb67:
          %666 = arith.constant 1 : i32
          %667 = arith.extsi %666 : i32 to i64
          %668 = llvm.mlir.constant(1 : i64) : i64
          %669 = llvm.alloca %668 x i64 : (i64) -> !llvm.ptr
          llvm.store %667, %669 : i64, !llvm.ptr
          cf.br ^bb69
          ^bb69:
          %670 = llvm.load %669 : !llvm.ptr -> i64
          %671 = llvm.load %636 : !llvm.ptr -> i64
          %672 = arith.subi %arg0, %671 : i64
          %673 = arith.cmpi slt, %670, %672 : i64
          cf.cond_br %673, ^bb70, ^bb71
          ^bb70:
            %675 = llvm.load %585 : !llvm.ptr -> i64
            %676 = llvm.load %636 : !llvm.ptr -> i64
            %677 = llvm.load %661 : !llvm.ptr -> i64
            %678 = llvm.load %669 : !llvm.ptr -> i64
            %674 = func.call @cross_integral(%arg0, %arg0, %675, %676, %677, %678, %532, %536, %543, %arg0, %530, %arg0) : (i64, i64, i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> f64
            %679 = arith.constant 2.0 : f32
            %681 = arith.extf %679 : f32 to f64
            %680 = arith.mulf %681, %674 : f64
            %682 = arith.subf %566, %680 : f64
            %683 = arith.addf %682, %652 : f64
            %684 = llvm.load %625 : !llvm.ptr -> f64
            %685 = arith.mulf %683, %650 : f64
            %686 = arith.addf %684, %685 : f64
            llvm.store %686, %625 : f64, !llvm.ptr
            %687 = llvm.load %669 : !llvm.ptr -> i64
            %688 = arith.constant 1 : i32
            %690 = arith.extsi %688 : i32 to i64
            %689 = arith.addi %687, %690 : i64
            llvm.store %689, %669 : i64, !llvm.ptr
            cf.br ^bb69
          ^bb71:
          %691 = llvm.load %661 : !llvm.ptr -> i64
          %692 = arith.constant 1 : i32
          %694 = arith.extsi %692 : i32 to i64
          %693 = arith.addi %691, %694 : i64
          llvm.store %693, %661 : i64, !llvm.ptr
          cf.br ^bb66
        ^bb68:
        %695 = llvm.load %636 : !llvm.ptr -> i64
        %696 = arith.constant 1 : i32
        %698 = arith.extsi %696 : i32 to i64
        %697 = arith.addi %695, %698 : i64
        llvm.store %697, %636 : i64, !llvm.ptr
        cf.br ^bb63
      ^bb65:
      %699 = llvm.load %585 : !llvm.ptr -> i64
      %700 = arith.constant 1 : i32
      %702 = arith.extsi %700 : i32 to i64
      %701 = arith.addi %699, %702 : i64
      llvm.store %701, %585 : i64, !llvm.ptr
      cf.br ^bb60
    ^bb62:
    func.call @free(%532) : (!llvm.ptr) -> ()
    func.call @free(%536) : (!llvm.ptr) -> ()
    func.call @free(%543) : (!llvm.ptr) -> ()
    func.call @free(%571) : (!llvm.ptr) -> ()
    %707 = llvm.load %625 : !llvm.ptr -> f64
    func.return %707 : f64
  }
  func.func @main() -> i32 {
    %709 = llvm.mlir.addressof @N : !llvm.ptr
    %710 = llvm.load %709 : !llvm.ptr -> i64
    %708 = func.call @solve_S(%710) : (i64) -> f64
    %711 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %712 = llvm.call @printf(%711, %708) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
    %713 = arith.constant 0 : i32
    func.return %713 : i32
  }
}