Problem 262

Shortest mosquito path over mountain terrain at minimum pass elevation.

Answer2531.205
Output2531.205
StatusPASS
Native helperno
Runtime40 ms
Peak memory1168 KB
Time complexityO(n^2) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log n)
Space complexityO(1)O(n)
ApproachFlow solutionSearch with pruning or sieve
VerdictSuboptimal

Flow source

# Project Euler 262
# Shortest mosquito path over mountain terrain at minimum pass elevation.

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

let mut L: f64 = 1600.0
let mut AX: f64 = 200.0
let mut AY: f64 = 200.0
let mut BX: f64 = 1400.0
let mut BY: f64 = 1400.0

function h_only(x: f64, y: f64) -> f64 {
    let xx: f64 = x * x
    let yy: f64 = y * y
    let P: f64 = 5000.0 - 0.005 * (xx + yy + x * y) + 12.5 * (x + y)
    let Q: f64 = 0.000001 * (xx + yy) - 0.0015 * (x + y) + 0.7
    let absQ: f64 = Q
    if absQ < 0.0 { absQ = -absQ }
    return P * exp(-absQ)
}

function h_and_grad(x: f64, y: f64, out_h: ptr<f64>, out_hx: ptr<f64>, out_hy: ptr<f64>) -> void {
    let xx: f64 = x * x
    let yy: f64 = y * y
    let P: f64 = 5000.0 - 0.005 * (xx + yy + x * y) + 12.5 * (x + y)
    let Q: f64 = 0.000001 * (xx + yy) - 0.0015 * (x + y) + 0.7
    let absQ: f64 = Q
    let mut sign: f64 = 1.0
    if Q < 0.0 { absQ = -Q; sign = -1.0 }
    let E: f64 = exp(-absQ)
    out_h[0] = P * E
    let Px: f64 = 12.5 - 0.01 * x - 0.005 * y
    let Py: f64 = 12.5 - 0.01 * y - 0.005 * x
    let Qx: f64 = 0.000002 * x - 0.0015
    let Qy: f64 = 0.000002 * y - 0.0015
    out_hx[0] = E * (Px - P * sign * Qx)
    out_hy[0] = E * (Py - P * sign * Qy)
}

function golden_max(lo: f64, hi: f64) -> f64 {
    let phi: f64 = 0.6180339887498949
    let mut a: f64 = lo
    let mut b: f64 = hi
    let mut c: f64 = b - phi * (b - a)
    let mut d: f64 = a + phi * (b - a)
    let mut fc: f64 = h_only(0.0, c)
    let mut fd: f64 = h_only(0.0, d)
    let mut it: i64 = 0
    while it < 200 {
        if b - a < 0.0000000000001 { break }
        if fc < fd {
            a = c
            c = d
            fc = fd
            d = a + phi * (b - a)
            fd = h_only(0.0, d)
        } else {
            b = d
            d = c
            fd = fc
            c = b - phi * (b - a)
            fc = h_only(0.0, c)
        }
        it = it + 1
    }
    return h_only(0.0, (a + b) * 0.5)
}

function segment_clear(ox: f64, oy: f64, px: f64, py: f64, fmin: f64) -> bool {
    let mut i: i64 = 1
    while i < 200 {
        let t: f64 = (i as f64) / 200.0
        let x: f64 = ox + (px - ox) * t
        let y: f64 = oy + (py - oy) * t
        if h_only(x, y) > fmin + 0.000001 { return false }
        i = i + 1
    }
    return true
}

function newton_tangent(ox: f64, oy: f64, fmin: f64, x0: f64, y0: f64, out_x: ptr<f64>, out_y: ptr<f64>) -> void {
    let mut x: f64 = x0
    let mut y: f64 = y0
    let hh: ptr<f64> = calloc(1, 8)
    let hx: ptr<f64> = calloc(1, 8)
    let hy: ptr<f64> = calloc(1, 8)
    let mut it: i64 = 0
    while it < 120 {
        h_and_grad(x, y, hh, hx, hy)
        let f1: f64 = hh[0] - fmin
        let f2: f64 = hx[0] * (ox - x) + hy[0] * (oy - y)
        if f1 < 0.0 { if f1 > -0.0000000001 { f1 = 0.0 } }
        if f1 > 0.0 { if f1 < 0.0000000001 { f1 = 0.0 } }
        if f2 < 0.0 { if f2 > -0.00000001 { f2 = 0.0 } }
        if f2 > 0.0 { if f2 < 0.00000001 { f2 = 0.0 } }
        if f1 == 0.0 && f2 == 0.0 { break }

        let mut epsx: f64 = 0.000001 * x
        if epsx < 0.0 { epsx = -epsx }
        if epsx < 0.000001 { epsx = 0.000001 }
        let mut epsy: f64 = 0.000001 * y
        if epsy < 0.0 { epsy = -epsy }
        if epsy < 0.000001 { epsy = 0.000001 }

        h_and_grad(x + epsx, y, hh, hx, hy)
        let fpx1: f64 = hh[0] - fmin
        let fpx2: f64 = hx[0] * (ox - (x + epsx)) + hy[0] * (oy - y)
        h_and_grad(x - epsx, y, hh, hx, hy)
        let fmx1: f64 = hh[0] - fmin
        let fmx2: f64 = hx[0] * (ox - (x - epsx)) + hy[0] * (oy - y)
        let dF1dx: f64 = (fpx1 - fmx1) / (2.0 * epsx)
        let dF2dx: f64 = (fpx2 - fmx2) / (2.0 * epsx)

        h_and_grad(x, y + epsy, hh, hx, hy)
        let fpy1: f64 = hh[0] - fmin
        let fpy2: f64 = hx[0] * (ox - x) + hy[0] * (oy - (y + epsy))
        h_and_grad(x, y - epsy, hh, hx, hy)
        let fmy1: f64 = hh[0] - fmin
        let fmy2: f64 = hx[0] * (ox - x) + hy[0] * (oy - (y - epsy))
        let dF1dy: f64 = (fpy1 - fmy1) / (2.0 * epsy)
        let dF2dy: f64 = (fpy2 - fmy2) / (2.0 * epsy)

        let det: f64 = dF1dx * dF2dy - dF1dy * dF2dx
        if det > -0.000000000000000001 && det < 0.000000000000000001 {
            x = x + 0.0003
            y = y - 0.0002
            it = it + 1
            continue
        }
        let dx: f64 = (-f1 * dF2dy + f2 * dF1dy) / det
        let dy: f64 = (-dF1dx * f2 + dF2dx * f1) / det
        let base: f64 = f1
        if f1 < 0.0 { let t: f64 = -f1; } else {}
        let mut lam: f64 = 1.0
        let mut accepted: bool = false
        let mut ls: i64 = 0
        while ls < 25 {
            let xn: f64 = x + lam * dx
            let yn: f64 = y + lam * dy
            if xn >= 0.0 && xn <= L && yn >= 0.0 && yn <= L {
                h_and_grad(xn, yn, hh, hx, hy)
                let nf1: f64 = hh[0] - fmin
                let nf2: f64 = hx[0] * (ox - xn) + hy[0] * (oy - yn)
                let mut af1: f64 = nf1
                let mut af2: f64 = nf2
                if af1 < 0.0 { af1 = -af1 }
                if af2 < 0.0 { af2 = -af2 }
                let mut bf1: f64 = f1
                let mut bf2: f64 = f2
                if bf1 < 0.0 { bf1 = -bf1 }
                if bf2 < 0.0 { bf2 = -bf2 }
                if af1 + af2 < bf1 + bf2 {
                    x = xn
                    y = yn
                    accepted = true
                    break
                }
            }
            lam = lam * 0.5
            ls = ls + 1
        }
        if !accepted {
            x = x + dx
            y = y + dy
        }
        it = it + 1
    }
    out_x[0] = x
    out_y[0] = y
    free(hh); free(hx); free(hy)
}

function project_to_level(x0: f64, y0: f64, fmin: f64, out_x: ptr<f64>, out_y: ptr<f64>) -> void {
    let mut x: f64 = x0
    let mut y: f64 = y0
    let hh: ptr<f64> = calloc(1, 8)
    let hx: ptr<f64> = calloc(1, 8)
    let hy: ptr<f64> = calloc(1, 8)
    let mut i: i64 = 0
    while i < 3 {
        h_and_grad(x, y, hh, hx, hy)
        let F: f64 = hh[0] - fmin
        let denom: f64 = hx[0] * hx[0] + hy[0] * hy[0]
        if denom == 0.0 { break }
        x = x - F * hx[0] / denom
        y = y - F * hy[0] / denom
        i = i + 1
    }
    out_x[0] = x
    out_y[0] = y
    free(hh); free(hx); free(hy)
}

function walk_to_target(sx: f64, sy: f64, tx: f64, ty: f64, fmin: f64, direction: f64) -> f64 {
    let px: ptr<f64> = calloc(1, 8)
    let py: ptr<f64> = calloc(1, 8)
    project_to_level(sx, sy, fmin, px, py)
    let mut x: f64 = px[0]
    let mut y: f64 = py[0]
    let hh: ptr<f64> = calloc(1, 8)
    let hx: ptr<f64> = calloc(1, 8)
    let hy: ptr<f64> = calloc(1, 8)
    let mut s: f64 = 0.0
    let mut ds: f64 = 0.1
    let mut step: i64 = 0
    while step < 2000000 {
        let dx: f64 = x - tx
        let dy: f64 = y - ty
        let d: f64 = sqrt(dx * dx + dy * dy)
        if d < 0.0000000001 { break }
        if ds > d * 0.5 { ds = d * 0.5 }
        if ds < 0.0000000001 { ds = 0.0000000001 }

        h_and_grad(x, y, hh, hx, hy)
        let nrm: f64 = sqrt(hx[0] * hx[0] + hy[0] * hy[0])
        let k1x: f64 = (-hy[0] / nrm) * direction
        let k1y: f64 = (hx[0] / nrm) * direction

        h_and_grad(x + 0.5 * ds * k1x, y + 0.5 * ds * k1y, hh, hx, hy)
        let n2: f64 = sqrt(hx[0] * hx[0] + hy[0] * hy[0])
        let k2x: f64 = (-hy[0] / n2) * direction
        let k2y: f64 = (hx[0] / n2) * direction

        h_and_grad(x + 0.5 * ds * k2x, y + 0.5 * ds * k2y, hh, hx, hy)
        let n3: f64 = sqrt(hx[0] * hx[0] + hy[0] * hy[0])
        let k3x: f64 = (-hy[0] / n3) * direction
        let k3y: f64 = (hx[0] / n3) * direction

        h_and_grad(x + ds * k3x, y + ds * k3y, hh, hx, hy)
        let n4: f64 = sqrt(hx[0] * hx[0] + hy[0] * hy[0])
        let k4x: f64 = (-hy[0] / n4) * direction
        let k4y: f64 = (hx[0] / n4) * direction

        let xn: f64 = x + ds * (k1x + 2.0 * k2x + 2.0 * k3x + k4x) / 6.0
        let yn: f64 = y + ds * (k1y + 2.0 * k2y + 2.0 * k3y + k4y) / 6.0
        project_to_level(xn, yn, fmin, px, py)
        let dxn: f64 = px[0] - tx
        let dyn: f64 = py[0] - ty
        let dn: f64 = sqrt(dxn * dxn + dyn * dyn)
        if d < 1.0 && dn > d {
            ds = ds * 0.5
            if ds < 0.000000000000001 { break }
            step = step + 1
            continue
        }
        x = px[0]
        y = py[0]
        s = s + ds
        if s > 20000.0 { break }
        step = step + 1
    }
    free(px); free(py); free(hh); free(hx); free(hy)
    return s
}

function main() -> i32 {
    let mut best_y: f64 = 0.0
    let mut best_h: f64 = -1000000000000.0
    let mut yi: i64 = 0
    while yi <= 1600 {
        let v: f64 = h_only(0.0, yi as f64)
        if v > best_h {
            best_h = v
            best_y = yi as f64
        }
        yi = yi + 1
    }
    let lo: f64 = best_y - 5.0
    let hi: f64 = best_y + 5.0
    let fmin: f64 = golden_max(lo, hi)

    let tx: ptr<f64> = calloc(16, 8)
    let ty: ptr<f64> = calloc(16, 8)
    let mut tc: i64 = 0

    let hh: ptr<f64> = calloc(1, 8)
    let hx: ptr<f64> = calloc(1, 8)
    let hy: ptr<f64> = calloc(1, 8)
    let ox: ptr<f64> = calloc(1, 8)
    let oy: ptr<f64> = calloc(1, 8)

    let mut xi: i64 = 0
    while xi <= 1600 {
        let x: f64 = xi as f64
        let mut yj: i64 = 0
        while yj <= 1600 {
            let y: f64 = yj as f64
            h_and_grad(x, y, hh, hx, hy)
            let mut dh: f64 = hh[0] - fmin
            if dh < 0.0 { dh = -dh }
            if dh < 300.0 {
                let tang: f64 = hx[0] * (AX - x) + hy[0] * (AY - y)
                let mut at: f64 = tang
                if at < 0.0 { at = -at }
                if at < 400.0 {
                    ox[0] = x
                    oy[0] = y
                    newton_tangent(AX, AY, fmin, x, y, ox, oy)
                    let rx: f64 = ox[0]
                    let ry: f64 = oy[0]
                    let mut dup: bool = false
                    let mut k: i64 = 0
                    while k < tc {
                        let ddx: f64 = rx - tx[k]
                        let ddy: f64 = ry - ty[k]
                        if ddx * ddx + ddy * ddy < 0.000001 {
                            dup = true
                            break
                        }
                        k = k + 1
                    }
                    if !dup && segment_clear(AX, AY, rx, ry, fmin) {
                        tx[tc] = rx
                        ty[tc] = ry
                        tc = tc + 1
                    }
                }
            }
            yj = yj + 10
        }
        xi = xi + 10
    }

    let bx: ptr<f64> = calloc(16, 8)
    let by: ptr<f64> = calloc(16, 8)
    let mut bc: i64 = 0
    xi = 0
    while xi <= 1600 {
        let x: f64 = xi as f64
        let mut yj: i64 = 0
        while yj <= 1600 {
            let y: f64 = yj as f64
            h_and_grad(x, y, hh, hx, hy)
            let mut dh: f64 = hh[0] - fmin
            if dh < 0.0 { dh = -dh }
            if dh < 300.0 {
                let tang: f64 = hx[0] * (BX - x) + hy[0] * (BY - y)
                let mut at: f64 = tang
                if at < 0.0 { at = -at }
                if at < 400.0 {
                    ox[0] = x
                    oy[0] = y
                    newton_tangent(BX, BY, fmin, x, y, ox, oy)
                    let rx: f64 = ox[0]
                    let ry: f64 = oy[0]
                    let mut dup: bool = false
                    let mut k: i64 = 0
                    while k < bc {
                        let ddx: f64 = rx - bx[k]
                        let ddy: f64 = ry - by[k]
                        if ddx * ddx + ddy * ddy < 0.000001 {
                            dup = true
                            break
                        }
                        k = k + 1
                    }
                    if !dup && segment_clear(BX, BY, rx, ry, fmin) {
                        bx[bc] = rx
                        by[bc] = ry
                        bc = bc + 1
                    }
                }
            }
            yj = yj + 10
        }
        xi = xi + 10
    }

    let mut best: f64 = 1000000000000.0
    let mut i: i64 = 0
    while i < tc {
        let mut j: i64 = 0
        while j < bc {
            let px: f64 = tx[i]
            let py: f64 = ty[i]
            let qx: f64 = bx[j]
            let qy: f64 = by[j]
            let arc1: f64 = walk_to_target(px, py, qx, qy, fmin, 1.0)
            let arc2: f64 = walk_to_target(px, py, qx, qy, fmin, -1.0)
            let arc: f64 = arc1
            let mut use_arc: f64 = arc1
            if arc2 < use_arc { use_arc = arc2 }
            let dax: f64 = px - AX
            let day: f64 = py - AY
            let dbx: f64 = qx - BX
            let dby: f64 = qy - BY
            let total: f64 = sqrt(dax * dax + day * day) + use_arc + sqrt(dbx * dbx + dby * dby)
            if total < best { best = total }
            j = j + 1
        }
        i = i + 1
    }

    free(tx); free(ty); free(bx); free(by); free(hh); free(hx); free(hy); free(ox); free(oy)
    printf("%.3f\n", best)
    return 0
}

Generated C

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

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

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

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

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

#include <math.h>

void* _ui_state = NULL;

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

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

double h_only_f64_f64(double x, double y);
void h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(double x, double y, double* out_h, double* out_hx, double* out_hy);
double golden_max_f64_f64(double lo, double hi);
bool segment_clear_f64_f64_f64_f64_f64(double ox, double oy, double px, double py, double fmin);
void newton_tangent_f64_f64_f64_f64_f64_ptr_f64_ptr_f64(double ox, double oy, double fmin, double x0, double y0, double* out_x, double* out_y);
void project_to_level_f64_f64_f64_ptr_f64_ptr_f64(double x0, double y0, double fmin, double* out_x, double* out_y);
double walk_to_target_f64_f64_f64_f64_f64_f64(double sx, double sy, double tx, double ty, double fmin, double direction);
int32_t main(void);

/* Module statics */
static double L = 1600.0;
static double AX = 200.0;
static double AY = 200.0;
static double BX = 1400.0;
static double BY = 1400.0;





double h_only_f64_f64(double x, double y) {
    double xx = (x * x);
    double yy = (y * y);
    double P = ((5000.0 - (0.005 * ((xx + yy) + (x * y)))) + (12.5 * (x + y)));
    double Q = (((0.000001 * (xx + yy)) - (0.0015 * (x + y))) + 0.7);
    double absQ = Q;
    if (absQ < 0.0) {
        absQ = (-absQ);
    }
    return (P * exp((-absQ)));
}

