Problem 975

Winding walk on turning points of H(a,b,x) over prime pairs. Port of the C reference solver to pure Flow.

Answer88597366.47748
Output88597366.47748
StatusPASS
Native helperno
Runtime14360 ms
Peak memory1504 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionSieve of Eratosthenes
VerdictSuboptimal

Flow source

# Project Euler 975
# Winding walk on turning points of H(a,b,x) over prime pairs.
# Port of the C reference solver to pure Flow.

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

const PI: f64 = 3.14159265358979323846
const MAXC: i64 = 4096

function gcd_int(a: i64, b: i64) -> i64 {
    if a < 0 { a = -a }
    if b < 0 { b = -b }
    while b != 0 {
        let t: i64 = a % b
        a = b
        b = t
    }
    return a
}

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

function fmaxv(a: f64, b: f64) -> f64 {
    if a > b { return a }
    return b
}

function fminv(a: f64, b: f64) -> f64 {
    if a < b { return a }
    return b
}

# candidate points stored in global buffers
let mut g_num: ptr<i64> = null
let mut g_den: ptr<i64> = null
let mut g_signs: ptr<i64> = null
let mut g_kept_num: ptr<i64> = null
let mut g_kept_den: ptr<i64> = null

function make_normalized(num: i64, den: i64, idx: i64) -> void {
    let g: i64 = gcd_int(num, den)
    g_num[idx] = num / g
    g_den[idx] = den / g
}

function height_val(a: i64, b: i64, num: i64, den: i64) -> f64 {
    if num == 0 { return 0.0 }
    if num == den { return 1.0 }
    let x: f64 = (num as f64) / (den as f64)
    let z: f64 = 0.5 - ((b as f64) * cos((a as f64) * PI * x) + (a as f64) * cos((b as f64) * PI * x)) / (2.0 * ((a + b) as f64))
    if z < 0.0 {
        if z > -1e-14 { return 0.0 }
    }
    if z > 1.0 {
        if z < 1.0 + 1e-14 { return 1.0 }
    }
    return z
}

function deriv_sign(a: i64, b: i64, ln: i64, ld: i64, rn: i64, rd: i64) -> i64 {
    let x: f64 = ((ln * rd + rn * ld) as f64) / (2.0 * ((ld * rd) as f64))
    let value: f64 = sin(((a + b) as f64) * PI * x * 0.5) * cos((iabs(a - b) as f64) * PI * x * 0.5)
    if value > 0.0 { return 1 }
    return -1
}

# selection sort candidate points by value num/den ascending
function sort_cand2(nc: i64) -> void {
    let mut i: i64 = 0
    while i < nc {
        let mut best: i64 = i
        let mut j: i64 = i + 1
        while j < nc {
            # compare g_num[j]/g_den[j] < g_num[best]/g_den[best]
            if g_num[j] * g_den[best] < g_num[best] * g_den[j] {
                best = j
            }
            j = j + 1
        }
        if best != i {
            let tn: i64 = g_num[i]
            let td: i64 = g_den[i]
            g_num[i] = g_num[best]
            g_den[i] = g_den[best]
            g_num[best] = tn
            g_den[best] = td
        }
        i = i + 1
    }
}

function turning_values(a: i64, b: i64, tv: ptr<f64>) -> i64 {
    let s: i64 = a + b
    let delta: i64 = iabs(a - b)

    let mut nc: i64 = 0
    let mut k: i64 = 0
    while k <= s / 2 {
        make_normalized(2 * k, s, nc)
        nc = nc + 1
        k = k + 1
    }
    k = 0
    while k < delta / 2 {
        make_normalized(2 * k + 1, delta, nc)
        nc = nc + 1
        k = k + 1
    }

    sort_cand2(nc)

    # dedupe
    let mut unique: i64 = 1
    let mut i: i64 = 1
    while i < nc {
        if g_num[i] != g_num[unique - 1] || g_den[i] != g_den[unique - 1] {
            g_num[unique] = g_num[i]
            g_den[unique] = g_den[i]
            unique = unique + 1
        }
        i = i + 1
    }
    nc = unique

    i = 0
    while i < nc - 1 {
        g_signs[i] = deriv_sign(a, b, g_num[i], g_den[i], g_num[i + 1], g_den[i + 1])
        i = i + 1
    }

    let mut nk: i64 = 0
    g_kept_num[nk] = g_num[0]
    g_kept_den[nk] = g_den[0]
    nk = nk + 1
    i = 1
    while i < nc - 1 {
        if g_signs[i - 1] != g_signs[i] {
            g_kept_num[nk] = g_num[i]
            g_kept_den[nk] = g_den[i]
            nk = nk + 1
        }
        i = i + 1
    }
    g_kept_num[nk] = g_num[nc - 1]
    g_kept_den[nk] = g_den[nc - 1]
    nk = nk + 1

    i = 0
    while i < nk {
        tv[i] = height_val(a, b, g_kept_num[i], g_kept_den[i])
        i = i + 1
    }
    return nk
}