void h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(double x, double y, double* out_h, double* out_hx, double* out_hy) {
    double xx = (x * x);
    double yy = (y * y);
    double P = ((5000.0 - (0.005 * ((xx + yy) + (x * y)))) + (12.5 * (x + y)));
    double Q = (((0.000001 * (xx + yy)) - (0.0015 * (x + y))) + 0.7);
    double absQ = Q;
    double sign = 1.0;
    if (Q < 0.0) {
        absQ = (-Q);
        sign = (-1.0);
    }
    double E = exp((-absQ));
    out_h[0] = (P * E);
    double Px = ((12.5 - (0.01 * x)) - (0.005 * y));
    double Py = ((12.5 - (0.01 * y)) - (0.005 * x));
    double Qx = ((0.000002 * x) - 0.0015);
    double Qy = ((0.000002 * y) - 0.0015);
    out_hx[0] = (E * (Px - ((P * sign) * Qx)));
    out_hy[0] = (E * (Py - ((P * sign) * Qy)));
}

double golden_max_f64_f64(double lo, double hi) {
    double phi = 0.6180339887498949;
    double a = lo;
    double b = hi;
    double c = (b - (phi * (b - a)));
    double d = (a + (phi * (b - a)));
    double fc = h_only_f64_f64(0.0, c);
    double fd = h_only_f64_f64(0.0, d);
    int64_t it = 0;
    while (it < 200) {
        if ((b - a) < 0.0000000000001) {
            break;
        }
        if (fc < fd) {
            a = c;
            c = d;
            fc = fd;
            d = (a + (phi * (b - a)));
            fd = h_only_f64_f64(0.0, d);
        } else {
            b = d;
            d = c;
            fd = fc;
            c = (b - (phi * (b - a)));
            fc = h_only_f64_f64(0.0, c);
        }
        it = (it + 1);
    }
    return h_only_f64_f64(0.0, ((a + b) * 0.5));
}

bool segment_clear_f64_f64_f64_f64_f64(double ox, double oy, double px, double py, double fmin) {
    int64_t i = 1;
    while (i < 200) {
        double t = (((double)(i)) / 200.0);
        double x = (ox + ((px - ox) * t));
        double y = (oy + ((py - oy) * t));
        if (h_only_f64_f64(x, y) > (fmin + 0.000001)) {
            return 0;
        }
        i = (i + 1);
    }
    return 1;
}

void newton_tangent_f64_f64_f64_f64_f64_ptr_f64_ptr_f64(double ox, double oy, double fmin, double x0, double y0, double* out_x, double* out_y) {
    double x = x0;
    double y = y0;
    double* hh = (double*)(calloc(1, 8));
    double* hx = (double*)(calloc(1, 8));
    double* hy = (double*)(calloc(1, 8));
    int64_t it = 0;
    while (it < 120) {
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, y, hh, hx, hy);
        double f1 = (hh[0] - fmin);
        double f2 = ((hx[0] * (ox - x)) + (hy[0] * (oy - y)));
        if (f1 < 0.0) {
            if (f1 > (-0.0000000001)) {
                f1 = 0.0;
            }
        }
        if (f1 > 0.0) {
            if (f1 < 0.0000000001) {
                f1 = 0.0;
            }
        }
        if (f2 < 0.0) {
            if (f2 > (-0.00000001)) {
                f2 = 0.0;
            }
        }
        if (f2 > 0.0) {
            if (f2 < 0.00000001) {
                f2 = 0.0;
            }
        }
        if ((f1 == 0.0 && f2 == 0.0)) {
            break;
        }
        double epsx = (0.000001 * x);
        if (epsx < 0.0) {
            epsx = (-epsx);
        }
        if (epsx < 0.000001) {
            epsx = 0.000001;
        }
        double epsy = (0.000001 * y);
        if (epsy < 0.0) {
            epsy = (-epsy);
        }
        if (epsy < 0.000001) {
            epsy = 0.000001;
        }
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64((x + epsx), y, hh, hx, hy);
        double fpx1 = (hh[0] - fmin);
        double fpx2 = ((hx[0] * (ox - (x + epsx))) + (hy[0] * (oy - y)));
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64((x - epsx), y, hh, hx, hy);
        double fmx1 = (hh[0] - fmin);
        double fmx2 = ((hx[0] * (ox - (x - epsx))) + (hy[0] * (oy - y)));
        double dF1dx = ((fpx1 - fmx1) / (2.0 * epsx));
        double dF2dx = ((fpx2 - fmx2) / (2.0 * epsx));
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, (y + epsy), hh, hx, hy);
        double fpy1 = (hh[0] - fmin);
        double fpy2 = ((hx[0] * (ox - x)) + (hy[0] * (oy - (y + epsy))));
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, (y - epsy), hh, hx, hy);
        double fmy1 = (hh[0] - fmin);
        double fmy2 = ((hx[0] * (ox - x)) + (hy[0] * (oy - (y - epsy))));
        double dF1dy = ((fpy1 - fmy1) / (2.0 * epsy));
        double dF2dy = ((fpy2 - fmy2) / (2.0 * epsy));
        double det = ((dF1dx * dF2dy) - (dF1dy * dF2dx));
        if ((det > (-0.000000000000000001) && det < 0.000000000000000001)) {
            x = (x + 0.0003);
            y = (y - 0.0002);
            it = (it + 1);
            continue;
        }
        double dx = ((((-f1) * dF2dy) + (f2 * dF1dy)) / det);
        double dy = ((((-dF1dx) * f2) + (dF2dx * f1)) / det);
        double base = f1;
        if (f1 < 0.0) {
            double t = (-f1);
        } else {
        }
        double lam = 1.0;
        bool accepted = 0;
        int64_t ls = 0;
        while (ls < 25) {
            double xn = (x + (lam * dx));
            double yn = (y + (lam * dy));
            if ((((xn >= 0.0 && xn <= L) && yn >= 0.0) && yn <= L)) {
                h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(xn, yn, hh, hx, hy);
                double nf1 = (hh[0] - fmin);
                double nf2 = ((hx[0] * (ox - xn)) + (hy[0] * (oy - yn)));
                double af1 = nf1;
                double af2 = nf2;
                if (af1 < 0.0) {
                    af1 = (-af1);
                }
                if (af2 < 0.0) {
                    af2 = (-af2);
                }
                double bf1 = f1;
                double bf2 = f2;
                if (bf1 < 0.0) {
                    bf1 = (-bf1);
                }
                if (bf2 < 0.0) {
                    bf2 = (-bf2);
                }
                if ((af1 + af2) < (bf1 + bf2)) {
                    x = xn;
                    y = yn;
                    accepted = 1;
                    break;
                }
            }
            lam = (lam * 0.5);
            ls = (ls + 1);
        }
        if ((!(accepted))) {
            x = (x + dx);
            y = (y + dy);
        }
        it = (it + 1);
    }
    out_x[0] = x;
    out_y[0] = y;
    free(hh);
    free(hx);
    free(hy);
}

void project_to_level_f64_f64_f64_ptr_f64_ptr_f64(double x0, double y0, double fmin, double* out_x, double* out_y) {
    double x = x0;
    double y = y0;
    double* hh = (double*)(calloc(1, 8));
    double* hx = (double*)(calloc(1, 8));
    double* hy = (double*)(calloc(1, 8));
    int64_t i = 0;
    while (i < 3) {
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, y, hh, hx, hy);
        double F = (hh[0] - fmin);
        double denom = ((hx[0] * hx[0]) + (hy[0] * hy[0]));
        if (denom == 0.0) {
            break;
        }
        x = (x - ((F * hx[0]) / denom));
        y = (y - ((F * hy[0]) / denom));
        i = (i + 1);
    }
    out_x[0] = x;
    out_y[0] = y;
    free(hh);
    free(hx);
    free(hy);
}

double walk_to_target_f64_f64_f64_f64_f64_f64(double sx, double sy, double tx, double ty, double fmin, double direction) {
    double* px = (double*)(calloc(1, 8));
    double* py = (double*)(calloc(1, 8));
    project_to_level_f64_f64_f64_ptr_f64_ptr_f64(sx, sy, fmin, px, py);
    double x = px[0];
    double y = py[0];
    double* hh = (double*)(calloc(1, 8));
    double* hx = (double*)(calloc(1, 8));
    double* hy = (double*)(calloc(1, 8));
    double s = 0.0;
    double ds = 0.1;
    int64_t step = 0;
    while (step < 2000000) {
        double dx = (x - tx);
        double dy = (y - ty);
        double d = sqrt(((dx * dx) + (dy * dy)));
        if (d < 0.0000000001) {
            break;
        }
        if (ds > (d * 0.5)) {
            ds = (d * 0.5);
        }
        if (ds < 0.0000000001) {
            ds = 0.0000000001;
        }
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, y, hh, hx, hy);
        double nrm = sqrt(((hx[0] * hx[0]) + (hy[0] * hy[0])));
        double k1x = (((-hy[0]) / nrm) * direction);
        double k1y = ((hx[0] / nrm) * direction);
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64((x + ((0.5 * ds) * k1x)), (y + ((0.5 * ds) * k1y)), hh, hx, hy);
        double n2 = sqrt(((hx[0] * hx[0]) + (hy[0] * hy[0])));
        double k2x = (((-hy[0]) / n2) * direction);
        double k2y = ((hx[0] / n2) * direction);
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64((x + ((0.5 * ds) * k2x)), (y + ((0.5 * ds) * k2y)), hh, hx, hy);
        double n3 = sqrt(((hx[0] * hx[0]) + (hy[0] * hy[0])));
        double k3x = (((-hy[0]) / n3) * direction);
        double k3y = ((hx[0] / n3) * direction);
        h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64((x + (ds * k3x)), (y + (ds * k3y)), hh, hx, hy);
        double n4 = sqrt(((hx[0] * hx[0]) + (hy[0] * hy[0])));
        double k4x = (((-hy[0]) / n4) * direction);
        double k4y = ((hx[0] / n4) * direction);
        double xn = (x + ((ds * (((k1x + (2.0 * k2x)) + (2.0 * k3x)) + k4x)) / 6.0));
        double yn = (y + ((ds * (((k1y + (2.0 * k2y)) + (2.0 * k3y)) + k4y)) / 6.0));
        project_to_level_f64_f64_f64_ptr_f64_ptr_f64(xn, yn, fmin, px, py);
        double dxn = (px[0] - tx);
        double dyn = (py[0] - ty);
        double dn = sqrt(((dxn * dxn) + (dyn * dyn)));
        if ((d < 1.0 && dn > d)) {
            ds = (ds * 0.5);
            if (ds < 0.000000000000001) {
                break;
            }
            step = (step + 1);
            continue;
        }
        x = px[0];
        y = py[0];
        s = (s + ds);
        if (s > 20000.0) {
            break;
        }
        step = (step + 1);
    }
    free(px);
    free(py);
    free(hh);
    free(hx);
    free(hy);
    return s;
}