function F_func(a: i64, b: i64, c: i64, d: i64) -> f64 {
    let za: ptr<f64> = calloc(MAXC, 8)
    let zb: ptr<f64> = calloc(MAXC, 8)
    let na: i64 = turning_values(a, b, za)
    let nb: i64 = turning_values(c, d, zb)

    let mut i: i64 = 0
    let mut j: i64 = 0
    let mut current: f64 = 0.0
    let mut total: f64 = 0.0
    let mut upward: i64 = 1
    let eps: f64 = 1e-12
    let max_steps: i64 = 4 * (na + nb) * (na + nb)

    let mut step: i64 = 0
    while step < max_steps {
        if i < 0 || i >= na - 1 || j < 0 || j >= nb - 1 {
            free(za as ptr<void>)
            free(zb as ptr<void>)
            return total
        }
        let a0: f64 = za[i]
        let a1: f64 = za[i + 1]
        let b0: f64 = zb[j]
        let b1: f64 = zb[j + 1]
        let lower: f64 = fmaxv(fminv(a0, a1), fminv(b0, b1))
        let upper: f64 = fminv(fmaxv(a0, a1), fmaxv(b0, b1))
        let nxt: f64 = 0.0
        if upward != 0 { nxt = upper } else { nxt = lower }
        total = total + fabs(nxt - current)
        let mut advanced: i64 = 0
        if fabs(nxt - a0) <= eps { i = i - 1; advanced = 1 }
        else {
            if fabs(nxt - a1) <= eps { i = i + 1; advanced = 1 }
        }
        if fabs(nxt - b0) <= eps { j = j - 1; advanced = 1 }
        else {
            if fabs(nxt - b1) <= eps { j = j + 1; advanced = 1 }
        }
        if advanced == 0 {
            free(za as ptr<void>)
            free(zb as ptr<void>)
            return total
        }
        current = nxt
        upward = 1 - upward
        step = step + 1
    }
    free(za as ptr<void>)
    free(zb as ptr<void>)
    return total
}

function G_func(m: i64, n: i64) -> f64 {
    let is_prime: ptr<i64> = calloc(n + 1, 8)
    let mut p: i64 = 0
    while p <= n {
        is_prime[p] = 1
        p = p + 1
    }
    is_prime[0] = 0
    is_prime[1] = 0
    p = 2
    while p * p <= n {
        if is_prime[p] != 0 {
            let mut j: i64 = p * p
            while j <= n {
                is_prime[j] = 0
                j = j + p
            }
        }
        p = p + 1
    }

    let ps: ptr<i64> = calloc(256, 8)
    let mut np: i64 = 0
    p = m
    while p <= n {
        if is_prime[p] != 0 {
            ps[np] = p
            np = np + 1
        }
        p = p + 1
    }
    free(is_prime as ptr<void>)

    let mut total: f64 = 0.0
    let mut i: i64 = 0
    while i < np {
        let mut j: i64 = i + 1
        while j < np {
            let pp: i64 = ps[i]
            let qq: i64 = ps[j]
            total = total + F_func(pp, qq, pp, 2 * qq - pp)
            j = j + 1
        }
        i = i + 1
    }
    free(ps as ptr<void>)
    return total
}

function main() -> i32 {
    g_num = calloc(MAXC, 8) as ptr<i64>
    g_den = calloc(MAXC, 8) as ptr<i64>
    g_signs = calloc(MAXC, 8) as ptr<i64>
    g_kept_num = calloc(MAXC, 8) as ptr<i64>
    g_kept_den = calloc(MAXC, 8) as ptr<i64>
    printf("%.5f\n", G_func(500, 1000))
    return 0
}

Generated C

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

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

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

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

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

#include <math.h>

void* _ui_state = NULL;

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

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

int64_t gcd_int_i64_i64(int64_t a, int64_t b);
int64_t iabs_i64(int64_t x);
double fmaxv_f64_f64(double a, double b);
double fminv_f64_f64(double a, double b);
void make_normalized_i64_i64_i64(int64_t num, int64_t den, int64_t idx);
double height_val_i64_i64_i64_i64(int64_t a, int64_t b, int64_t num, int64_t den);
int64_t deriv_sign_i64_i64_i64_i64_i64_i64(int64_t a, int64_t b, int64_t ln, int64_t ld, int64_t rn, int64_t rd);
void sort_cand2_i64(int64_t nc);
int64_t turning_values_i64_i64_ptr_f64(int64_t a, int64_t b, double* tv);
double F_func_i64_i64_i64_i64(int64_t a, int64_t b, int64_t c, int64_t d);
double G_func_i64_i64(int64_t m, int64_t n);
int32_t main(void);