int32_t main(void) {
    double best_y = 0.0;
    double best_h = (-1000000000000.0);
    int64_t yi = 0;
    while (yi <= 1600) {
        double v = h_only_f64_f64(0.0, ((double)(yi)));
        if (v > best_h) {
            best_h = v;
            best_y = ((double)(yi));
        }
        yi = (yi + 1);
    }
    double lo = (best_y - 5.0);
    double hi = (best_y + 5.0);
    double fmin = golden_max_f64_f64(lo, hi);
    double* tx = (double*)(calloc(16, 8));
    double* ty = (double*)(calloc(16, 8));
    int64_t tc = 0;
    double* hh = (double*)(calloc(1, 8));
    double* hx = (double*)(calloc(1, 8));
    double* hy = (double*)(calloc(1, 8));
    double* ox = (double*)(calloc(1, 8));
    double* oy = (double*)(calloc(1, 8));
    int64_t xi = 0;
    while (xi <= 1600) {
        double x = ((double)(xi));
        int64_t yj = 0;
        while (yj <= 1600) {
            double y = ((double)(yj));
            h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, y, hh, hx, hy);
            double dh = (hh[0] - fmin);
            if (dh < 0.0) {
                dh = (-dh);
            }
            if (dh < 300.0) {
                double tang = ((hx[0] * (AX - x)) + (hy[0] * (AY - y)));
                double at = tang;
                if (at < 0.0) {
                    at = (-at);
                }
                if (at < 400.0) {
                    ox[0] = x;
                    oy[0] = y;
                    newton_tangent_f64_f64_f64_f64_f64_ptr_f64_ptr_f64(AX, AY, fmin, x, y, ox, oy);
                    double rx = ox[0];
                    double ry = oy[0];
                    bool dup = 0;
                    int64_t k = 0;
                    while (k < tc) {
                        double ddx = (rx - tx[k]);
                        double ddy = (ry - ty[k]);
                        if (((ddx * ddx) + (ddy * ddy)) < 0.000001) {
                            dup = 1;
                            break;
                        }
                        k = (k + 1);
                    }
                    if (((!(dup)) && segment_clear_f64_f64_f64_f64_f64(AX, AY, rx, ry, fmin))) {
                        tx[tc] = rx;
                        ty[tc] = ry;
                        tc = (tc + 1);
                    }
                }
            }
            yj = (yj + 10);
        }
        xi = (xi + 10);
    }
    double* bx = (double*)(calloc(16, 8));
    double* by = (double*)(calloc(16, 8));
    int64_t bc = 0;
    xi = 0;
    while (xi <= 1600) {
        double x = ((double)(xi));
        int64_t yj = 0;
        while (yj <= 1600) {
            double y = ((double)(yj));
            h_and_grad_f64_f64_ptr_f64_ptr_f64_ptr_f64(x, y, hh, hx, hy);
            double dh = (hh[0] - fmin);
            if (dh < 0.0) {
                dh = (-dh);
            }
            if (dh < 300.0) {
                double tang = ((hx[0] * (BX - x)) + (hy[0] * (BY - y)));
                double at = tang;
                if (at < 0.0) {
                    at = (-at);
                }
                if (at < 400.0) {
                    ox[0] = x;
                    oy[0] = y;
                    newton_tangent_f64_f64_f64_f64_f64_ptr_f64_ptr_f64(BX, BY, fmin, x, y, ox, oy);
                    double rx = ox[0];
                    double ry = oy[0];
                    bool dup = 0;
                    int64_t k = 0;
                    while (k < bc) {
                        double ddx = (rx - bx[k]);
                        double ddy = (ry - by[k]);
                        if (((ddx * ddx) + (ddy * ddy)) < 0.000001) {
                            dup = 1;
                            break;
                        }
                        k = (k + 1);
                    }
                    if (((!(dup)) && segment_clear_f64_f64_f64_f64_f64(BX, BY, rx, ry, fmin))) {
                        bx[bc] = rx;
                        by[bc] = ry;
                        bc = (bc + 1);
                    }
                }
            }
            yj = (yj + 10);
        }
        xi = (xi + 10);
    }
    double best = 1000000000000.0;
    int64_t i = 0;
    while (i < tc) {
        int64_t j = 0;
        while (j < bc) {
            double px = tx[i];
            double py = ty[i];
            double qx = bx[j];
            double qy = by[j];
            double arc1 = walk_to_target_f64_f64_f64_f64_f64_f64(px, py, qx, qy, fmin, 1.0);
            double arc2 = walk_to_target_f64_f64_f64_f64_f64_f64(px, py, qx, qy, fmin, (-1.0));
            double arc = arc1;
            double use_arc = arc1;
            if (arc2 < use_arc) {
                use_arc = arc2;
            }
            double dax = (px - AX);
            double day = (py - AY);
            double dbx = (qx - BX);
            double dby = (qy - BY);
            double total = ((sqrt(((dax * dax) + (day * day))) + use_arc) + sqrt(((dbx * dbx) + (dby * dby))));
            if (total < best) {
                best = total;
            }
            j = (j + 1);
        }
        i = (i + 1);
    }
    free(tx);
    free(ty);
    free(bx);
    free(by);
    free(hh);
    free(hx);
    free(hy);
    free(ox);
    free(oy);
    printf("%.3f\n", best);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%.3f\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 @sqrt(f64) -> f64
  func.func private @exp(f64) -> f64
  // Module static: L
  llvm.mlir.global internal @L(1600.0 : f64) : f64
  // Module static: AX
  llvm.mlir.global internal @AX(200.0 : f64) : f64
  // Module static: AY
  llvm.mlir.global internal @AY(200.0 : f64) : f64
  // Module static: BX
  llvm.mlir.global internal @BX(1400.0 : f64) : f64
  // Module static: BY
  llvm.mlir.global internal @BY(1400.0 : f64) : f64
  func.func @h_only(%arg0: f64, %arg1: f64) -> f64 {
    %0 = arith.mulf %arg0, %arg0 : f64
    %1 = arith.mulf %arg1, %arg1 : f64
    %2 = arith.constant 5000.0 : f32
    %3 = arith.constant 0.005 : f32
    %4 = arith.addf %0, %1 : f64
    %5 = arith.mulf %arg0, %arg1 : f64
    %6 = arith.addf %4, %5 : f64
    %8 = arith.extf %3 : f32 to f64
    %7 = arith.mulf %8, %6 : f64
    %10 = arith.extf %2 : f32 to f64
    %9 = arith.subf %10, %7 : f64
    %11 = arith.constant 12.5 : f32
    %12 = arith.addf %arg0, %arg1 : f64
    %14 = arith.extf %11 : f32 to f64
    %13 = arith.mulf %14, %12 : f64
    %15 = arith.addf %9, %13 : f64
    %16 = arith.constant 0.000001 : f32
    %17 = arith.addf %0, %1 : f64
    %19 = arith.extf %16 : f32 to f64
    %18 = arith.mulf %19, %17 : f64
    %20 = arith.constant 0.0015 : f32
    %21 = arith.addf %arg0, %arg1 : f64
    %23 = arith.extf %20 : f32 to f64
    %22 = arith.mulf %23, %21 : f64
    %24 = arith.subf %18, %22 : f64
    %25 = arith.constant 0.7 : f32
    %27 = arith.extf %25 : f32 to f64
    %26 = arith.addf %24, %27 : f64
    %28 = arith.constant 0.0 : f32
    %30 = arith.extf %28 : f32 to f64
    %29 = arith.cmpf olt, %26, %30 : f64
    %31 = scf.if %29 -> (f64) {
      %32 = arith.negf %26 : f64
      scf.yield %32 : f64
    } else {
      scf.yield %26 : f64
    }
    %33 = arith.negf %31 : f64
    %34 = math.exp %33 : f64
    %35 = arith.mulf %15, %34 : f64
    func.return %35 : f64
  }
  func.func @h_and_grad(%arg0: f64, %arg1: f64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> () {
    %36 = arith.mulf %arg0, %arg0 : f64
    %37 = arith.mulf %arg1, %arg1 : f64
    %38 = arith.constant 5000.0 : f32
    %39 = arith.constant 0.005 : f32
    %40 = arith.addf %36, %37 : f64
    %41 = arith.mulf %arg0, %arg1 : f64
    %42 = arith.addf %40, %41 : f64
    %44 = arith.extf %39 : f32 to f64
    %43 = arith.mulf %44, %42 : f64
    %46 = arith.extf %38 : f32 to f64
    %45 = arith.subf %46, %43 : f64
    %47 = arith.constant 12.5 : f32
    %48 = arith.addf %arg0, %arg1 : f64
    %50 = arith.extf %47 : f32 to f64
    %49 = arith.mulf %50, %48 : f64
    %51 = arith.addf %45, %49 : f64
    %52 = arith.constant 0.000001 : f32
    %53 = arith.addf %36, %37 : f64
    %55 = arith.extf %52 : f32 to f64
    %54 = arith.mulf %55, %53 : f64
    %56 = arith.constant 0.0015 : f32
    %57 = arith.addf %arg0, %arg1 : f64
    %59 = arith.extf %56 : f32 to f64
    %58 = arith.mulf %59, %57 : f64
    %60 = arith.subf %54, %58 : f64
    %61 = arith.constant 0.7 : f32
    %63 = arith.extf %61 : f32 to f64
    %62 = arith.addf %60, %63 : f64
    %64 = arith.constant 1.0 : f32
    %65 = arith.extf %64 : f32 to f64
    %66 = llvm.mlir.constant(1 : i64) : i64
    %67 = llvm.alloca %66 x f64 : (i64) -> !llvm.ptr
    llvm.store %65, %67 : f64, !llvm.ptr
    %68 = arith.constant 0.0 : f32
    %70 = arith.extf %68 : f32 to f64
    %69 = arith.cmpf olt, %62, %70 : f64
    %71 = scf.if %69 -> (f64) {
      %72 = arith.negf %62 : f64
      %73 = arith.constant 1.0 : f32
      %74 = arith.negf %73 : f32
      %75 = arith.extf %74 : f32 to f64
      llvm.store %75, %67 : f64, !llvm.ptr
      scf.yield %72 : f64
    } else {
      scf.yield %62 : f64
    }
    %76 = arith.negf %71 : f64
    %77 = math.exp %76 : f64
    %78 = arith.mulf %51, %77 : f64
    %79 = arith.constant 0 : i32
    %80 = arith.extsi %79 : i32 to i64
    %81 = llvm.getelementptr %arg2[%80] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %78, %81 : f64, !llvm.ptr
    %82 = arith.constant 12.5 : f32
    %83 = arith.constant 0.01 : f32
    %85 = arith.extf %83 : f32 to f64
    %84 = arith.mulf %85, %arg0 : f64
    %87 = arith.extf %82 : f32 to f64
    %86 = arith.subf %87, %84 : f64
    %88 = arith.constant 0.005 : f32
    %90 = arith.extf %88 : f32 to f64
    %89 = arith.mulf %90, %arg1 : f64
    %91 = arith.subf %86, %89 : f64
    %92 = arith.constant 12.5 : f32
    %93 = arith.constant 0.01 : f32
    %95 = arith.extf %93 : f32 to f64
    %94 = arith.mulf %95, %arg1 : f64
    %97 = arith.extf %92 : f32 to f64
    %96 = arith.subf %97, %94 : f64
    %98 = arith.constant 0.005 : f32
    %100 = arith.extf %98 : f32 to f64
    %99 = arith.mulf %100, %arg0 : f64
    %101 = arith.subf %96, %99 : f64
    %102 = arith.constant 0.000002 : f32
    %104 = arith.extf %102 : f32 to f64
    %103 = arith.mulf %104, %arg0 : f64
    %105 = arith.constant 0.0015 : f32
    %107 = arith.extf %105 : f32 to f64
    %106 = arith.subf %103, %107 : f64
    %108 = arith.constant 0.000002 : f32
    %110 = arith.extf %108 : f32 to f64
    %109 = arith.mulf %110, %arg1 : f64
    %111 = arith.constant 0.0015 : f32
    %113 = arith.extf %111 : f32 to f64
    %112 = arith.subf %109, %113 : f64
    %114 = llvm.load %67 : !llvm.ptr -> f64
    %115 = arith.mulf %51, %114 : f64
    %116 = arith.mulf %115, %106 : f64
    %117 = arith.subf %91, %116 : f64
    %118 = arith.mulf %77, %117 : f64
    %119 = arith.constant 0 : i32
    %120 = arith.extsi %119 : i32 to i64
    %121 = llvm.getelementptr %arg3[%120] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %118, %121 : f64, !llvm.ptr
    %122 = llvm.load %67 : !llvm.ptr -> f64
    %123 = arith.mulf %51, %122 : f64
    %124 = arith.mulf %123, %112 : f64
    %125 = arith.subf %101, %124 : f64
    %126 = arith.mulf %77, %125 : f64
    %127 = arith.constant 0 : i32
    %128 = arith.extsi %127 : i32 to i64
    %129 = llvm.getelementptr %arg4[%128] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %126, %129 : f64, !llvm.ptr
    func.return
  }
  func.func @golden_max(%arg0: f64, %arg1: f64) -> f64 {
    %130 = arith.constant 0.6180339887498949 : f32
    %131 = arith.extf %130 : f32 to f64
    %132 = llvm.mlir.constant(1 : i64) : i64
    %133 = llvm.alloca %132 x f64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %133 : f64, !llvm.ptr
    %134 = llvm.mlir.constant(1 : i64) : i64
    %135 = llvm.alloca %134 x f64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %135 : f64, !llvm.ptr
    %136 = llvm.load %135 : !llvm.ptr -> f64
    %137 = llvm.load %135 : !llvm.ptr -> f64
    %138 = llvm.load %133 : !llvm.ptr -> f64
    %139 = arith.subf %137, %138 : f64
    %140 = arith.mulf %131, %139 : f64
    %141 = arith.subf %136, %140 : f64
    %142 = llvm.mlir.constant(1 : i64) : i64
    %143 = llvm.alloca %142 x f64 : (i64) -> !llvm.ptr
    llvm.store %141, %143 : f64, !llvm.ptr
    %144 = llvm.load %133 : !llvm.ptr -> f64
    %145 = llvm.load %135 : !llvm.ptr -> f64
    %146 = llvm.load %133 : !llvm.ptr -> f64
    %147 = arith.subf %145, %146 : f64
    %148 = arith.mulf %131, %147 : f64
    %149 = arith.addf %144, %148 : f64
    %150 = llvm.mlir.constant(1 : i64) : i64
    %151 = llvm.alloca %150 x f64 : (i64) -> !llvm.ptr
    llvm.store %149, %151 : f64, !llvm.ptr
    %153 = arith.constant 0.0 : f32
    %154 = llvm.load %143 : !llvm.ptr -> f64
    %155 = arith.extf %153 : f32 to f64
    %152 = func.call @h_only(%155, %154) : (f64, f64) -> f64
    %156 = llvm.mlir.constant(1 : i64) : i64
    %157 = llvm.alloca %156 x f64 : (i64) -> !llvm.ptr
    llvm.store %152, %157 : f64, !llvm.ptr
    %159 = arith.constant 0.0 : f32
    %160 = llvm.load %151 : !llvm.ptr -> f64
    %161 = arith.extf %159 : f32 to f64
    %158 = func.call @h_only(%161, %160) : (f64, f64) -> f64
    %162 = llvm.mlir.constant(1 : i64) : i64
    %163 = llvm.alloca %162 x f64 : (i64) -> !llvm.ptr
    llvm.store %158, %163 : f64, !llvm.ptr
    %164 = arith.constant 0 : i32
    %165 = arith.extsi %164 : i32 to i64
    %166 = llvm.mlir.constant(1 : i64) : i64
    %167 = llvm.alloca %166 x i64 : (i64) -> !llvm.ptr
    llvm.store %165, %167 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %168 = llvm.load %167 : !llvm.ptr -> i64
    %169 = arith.constant 200 : i32
    %171 = arith.extsi %169 : i32 to i64
    %170 = arith.cmpi slt, %168, %171 : i64
    cf.cond_br %170, ^bb1, ^bb2
    ^bb1:
      %172 = llvm.load %135 : !llvm.ptr -> f64
      %173 = llvm.load %133 : !llvm.ptr -> f64
      %174 = arith.subf %172, %173 : f64
      %175 = arith.constant 0.0000000000001 : f32
      %177 = arith.extf %175 : f32 to f64
      %176 = arith.cmpf olt, %174, %177 : f64
      cf.cond_br %176, ^bb3, ^bb4
      ^bb3:
        cf.br ^bb2
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %178 = llvm.load %157 : !llvm.ptr -> f64
      %179 = llvm.load %163 : !llvm.ptr -> f64
      %180 = arith.cmpf olt, %178, %179 : f64
      cf.cond_br %180, ^bb6, ^bb7
      ^bb6:
        %181 = llvm.load %143 : !llvm.ptr -> f64
        llvm.store %181, %133 : f64, !llvm.ptr
        %182 = llvm.load %151 : !llvm.ptr -> f64
        llvm.store %182, %143 : f64, !llvm.ptr
        %183 = llvm.load %163 : !llvm.ptr -> f64
        llvm.store %183, %157 : f64, !llvm.ptr
        %184 = llvm.load %133 : !llvm.ptr -> f64
        %185 = llvm.load %135 : !llvm.ptr -> f64
        %186 = llvm.load %133 : !llvm.ptr -> f64
        %187 = arith.subf %185, %186 : f64
        %188 = arith.mulf %131, %187 : f64
        %189 = arith.addf %184, %188 : f64
        llvm.store %189, %151 : f64, !llvm.ptr
        %191 = arith.constant 0.0 : f32
        %192 = llvm.load %151 : !llvm.ptr -> f64
        %193 = arith.extf %191 : f32 to f64
        %190 = func.call @h_only(%193, %192) : (f64, f64) -> f64
        llvm.store %190, %163 : f64, !llvm.ptr
        cf.br ^bb8
      ^bb7:
        %194 = llvm.load %151 : !llvm.ptr -> f64
        llvm.store %194, %135 : f64, !llvm.ptr
        %195 = llvm.load %143 : !llvm.ptr -> f64
        llvm.store %195, %151 : f64, !llvm.ptr
        %196 = llvm.load %157 : !llvm.ptr -> f64
        llvm.store %196, %163 : f64, !llvm.ptr
        %197 = llvm.load %135 : !llvm.ptr -> f64
        %198 = llvm.load %135 : !llvm.ptr -> f64
        %199 = llvm.load %133 : !llvm.ptr -> f64
        %200 = arith.subf %198, %199 : f64
        %201 = arith.mulf %131, %200 : f64
        %202 = arith.subf %197, %201 : f64
        llvm.store %202, %143 : f64, !llvm.ptr
        %204 = arith.constant 0.0 : f32
        %205 = llvm.load %143 : !llvm.ptr -> f64
        %206 = arith.extf %204 : f32 to f64
        %203 = func.call @h_only(%206, %205) : (f64, f64) -> f64
        llvm.store %203, %157 : f64, !llvm.ptr
        cf.br ^bb8
      ^bb8:
      %207 = llvm.load %167 : !llvm.ptr -> i64
      %208 = arith.constant 1 : i32
      %210 = arith.extsi %208 : i32 to i64
      %209 = arith.addi %207, %210 : i64
      llvm.store %209, %167 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %212 = arith.constant 0.0 : f32
    %213 = llvm.load %133 : !llvm.ptr -> f64
    %214 = llvm.load %135 : !llvm.ptr -> f64
    %215 = arith.addf %213, %214 : f64
    %216 = arith.constant 0.5 : f32
    %218 = arith.extf %216 : f32 to f64
    %217 = arith.mulf %215, %218 : f64
    %219 = arith.extf %212 : f32 to f64
    %211 = func.call @h_only(%219, %217) : (f64, f64) -> f64
    func.return %211 : f64
  }
  func.func @segment_clear(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64, %arg4: f64) -> i1 {
    %220 = arith.constant 1 : i32
    %221 = arith.extsi %220 : i32 to i64
    %222 = llvm.mlir.constant(1 : i64) : i64
    %223 = llvm.alloca %222 x i64 : (i64) -> !llvm.ptr
    llvm.store %221, %223 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %224 = llvm.load %223 : !llvm.ptr -> i64
    %225 = arith.constant 200 : i32
    %227 = arith.extsi %225 : i32 to i64
    %226 = arith.cmpi slt, %224, %227 : i64
    cf.cond_br %226, ^bb10, ^bb11
    ^bb10:
      %228 = llvm.load %223 : !llvm.ptr -> i64
      %229 = arith.sitofp %228 : i64 to f64
      %230 = arith.constant 200.0 : f32
      %232 = arith.extf %230 : f32 to f64
      %231 = arith.divf %229, %232 : f64
      %233 = arith.subf %arg2, %arg0 : f64
      %234 = arith.mulf %233, %231 : f64
      %235 = arith.addf %arg0, %234 : f64
      %236 = arith.subf %arg3, %arg1 : f64
      %237 = arith.mulf %236, %231 : f64
      %238 = arith.addf %arg1, %237 : f64
      %239 = func.call @h_only(%235, %238) : (f64, f64) -> f64
      %240 = arith.constant 0.000001 : f32
      %242 = arith.extf %240 : f32 to f64
      %241 = arith.addf %arg4, %242 : f64
      %243 = arith.cmpf ogt, %239, %241 : f64
      cf.cond_br %243, ^bb12, ^bb13
      ^bb12:
        %244 = arith.constant 0 : i1
        func.return %244 : i1
      ^bb13:
        cf.br ^bb14
      ^bb14:
      %245 = llvm.load %223 : !llvm.ptr -> i64
      %246 = arith.constant 1 : i32
      %248 = arith.extsi %246 : i32 to i64
      %247 = arith.addi %245, %248 : i64
      llvm.store %247, %223 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %249 = arith.constant 1 : i1
    func.return %249 : i1
  }
  func.func @newton_tangent(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64, %arg4: f64, %arg5: !llvm.ptr, %arg6: !llvm.ptr) -> () {
    %250 = llvm.mlir.constant(1 : i64) : i64
    %251 = llvm.alloca %250 x f64 : (i64) -> !llvm.ptr
    llvm.store %arg3, %251 : f64, !llvm.ptr
    %252 = llvm.mlir.constant(1 : i64) : i64
    %253 = llvm.alloca %252 x f64 : (i64) -> !llvm.ptr
    llvm.store %arg4, %253 : f64, !llvm.ptr
    %255 = arith.constant 1 : i32
    %256 = arith.constant 8 : i32
    %257 = arith.extsi %255 : i32 to i64
    %258 = arith.extsi %256 : i32 to i64
    %254 = func.call @calloc(%257, %258) : (i64, i64) -> !llvm.ptr
    %260 = arith.constant 1 : i32
    %261 = arith.constant 8 : i32
    %262 = arith.extsi %260 : i32 to i64
    %263 = arith.extsi %261 : i32 to i64
    %259 = func.call @calloc(%262, %263) : (i64, i64) -> !llvm.ptr
    %265 = arith.constant 1 : i32
    %266 = arith.constant 8 : i32
    %267 = arith.extsi %265 : i32 to i64
    %268 = arith.extsi %266 : i32 to i64
    %264 = func.call @calloc(%267, %268) : (i64, i64) -> !llvm.ptr
    %269 = arith.constant 0 : i32
    %270 = arith.extsi %269 : i32 to i64
    %271 = llvm.mlir.constant(1 : i64) : i64
    %272 = llvm.alloca %271 x i64 : (i64) -> !llvm.ptr
    llvm.store %270, %272 : i64, !llvm.ptr
    cf.br ^bb15
    ^bb15:
    %273 = llvm.load %272 : !llvm.ptr -> i64
    %274 = arith.constant 120 : i32
    %276 = arith.extsi %274 : i32 to i64
    %275 = arith.cmpi slt, %273, %276 : i64
    cf.cond_br %275, ^bb16, ^bb17
    ^bb16:
      %278 = llvm.load %251 : !llvm.ptr -> f64
      %279 = llvm.load %253 : !llvm.ptr -> f64
      func.call @h_and_grad(%278, %279, %254, %259, %264) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %281 = arith.constant 0 : i32
      %282 = arith.extsi %281 : i32 to i64
      %283 = llvm.getelementptr %254[%282] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %280 = llvm.load %283 : !llvm.ptr -> f64
      %284 = arith.subf %280, %arg2 : f64
      %286 = arith.constant 0 : i32
      %287 = arith.extsi %286 : i32 to i64
      %288 = llvm.getelementptr %259[%287] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %285 = llvm.load %288 : !llvm.ptr -> f64
      %289 = llvm.load %251 : !llvm.ptr -> f64
      %290 = arith.subf %arg0, %289 : f64
      %291 = arith.mulf %285, %290 : f64
      %293 = arith.constant 0 : i32
      %294 = arith.extsi %293 : i32 to i64
      %295 = llvm.getelementptr %264[%294] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %292 = llvm.load %295 : !llvm.ptr -> f64
      %296 = llvm.load %253 : !llvm.ptr -> f64
      %297 = arith.subf %arg1, %296 : f64
      %298 = arith.mulf %292, %297 : f64
      %299 = arith.addf %291, %298 : f64
      %300 = arith.constant 0.0 : f32
      %302 = arith.extf %300 : f32 to f64
      %301 = arith.cmpf olt, %284, %302 : f64
      cf.cond_br %301, ^bb18, ^bb19
      ^bb18:
        %303 = arith.constant 0.0000000001 : f32
        %304 = arith.negf %303 : f32
        %306 = arith.extf %304 : f32 to f64
        %305 = arith.cmpf ogt, %284, %306 : f64
        %307 = scf.if %305 -> (f64) {
          %308 = arith.constant 0.0 : f32
          %309 = arith.extf %308 : f32 to f64
          scf.yield %309 : f64
        } else {
          scf.yield %284 : f64
        }
        cf.br ^bb20(%307 : f64)
      ^bb19:
        cf.br ^bb20(%284 : f64)
      ^bb20(%310: f64):
      %311 = arith.constant 0.0 : f32
      %313 = arith.extf %311 : f32 to f64
      %312 = arith.cmpf ogt, %310, %313 : f64
      cf.cond_br %312, ^bb21, ^bb22
      ^bb21:
        %314 = arith.constant 0.0000000001 : f32
        %316 = arith.extf %314 : f32 to f64
        %315 = arith.cmpf olt, %310, %316 : f64
        %317 = scf.if %315 -> (f64) {
          %318 = arith.constant 0.0 : f32
          %319 = arith.extf %318 : f32 to f64
          scf.yield %319 : f64
        } else {
          scf.yield %310 : f64
        }
        cf.br ^bb23(%317 : f64)
      ^bb22:
        cf.br ^bb23(%310 : f64)
      ^bb23(%320: f64):
      %321 = arith.constant 0.0 : f32
      %323 = arith.extf %321 : f32 to f64
      %322 = arith.cmpf olt, %299, %323 : f64
      cf.cond_br %322, ^bb24, ^bb25
      ^bb24:
        %324 = arith.constant 0.00000001 : f32
        %325 = arith.negf %324 : f32
        %327 = arith.extf %325 : f32 to f64
        %326 = arith.cmpf ogt, %299, %327 : f64
        %328 = scf.if %326 -> (f64) {
          %329 = arith.constant 0.0 : f32
          %330 = arith.extf %329 : f32 to f64
          scf.yield %330 : f64
        } else {
          scf.yield %299 : f64
        }
        cf.br ^bb26(%328 : f64)
      ^bb25:
        cf.br ^bb26(%299 : f64)
      ^bb26(%331: f64):
      %332 = arith.constant 0.0 : f32
      %334 = arith.extf %332 : f32 to f64
      %333 = arith.cmpf ogt, %331, %334 : f64
      cf.cond_br %333, ^bb27, ^bb28
      ^bb27:
        %335 = arith.constant 0.00000001 : f32
        %337 = arith.extf %335 : f32 to f64
        %336 = arith.cmpf olt, %331, %337 : f64
        %338 = scf.if %336 -> (f64) {
          %339 = arith.constant 0.0 : f32
          %340 = arith.extf %339 : f32 to f64
          scf.yield %340 : f64
        } else {
          scf.yield %331 : f64
        }
        cf.br ^bb29(%338 : f64)
      ^bb28:
        cf.br ^bb29(%331 : f64)
      ^bb29(%341: f64):
      %342 = arith.constant 0.0 : f32
      %344 = arith.extf %342 : f32 to f64
      %343 = arith.cmpf oeq, %320, %344 : f64
      %345 = scf.if %343 -> (i1) {
        %346 = arith.constant 0.0 : f32
        %348 = arith.extf %346 : f32 to f64
        %347 = arith.cmpf oeq, %341, %348 : f64
        scf.yield %347 : i1
      } else {
        %349 = arith.constant false
        scf.yield %349 : i1
      }
      cf.cond_br %345, ^bb30, ^bb31
      ^bb30:
        cf.br ^bb17
      ^bb31:
        cf.br ^bb32
      ^bb32:
      %350 = arith.constant 0.000001 : f32
      %351 = llvm.load %251 : !llvm.ptr -> f64
      %353 = arith.extf %350 : f32 to f64
      %352 = arith.mulf %353, %351 : f64
      %354 = llvm.mlir.constant(1 : i64) : i64
      %355 = llvm.alloca %354 x f64 : (i64) -> !llvm.ptr
      llvm.store %352, %355 : f64, !llvm.ptr
      %356 = llvm.load %355 : !llvm.ptr -> f64
      %357 = arith.constant 0.0 : f32
      %359 = arith.extf %357 : f32 to f64
      %358 = arith.cmpf olt, %356, %359 : f64
      cf.cond_br %358, ^bb33, ^bb34
      ^bb33:
        %360 = llvm.load %355 : !llvm.ptr -> f64
        %361 = arith.negf %360 : f64
        llvm.store %361, %355 : f64, !llvm.ptr
        cf.br ^bb35
      ^bb34:
        cf.br ^bb35
      ^bb35:
      %362 = llvm.load %355 : !llvm.ptr -> f64
      %363 = arith.constant 0.000001 : f32
      %365 = arith.extf %363 : f32 to f64
      %364 = arith.cmpf olt, %362, %365 : f64
      cf.cond_br %364, ^bb36, ^bb37
      ^bb36:
        %366 = arith.constant 0.000001 : f32
        %367 = arith.extf %366 : f32 to f64
        llvm.store %367, %355 : f64, !llvm.ptr
        cf.br ^bb38
      ^bb37:
        cf.br ^bb38
      ^bb38:
      %368 = arith.constant 0.000001 : f32
      %369 = llvm.load %253 : !llvm.ptr -> f64
      %371 = arith.extf %368 : f32 to f64
      %370 = arith.mulf %371, %369 : f64
      %372 = llvm.mlir.constant(1 : i64) : i64
      %373 = llvm.alloca %372 x f64 : (i64) -> !llvm.ptr
      llvm.store %370, %373 : f64, !llvm.ptr
      %374 = llvm.load %373 : !llvm.ptr -> f64
      %375 = arith.constant 0.0 : f32
      %377 = arith.extf %375 : f32 to f64
      %376 = arith.cmpf olt, %374, %377 : f64
      cf.cond_br %376, ^bb39, ^bb40
      ^bb39:
        %378 = llvm.load %373 : !llvm.ptr -> f64
        %379 = arith.negf %378 : f64
        llvm.store %379, %373 : f64, !llvm.ptr
        cf.br ^bb41
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %380 = llvm.load %373 : !llvm.ptr -> f64
      %381 = arith.constant 0.000001 : f32
      %383 = arith.extf %381 : f32 to f64
      %382 = arith.cmpf olt, %380, %383 : f64
      cf.cond_br %382, ^bb42, ^bb43
      ^bb42:
        %384 = arith.constant 0.000001 : f32
        %385 = arith.extf %384 : f32 to f64
        llvm.store %385, %373 : f64, !llvm.ptr
        cf.br ^bb44
      ^bb43:
        cf.br ^bb44
      ^bb44:
      %387 = llvm.load %251 : !llvm.ptr -> f64
      %388 = llvm.load %355 : !llvm.ptr -> f64
      %389 = arith.addf %387, %388 : f64
      %390 = llvm.load %253 : !llvm.ptr -> f64
      func.call @h_and_grad(%389, %390, %254, %259, %264) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %392 = arith.constant 0 : i32
      %393 = arith.extsi %392 : i32 to i64
      %394 = llvm.getelementptr %254[%393] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %391 = llvm.load %394 : !llvm.ptr -> f64
      %395 = arith.subf %391, %arg2 : f64
      %397 = arith.constant 0 : i32
      %398 = arith.extsi %397 : i32 to i64
      %399 = llvm.getelementptr %259[%398] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %396 = llvm.load %399 : !llvm.ptr -> f64
      %400 = llvm.load %251 : !llvm.ptr -> f64
      %401 = llvm.load %355 : !llvm.ptr -> f64
      %402 = arith.addf %400, %401 : f64
      %403 = arith.subf %arg0, %402 : f64
      %404 = arith.mulf %396, %403 : f64
      %406 = arith.constant 0 : i32
      %407 = arith.extsi %406 : i32 to i64
      %408 = llvm.getelementptr %264[%407] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %405 = llvm.load %408 : !llvm.ptr -> f64
      %409 = llvm.load %253 : !llvm.ptr -> f64
      %410 = arith.subf %arg1, %409 : f64
      %411 = arith.mulf %405, %410 : f64
      %412 = arith.addf %404, %411 : f64
      %414 = llvm.load %251 : !llvm.ptr -> f64
      %415 = llvm.load %355 : !llvm.ptr -> f64
      %416 = arith.subf %414, %415 : f64
      %417 = llvm.load %253 : !llvm.ptr -> f64
      func.call @h_and_grad(%416, %417, %254, %259, %264) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %419 = arith.constant 0 : i32
      %420 = arith.extsi %419 : i32 to i64
      %421 = llvm.getelementptr %254[%420] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %418 = llvm.load %421 : !llvm.ptr -> f64
      %422 = arith.subf %418, %arg2 : f64
      %424 = arith.constant 0 : i32
      %425 = arith.extsi %424 : i32 to i64
      %426 = llvm.getelementptr %259[%425] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %423 = llvm.load %426 : !llvm.ptr -> f64
      %427 = llvm.load %251 : !llvm.ptr -> f64
      %428 = llvm.load %355 : !llvm.ptr -> f64
      %429 = arith.subf %427, %428 : f64
      %430 = arith.subf %arg0, %429 : f64
      %431 = arith.mulf %423, %430 : f64
      %433 = arith.constant 0 : i32
      %434 = arith.extsi %433 : i32 to i64
      %435 = llvm.getelementptr %264[%434] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %432 = llvm.load %435 : !llvm.ptr -> f64
      %436 = llvm.load %253 : !llvm.ptr -> f64
      %437 = arith.subf %arg1, %436 : f64
      %438 = arith.mulf %432, %437 : f64
      %439 = arith.addf %431, %438 : f64
      %440 = arith.subf %395, %422 : f64
      %441 = arith.constant 2.0 : f32
      %442 = llvm.load %355 : !llvm.ptr -> f64
      %444 = arith.extf %441 : f32 to f64
      %443 = arith.mulf %444, %442 : f64
      %445 = arith.divf %440, %443 : f64
      %446 = arith.subf %412, %439 : f64
      %447 = arith.constant 2.0 : f32
      %448 = llvm.load %355 : !llvm.ptr -> f64
      %450 = arith.extf %447 : f32 to f64
      %449 = arith.mulf %450, %448 : f64
      %451 = arith.divf %446, %449 : f64
      %453 = llvm.load %251 : !llvm.ptr -> f64
      %454 = llvm.load %253 : !llvm.ptr -> f64
      %455 = llvm.load %373 : !llvm.ptr -> f64
      %456 = arith.addf %454, %455 : f64
      func.call @h_and_grad(%453, %456, %254, %259, %264) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %458 = arith.constant 0 : i32
      %459 = arith.extsi %458 : i32 to i64
      %460 = llvm.getelementptr %254[%459] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %457 = llvm.load %460 : !llvm.ptr -> f64
      %461 = arith.subf %457, %arg2 : f64
      %463 = arith.constant 0 : i32
      %464 = arith.extsi %463 : i32 to i64
      %465 = llvm.getelementptr %259[%464] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %462 = llvm.load %465 : !llvm.ptr -> f64
      %466 = llvm.load %251 : !llvm.ptr -> f64
      %467 = arith.subf %arg0, %466 : f64
      %468 = arith.mulf %462, %467 : f64
      %470 = arith.constant 0 : i32
      %471 = arith.extsi %470 : i32 to i64
      %472 = llvm.getelementptr %264[%471] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %469 = llvm.load %472 : !llvm.ptr -> f64
      %473 = llvm.load %253 : !llvm.ptr -> f64
      %474 = llvm.load %373 : !llvm.ptr -> f64
      %475 = arith.addf %473, %474 : f64
      %476 = arith.subf %arg1, %475 : f64
      %477 = arith.mulf %469, %476 : f64
      %478 = arith.addf %468, %477 : f64
      %480 = llvm.load %251 : !llvm.ptr -> f64
      %481 = llvm.load %253 : !llvm.ptr -> f64
      %482 = llvm.load %373 : !llvm.ptr -> f64
      %483 = arith.subf %481, %482 : f64
      func.call @h_and_grad(%480, %483, %254, %259, %264) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %485 = arith.constant 0 : i32
      %486 = arith.extsi %485 : i32 to i64
      %487 = llvm.getelementptr %254[%486] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %484 = llvm.load %487 : !llvm.ptr -> f64
      %488 = arith.subf %484, %arg2 : f64
      %490 = arith.constant 0 : i32
      %491 = arith.extsi %490 : i32 to i64
      %492 = llvm.getelementptr %259[%491] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %489 = llvm.load %492 : !llvm.ptr -> f64
      %493 = llvm.load %251 : !llvm.ptr -> f64
      %494 = arith.subf %arg0, %493 : f64
      %495 = arith.mulf %489, %494 : f64
      %497 = arith.constant 0 : i32
      %498 = arith.extsi %497 : i32 to i64
      %499 = llvm.getelementptr %264[%498] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %496 = llvm.load %499 : !llvm.ptr -> f64
      %500 = llvm.load %253 : !llvm.ptr -> f64
      %501 = llvm.load %373 : !llvm.ptr -> f64
      %502 = arith.subf %500, %501 : f64
      %503 = arith.subf %arg1, %502 : f64
      %504 = arith.mulf %496, %503 : f64
      %505 = arith.addf %495, %504 : f64
      %506 = arith.subf %461, %488 : f64
      %507 = arith.constant 2.0 : f32
      %508 = llvm.load %373 : !llvm.ptr -> f64
      %510 = arith.extf %507 : f32 to f64
      %509 = arith.mulf %510, %508 : f64
      %511 = arith.divf %506, %509 : f64
      %512 = arith.subf %478, %505 : f64
      %513 = arith.constant 2.0 : f32
      %514 = llvm.load %373 : !llvm.ptr -> f64
      %516 = arith.extf %513 : f32 to f64
      %515 = arith.mulf %516, %514 : f64
      %517 = arith.divf %512, %515 : f64
      %518 = arith.mulf %445, %517 : f64
      %519 = arith.mulf %511, %451 : f64
      %520 = arith.subf %518, %519 : f64
      %521 = arith.constant 0.000000000000000001 : f32
      %522 = arith.negf %521 : f32
      %524 = arith.extf %522 : f32 to f64
      %523 = arith.cmpf ogt, %520, %524 : f64
      %525 = scf.if %523 -> (i1) {
        %526 = arith.constant 0.000000000000000001 : f32
        %528 = arith.extf %526 : f32 to f64
        %527 = arith.cmpf olt, %520, %528 : f64
        scf.yield %527 : i1
      } else {
        %529 = arith.constant false
        scf.yield %529 : i1
      }
      cf.cond_br %525, ^bb45, ^bb46
      ^bb45:
        %530 = llvm.load %251 : !llvm.ptr -> f64
        %531 = arith.constant 0.0003 : f32
        %533 = arith.extf %531 : f32 to f64
        %532 = arith.addf %530, %533 : f64
        llvm.store %532, %251 : f64, !llvm.ptr
        %534 = llvm.load %253 : !llvm.ptr -> f64
        %535 = arith.constant 0.0002 : f32
        %537 = arith.extf %535 : f32 to f64
        %536 = arith.subf %534, %537 : f64
        llvm.store %536, %253 : f64, !llvm.ptr
        %538 = llvm.load %272 : !llvm.ptr -> i64
        %539 = arith.constant 1 : i32
        %541 = arith.extsi %539 : i32 to i64
        %540 = arith.addi %538, %541 : i64
        llvm.store %540, %272 : i64, !llvm.ptr
        cf.br ^bb15
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %542 = arith.negf %320 : f64
      %543 = arith.mulf %542, %517 : f64
      %544 = arith.mulf %341, %511 : f64
      %545 = arith.addf %543, %544 : f64
      %546 = arith.divf %545, %520 : f64
      %547 = arith.negf %445 : f64
      %548 = arith.mulf %547, %341 : f64
      %549 = arith.mulf %451, %320 : f64
      %550 = arith.addf %548, %549 : f64
      %551 = arith.divf %550, %520 : f64
      %552 = arith.constant 0.0 : f32
      %554 = arith.extf %552 : f32 to f64
      %553 = arith.cmpf olt, %320, %554 : f64
      cf.cond_br %553, ^bb48, ^bb49
      ^bb48:
        %555 = arith.negf %320 : f64
        cf.br ^bb50
      ^bb49:
        cf.br ^bb50
      ^bb50:
      %556 = arith.constant 1.0 : f32
      %557 = arith.extf %556 : f32 to f64
      %558 = llvm.mlir.constant(1 : i64) : i64
      %559 = llvm.alloca %558 x f64 : (i64) -> !llvm.ptr
      llvm.store %557, %559 : f64, !llvm.ptr
      %560 = arith.constant 0 : i1
      %561 = llvm.mlir.constant(1 : i64) : i64
      %562 = llvm.alloca %561 x i1 : (i64) -> !llvm.ptr
      llvm.store %560, %562 : i1, !llvm.ptr
      %563 = arith.constant 0 : i32
      %564 = arith.extsi %563 : i32 to i64
      %565 = llvm.mlir.constant(1 : i64) : i64
      %566 = llvm.alloca %565 x i64 : (i64) -> !llvm.ptr
      llvm.store %564, %566 : i64, !llvm.ptr
      cf.br ^bb51
      ^bb51:
      %567 = llvm.load %566 : !llvm.ptr -> i64
      %568 = arith.constant 25 : i32
      %570 = arith.extsi %568 : i32 to i64
      %569 = arith.cmpi slt, %567, %570 : i64
      cf.cond_br %569, ^bb52, ^bb53
      ^bb52:
        %571 = llvm.load %251 : !llvm.ptr -> f64
        %572 = llvm.load %559 : !llvm.ptr -> f64
        %573 = arith.mulf %572, %546 : f64
        %574 = arith.addf %571, %573 : f64
        %575 = llvm.load %253 : !llvm.ptr -> f64
        %576 = llvm.load %559 : !llvm.ptr -> f64
        %577 = arith.mulf %576, %551 : f64
        %578 = arith.addf %575, %577 : f64
        %579 = arith.constant 0.0 : f32
        %581 = arith.extf %579 : f32 to f64
        %580 = arith.cmpf oge, %574, %581 : f64
        %582 = scf.if %580 -> (i1) {
          %583 = llvm.mlir.addressof @L : !llvm.ptr
          %584 = llvm.load %583 : !llvm.ptr -> f64
          %585 = arith.cmpf ole, %574, %584 : f64
          scf.yield %585 : i1
        } else {
          %586 = arith.constant false
          scf.yield %586 : i1
        }
        %587 = scf.if %582 -> (i1) {
          %588 = arith.constant 0.0 : f32
          %590 = arith.extf %588 : f32 to f64
          %589 = arith.cmpf oge, %578, %590 : f64
          scf.yield %589 : i1
        } else {
          %591 = arith.constant false
          scf.yield %591 : i1
        }
        %592 = scf.if %587 -> (i1) {
          %593 = llvm.mlir.addressof @L : !llvm.ptr
          %594 = llvm.load %593 : !llvm.ptr -> f64
          %595 = arith.cmpf ole, %578, %594 : f64
          scf.yield %595 : i1
        } else {
          %596 = arith.constant false
          scf.yield %596 : i1
        }
        cf.cond_br %592, ^bb54, ^bb55
        ^bb54:
          func.call @h_and_grad(%574, %578, %254, %259, %264) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
          %599 = arith.constant 0 : i32
          %600 = arith.extsi %599 : i32 to i64
          %601 = llvm.getelementptr %254[%600] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %598 = llvm.load %601 : !llvm.ptr -> f64
          %602 = arith.subf %598, %arg2 : f64
          %604 = arith.constant 0 : i32
          %605 = arith.extsi %604 : i32 to i64
          %606 = llvm.getelementptr %259[%605] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %603 = llvm.load %606 : !llvm.ptr -> f64
          %607 = arith.subf %arg0, %574 : f64
          %608 = arith.mulf %603, %607 : f64
          %610 = arith.constant 0 : i32
          %611 = arith.extsi %610 : i32 to i64
          %612 = llvm.getelementptr %264[%611] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %609 = llvm.load %612 : !llvm.ptr -> f64
          %613 = arith.subf %arg1, %578 : f64
          %614 = arith.mulf %609, %613 : f64
          %615 = arith.addf %608, %614 : f64
          %616 = llvm.mlir.constant(1 : i64) : i64
          %617 = llvm.alloca %616 x f64 : (i64) -> !llvm.ptr
          llvm.store %602, %617 : f64, !llvm.ptr
          %618 = llvm.mlir.constant(1 : i64) : i64
          %619 = llvm.alloca %618 x f64 : (i64) -> !llvm.ptr
          llvm.store %615, %619 : f64, !llvm.ptr
          %620 = llvm.load %617 : !llvm.ptr -> f64
          %621 = arith.constant 0.0 : f32
          %623 = arith.extf %621 : f32 to f64
          %622 = arith.cmpf olt, %620, %623 : f64
          cf.cond_br %622, ^bb57, ^bb58
          ^bb57:
            %624 = llvm.load %617 : !llvm.ptr -> f64
            %625 = arith.negf %624 : f64
            llvm.store %625, %617 : f64, !llvm.ptr
            cf.br ^bb59
          ^bb58:
            cf.br ^bb59
          ^bb59:
          %626 = llvm.load %619 : !llvm.ptr -> f64
          %627 = arith.constant 0.0 : f32
          %629 = arith.extf %627 : f32 to f64
          %628 = arith.cmpf olt, %626, %629 : f64
          cf.cond_br %628, ^bb60, ^bb61
          ^bb60:
            %630 = llvm.load %619 : !llvm.ptr -> f64
            %631 = arith.negf %630 : f64
            llvm.store %631, %619 : f64, !llvm.ptr
            cf.br ^bb62
          ^bb61:
            cf.br ^bb62
          ^bb62:
          %632 = llvm.mlir.constant(1 : i64) : i64
          %633 = llvm.alloca %632 x f64 : (i64) -> !llvm.ptr
          llvm.store %320, %633 : f64, !llvm.ptr
          %634 = llvm.mlir.constant(1 : i64) : i64
          %635 = llvm.alloca %634 x f64 : (i64) -> !llvm.ptr
          llvm.store %341, %635 : f64, !llvm.ptr
          %636 = llvm.load %633 : !llvm.ptr -> f64
          %637 = arith.constant 0.0 : f32
          %639 = arith.extf %637 : f32 to f64
          %638 = arith.cmpf olt, %636, %639 : f64
          cf.cond_br %638, ^bb63, ^bb64
          ^bb63:
            %640 = llvm.load %633 : !llvm.ptr -> f64
            %641 = arith.negf %640 : f64
            llvm.store %641, %633 : f64, !llvm.ptr
            cf.br ^bb65
          ^bb64:
            cf.br ^bb65
          ^bb65:
          %642 = llvm.load %635 : !llvm.ptr -> f64
          %643 = arith.constant 0.0 : f32
          %645 = arith.extf %643 : f32 to f64
          %644 = arith.cmpf olt, %642, %645 : f64
          cf.cond_br %644, ^bb66, ^bb67
          ^bb66:
            %646 = llvm.load %635 : !llvm.ptr -> f64
            %647 = arith.negf %646 : f64
            llvm.store %647, %635 : f64, !llvm.ptr
            cf.br ^bb68
          ^bb67:
            cf.br ^bb68
          ^bb68:
          %648 = llvm.load %617 : !llvm.ptr -> f64
          %649 = llvm.load %619 : !llvm.ptr -> f64
          %650 = arith.addf %648, %649 : f64
          %651 = llvm.load %633 : !llvm.ptr -> f64
          %652 = llvm.load %635 : !llvm.ptr -> f64
          %653 = arith.addf %651, %652 : f64
          %654 = arith.cmpf olt, %650, %653 : f64
          cf.cond_br %654, ^bb69, ^bb70
          ^bb69:
            llvm.store %574, %251 : f64, !llvm.ptr
            llvm.store %578, %253 : f64, !llvm.ptr
            %655 = arith.constant 1 : i1
            llvm.store %655, %562 : i1, !llvm.ptr
            cf.br ^bb53
          ^bb70:
            cf.br ^bb71
          ^bb71:
          cf.br ^bb56
        ^bb55:
          cf.br ^bb56
        ^bb56:
        %656 = llvm.load %559 : !llvm.ptr -> f64
        %657 = arith.constant 0.5 : f32
        %659 = arith.extf %657 : f32 to f64
        %658 = arith.mulf %656, %659 : f64
        llvm.store %658, %559 : f64, !llvm.ptr
        %660 = llvm.load %566 : !llvm.ptr -> i64
        %661 = arith.constant 1 : i32
        %663 = arith.extsi %661 : i32 to i64
        %662 = arith.addi %660, %663 : i64
        llvm.store %662, %566 : i64, !llvm.ptr
        cf.br ^bb51
      ^bb53:
      %664 = llvm.load %562 : !llvm.ptr -> i1
      %666 = arith.constant 1 : i1
      %665 = arith.xori %664, %666 : i1
      cf.cond_br %665, ^bb72, ^bb73
      ^bb72:
        %668 = llvm.load %251 : !llvm.ptr -> f64
        %669 = arith.addf %668, %546 : f64
        llvm.store %669, %251 : f64, !llvm.ptr
        %670 = llvm.load %253 : !llvm.ptr -> f64
        %671 = arith.addf %670, %551 : f64
        llvm.store %671, %253 : f64, !llvm.ptr
        cf.br ^bb74
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %672 = llvm.load %272 : !llvm.ptr -> i64
      %673 = arith.constant 1 : i32
      %675 = arith.extsi %673 : i32 to i64
      %674 = arith.addi %672, %675 : i64
      llvm.store %674, %272 : i64, !llvm.ptr
      cf.br ^bb15
    ^bb17:
    %676 = llvm.load %251 : !llvm.ptr -> f64
    %677 = arith.constant 0 : i32
    %678 = arith.extsi %677 : i32 to i64
    %679 = llvm.getelementptr %arg5[%678] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %676, %679 : f64, !llvm.ptr
    %680 = llvm.load %253 : !llvm.ptr -> f64
    %681 = arith.constant 0 : i32
    %682 = arith.extsi %681 : i32 to i64
    %683 = llvm.getelementptr %arg6[%682] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %680, %683 : f64, !llvm.ptr
    func.call @free(%254) : (!llvm.ptr) -> ()
    func.call @free(%259) : (!llvm.ptr) -> ()
    func.call @free(%264) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @project_to_level(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> () {
    %687 = llvm.mlir.constant(1 : i64) : i64
    %688 = llvm.alloca %687 x f64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %688 : f64, !llvm.ptr
    %689 = llvm.mlir.constant(1 : i64) : i64
    %690 = llvm.alloca %689 x f64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %690 : f64, !llvm.ptr
    %692 = arith.constant 1 : i32
    %693 = arith.constant 8 : i32
    %694 = arith.extsi %692 : i32 to i64
    %695 = arith.extsi %693 : i32 to i64
    %691 = func.call @calloc(%694, %695) : (i64, i64) -> !llvm.ptr
    %697 = arith.constant 1 : i32
    %698 = arith.constant 8 : i32
    %699 = arith.extsi %697 : i32 to i64
    %700 = arith.extsi %698 : i32 to i64
    %696 = func.call @calloc(%699, %700) : (i64, i64) -> !llvm.ptr
    %702 = arith.constant 1 : i32
    %703 = arith.constant 8 : i32
    %704 = arith.extsi %702 : i32 to i64
    %705 = arith.extsi %703 : i32 to i64
    %701 = func.call @calloc(%704, %705) : (i64, i64) -> !llvm.ptr
    %706 = arith.constant 0 : i32
    %707 = arith.extsi %706 : i32 to i64
    %708 = llvm.mlir.constant(1 : i64) : i64
    %709 = llvm.alloca %708 x i64 : (i64) -> !llvm.ptr
    llvm.store %707, %709 : i64, !llvm.ptr
    cf.br ^bb75
    ^bb75:
    %710 = llvm.load %709 : !llvm.ptr -> i64
    %711 = arith.constant 3 : i32
    %713 = arith.extsi %711 : i32 to i64
    %712 = arith.cmpi slt, %710, %713 : i64
    cf.cond_br %712, ^bb76, ^bb77
    ^bb76:
      %715 = llvm.load %688 : !llvm.ptr -> f64
      %716 = llvm.load %690 : !llvm.ptr -> f64
      func.call @h_and_grad(%715, %716, %691, %696, %701) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %718 = arith.constant 0 : i32
      %719 = arith.extsi %718 : i32 to i64
      %720 = llvm.getelementptr %691[%719] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %717 = llvm.load %720 : !llvm.ptr -> f64
      %721 = arith.subf %717, %arg2 : f64
      %723 = arith.constant 0 : i32
      %724 = arith.extsi %723 : i32 to i64
      %725 = llvm.getelementptr %696[%724] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %722 = llvm.load %725 : !llvm.ptr -> f64
      %727 = arith.constant 0 : i32
      %728 = arith.extsi %727 : i32 to i64
      %729 = llvm.getelementptr %696[%728] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %726 = llvm.load %729 : !llvm.ptr -> f64
      %730 = arith.mulf %722, %726 : f64
      %732 = arith.constant 0 : i32
      %733 = arith.extsi %732 : i32 to i64
      %734 = llvm.getelementptr %701[%733] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %731 = llvm.load %734 : !llvm.ptr -> f64
      %736 = arith.constant 0 : i32
      %737 = arith.extsi %736 : i32 to i64
      %738 = llvm.getelementptr %701[%737] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %735 = llvm.load %738 : !llvm.ptr -> f64
      %739 = arith.mulf %731, %735 : f64
      %740 = arith.addf %730, %739 : f64
      %741 = arith.constant 0.0 : f32
      %743 = arith.extf %741 : f32 to f64
      %742 = arith.cmpf oeq, %740, %743 : f64
      cf.cond_br %742, ^bb78, ^bb79
      ^bb78:
        cf.br ^bb77
      ^bb79:
        cf.br ^bb80
      ^bb80:
      %744 = llvm.load %688 : !llvm.ptr -> f64
      %746 = arith.constant 0 : i32
      %747 = arith.extsi %746 : i32 to i64
      %748 = llvm.getelementptr %696[%747] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %745 = llvm.load %748 : !llvm.ptr -> f64
      %749 = arith.mulf %721, %745 : f64
      %750 = arith.divf %749, %740 : f64
      %751 = arith.subf %744, %750 : f64
      llvm.store %751, %688 : f64, !llvm.ptr
      %752 = llvm.load %690 : !llvm.ptr -> f64
      %754 = arith.constant 0 : i32
      %755 = arith.extsi %754 : i32 to i64
      %756 = llvm.getelementptr %701[%755] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %753 = llvm.load %756 : !llvm.ptr -> f64
      %757 = arith.mulf %721, %753 : f64
      %758 = arith.divf %757, %740 : f64
      %759 = arith.subf %752, %758 : f64
      llvm.store %759, %690 : f64, !llvm.ptr
      %760 = llvm.load %709 : !llvm.ptr -> i64
      %761 = arith.constant 1 : i32
      %763 = arith.extsi %761 : i32 to i64
      %762 = arith.addi %760, %763 : i64
      llvm.store %762, %709 : i64, !llvm.ptr
      cf.br ^bb75
    ^bb77:
    %764 = llvm.load %688 : !llvm.ptr -> f64
    %765 = arith.constant 0 : i32
    %766 = arith.extsi %765 : i32 to i64
    %767 = llvm.getelementptr %arg3[%766] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %764, %767 : f64, !llvm.ptr
    %768 = llvm.load %690 : !llvm.ptr -> f64
    %769 = arith.constant 0 : i32
    %770 = arith.extsi %769 : i32 to i64
    %771 = llvm.getelementptr %arg4[%770] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %768, %771 : f64, !llvm.ptr
    func.call @free(%691) : (!llvm.ptr) -> ()
    func.call @free(%696) : (!llvm.ptr) -> ()
    func.call @free(%701) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @walk_to_target(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64, %arg4: f64, %arg5: f64) -> f64 {
    %776 = arith.constant 1 : i32
    %777 = arith.constant 8 : i32
    %778 = arith.extsi %776 : i32 to i64
    %779 = arith.extsi %777 : i32 to i64
    %775 = func.call @calloc(%778, %779) : (i64, i64) -> !llvm.ptr
    %781 = arith.constant 1 : i32
    %782 = arith.constant 8 : i32
    %783 = arith.extsi %781 : i32 to i64
    %784 = arith.extsi %782 : i32 to i64
    %780 = func.call @calloc(%783, %784) : (i64, i64) -> !llvm.ptr
    func.call @project_to_level(%arg0, %arg1, %arg4, %775, %780) : (f64, f64, f64, !llvm.ptr, !llvm.ptr) -> ()
    %787 = arith.constant 0 : i32
    %788 = arith.extsi %787 : i32 to i64
    %789 = llvm.getelementptr %775[%788] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %786 = llvm.load %789 : !llvm.ptr -> f64
    %790 = llvm.mlir.constant(1 : i64) : i64
    %791 = llvm.alloca %790 x f64 : (i64) -> !llvm.ptr
    llvm.store %786, %791 : f64, !llvm.ptr
    %793 = arith.constant 0 : i32
    %794 = arith.extsi %793 : i32 to i64
    %795 = llvm.getelementptr %780[%794] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    %792 = llvm.load %795 : !llvm.ptr -> f64
    %796 = llvm.mlir.constant(1 : i64) : i64
    %797 = llvm.alloca %796 x f64 : (i64) -> !llvm.ptr
    llvm.store %792, %797 : f64, !llvm.ptr
    %799 = arith.constant 1 : i32
    %800 = arith.constant 8 : i32
    %801 = arith.extsi %799 : i32 to i64
    %802 = arith.extsi %800 : i32 to i64
    %798 = func.call @calloc(%801, %802) : (i64, i64) -> !llvm.ptr
    %804 = arith.constant 1 : i32
    %805 = arith.constant 8 : i32
    %806 = arith.extsi %804 : i32 to i64
    %807 = arith.extsi %805 : i32 to i64
    %803 = func.call @calloc(%806, %807) : (i64, i64) -> !llvm.ptr
    %809 = arith.constant 1 : i32
    %810 = arith.constant 8 : i32
    %811 = arith.extsi %809 : i32 to i64
    %812 = arith.extsi %810 : i32 to i64
    %808 = func.call @calloc(%811, %812) : (i64, i64) -> !llvm.ptr
    %813 = arith.constant 0.0 : f32
    %814 = arith.extf %813 : f32 to f64
    %815 = llvm.mlir.constant(1 : i64) : i64
    %816 = llvm.alloca %815 x f64 : (i64) -> !llvm.ptr
    llvm.store %814, %816 : f64, !llvm.ptr
    %817 = arith.constant 0.1 : f32
    %818 = arith.extf %817 : f32 to f64
    %819 = llvm.mlir.constant(1 : i64) : i64
    %820 = llvm.alloca %819 x f64 : (i64) -> !llvm.ptr
    llvm.store %818, %820 : f64, !llvm.ptr
    %821 = arith.constant 0 : i32
    %822 = arith.extsi %821 : i32 to i64
    %823 = llvm.mlir.constant(1 : i64) : i64
    %824 = llvm.alloca %823 x i64 : (i64) -> !llvm.ptr
    llvm.store %822, %824 : i64, !llvm.ptr
    cf.br ^bb81
    ^bb81:
    %825 = llvm.load %824 : !llvm.ptr -> i64
    %826 = arith.constant 2000000 : i32
    %828 = arith.extsi %826 : i32 to i64
    %827 = arith.cmpi slt, %825, %828 : i64
    cf.cond_br %827, ^bb82, ^bb83
    ^bb82:
      %829 = llvm.load %791 : !llvm.ptr -> f64
      %830 = arith.subf %829, %arg2 : f64
      %831 = llvm.load %797 : !llvm.ptr -> f64
      %832 = arith.subf %831, %arg3 : f64
      %833 = arith.mulf %830, %830 : f64
      %834 = arith.mulf %832, %832 : f64
      %835 = arith.addf %833, %834 : f64
      %836 = math.sqrt %835 : f64
      %837 = arith.constant 0.0000000001 : f32
      %839 = arith.extf %837 : f32 to f64
      %838 = arith.cmpf olt, %836, %839 : f64
      cf.cond_br %838, ^bb84, ^bb85
      ^bb84:
        cf.br ^bb83
      ^bb85:
        cf.br ^bb86
      ^bb86:
      %840 = llvm.load %820 : !llvm.ptr -> f64
      %841 = arith.constant 0.5 : f32
      %843 = arith.extf %841 : f32 to f64
      %842 = arith.mulf %836, %843 : f64
      %844 = arith.cmpf ogt, %840, %842 : f64
      cf.cond_br %844, ^bb87, ^bb88
      ^bb87:
        %845 = arith.constant 0.5 : f32
        %847 = arith.extf %845 : f32 to f64
        %846 = arith.mulf %836, %847 : f64
        llvm.store %846, %820 : f64, !llvm.ptr
        cf.br ^bb89
      ^bb88:
        cf.br ^bb89
      ^bb89:
      %848 = llvm.load %820 : !llvm.ptr -> f64
      %849 = arith.constant 0.0000000001 : f32
      %851 = arith.extf %849 : f32 to f64
      %850 = arith.cmpf olt, %848, %851 : f64
      cf.cond_br %850, ^bb90, ^bb91
      ^bb90:
        %852 = arith.constant 0.0000000001 : f32
        %853 = arith.extf %852 : f32 to f64
        llvm.store %853, %820 : f64, !llvm.ptr
        cf.br ^bb92
      ^bb91:
        cf.br ^bb92
      ^bb92:
      %855 = llvm.load %791 : !llvm.ptr -> f64
      %856 = llvm.load %797 : !llvm.ptr -> f64
      func.call @h_and_grad(%855, %856, %798, %803, %808) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %858 = arith.constant 0 : i32
      %859 = arith.extsi %858 : i32 to i64
      %860 = llvm.getelementptr %803[%859] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %857 = llvm.load %860 : !llvm.ptr -> f64
      %862 = arith.constant 0 : i32
      %863 = arith.extsi %862 : i32 to i64
      %864 = llvm.getelementptr %803[%863] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %861 = llvm.load %864 : !llvm.ptr -> f64
      %865 = arith.mulf %857, %861 : f64
      %867 = arith.constant 0 : i32
      %868 = arith.extsi %867 : i32 to i64
      %869 = llvm.getelementptr %808[%868] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %866 = llvm.load %869 : !llvm.ptr -> f64
      %871 = arith.constant 0 : i32
      %872 = arith.extsi %871 : i32 to i64
      %873 = llvm.getelementptr %808[%872] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %870 = llvm.load %873 : !llvm.ptr -> f64
      %874 = arith.mulf %866, %870 : f64
      %875 = arith.addf %865, %874 : f64
      %876 = math.sqrt %875 : f64
      %878 = arith.constant 0 : i32
      %879 = arith.extsi %878 : i32 to i64
      %880 = llvm.getelementptr %808[%879] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %877 = llvm.load %880 : !llvm.ptr -> f64
      %881 = arith.negf %877 : f64
      %882 = arith.divf %881, %876 : f64
      %883 = arith.mulf %882, %arg5 : f64
      %885 = arith.constant 0 : i32
      %886 = arith.extsi %885 : i32 to i64
      %887 = llvm.getelementptr %803[%886] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %884 = llvm.load %887 : !llvm.ptr -> f64
      %888 = arith.divf %884, %876 : f64
      %889 = arith.mulf %888, %arg5 : f64
      %891 = llvm.load %791 : !llvm.ptr -> f64
      %892 = arith.constant 0.5 : f32
      %893 = llvm.load %820 : !llvm.ptr -> f64
      %895 = arith.extf %892 : f32 to f64
      %894 = arith.mulf %895, %893 : f64
      %896 = arith.mulf %894, %883 : f64
      %897 = arith.addf %891, %896 : f64
      %898 = llvm.load %797 : !llvm.ptr -> f64
      %899 = arith.constant 0.5 : f32
      %900 = llvm.load %820 : !llvm.ptr -> f64
      %902 = arith.extf %899 : f32 to f64
      %901 = arith.mulf %902, %900 : f64
      %903 = arith.mulf %901, %889 : f64
      %904 = arith.addf %898, %903 : f64
      func.call @h_and_grad(%897, %904, %798, %803, %808) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %906 = arith.constant 0 : i32
      %907 = arith.extsi %906 : i32 to i64
      %908 = llvm.getelementptr %803[%907] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %905 = llvm.load %908 : !llvm.ptr -> f64
      %910 = arith.constant 0 : i32
      %911 = arith.extsi %910 : i32 to i64
      %912 = llvm.getelementptr %803[%911] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %909 = llvm.load %912 : !llvm.ptr -> f64
      %913 = arith.mulf %905, %909 : f64
      %915 = arith.constant 0 : i32
      %916 = arith.extsi %915 : i32 to i64
      %917 = llvm.getelementptr %808[%916] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %914 = llvm.load %917 : !llvm.ptr -> f64
      %919 = arith.constant 0 : i32
      %920 = arith.extsi %919 : i32 to i64
      %921 = llvm.getelementptr %808[%920] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %918 = llvm.load %921 : !llvm.ptr -> f64
      %922 = arith.mulf %914, %918 : f64
      %923 = arith.addf %913, %922 : f64
      %924 = math.sqrt %923 : f64
      %926 = arith.constant 0 : i32
      %927 = arith.extsi %926 : i32 to i64
      %928 = llvm.getelementptr %808[%927] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %925 = llvm.load %928 : !llvm.ptr -> f64
      %929 = arith.negf %925 : f64
      %930 = arith.divf %929, %924 : f64
      %931 = arith.mulf %930, %arg5 : f64
      %933 = arith.constant 0 : i32
      %934 = arith.extsi %933 : i32 to i64
      %935 = llvm.getelementptr %803[%934] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %932 = llvm.load %935 : !llvm.ptr -> f64
      %936 = arith.divf %932, %924 : f64
      %937 = arith.mulf %936, %arg5 : f64
      %939 = llvm.load %791 : !llvm.ptr -> f64
      %940 = arith.constant 0.5 : f32
      %941 = llvm.load %820 : !llvm.ptr -> f64
      %943 = arith.extf %940 : f32 to f64
      %942 = arith.mulf %943, %941 : f64
      %944 = arith.mulf %942, %931 : f64
      %945 = arith.addf %939, %944 : f64
      %946 = llvm.load %797 : !llvm.ptr -> f64
      %947 = arith.constant 0.5 : f32
      %948 = llvm.load %820 : !llvm.ptr -> f64
      %950 = arith.extf %947 : f32 to f64
      %949 = arith.mulf %950, %948 : f64
      %951 = arith.mulf %949, %937 : f64
      %952 = arith.addf %946, %951 : f64
      func.call @h_and_grad(%945, %952, %798, %803, %808) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %954 = arith.constant 0 : i32
      %955 = arith.extsi %954 : i32 to i64
      %956 = llvm.getelementptr %803[%955] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %953 = llvm.load %956 : !llvm.ptr -> f64
      %958 = arith.constant 0 : i32
      %959 = arith.extsi %958 : i32 to i64
      %960 = llvm.getelementptr %803[%959] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %957 = llvm.load %960 : !llvm.ptr -> f64
      %961 = arith.mulf %953, %957 : f64
      %963 = arith.constant 0 : i32
      %964 = arith.extsi %963 : i32 to i64
      %965 = llvm.getelementptr %808[%964] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %962 = llvm.load %965 : !llvm.ptr -> f64
      %967 = arith.constant 0 : i32
      %968 = arith.extsi %967 : i32 to i64
      %969 = llvm.getelementptr %808[%968] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %966 = llvm.load %969 : !llvm.ptr -> f64
      %970 = arith.mulf %962, %966 : f64
      %971 = arith.addf %961, %970 : f64
      %972 = math.sqrt %971 : f64
      %974 = arith.constant 0 : i32
      %975 = arith.extsi %974 : i32 to i64
      %976 = llvm.getelementptr %808[%975] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %973 = llvm.load %976 : !llvm.ptr -> f64
      %977 = arith.negf %973 : f64
      %978 = arith.divf %977, %972 : f64
      %979 = arith.mulf %978, %arg5 : f64
      %981 = arith.constant 0 : i32
      %982 = arith.extsi %981 : i32 to i64
      %983 = llvm.getelementptr %803[%982] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %980 = llvm.load %983 : !llvm.ptr -> f64
      %984 = arith.divf %980, %972 : f64
      %985 = arith.mulf %984, %arg5 : f64
      %987 = llvm.load %791 : !llvm.ptr -> f64
      %988 = llvm.load %820 : !llvm.ptr -> f64
      %989 = arith.mulf %988, %979 : f64
      %990 = arith.addf %987, %989 : f64
      %991 = llvm.load %797 : !llvm.ptr -> f64
      %992 = llvm.load %820 : !llvm.ptr -> f64
      %993 = arith.mulf %992, %985 : f64
      %994 = arith.addf %991, %993 : f64
      func.call @h_and_grad(%990, %994, %798, %803, %808) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %996 = arith.constant 0 : i32
      %997 = arith.extsi %996 : i32 to i64
      %998 = llvm.getelementptr %803[%997] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %995 = llvm.load %998 : !llvm.ptr -> f64
      %1000 = arith.constant 0 : i32
      %1001 = arith.extsi %1000 : i32 to i64
      %1002 = llvm.getelementptr %803[%1001] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %999 = llvm.load %1002 : !llvm.ptr -> f64
      %1003 = arith.mulf %995, %999 : f64
      %1005 = arith.constant 0 : i32
      %1006 = arith.extsi %1005 : i32 to i64
      %1007 = llvm.getelementptr %808[%1006] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1004 = llvm.load %1007 : !llvm.ptr -> f64
      %1009 = arith.constant 0 : i32
      %1010 = arith.extsi %1009 : i32 to i64
      %1011 = llvm.getelementptr %808[%1010] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1008 = llvm.load %1011 : !llvm.ptr -> f64
      %1012 = arith.mulf %1004, %1008 : f64
      %1013 = arith.addf %1003, %1012 : f64
      %1014 = math.sqrt %1013 : f64
      %1016 = arith.constant 0 : i32
      %1017 = arith.extsi %1016 : i32 to i64
      %1018 = llvm.getelementptr %808[%1017] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1015 = llvm.load %1018 : !llvm.ptr -> f64
      %1019 = arith.negf %1015 : f64
      %1020 = arith.divf %1019, %1014 : f64
      %1021 = arith.mulf %1020, %arg5 : f64
      %1023 = arith.constant 0 : i32
      %1024 = arith.extsi %1023 : i32 to i64
      %1025 = llvm.getelementptr %803[%1024] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1022 = llvm.load %1025 : !llvm.ptr -> f64
      %1026 = arith.divf %1022, %1014 : f64
      %1027 = arith.mulf %1026, %arg5 : f64
      %1028 = llvm.load %791 : !llvm.ptr -> f64
      %1029 = llvm.load %820 : !llvm.ptr -> f64
      %1030 = arith.constant 2.0 : f32
      %1032 = arith.extf %1030 : f32 to f64
      %1031 = arith.mulf %1032, %931 : f64
      %1033 = arith.addf %883, %1031 : f64
      %1034 = arith.constant 2.0 : f32
      %1036 = arith.extf %1034 : f32 to f64
      %1035 = arith.mulf %1036, %979 : f64
      %1037 = arith.addf %1033, %1035 : f64
      %1038 = arith.addf %1037, %1021 : f64
      %1039 = arith.mulf %1029, %1038 : f64
      %1040 = arith.constant 6.0 : f32
      %1042 = arith.extf %1040 : f32 to f64
      %1041 = arith.divf %1039, %1042 : f64
      %1043 = arith.addf %1028, %1041 : f64
      %1044 = llvm.load %797 : !llvm.ptr -> f64
      %1045 = llvm.load %820 : !llvm.ptr -> f64
      %1046 = arith.constant 2.0 : f32
      %1048 = arith.extf %1046 : f32 to f64
      %1047 = arith.mulf %1048, %937 : f64
      %1049 = arith.addf %889, %1047 : f64
      %1050 = arith.constant 2.0 : f32
      %1052 = arith.extf %1050 : f32 to f64
      %1051 = arith.mulf %1052, %985 : f64
      %1053 = arith.addf %1049, %1051 : f64
      %1054 = arith.addf %1053, %1027 : f64
      %1055 = arith.mulf %1045, %1054 : f64
      %1056 = arith.constant 6.0 : f32
      %1058 = arith.extf %1056 : f32 to f64
      %1057 = arith.divf %1055, %1058 : f64
      %1059 = arith.addf %1044, %1057 : f64
      func.call @project_to_level(%1043, %1059, %arg4, %775, %780) : (f64, f64, f64, !llvm.ptr, !llvm.ptr) -> ()
      %1062 = arith.constant 0 : i32
      %1063 = arith.extsi %1062 : i32 to i64
      %1064 = llvm.getelementptr %775[%1063] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1061 = llvm.load %1064 : !llvm.ptr -> f64
      %1065 = arith.subf %1061, %arg2 : f64
      %1067 = arith.constant 0 : i32
      %1068 = arith.extsi %1067 : i32 to i64
      %1069 = llvm.getelementptr %780[%1068] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1066 = llvm.load %1069 : !llvm.ptr -> f64
      %1070 = arith.subf %1066, %arg3 : f64
      %1071 = arith.mulf %1065, %1065 : f64
      %1072 = arith.mulf %1070, %1070 : f64
      %1073 = arith.addf %1071, %1072 : f64
      %1074 = math.sqrt %1073 : f64
      %1075 = arith.constant 1.0 : f32
      %1077 = arith.extf %1075 : f32 to f64
      %1076 = arith.cmpf olt, %836, %1077 : f64
      %1078 = scf.if %1076 -> (i1) {
        %1079 = arith.cmpf ogt, %1074, %836 : f64
        scf.yield %1079 : i1
      } else {
        %1080 = arith.constant false
        scf.yield %1080 : i1
      }
      cf.cond_br %1078, ^bb93, ^bb94
      ^bb93:
        %1081 = llvm.load %820 : !llvm.ptr -> f64
        %1082 = arith.constant 0.5 : f32
        %1084 = arith.extf %1082 : f32 to f64
        %1083 = arith.mulf %1081, %1084 : f64
        llvm.store %1083, %820 : f64, !llvm.ptr
        %1085 = llvm.load %820 : !llvm.ptr -> f64
        %1086 = arith.constant 0.000000000000001 : f32
        %1088 = arith.extf %1086 : f32 to f64
        %1087 = arith.cmpf olt, %1085, %1088 : f64
        cf.cond_br %1087, ^bb96, ^bb97
        ^bb96:
          cf.br ^bb83
        ^bb97:
          cf.br ^bb98
        ^bb98:
        %1089 = llvm.load %824 : !llvm.ptr -> i64
        %1090 = arith.constant 1 : i32
        %1092 = arith.extsi %1090 : i32 to i64
        %1091 = arith.addi %1089, %1092 : i64
        llvm.store %1091, %824 : i64, !llvm.ptr
        cf.br ^bb81
      ^bb94:
        cf.br ^bb95
      ^bb95:
      %1094 = arith.constant 0 : i32
      %1095 = arith.extsi %1094 : i32 to i64
      %1096 = llvm.getelementptr %775[%1095] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1093 = llvm.load %1096 : !llvm.ptr -> f64
      llvm.store %1093, %791 : f64, !llvm.ptr
      %1098 = arith.constant 0 : i32
      %1099 = arith.extsi %1098 : i32 to i64
      %1100 = llvm.getelementptr %780[%1099] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %1097 = llvm.load %1100 : !llvm.ptr -> f64
      llvm.store %1097, %797 : f64, !llvm.ptr
      %1101 = llvm.load %816 : !llvm.ptr -> f64
      %1102 = llvm.load %820 : !llvm.ptr -> f64
      %1103 = arith.addf %1101, %1102 : f64
      llvm.store %1103, %816 : f64, !llvm.ptr
      %1104 = llvm.load %816 : !llvm.ptr -> f64
      %1105 = arith.constant 20000.0 : f32
      %1107 = arith.extf %1105 : f32 to f64
      %1106 = arith.cmpf ogt, %1104, %1107 : f64
      cf.cond_br %1106, ^bb99, ^bb100
      ^bb99:
        cf.br ^bb83
      ^bb100:
        cf.br ^bb101
      ^bb101:
      %1108 = llvm.load %824 : !llvm.ptr -> i64
      %1109 = arith.constant 1 : i32
      %1111 = arith.extsi %1109 : i32 to i64
      %1110 = arith.addi %1108, %1111 : i64
      llvm.store %1110, %824 : i64, !llvm.ptr
      cf.br ^bb81
    ^bb83:
    func.call @free(%775) : (!llvm.ptr) -> ()
    func.call @free(%780) : (!llvm.ptr) -> ()
    func.call @free(%798) : (!llvm.ptr) -> ()
    func.call @free(%803) : (!llvm.ptr) -> ()
    func.call @free(%808) : (!llvm.ptr) -> ()
    %1117 = llvm.load %816 : !llvm.ptr -> f64
    func.return %1117 : f64
  }
  func.func @main() -> i32 {
    %1118 = arith.constant 0.0 : f32
    %1119 = arith.extf %1118 : f32 to f64
    %1120 = llvm.mlir.constant(1 : i64) : i64
    %1121 = llvm.alloca %1120 x f64 : (i64) -> !llvm.ptr
    llvm.store %1119, %1121 : f64, !llvm.ptr
    %1122 = arith.constant 1000000000000.0 : f32
    %1123 = arith.negf %1122 : f32
    %1124 = arith.extf %1123 : f32 to f64
    %1125 = llvm.mlir.constant(1 : i64) : i64
    %1126 = llvm.alloca %1125 x f64 : (i64) -> !llvm.ptr
    llvm.store %1124, %1126 : f64, !llvm.ptr
    %1127 = arith.constant 0 : i32
    %1128 = arith.extsi %1127 : i32 to i64
    %1129 = llvm.mlir.constant(1 : i64) : i64
    %1130 = llvm.alloca %1129 x i64 : (i64) -> !llvm.ptr
    llvm.store %1128, %1130 : i64, !llvm.ptr
    cf.br ^bb102
    ^bb102:
    %1131 = llvm.load %1130 : !llvm.ptr -> i64
    %1132 = arith.constant 1600 : i32
    %1134 = arith.extsi %1132 : i32 to i64
    %1133 = arith.cmpi sle, %1131, %1134 : i64
    cf.cond_br %1133, ^bb103, ^bb104
    ^bb103:
      %1136 = arith.constant 0.0 : f32
      %1137 = llvm.load %1130 : !llvm.ptr -> i64
      %1138 = arith.sitofp %1137 : i64 to f64
      %1139 = arith.extf %1136 : f32 to f64
      %1135 = func.call @h_only(%1139, %1138) : (f64, f64) -> f64
      %1140 = llvm.load %1126 : !llvm.ptr -> f64
      %1141 = arith.cmpf ogt, %1135, %1140 : f64
      cf.cond_br %1141, ^bb105, ^bb106
      ^bb105:
        llvm.store %1135, %1126 : f64, !llvm.ptr
        %1142 = llvm.load %1130 : !llvm.ptr -> i64
        %1143 = arith.sitofp %1142 : i64 to f64
        llvm.store %1143, %1121 : f64, !llvm.ptr
        cf.br ^bb107
      ^bb106:
        cf.br ^bb107
      ^bb107:
      %1144 = llvm.load %1130 : !llvm.ptr -> i64
      %1145 = arith.constant 1 : i32
      %1147 = arith.extsi %1145 : i32 to i64
      %1146 = arith.addi %1144, %1147 : i64
      llvm.store %1146, %1130 : i64, !llvm.ptr
      cf.br ^bb102
    ^bb104:
    %1148 = llvm.load %1121 : !llvm.ptr -> f64
    %1149 = arith.constant 5.0 : f32
    %1151 = arith.extf %1149 : f32 to f64
    %1150 = arith.subf %1148, %1151 : f64
    %1152 = llvm.load %1121 : !llvm.ptr -> f64
    %1153 = arith.constant 5.0 : f32
    %1155 = arith.extf %1153 : f32 to f64
    %1154 = arith.addf %1152, %1155 : f64
    %1156 = func.call @golden_max(%1150, %1154) : (f64, f64) -> f64
    %1158 = arith.constant 16 : i32
    %1159 = arith.constant 8 : i32
    %1160 = arith.extsi %1158 : i32 to i64
    %1161 = arith.extsi %1159 : i32 to i64
    %1157 = func.call @calloc(%1160, %1161) : (i64, i64) -> !llvm.ptr
    %1163 = arith.constant 16 : i32
    %1164 = arith.constant 8 : i32
    %1165 = arith.extsi %1163 : i32 to i64
    %1166 = arith.extsi %1164 : i32 to i64
    %1162 = func.call @calloc(%1165, %1166) : (i64, i64) -> !llvm.ptr
    %1167 = arith.constant 0 : i32
    %1168 = arith.extsi %1167 : i32 to i64
    %1169 = llvm.mlir.constant(1 : i64) : i64
    %1170 = llvm.alloca %1169 x i64 : (i64) -> !llvm.ptr
    llvm.store %1168, %1170 : i64, !llvm.ptr
    %1172 = arith.constant 1 : i32
    %1173 = arith.constant 8 : i32
    %1174 = arith.extsi %1172 : i32 to i64
    %1175 = arith.extsi %1173 : i32 to i64
    %1171 = func.call @calloc(%1174, %1175) : (i64, i64) -> !llvm.ptr
    %1177 = arith.constant 1 : i32
    %1178 = arith.constant 8 : i32
    %1179 = arith.extsi %1177 : i32 to i64
    %1180 = arith.extsi %1178 : i32 to i64
    %1176 = func.call @calloc(%1179, %1180) : (i64, i64) -> !llvm.ptr
    %1182 = arith.constant 1 : i32
    %1183 = arith.constant 8 : i32
    %1184 = arith.extsi %1182 : i32 to i64
    %1185 = arith.extsi %1183 : i32 to i64
    %1181 = func.call @calloc(%1184, %1185) : (i64, i64) -> !llvm.ptr
    %1187 = arith.constant 1 : i32
    %1188 = arith.constant 8 : i32
    %1189 = arith.extsi %1187 : i32 to i64
    %1190 = arith.extsi %1188 : i32 to i64
    %1186 = func.call @calloc(%1189, %1190) : (i64, i64) -> !llvm.ptr
    %1192 = arith.constant 1 : i32
    %1193 = arith.constant 8 : i32
    %1194 = arith.extsi %1192 : i32 to i64
    %1195 = arith.extsi %1193 : i32 to i64
    %1191 = func.call @calloc(%1194, %1195) : (i64, i64) -> !llvm.ptr
    %1196 = arith.constant 0 : i32
    %1197 = arith.extsi %1196 : i32 to i64
    %1198 = llvm.mlir.constant(1 : i64) : i64
    %1199 = llvm.alloca %1198 x i64 : (i64) -> !llvm.ptr
    llvm.store %1197, %1199 : i64, !llvm.ptr
    cf.br ^bb108
    ^bb108:
    %1200 = llvm.load %1199 : !llvm.ptr -> i64
    %1201 = arith.constant 1600 : i32
    %1203 = arith.extsi %1201 : i32 to i64
    %1202 = arith.cmpi sle, %1200, %1203 : i64
    cf.cond_br %1202, ^bb109, ^bb110
    ^bb109:
      %1204 = llvm.load %1199 : !llvm.ptr -> i64
      %1205 = arith.sitofp %1204 : i64 to f64
      %1206 = arith.constant 0 : i32
      %1207 = arith.extsi %1206 : i32 to i64
      %1208 = llvm.mlir.constant(1 : i64) : i64
      %1209 = llvm.alloca %1208 x i64 : (i64) -> !llvm.ptr
      llvm.store %1207, %1209 : i64, !llvm.ptr
      cf.br ^bb111
      ^bb111:
      %1210 = llvm.load %1209 : !llvm.ptr -> i64
      %1211 = arith.constant 1600 : i32
      %1213 = arith.extsi %1211 : i32 to i64
      %1212 = arith.cmpi sle, %1210, %1213 : i64
      cf.cond_br %1212, ^bb112, ^bb113
      ^bb112:
        %1214 = llvm.load %1209 : !llvm.ptr -> i64
        %1215 = arith.sitofp %1214 : i64 to f64
        func.call @h_and_grad(%1205, %1215, %1171, %1176, %1181) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
        %1218 = arith.constant 0 : i32
        %1219 = arith.extsi %1218 : i32 to i64
        %1220 = llvm.getelementptr %1171[%1219] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %1217 = llvm.load %1220 : !llvm.ptr -> f64
        %1221 = arith.subf %1217, %1156 : f64
        %1222 = llvm.mlir.constant(1 : i64) : i64
        %1223 = llvm.alloca %1222 x f64 : (i64) -> !llvm.ptr
        llvm.store %1221, %1223 : f64, !llvm.ptr
        %1224 = llvm.load %1223 : !llvm.ptr -> f64
        %1225 = arith.constant 0.0 : f32
        %1227 = arith.extf %1225 : f32 to f64
        %1226 = arith.cmpf olt, %1224, %1227 : f64
        cf.cond_br %1226, ^bb114, ^bb115
        ^bb114:
          %1228 = llvm.load %1223 : !llvm.ptr -> f64
          %1229 = arith.negf %1228 : f64
          llvm.store %1229, %1223 : f64, !llvm.ptr
          cf.br ^bb116
        ^bb115:
          cf.br ^bb116
        ^bb116:
        %1230 = llvm.load %1223 : !llvm.ptr -> f64
        %1231 = arith.constant 300.0 : f32
        %1233 = arith.extf %1231 : f32 to f64
        %1232 = arith.cmpf olt, %1230, %1233 : f64
        cf.cond_br %1232, ^bb117, ^bb118
        ^bb117:
          %1235 = arith.constant 0 : i32
          %1236 = arith.extsi %1235 : i32 to i64
          %1237 = llvm.getelementptr %1176[%1236] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %1234 = llvm.load %1237 : !llvm.ptr -> f64
          %1238 = llvm.mlir.addressof @AX : !llvm.ptr
          %1239 = llvm.load %1238 : !llvm.ptr -> f64
          %1240 = arith.subf %1239, %1205 : f64
          %1241 = arith.mulf %1234, %1240 : f64
          %1243 = arith.constant 0 : i32
          %1244 = arith.extsi %1243 : i32 to i64
          %1245 = llvm.getelementptr %1181[%1244] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %1242 = llvm.load %1245 : !llvm.ptr -> f64
          %1246 = llvm.mlir.addressof @AY : !llvm.ptr
          %1247 = llvm.load %1246 : !llvm.ptr -> f64
          %1248 = arith.subf %1247, %1215 : f64
          %1249 = arith.mulf %1242, %1248 : f64
          %1250 = arith.addf %1241, %1249 : f64
          %1251 = llvm.mlir.constant(1 : i64) : i64
          %1252 = llvm.alloca %1251 x f64 : (i64) -> !llvm.ptr
          llvm.store %1250, %1252 : f64, !llvm.ptr
          %1253 = llvm.load %1252 : !llvm.ptr -> f64
          %1254 = arith.constant 0.0 : f32
          %1256 = arith.extf %1254 : f32 to f64
          %1255 = arith.cmpf olt, %1253, %1256 : f64
          cf.cond_br %1255, ^bb120, ^bb121
          ^bb120:
            %1257 = llvm.load %1252 : !llvm.ptr -> f64
            %1258 = arith.negf %1257 : f64
            llvm.store %1258, %1252 : f64, !llvm.ptr
            cf.br ^bb122
          ^bb121:
            cf.br ^bb122
          ^bb122:
          %1259 = llvm.load %1252 : !llvm.ptr -> f64
          %1260 = arith.constant 400.0 : f32
          %1262 = arith.extf %1260 : f32 to f64
          %1261 = arith.cmpf olt, %1259, %1262 : f64
          cf.cond_br %1261, ^bb123, ^bb124
          ^bb123:
            %1263 = arith.constant 0 : i32
            %1264 = arith.extsi %1263 : i32 to i64
            %1265 = llvm.getelementptr %1186[%1264] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            llvm.store %1205, %1265 : f64, !llvm.ptr
            %1266 = arith.constant 0 : i32
            %1267 = arith.extsi %1266 : i32 to i64
            %1268 = llvm.getelementptr %1191[%1267] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            llvm.store %1215, %1268 : f64, !llvm.ptr
            %1270 = llvm.mlir.addressof @AX : !llvm.ptr
            %1271 = llvm.load %1270 : !llvm.ptr -> f64
            %1272 = llvm.mlir.addressof @AY : !llvm.ptr
            %1273 = llvm.load %1272 : !llvm.ptr -> f64
            func.call @newton_tangent(%1271, %1273, %1156, %1205, %1215, %1186, %1191) : (f64, f64, f64, f64, f64, !llvm.ptr, !llvm.ptr) -> ()
            %1275 = arith.constant 0 : i32
            %1276 = arith.extsi %1275 : i32 to i64
            %1277 = llvm.getelementptr %1186[%1276] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %1274 = llvm.load %1277 : !llvm.ptr -> f64
            %1279 = arith.constant 0 : i32
            %1280 = arith.extsi %1279 : i32 to i64
            %1281 = llvm.getelementptr %1191[%1280] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %1278 = llvm.load %1281 : !llvm.ptr -> f64
            %1282 = arith.constant 0 : i1
            %1283 = llvm.mlir.constant(1 : i64) : i64
            %1284 = llvm.alloca %1283 x i1 : (i64) -> !llvm.ptr
            llvm.store %1282, %1284 : i1, !llvm.ptr
            %1285 = arith.constant 0 : i32
            %1286 = arith.extsi %1285 : i32 to i64
            %1287 = llvm.mlir.constant(1 : i64) : i64
            %1288 = llvm.alloca %1287 x i64 : (i64) -> !llvm.ptr
            llvm.store %1286, %1288 : i64, !llvm.ptr
            cf.br ^bb126
            ^bb126:
            %1289 = llvm.load %1288 : !llvm.ptr -> i64
            %1290 = llvm.load %1170 : !llvm.ptr -> i64
            %1291 = arith.cmpi slt, %1289, %1290 : i64
            cf.cond_br %1291, ^bb127, ^bb128
            ^bb127:
              %1293 = llvm.load %1288 : !llvm.ptr -> i64
              %1294 = llvm.getelementptr %1157[%1293] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %1292 = llvm.load %1294 : !llvm.ptr -> f64
              %1295 = arith.subf %1274, %1292 : f64
              %1297 = llvm.load %1288 : !llvm.ptr -> i64
              %1298 = llvm.getelementptr %1162[%1297] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %1296 = llvm.load %1298 : !llvm.ptr -> f64
              %1299 = arith.subf %1278, %1296 : f64
              %1300 = arith.mulf %1295, %1295 : f64
              %1301 = arith.mulf %1299, %1299 : f64
              %1302 = arith.addf %1300, %1301 : f64
              %1303 = arith.constant 0.000001 : f32
              %1305 = arith.extf %1303 : f32 to f64
              %1304 = arith.cmpf olt, %1302, %1305 : f64
              cf.cond_br %1304, ^bb129, ^bb130
              ^bb129:
                %1306 = arith.constant 1 : i1
                llvm.store %1306, %1284 : i1, !llvm.ptr
                cf.br ^bb128
              ^bb130:
                cf.br ^bb131
              ^bb131:
              %1307 = llvm.load %1288 : !llvm.ptr -> i64
              %1308 = arith.constant 1 : i32
              %1310 = arith.extsi %1308 : i32 to i64
              %1309 = arith.addi %1307, %1310 : i64
              llvm.store %1309, %1288 : i64, !llvm.ptr
              cf.br ^bb126
            ^bb128:
            %1311 = llvm.load %1284 : !llvm.ptr -> i1
            %1313 = arith.constant 1 : i1
            %1312 = arith.xori %1311, %1313 : i1
            %1315 = scf.if %1312 -> (i1) {
              %1317 = llvm.mlir.addressof @AX : !llvm.ptr
              %1318 = llvm.load %1317 : !llvm.ptr -> f64
              %1319 = llvm.mlir.addressof @AY : !llvm.ptr
              %1320 = llvm.load %1319 : !llvm.ptr -> f64
              %1316 = func.call @segment_clear(%1318, %1320, %1274, %1278, %1156) : (f64, f64, f64, f64, f64) -> i1
              scf.yield %1316 : i1
            } else {
              %1321 = arith.constant false
              scf.yield %1321 : i1
            }
            cf.cond_br %1315, ^bb132, ^bb133
            ^bb132:
              %1322 = llvm.load %1170 : !llvm.ptr -> i64
              %1323 = llvm.getelementptr %1157[%1322] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              llvm.store %1274, %1323 : f64, !llvm.ptr
              %1324 = llvm.load %1170 : !llvm.ptr -> i64
              %1325 = llvm.getelementptr %1162[%1324] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              llvm.store %1278, %1325 : f64, !llvm.ptr
              %1326 = llvm.load %1170 : !llvm.ptr -> i64
              %1327 = arith.constant 1 : i32
              %1329 = arith.extsi %1327 : i32 to i64
              %1328 = arith.addi %1326, %1329 : i64
              llvm.store %1328, %1170 : i64, !llvm.ptr
              cf.br ^bb134
            ^bb133:
              cf.br ^bb134
            ^bb134:
            cf.br ^bb125
          ^bb124:
            cf.br ^bb125
          ^bb125:
          cf.br ^bb119
        ^bb118:
          cf.br ^bb119
        ^bb119:
        %1330 = llvm.load %1209 : !llvm.ptr -> i64
        %1331 = arith.constant 10 : i32
        %1333 = arith.extsi %1331 : i32 to i64
        %1332 = arith.addi %1330, %1333 : i64
        llvm.store %1332, %1209 : i64, !llvm.ptr
        cf.br ^bb111
      ^bb113:
      %1334 = llvm.load %1199 : !llvm.ptr -> i64
      %1335 = arith.constant 10 : i32
      %1337 = arith.extsi %1335 : i32 to i64
      %1336 = arith.addi %1334, %1337 : i64
      llvm.store %1336, %1199 : i64, !llvm.ptr
      cf.br ^bb108
    ^bb110:
    %1339 = arith.constant 16 : i32
    %1340 = arith.constant 8 : i32
    %1341 = arith.extsi %1339 : i32 to i64
    %1342 = arith.extsi %1340 : i32 to i64
    %1338 = func.call @calloc(%1341, %1342) : (i64, i64) -> !llvm.ptr
    %1344 = arith.constant 16 : i32
    %1345 = arith.constant 8 : i32
    %1346 = arith.extsi %1344 : i32 to i64
    %1347 = arith.extsi %1345 : i32 to i64
    %1343 = func.call @calloc(%1346, %1347) : (i64, i64) -> !llvm.ptr
    %1348 = arith.constant 0 : i32
    %1349 = arith.extsi %1348 : i32 to i64
    %1350 = llvm.mlir.constant(1 : i64) : i64
    %1351 = llvm.alloca %1350 x i64 : (i64) -> !llvm.ptr
    llvm.store %1349, %1351 : i64, !llvm.ptr
    %1352 = arith.constant 0 : i32
    %1353 = arith.extsi %1352 : i32 to i64
    llvm.store %1353, %1199 : i64, !llvm.ptr
    cf.br ^bb135
    ^bb135:
    %1354 = llvm.load %1199 : !llvm.ptr -> i64
    %1355 = arith.constant 1600 : i32
    %1357 = arith.extsi %1355 : i32 to i64
    %1356 = arith.cmpi sle, %1354, %1357 : i64
    cf.cond_br %1356, ^bb136, ^bb137
    ^bb136:
      %1358 = llvm.load %1199 : !llvm.ptr -> i64
      %1359 = arith.sitofp %1358 : i64 to f64
      %1360 = arith.constant 0 : i32
      %1361 = arith.extsi %1360 : i32 to i64
      %1362 = llvm.mlir.constant(1 : i64) : i64
      %1363 = llvm.alloca %1362 x i64 : (i64) -> !llvm.ptr
      llvm.store %1361, %1363 : i64, !llvm.ptr
      cf.br ^bb138
      ^bb138:
      %1364 = llvm.load %1363 : !llvm.ptr -> i64
      %1365 = arith.constant 1600 : i32
      %1367 = arith.extsi %1365 : i32 to i64
      %1366 = arith.cmpi sle, %1364, %1367 : i64
      cf.cond_br %1366, ^bb139, ^bb140
      ^bb139:
        %1368 = llvm.load %1363 : !llvm.ptr -> i64
        %1369 = arith.sitofp %1368 : i64 to f64
        func.call @h_and_grad(%1359, %1369, %1171, %1176, %1181) : (f64, f64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
        %1372 = arith.constant 0 : i32
        %1373 = arith.extsi %1372 : i32 to i64
        %1374 = llvm.getelementptr %1171[%1373] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %1371 = llvm.load %1374 : !llvm.ptr -> f64
        %1375 = arith.subf %1371, %1156 : f64
        %1376 = llvm.mlir.constant(1 : i64) : i64
        %1377 = llvm.alloca %1376 x f64 : (i64) -> !llvm.ptr
        llvm.store %1375, %1377 : f64, !llvm.ptr
        %1378 = llvm.load %1377 : !llvm.ptr -> f64
        %1379 = arith.constant 0.0 : f32
        %1381 = arith.extf %1379 : f32 to f64
        %1380 = arith.cmpf olt, %1378, %1381 : f64
        cf.cond_br %1380, ^bb141, ^bb142
        ^bb141:
          %1382 = llvm.load %1377 : !llvm.ptr -> f64
          %1383 = arith.negf %1382 : f64
          llvm.store %1383, %1377 : f64, !llvm.ptr
          cf.br ^bb143
        ^bb142:
          cf.br ^bb143
        ^bb143:
        %1384 = llvm.load %1377 : !llvm.ptr -> f64
        %1385 = arith.constant 300.0 : f32
        %1387 = arith.extf %1385 : f32 to f64
        %1386 = arith.cmpf olt, %1384, %1387 : f64
        cf.cond_br %1386, ^bb144, ^bb145
        ^bb144:
          %1389 = arith.constant 0 : i32
          %1390 = arith.extsi %1389 : i32 to i64
          %1391 = llvm.getelementptr %1176[%1390] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %1388 = llvm.load %1391 : !llvm.ptr -> f64
          %1392 = llvm.mlir.addressof @BX : !llvm.ptr
          %1393 = llvm.load %1392 : !llvm.ptr -> f64
          %1394 = arith.subf %1393, %1359 : f64
          %1395 = arith.mulf %1388, %1394 : f64
          %1397 = arith.constant 0 : i32
          %1398 = arith.extsi %1397 : i32 to i64
          %1399 = llvm.getelementptr %1181[%1398] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %1396 = llvm.load %1399 : !llvm.ptr -> f64
          %1400 = llvm.mlir.addressof @BY : !llvm.ptr
          %1401 = llvm.load %1400 : !llvm.ptr -> f64
          %1402 = arith.subf %1401, %1369 : f64
          %1403 = arith.mulf %1396, %1402 : f64
          %1404 = arith.addf %1395, %1403 : f64
          %1405 = llvm.mlir.constant(1 : i64) : i64
          %1406 = llvm.alloca %1405 x f64 : (i64) -> !llvm.ptr
          llvm.store %1404, %1406 : f64, !llvm.ptr
          %1407 = llvm.load %1406 : !llvm.ptr -> f64
          %1408 = arith.constant 0.0 : f32
          %1410 = arith.extf %1408 : f32 to f64
          %1409 = arith.cmpf olt, %1407, %1410 : f64
          cf.cond_br %1409, ^bb147, ^bb148
          ^bb147:
            %1411 = llvm.load %1406 : !llvm.ptr -> f64
            %1412 = arith.negf %1411 : f64
            llvm.store %1412, %1406 : f64, !llvm.ptr
            cf.br ^bb149
          ^bb148:
            cf.br ^bb149
          ^bb149:
          %1413 = llvm.load %1406 : !llvm.ptr -> f64
          %1414 = arith.constant 400.0 : f32
          %1416 = arith.extf %1414 : f32 to f64
          %1415 = arith.cmpf olt, %1413, %1416 : f64
          cf.cond_br %1415, ^bb150, ^bb151
          ^bb150:
            %1417 = arith.constant 0 : i32
            %1418 = arith.extsi %1417 : i32 to i64
            %1419 = llvm.getelementptr %1186[%1418] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            llvm.store %1359, %1419 : f64, !llvm.ptr
            %1420 = arith.constant 0 : i32
            %1421 = arith.extsi %1420 : i32 to i64
            %1422 = llvm.getelementptr %1191[%1421] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            llvm.store %1369, %1422 : f64, !llvm.ptr
            %1424 = llvm.mlir.addressof @BX : !llvm.ptr
            %1425 = llvm.load %1424 : !llvm.ptr -> f64
            %1426 = llvm.mlir.addressof @BY : !llvm.ptr
            %1427 = llvm.load %1426 : !llvm.ptr -> f64
            func.call @newton_tangent(%1425, %1427, %1156, %1359, %1369, %1186, %1191) : (f64, f64, f64, f64, f64, !llvm.ptr, !llvm.ptr) -> ()
            %1429 = arith.constant 0 : i32
            %1430 = arith.extsi %1429 : i32 to i64
            %1431 = llvm.getelementptr %1186[%1430] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %1428 = llvm.load %1431 : !llvm.ptr -> f64
            %1433 = arith.constant 0 : i32
            %1434 = arith.extsi %1433 : i32 to i64
            %1435 = llvm.getelementptr %1191[%1434] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %1432 = llvm.load %1435 : !llvm.ptr -> f64
            %1436 = arith.constant 0 : i1
            %1437 = llvm.mlir.constant(1 : i64) : i64
            %1438 = llvm.alloca %1437 x i1 : (i64) -> !llvm.ptr
            llvm.store %1436, %1438 : i1, !llvm.ptr
            %1439 = arith.constant 0 : i32
            %1440 = arith.extsi %1439 : i32 to i64
            %1441 = llvm.mlir.constant(1 : i64) : i64
            %1442 = llvm.alloca %1441 x i64 : (i64) -> !llvm.ptr
            llvm.store %1440, %1442 : i64, !llvm.ptr
            cf.br ^bb153
            ^bb153:
            %1443 = llvm.load %1442 : !llvm.ptr -> i64
            %1444 = llvm.load %1351 : !llvm.ptr -> i64
            %1445 = arith.cmpi slt, %1443, %1444 : i64
            cf.cond_br %1445, ^bb154, ^bb155
            ^bb154:
              %1447 = llvm.load %1442 : !llvm.ptr -> i64
              %1448 = llvm.getelementptr %1338[%1447] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %1446 = llvm.load %1448 : !llvm.ptr -> f64
              %1449 = arith.subf %1428, %1446 : f64
              %1451 = llvm.load %1442 : !llvm.ptr -> i64
              %1452 = llvm.getelementptr %1343[%1451] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %1450 = llvm.load %1452 : !llvm.ptr -> f64
              %1453 = arith.subf %1432, %1450 : f64
              %1454 = arith.mulf %1449, %1449 : f64
              %1455 = arith.mulf %1453, %1453 : f64
              %1456 = arith.addf %1454, %1455 : f64
              %1457 = arith.constant 0.000001 : f32
              %1459 = arith.extf %1457 : f32 to f64
              %1458 = arith.cmpf olt, %1456, %1459 : f64
              cf.cond_br %1458, ^bb156, ^bb157
              ^bb156:
                %1460 = arith.constant 1 : i1
                llvm.store %1460, %1438 : i1, !llvm.ptr
                cf.br ^bb155
              ^bb157:
                cf.br ^bb158
              ^bb158:
              %1461 = llvm.load %1442 : !llvm.ptr -> i64
              %1462 = arith.constant 1 : i32
              %1464 = arith.extsi %1462 : i32 to i64
              %1463 = arith.addi %1461, %1464 : i64
              llvm.store %1463, %1442 : i64, !llvm.ptr
              cf.br ^bb153
            ^bb155:
            %1465 = llvm.load %1438 : !llvm.ptr -> i1
            %1467 = arith.constant 1 : i1
            %1466 = arith.xori %1465, %1467 : i1
            %1469 = scf.if %1466 -> (i1) {
              %1471 = llvm.mlir.addressof @BX : !llvm.ptr
              %1472 = llvm.load %1471 : !llvm.ptr -> f64
              %1473 = llvm.mlir.addressof @BY : !llvm.ptr
              %1474 = llvm.load %1473 : !llvm.ptr -> f64
              %1470 = func.call @segment_clear(%1472, %1474, %1428, %1432, %1156) : (f64, f64, f64, f64, f64) -> i1
              scf.yield %1470 : i1
            } else {
              %1475 = arith.constant false
              scf.yield %1475 : i1
            }
            cf.cond_br %1469, ^bb159, ^bb160
            ^bb159:
              %1476 = llvm.load %1351 : !llvm.ptr -> i64
              %1477 = llvm.getelementptr %1338[%1476] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              llvm.store %1428, %1477 : f64, !llvm.ptr
              %1478 = llvm.load %1351 : !llvm.ptr -> i64
              %1479 = llvm.getelementptr %1343[%1478] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              llvm.store %1432, %1479 : f64, !llvm.ptr
              %1480 = llvm.load %1351 : !llvm.ptr -> i64
              %1481 = arith.constant 1 : i32
              %1483 = arith.extsi %1481 : i32 to i64
              %1482 = arith.addi %1480, %1483 : i64
              llvm.store %1482, %1351 : i64, !llvm.ptr
              cf.br ^bb161
            ^bb160:
              cf.br ^bb161
            ^bb161:
            cf.br ^bb152
          ^bb151:
            cf.br ^bb152
          ^bb152:
          cf.br ^bb146
        ^bb145:
          cf.br ^bb146
        ^bb146:
        %1484 = llvm.load %1363 : !llvm.ptr -> i64
        %1485 = arith.constant 10 : i32
        %1487 = arith.extsi %1485 : i32 to i64
        %1486 = arith.addi %1484, %1487 : i64
        llvm.store %1486, %1363 : i64, !llvm.ptr
        cf.br ^bb138
      ^bb140:
      %1488 = llvm.load %1199 : !llvm.ptr -> i64
      %1489 = arith.constant 10 : i32
      %1491 = arith.extsi %1489 : i32 to i64
      %1490 = arith.addi %1488, %1491 : i64
      llvm.store %1490, %1199 : i64, !llvm.ptr
      cf.br ^bb135
    ^bb137:
    %1492 = arith.constant 1000000000000.0 : f32
    %1493 = arith.extf %1492 : f32 to f64
    %1494 = llvm.mlir.constant(1 : i64) : i64
    %1495 = llvm.alloca %1494 x f64 : (i64) -> !llvm.ptr
    llvm.store %1493, %1495 : f64, !llvm.ptr
    %1496 = arith.constant 0 : i32
    %1497 = arith.extsi %1496 : i32 to i64
    %1498 = llvm.mlir.constant(1 : i64) : i64
    %1499 = llvm.alloca %1498 x i64 : (i64) -> !llvm.ptr
    llvm.store %1497, %1499 : i64, !llvm.ptr
    cf.br ^bb162
    ^bb162:
    %1500 = llvm.load %1499 : !llvm.ptr -> i64
    %1501 = llvm.load %1170 : !llvm.ptr -> i64
    %1502 = arith.cmpi slt, %1500, %1501 : i64
    cf.cond_br %1502, ^bb163, ^bb164
    ^bb163:
      %1503 = arith.constant 0 : i32
      %1504 = arith.extsi %1503 : i32 to i64
      %1505 = llvm.mlir.constant(1 : i64) : i64
      %1506 = llvm.alloca %1505 x i64 : (i64) -> !llvm.ptr
      llvm.store %1504, %1506 : i64, !llvm.ptr
      cf.br ^bb165
      ^bb165:
      %1507 = llvm.load %1506 : !llvm.ptr -> i64
      %1508 = llvm.load %1351 : !llvm.ptr -> i64
      %1509 = arith.cmpi slt, %1507, %1508 : i64
      cf.cond_br %1509, ^bb166, ^bb167
      ^bb166:
        %1511 = llvm.load %1499 : !llvm.ptr -> i64
        %1512 = llvm.getelementptr %1157[%1511] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %1510 = llvm.load %1512 : !llvm.ptr -> f64
        %1514 = llvm.load %1499 : !llvm.ptr -> i64
        %1515 = llvm.getelementptr %1162[%1514] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %1513 = llvm.load %1515 : !llvm.ptr -> f64
        %1517 = llvm.load %1506 : !llvm.ptr -> i64
        %1518 = llvm.getelementptr %1338[%1517] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %1516 = llvm.load %1518 : !llvm.ptr -> f64
        %1520 = llvm.load %1506 : !llvm.ptr -> i64
        %1521 = llvm.getelementptr %1343[%1520] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %1519 = llvm.load %1521 : !llvm.ptr -> f64
        %1523 = arith.constant 1.0 : f32
        %1524 = arith.extf %1523 : f32 to f64
        %1522 = func.call @walk_to_target(%1510, %1513, %1516, %1519, %1156, %1524) : (f64, f64, f64, f64, f64, f64) -> f64
        %1526 = arith.constant 1.0 : f32
        %1527 = arith.negf %1526 : f32
        %1528 = arith.extf %1527 : f32 to f64
        %1525 = func.call @walk_to_target(%1510, %1513, %1516, %1519, %1156, %1528) : (f64, f64, f64, f64, f64, f64) -> f64
        %1529 = llvm.mlir.constant(1 : i64) : i64
        %1530 = llvm.alloca %1529 x f64 : (i64) -> !llvm.ptr
        llvm.store %1522, %1530 : f64, !llvm.ptr
        %1531 = llvm.load %1530 : !llvm.ptr -> f64
        %1532 = arith.cmpf olt, %1525, %1531 : f64
        cf.cond_br %1532, ^bb168, ^bb169
        ^bb168:
          llvm.store %1525, %1530 : f64, !llvm.ptr
          cf.br ^bb170
        ^bb169:
          cf.br ^bb170
        ^bb170:
        %1533 = llvm.mlir.addressof @AX : !llvm.ptr
        %1534 = llvm.load %1533 : !llvm.ptr -> f64
        %1535 = arith.subf %1510, %1534 : f64
        %1536 = llvm.mlir.addressof @AY : !llvm.ptr
        %1537 = llvm.load %1536 : !llvm.ptr -> f64
        %1538 = arith.subf %1513, %1537 : f64
        %1539 = llvm.mlir.addressof @BX : !llvm.ptr
        %1540 = llvm.load %1539 : !llvm.ptr -> f64
        %1541 = arith.subf %1516, %1540 : f64
        %1542 = llvm.mlir.addressof @BY : !llvm.ptr
        %1543 = llvm.load %1542 : !llvm.ptr -> f64
        %1544 = arith.subf %1519, %1543 : f64
        %1545 = arith.mulf %1535, %1535 : f64
        %1546 = arith.mulf %1538, %1538 : f64
        %1547 = arith.addf %1545, %1546 : f64
        %1548 = math.sqrt %1547 : f64
        %1549 = llvm.load %1530 : !llvm.ptr -> f64
        %1550 = arith.addf %1548, %1549 : f64
        %1551 = arith.mulf %1541, %1541 : f64
        %1552 = arith.mulf %1544, %1544 : f64
        %1553 = arith.addf %1551, %1552 : f64
        %1554 = math.sqrt %1553 : f64
        %1555 = arith.addf %1550, %1554 : f64
        %1556 = llvm.load %1495 : !llvm.ptr -> f64
        %1557 = arith.cmpf olt, %1555, %1556 : f64
        cf.cond_br %1557, ^bb171, ^bb172
        ^bb171:
          llvm.store %1555, %1495 : f64, !llvm.ptr
          cf.br ^bb173
        ^bb172:
          cf.br ^bb173
        ^bb173:
        %1558 = llvm.load %1506 : !llvm.ptr -> i64
        %1559 = arith.constant 1 : i32
        %1561 = arith.extsi %1559 : i32 to i64
        %1560 = arith.addi %1558, %1561 : i64
        llvm.store %1560, %1506 : i64, !llvm.ptr
        cf.br ^bb165
      ^bb167:
      %1562 = llvm.load %1499 : !llvm.ptr -> i64
      %1563 = arith.constant 1 : i32
      %1565 = arith.extsi %1563 : i32 to i64
      %1564 = arith.addi %1562, %1565 : i64
      llvm.store %1564, %1499 : i64, !llvm.ptr
      cf.br ^bb162
    ^bb164:
    func.call @free(%1157) : (!llvm.ptr) -> ()
    func.call @free(%1162) : (!llvm.ptr) -> ()
    func.call @free(%1338) : (!llvm.ptr) -> ()
    func.call @free(%1343) : (!llvm.ptr) -> ()
    func.call @free(%1171) : (!llvm.ptr) -> ()
    func.call @free(%1176) : (!llvm.ptr) -> ()
    func.call @free(%1181) : (!llvm.ptr) -> ()
    func.call @free(%1186) : (!llvm.ptr) -> ()
    func.call @free(%1191) : (!llvm.ptr) -> ()
    %1575 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1576 = llvm.load %1495 : !llvm.ptr -> f64
    %1577 = llvm.call @printf(%1575, %1576) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
    %1578 = arith.constant 0 : i32
    func.return %1578 : i32
  }
}