static const double PI = 3.14159265358979323846;
static const int64_t MAXC = 4096;

/* Module statics */
static int64_t* g_num = NULL;
static int64_t* g_den = NULL;
static int64_t* g_signs = NULL;
static int64_t* g_kept_num = NULL;
static int64_t* g_kept_den = NULL;






int64_t gcd_int_i64_i64(int64_t a, int64_t b) {
    if (a < 0) {
        a = (-a);
    }
    if (b < 0) {
        b = (-b);
    }
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

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

double fmaxv_f64_f64(double a, double b) {
    if (a > b) {
        return a;
    }
    return b;
}

double fminv_f64_f64(double a, double b) {
    if (a < b) {
        return a;
    }
    return b;
}

void make_normalized_i64_i64_i64(int64_t num, int64_t den, int64_t idx) {
    int64_t g = gcd_int_i64_i64(num, den);
    g_num[idx] = FLOW_CHECKED_DIV((num), (g));
    g_den[idx] = FLOW_CHECKED_DIV((den), (g));
}

double height_val_i64_i64_i64_i64(int64_t a, int64_t b, int64_t num, int64_t den) {
    if (num == 0) {
        return 0.0;
    }
    if (num == den) {
        return 1.0;
    }
    double x = (((double)(num)) / ((double)(den)));
    double z = (0.5 - (((((double)(b)) * cos(((((double)(a)) * PI) * x))) + (((double)(a)) * cos(((((double)(b)) * PI) * x)))) / (2.0 * ((double)((a + b))))));
    if (z < 0.0) {
        if (z > (-1e-14)) {
            return 0.0;
        }
    }
    if (z > 1.0) {
        if (z < (1.0 + 1e-14)) {
            return 1.0;
        }
    }
    return z;
}

int64_t deriv_sign_i64_i64_i64_i64_i64_i64(int64_t a, int64_t b, int64_t ln, int64_t ld, int64_t rn, int64_t rd) {
    double x = (((double)(((ln * rd) + (rn * ld)))) / (2.0 * ((double)((ld * rd)))));
    double value = (sin((((((double)((a + b))) * PI) * x) * 0.5)) * cos((((((double)(iabs_i64((a - b)))) * PI) * x) * 0.5)));
    if (value > 0.0) {
        return 1;
    }
    return (-1);
}

void sort_cand2_i64(int64_t nc) {
    int64_t i = 0;
    while (i < nc) {
        int64_t best = i;
        int64_t j = (i + 1);
        while (j < nc) {
            if ((g_num[j] * g_den[best]) < (g_num[best] * g_den[j])) {
                best = j;
            }
            j = (j + 1);
        }
        if (best != i) {
            int64_t tn = g_num[i];
            int64_t td = g_den[i];
            g_num[i] = g_num[best];
            g_den[i] = g_den[best];
            g_num[best] = tn;
            g_den[best] = td;
        }
        i = (i + 1);
    }
}

int64_t turning_values_i64_i64_ptr_f64(int64_t a, int64_t b, double* tv) {
    int64_t s = (a + b);
    int64_t delta = iabs_i64((a - b));
    int64_t nc = 0;
    int64_t k = 0;
    while (k <= FLOW_CHECKED_DIV((s), (2))) {
        make_normalized_i64_i64_i64((2 * k), s, nc);
        nc = (nc + 1);
        k = (k + 1);
    }
    k = 0;
    while (k < FLOW_CHECKED_DIV((delta), (2))) {
        make_normalized_i64_i64_i64(((2 * k) + 1), delta, nc);
        nc = (nc + 1);
        k = (k + 1);
    }
    sort_cand2_i64(nc);
    int64_t unique = 1;
    int64_t i = 1;
    while (i < nc) {
        if ((g_num[i] != g_num[(unique - 1)] || g_den[i] != g_den[(unique - 1)])) {
            g_num[unique] = g_num[i];
            g_den[unique] = g_den[i];
            unique = (unique + 1);
        }
        i = (i + 1);
    }
    nc = unique;
    i = 0;
    while (i < (nc - 1)) {
        g_signs[i] = deriv_sign_i64_i64_i64_i64_i64_i64(a, b, g_num[i], g_den[i], g_num[(i + 1)], g_den[(i + 1)]);
        i = (i + 1);
    }
    int64_t nk = 0;
    g_kept_num[nk] = g_num[0];
    g_kept_den[nk] = g_den[0];
    nk = (nk + 1);
    i = 1;
    while (i < (nc - 1)) {
        if (g_signs[(i - 1)] != g_signs[i]) {
            g_kept_num[nk] = g_num[i];
            g_kept_den[nk] = g_den[i];
            nk = (nk + 1);
        }
        i = (i + 1);
    }
    g_kept_num[nk] = g_num[(nc - 1)];
    g_kept_den[nk] = g_den[(nc - 1)];
    nk = (nk + 1);
    i = 0;
    while (i < nk) {
        tv[i] = height_val_i64_i64_i64_i64(a, b, g_kept_num[i], g_kept_den[i]);
        i = (i + 1);
    }
    return nk;
}

double F_func_i64_i64_i64_i64(int64_t a, int64_t b, int64_t c, int64_t d) {
    double* za = (double*)(calloc(MAXC, 8));
    double* zb = (double*)(calloc(MAXC, 8));
    int64_t na = turning_values_i64_i64_ptr_f64(a, b, za);
    int64_t nb = turning_values_i64_i64_ptr_f64(c, d, zb);
    int64_t i = 0;
    int64_t j = 0;
    double current = 0.0;
    double total = 0.0;
    int64_t upward = 1;
    double eps = 1e-12;
    int64_t max_steps = ((4 * (na + nb)) * (na + nb));
    int64_t step = 0;
    while (step < max_steps) {
        if ((((i < 0 || i >= (na - 1)) || j < 0) || j >= (nb - 1))) {
            free(((void*)(za)));
            free(((void*)(zb)));
            return total;
        }
        double a0 = za[i];
        double a1 = za[(i + 1)];
        double b0 = zb[j];
        double b1 = zb[(j + 1)];
        double lower = fmaxv_f64_f64(fminv_f64_f64(a0, a1), fminv_f64_f64(b0, b1));
        double upper = fminv_f64_f64(fmaxv_f64_f64(a0, a1), fmaxv_f64_f64(b0, b1));
        double nxt = 0.0;
        if (upward != 0) {
            nxt = upper;
        } else {
            nxt = lower;
        }
        total = (total + fabs((nxt - current)));
        int64_t advanced = 0;
        if (fabs((nxt - a0)) <= eps) {
            i = (i - 1);
            advanced = 1;
        } else {
            if (fabs((nxt - a1)) <= eps) {
                i = (i + 1);
                advanced = 1;
            }
        }
        if (fabs((nxt - b0)) <= eps) {
            j = (j - 1);
            advanced = 1;
        } else {
            if (fabs((nxt - b1)) <= eps) {
                j = (j + 1);
                advanced = 1;
            }
        }
        if (advanced == 0) {
            free(((void*)(za)));
            free(((void*)(zb)));
            return total;
        }
        current = nxt;
        upward = (1 - upward);
        step = (step + 1);
    }
    free(((void*)(za)));
    free(((void*)(zb)));
    return total;
}

double G_func_i64_i64(int64_t m, int64_t n) {
    int64_t* is_prime = (int64_t*)(calloc((n + 1), 8));
    int64_t p = 0;
    while (p <= n) {
        is_prime[p] = 1;
        p = (p + 1);
    }
    is_prime[0] = 0;
    is_prime[1] = 0;
    p = 2;
    while ((p * p) <= n) {
        if (is_prime[p] != 0) {
            int64_t j = (p * p);
            while (j <= n) {
                is_prime[j] = 0;
                j = (j + p);
            }
        }
        p = (p + 1);
    }
    int64_t* ps = (int64_t*)(calloc(256, 8));
    int64_t np = 0;
    p = m;
    while (p <= n) {
        if (is_prime[p] != 0) {
            ps[np] = p;
            np = (np + 1);
        }
        p = (p + 1);
    }
    free(((void*)(is_prime)));
    double total = 0.0;
    int64_t i = 0;
    while (i < np) {
        int64_t j = (i + 1);
        while (j < np) {
            int64_t pp = ps[i];
            int64_t qq = ps[j];
            total = (total + F_func_i64_i64_i64_i64(pp, qq, pp, ((2 * qq) - pp)));
            j = (j + 1);
        }
        i = (i + 1);
    }
    free(((void*)(ps)));
    return total;
}

int32_t main(void) {
    g_num = ((int64_t*)(calloc(MAXC, 8)));
    g_den = ((int64_t*)(calloc(MAXC, 8)));
    g_signs = ((int64_t*)(calloc(MAXC, 8)));
    g_kept_num = ((int64_t*)(calloc(MAXC, 8)));
    g_kept_den = ((int64_t*)(calloc(MAXC, 8)));
    printf("%.5f\n", G_func_i64_i64(500, 1000));
    return 0;
}

Generated MLIR

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