Problem 667

Nested golden-section + bisection optimization over pentagon shape and scale. Ported from C. Uses f64 math throughout. Function pointers inlined.

Answer1.5276527928
Output1.5276527928
StatusPASS
Native helperno
Runtime480 ms
Peak memory2896 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)?
Space complexityO(n^2)?
ApproachFlow solutionNot curated
VerdictUnknown

Flow source

# Project Euler 667: Moving Pentagon
# Nested golden-section + bisection optimization over pentagon shape and scale.
# Ported from C. Uses f64 math throughout. Function pointers inlined.

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

const PI: f64 = 3.14159265358979323846
const PHI: f64 = 0.61803398874989484820

function heron(a: f64, b: f64, c: f64) -> f64 {
    let s: f64 = (a + b + c) * 0.5
    let v: f64 = s * (s - a) * (s - b) * (s - c)
    if v > 0.0 { return sqrt(v) }
    return 0.0
}

function base_area(r: f64) -> f64 {
    return 2.0 * heron(1.0, 1.0, r) + heron(r, r, 1.0)
}

# Pentagon points: parallel arrays px[5], py[5]
function build_unit_pentagon(r: f64, px: ptr<f64>, py: ptr<f64>) -> i32 {
    if !(r > 0.5 && r < 2.0) { return 0 }
    let h2: f64 = r * r - 0.25
    if h2 <= 0.0 { return 0 }
    let h: f64 = sqrt(h2)
    # A = (0,0), E = (1,0), C = (0.5, h)
    let d: f64 = r
    if d >= 2.0 { return 0 }
    let k2: f64 = 1.0 - (d * 0.5) * (d * 0.5)
    if k2 <= 0.0 { return 0 }
    let k: f64 = sqrt(k2)
    let Mx: f64 = 0.25
    let My: f64 = h * 0.5
    let ux: f64 = -h / d
    let uy: f64 = 0.5 / d
    let Bx: f64 = Mx + k * ux
    let By: f64 = My + k * uy
    # A, B, C, D, E
    px[0] = 0.0; py[0] = 0.0
    px[1] = Bx;  py[1] = By
    px[2] = 0.5; py[2] = h
    px[3] = 1.0 - Bx; py[3] = By
    px[4] = 1.0; py[4] = 0.0
    return 1
}

function rotate_points(inx: ptr<f64>, iny: ptr<f64>, outx: ptr<f64>, outy: ptr<f64>, theta: f64) -> void {
    let c: f64 = cos(theta)
    let s: f64 = sin(theta)
    let mut i: i32 = 0
    while i < 5 {
        outx[i] = c * inx[i] - s * iny[i]
        outy[i] = s * inx[i] + c * iny[i]
        i = i + 1
    }
}

function min_x_above_y(ptsx: ptr<f64>, ptsy: ptr<f64>, ythr: f64) -> f64 {
    let mut mn: f64 = 1e308
    let mut i: i32 = 0
    while i < 5 {
        let p1x: f64 = ptsx[i]
        let p1y: f64 = ptsy[i]
        let i2: i32 = (i + 1) % 5
        let p2x: f64 = ptsx[i2]
        let p2y: f64 = ptsy[i2]
        if p1y >= ythr && p1x < mn { mn = p1x }
        if p2y >= ythr && p2x < mn { mn = p2x }
        let dy: f64 = p2y - p1y
        if dy == 0.0 { i = i + 1; continue }
        let t: f64 = (ythr - p1y) / dy
        if t >= 0.0 && t <= 1.0 {
            let x: f64 = p1x + (p2x - p1x) * t
            if x < mn { mn = x }
        }
        i = i + 1
    }
    return mn
}

function clearance_for_theta(ptsx: ptr<f64>, ptsy: ptr<f64>, min_y: f64, max_x: f64, scale: f64, eps_y: f64) -> f64 {
    let ythr: f64 = min_y + (1.0 + eps_y) / scale
    let x_min: f64 = min_x_above_y(ptsx, ptsy, ythr)
    if x_min > 1e290 { return 1e308 }
    return 1.0 + scale * (x_min - max_x)
}

# Precomputed rotation data: arrays of size n_theta
# precomp_ptsx: ptr<ptr<f64>>, precomp_ptsy: ptr<ptr<f64>>
# precomp_miny: ptr<f64>, precomp_maxx: ptr<f64>

function min_clearance(px: ptr<f64>, py: ptr<f64>, precomp_ptsx: ptr<ptr<f64> >, precomp_ptsy: ptr<ptr<f64> >, precomp_miny: ptr<f64>, precomp_maxx: ptr<f64>, thetas: ptr<f64>, n_theta: i32, scale: f64, eps_y: f64, local_k: i32, local_iters: i32) -> f64 {
    let vals: ptr<f64> = calloc((n_theta as i64), 8)
    let mut best: f64 = 1e308
    let mut i: i32 = 0
    while i < n_theta {
        vals[i] = clearance_for_theta(precomp_ptsx[i], precomp_ptsy[i], precomp_miny[i], precomp_maxx[i], scale, eps_y)
        if vals[i] < best { best = vals[i] }
        i = i + 1
    }
    # Selection sort top local_k indices
    let idx_sorted: ptr<i32> = calloc((n_theta as i64), 4)
    let mut ii: i32 = 0
    while ii < n_theta { idx_sorted[ii] = ii; ii = ii + 1 }
    let mut kk: i32 = 0
    while kk < local_k && kk < n_theta {
        let mut min_idx: i32 = kk
        let mut j: i32 = kk + 1
        while j < n_theta {
            if vals[idx_sorted[j]] < vals[idx_sorted[min_idx]] { min_idx = j }
            j = j + 1
        }
        let tmp: i32 = idx_sorted[kk]; idx_sorted[kk] = idx_sorted[min_idx]; idx_sorted[min_idx] = tmp
        kk = kk + 1
    }
    let mut ki: i32 = 0
    while ki < local_k && ki < n_theta {
        let idx: i32 = idx_sorted[ki]
        let a: f64 = thetas[if idx > 0 { idx - 1 } else { 0 }]
        let b: f64 = thetas[if idx < n_theta - 1 { idx + 1 } else { n_theta - 1 }]
        if b - a <= 1e-15 { ki = ki + 1; continue }
        let mut c: f64 = b - (b - a) * PHI
        let mut d: f64 = a + (b - a) * PHI
        let rcx: ptr<f64> = calloc(5, 8)
        let rcy: ptr<f64> = calloc(5, 8)
        let rdx: ptr<f64> = calloc(5, 8)
        let rdy: ptr<f64> = calloc(5, 8)
        rotate_points(px, py, rcx, rcy, c)
        rotate_points(px, py, rdx, rdy, d)
        let mut rc_min: f64 = 1e308; let mut rc_max: f64 = -1e308
        let mut rd_min: f64 = 1e308; let mut rd_max: f64 = -1e308
        let mut j2: i32 = 0
        while j2 < 5 {
            if rcy[j2] < rc_min { rc_min = rcy[j2] }
            if rcx[j2] > rc_max { rc_max = rcx[j2] }
            if rdy[j2] < rd_min { rd_min = rdy[j2] }
            if rdx[j2] > rd_max { rd_max = rdx[j2] }
            j2 = j2 + 1
        }
        let mut fc: f64 = clearance_for_theta(rcx, rcy, rc_min, rc_max, scale, eps_y)
        let mut fd: f64 = clearance_for_theta(rdx, rdy, rd_min, rd_max, scale, eps_y)
        let mut iter: i32 = 0
        while iter < local_iters {
            if fc < fd {
                b = d; d = c; fd = fc
                c = b - (b - a) * PHI
                rotate_points(px, py, rcx, rcy, c)
                rc_min = 1e308; rc_max = -1e308
                let mut j3: i32 = 0
                while j3 < 5 {
                    if rcy[j3] < rc_min { rc_min = rcy[j3] }
                    if rcx[j3] > rc_max { rc_max = rcx[j3] }
                    j3 = j3 + 1
                }
                fc = clearance_for_theta(rcx, rcy, rc_min, rc_max, scale, eps_y)
            } else {
                a = c; c = d; fc = fd
                d = a + (b - a) * PHI
                rotate_points(px, py, rdx, rdy, d)
                rd_min = 1e308; rd_max = -1e308
                let mut j4: i32 = 0
                while j4 < 5 {
                    if rdy[j4] < rd_min { rd_min = rdy[j4] }
                    if rdx[j4] > rd_max { rd_max = rdx[j4] }
                    j4 = j4 + 1
                }
                fd = clearance_for_theta(rdx, rdy, rd_min, rd_max, scale, eps_y)
            }
            iter = iter + 1
        }
        if fc < best { best = fc }
        if fd < best { best = fd }
        free(rcx as ptr<void>); free(rcy as ptr<void>)
        free(rdx as ptr<void>); free(rdy as ptr<void>)
        ki = ki + 1
    }
    free(vals as ptr<void>)
    free(idx_sorted as ptr<void>)
    return best
}

function max_scale(px: ptr<f64>, py: ptr<f64>, n_theta: i32, bisection_iters: i32, eps_y: f64) -> f64 {
    let thetas: ptr<f64> = calloc((n_theta as i64), 8)
    let precomp_ptsx: ptr<ptr<f64> > = calloc((n_theta as i64), 8)
    let precomp_ptsy: ptr<ptr<f64> > = calloc((n_theta as i64), 8)
    let precomp_miny: ptr<f64> = calloc((n_theta as i64), 8)
    let precomp_maxx: ptr<f64> = calloc((n_theta as i64), 8)
    let mut i: i32 = 0
    while i < n_theta {
        thetas[i] = (PI / 2.0) * (i as f64) / ((n_theta - 1) as f64)
        precomp_ptsx[i] = calloc(5, 8)
        precomp_ptsy[i] = calloc(5, 8)
        rotate_points(px, py, precomp_ptsx[i], precomp_ptsy[i], thetas[i])
        let mut mn_y: f64 = 1e308; let mut mx_x: f64 = -1e308
        let mut j: i32 = 0
        while j < 5 {
            if precomp_ptsy[i][j] < mn_y { mn_y = precomp_ptsy[i][j] }
            if precomp_ptsx[i][j] > mx_x { mx_x = precomp_ptsx[i][j] }
            j = j + 1
        }
        precomp_miny[i] = mn_y
        precomp_maxx[i] = mx_x
        i = i + 1
    }
    let mut lo: f64 = 0.0; let mut hi: f64 = 2.0
    # Expand hi until infeasible
    let mut expanding: i32 = 1
    while expanding == 1 {
        let mc: f64 = min_clearance(px, py, precomp_ptsx, precomp_ptsy, precomp_miny, precomp_maxx, thetas, n_theta, hi, eps_y, 3, 22)
        if mc < -1e-13 { break }
        hi = hi * 1.3
        if hi > 50.0 { break }
    }
    let mut iter: i32 = 0
    while iter < bisection_iters {
        let mid: f64 = (lo + hi) * 0.5
        let mc: f64 = min_clearance(px, py, precomp_ptsx, precomp_ptsy, precomp_miny, precomp_maxx, thetas, n_theta, mid, eps_y, 3, 22)
        if mc >= -1e-13 { lo = mid } else { hi = mid }
        iter = iter + 1
    }
    # Cleanup precomp
    let mut ci: i32 = 0
    while ci < n_theta {
        free(precomp_ptsx[ci] as ptr<void>)
        free(precomp_ptsy[ci] as ptr<void>)
        ci = ci + 1
    }
    free(thetas as ptr<void>)
    free(precomp_ptsx as ptr<void>)
    free(precomp_ptsy as ptr<void>)
    free(precomp_miny as ptr<void>)
    free(precomp_maxx as ptr<void>)
    return lo
}

function objective(r: f64, n_theta: i32, bisection_iters: i32, eps_y: f64) -> f64 {
    let px: ptr<f64> = calloc(5, 8)
    let py: ptr<f64> = calloc(5, 8)
    if build_unit_pentagon(r, px, py) == 0 { free(px as ptr<void>); free(py as ptr<void>); return -1.0 }
    let s: f64 = max_scale(px, py, n_theta, bisection_iters, eps_y)
    let area: f64 = base_area(r) * s * s
    free(px as ptr<void>)
    free(py as ptr<void>)
    return area
}

# Cache for f_mid
let mut cache_keys: ptr<f64> = null
let mut cache_vals: ptr<f64> = null
let mut cache_count: i32 = 0

function cache_get(key: f64) -> f64 {
    let mut i: i32 = 0
    while i < cache_count {
        if fabs(cache_keys[i] - key) < 1e-15 { return cache_vals[i] }
        i = i + 1
    }
    let val: f64 = objective(key, 1400, 55, 1e-14)
    if cache_count < 10000 {
        cache_keys[cache_count] = key
        cache_vals[cache_count] = val
        cache_count = cache_count + 1
    }
    return val
}

# Inlined golden_max for f_mid_cached
function golden_max_mid(a: f64, b: f64, iters: i32) -> f64 {
    let mut c: f64 = b - (b - a) * PHI
    let mut d: f64 = a + (b - a) * PHI
    let mut fc: f64 = cache_get(c)
    let mut fd: f64 = cache_get(d)
    let mut i: i32 = 0
    while i < iters {
        if fc > fd {
            b = d; d = c; fd = fc
            c = b - (b - a) * PHI
            fc = cache_get(c)
        } else {
            a = c; c = d; fc = fd
            d = a + (b - a) * PHI
            fd = cache_get(d)
        }
        i = i + 1
    }
    if fc > fd { return c }
    return d
}

function main() -> i32 {
    # 1) Coarse scan
    let rmin: f64 = 0.75
    let rmax: f64 = 1.05
    let steps: i32 = 240
    let mut best_r: f64 = 0.0
    let mut best_val: f64 = -1.0
    let mut i: i32 = 0
    while i <= steps {
        let r: f64 = rmin + (rmax - rmin) * (i as f64) / (steps as f64)
        let val: f64 = objective(r, 450, 35, 1e-12)
        if val > best_val { best_val = val; best_r = r }
        i = i + 1
    }

    # 2) Golden refine with mid precision + cache
    cache_keys = calloc(10000, 8)
    cache_vals = calloc(10000, 8)
    cache_count = 0
    let a: f64 = best_r - 0.02
    let b: f64 = best_r + 0.02
    let r1: f64 = golden_max_mid(a, b, 26)

    # 3) Narrow refine
    let a2: f64 = r1 - 0.002
    let b2: f64 = r1 + 0.002
    let r2: f64 = golden_max_mid(a2, b2, 35)

    # 4) Final high precision
    let final_area: f64 = objective(r2, 8000, 75, 1e-15)

    free(cache_keys as ptr<void>)
    free(cache_vals as ptr<void>)

    printf("%.10f\n", final_area)
    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 heron_f64_f64_f64(double a, double b, double c);
double base_area_f64(double r);
int32_t build_unit_pentagon_f64_ptr_f64_ptr_f64(double r, double* px, double* py);
void rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(double* inx, double* iny, double* outx, double* outy, double theta);
double min_x_above_y_ptr_f64_ptr_f64_f64(double* ptsx, double* ptsy, double ythr);
double clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(double* ptsx, double* ptsy, double min_y, double max_x, double scale, double eps_y);
double min_clearance_ptr_f64_ptr_f64_ptr_ptr_f64_ptr_ptr_f64_ptr_f64_ptr_f64_ptr_f64_i32_f64_f64_i32_i32(double* px, double* py, double** precomp_ptsx, double** precomp_ptsy, double* precomp_miny, double* precomp_maxx, double* thetas, int32_t n_theta, double scale, double eps_y, int32_t local_k, int32_t local_iters);
double max_scale_ptr_f64_ptr_f64_i32_i32_f64(double* px, double* py, int32_t n_theta, int32_t bisection_iters, double eps_y);
double objective_f64_i32_i32_f64(double r, int32_t n_theta, int32_t bisection_iters, double eps_y);
double cache_get_f64(double key);
double golden_max_mid_f64_f64_i32(double a, double b, int32_t iters);
int32_t main(void);

static const double PI = 3.14159265358979323846;
static const double PHI = 0.61803398874989484820;

/* Module statics */
static double* cache_keys = NULL;
static double* cache_vals = NULL;
static int32_t cache_count = 0;








double heron_f64_f64_f64(double a, double b, double c) {
    double s = (((a + b) + c) * 0.5);
    double v = (((s * (s - a)) * (s - b)) * (s - c));
    if (v > 0.0) {
        return sqrt(v);
    }
    return 0.0;
}

double base_area_f64(double r) {
    return ((2.0 * heron_f64_f64_f64(1.0, 1.0, r)) + heron_f64_f64_f64(r, r, 1.0));
}

int32_t build_unit_pentagon_f64_ptr_f64_ptr_f64(double r, double* px, double* py) {
    if ((!((r > 0.5 && r < 2.0)))) {
        return 0;
    }
    double h2 = ((r * r) - 0.25);
    if (h2 <= 0.0) {
        return 0;
    }
    double h = sqrt(h2);
    double d = r;
    if (d >= 2.0) {
        return 0;
    }
    double k2 = (1.0 - ((d * 0.5) * (d * 0.5)));
    if (k2 <= 0.0) {
        return 0;
    }
    double k = sqrt(k2);
    double Mx = 0.25;
    double My = (h * 0.5);
    double ux = ((-h) / d);
    double uy = (0.5 / d);
    double Bx = (Mx + (k * ux));
    double By = (My + (k * uy));
    px[0] = 0.0;
    py[0] = 0.0;
    px[1] = Bx;
    py[1] = By;
    px[2] = 0.5;
    py[2] = h;
    px[3] = (1.0 - Bx);
    py[3] = By;
    px[4] = 1.0;
    py[4] = 0.0;
    return 1;
}

void rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(double* inx, double* iny, double* outx, double* outy, double theta) {
    double c = cos(theta);
    double s = sin(theta);
    int32_t i = 0;
    while (i < 5) {
        outx[i] = ((c * inx[i]) - (s * iny[i]));
        outy[i] = ((s * inx[i]) + (c * iny[i]));
        i = (i + 1);
    }
}

double min_x_above_y_ptr_f64_ptr_f64_f64(double* ptsx, double* ptsy, double ythr) {
    double mn = 1e308;
    int32_t i = 0;
    while (i < 5) {
        double p1x = ptsx[i];
        double p1y = ptsy[i];
        int32_t i2 = FLOW_CHECKED_MOD(((i + 1)), (5));
        double p2x = ptsx[i2];
        double p2y = ptsy[i2];
        if ((p1y >= ythr && p1x < mn)) {
            mn = p1x;
        }
        if ((p2y >= ythr && p2x < mn)) {
            mn = p2x;
        }
        double dy = (p2y - p1y);
        if (dy == 0.0) {
            i = (i + 1);
            continue;
        }
        double t = ((ythr - p1y) / dy);
        if ((t >= 0.0 && t <= 1.0)) {
            double x = (p1x + ((p2x - p1x) * t));
            if (x < mn) {
                mn = x;
            }
        }
        i = (i + 1);
    }
    return mn;
}

double clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(double* ptsx, double* ptsy, double min_y, double max_x, double scale, double eps_y) {
    double ythr = (min_y + ((1.0 + eps_y) / scale));
    double x_min = min_x_above_y_ptr_f64_ptr_f64_f64(ptsx, ptsy, ythr);
    if (x_min > 1e290) {
        return 1e308;
    }
    return (1.0 + (scale * (x_min - max_x)));
}

double min_clearance_ptr_f64_ptr_f64_ptr_ptr_f64_ptr_ptr_f64_ptr_f64_ptr_f64_ptr_f64_i32_f64_f64_i32_i32(double* px, double* py, double** precomp_ptsx, double** precomp_ptsy, double* precomp_miny, double* precomp_maxx, double* thetas, int32_t n_theta, double scale, double eps_y, int32_t local_k, int32_t local_iters) {
    double* vals = (double*)(calloc(((int64_t)(n_theta)), 8));
    double best = 1e308;
    int32_t i = 0;
    while (i < n_theta) {
        vals[i] = clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(precomp_ptsx[i], precomp_ptsy[i], precomp_miny[i], precomp_maxx[i], scale, eps_y);
        if (vals[i] < best) {
            best = vals[i];
        }
        i = (i + 1);
    }
    int32_t* idx_sorted = (int32_t*)(calloc(((int64_t)(n_theta)), 4));
    int32_t ii = 0;
    while (ii < n_theta) {
        idx_sorted[ii] = ii;
        ii = (ii + 1);
    }
    int32_t kk = 0;
    while ((kk < local_k && kk < n_theta)) {
        int32_t min_idx = kk;
        int32_t j = (kk + 1);
        while (j < n_theta) {
            if (vals[idx_sorted[j]] < vals[idx_sorted[min_idx]]) {
                min_idx = j;
            }
            j = (j + 1);
        }
        int32_t tmp = idx_sorted[kk];
        idx_sorted[kk] = idx_sorted[min_idx];
        idx_sorted[min_idx] = tmp;
        kk = (kk + 1);
    }
    int32_t ki = 0;
    while ((ki < local_k && ki < n_theta)) {
        int32_t idx = idx_sorted[ki];
        double a = thetas[((idx > 0) ? ((idx - 1)) : (0))];
        double b = thetas[((idx < (n_theta - 1)) ? ((idx + 1)) : ((n_theta - 1)))];
        if ((b - a) <= 1e-15) {
            ki = (ki + 1);
            continue;
        }
        double c = (b - ((b - a) * PHI));
        double d = (a + ((b - a) * PHI));
        double* rcx = (double*)(calloc(5, 8));
        double* rcy = (double*)(calloc(5, 8));
        double* rdx = (double*)(calloc(5, 8));
        double* rdy = (double*)(calloc(5, 8));
        rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(px, py, rcx, rcy, c);
        rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(px, py, rdx, rdy, d);
        double rc_min = 1e308;
        double rc_max = (-1e308);
        double rd_min = 1e308;
        double rd_max = (-1e308);
        int32_t j2 = 0;
        while (j2 < 5) {
            if (rcy[j2] < rc_min) {
                rc_min = rcy[j2];
            }
            if (rcx[j2] > rc_max) {
                rc_max = rcx[j2];
            }
            if (rdy[j2] < rd_min) {
                rd_min = rdy[j2];
            }
            if (rdx[j2] > rd_max) {
                rd_max = rdx[j2];
            }
            j2 = (j2 + 1);
        }
        double fc = clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(rcx, rcy, rc_min, rc_max, scale, eps_y);
        double fd = clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(rdx, rdy, rd_min, rd_max, scale, eps_y);
        int32_t iter = 0;
        while (iter < local_iters) {
            if (fc < fd) {
                b = d;
                d = c;
                fd = fc;
                c = (b - ((b - a) * PHI));
                rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(px, py, rcx, rcy, c);
                rc_min = 1e308;
                rc_max = (-1e308);
                int32_t j3 = 0;
                while (j3 < 5) {
                    if (rcy[j3] < rc_min) {
                        rc_min = rcy[j3];
                    }
                    if (rcx[j3] > rc_max) {
                        rc_max = rcx[j3];
                    }
                    j3 = (j3 + 1);
                }
                fc = clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(rcx, rcy, rc_min, rc_max, scale, eps_y);
            } else {
                a = c;
                c = d;
                fc = fd;
                d = (a + ((b - a) * PHI));
                rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(px, py, rdx, rdy, d);
                rd_min = 1e308;
                rd_max = (-1e308);
                int32_t j4 = 0;
                while (j4 < 5) {
                    if (rdy[j4] < rd_min) {
                        rd_min = rdy[j4];
                    }
                    if (rdx[j4] > rd_max) {
                        rd_max = rdx[j4];
                    }
                    j4 = (j4 + 1);
                }
                fd = clearance_for_theta_ptr_f64_ptr_f64_f64_f64_f64_f64(rdx, rdy, rd_min, rd_max, scale, eps_y);
            }
            iter = (iter + 1);
        }
        if (fc < best) {
            best = fc;
        }
        if (fd < best) {
            best = fd;
        }
        free(((void*)(rcx)));
        free(((void*)(rcy)));
        free(((void*)(rdx)));
        free(((void*)(rdy)));
        ki = (ki + 1);
    }
    free(((void*)(vals)));
    free(((void*)(idx_sorted)));
    return best;
}

double max_scale_ptr_f64_ptr_f64_i32_i32_f64(double* px, double* py, int32_t n_theta, int32_t bisection_iters, double eps_y) {
    double* thetas = (double*)(calloc(((int64_t)(n_theta)), 8));
    double** precomp_ptsx = (double**)(calloc(((int64_t)(n_theta)), 8));
    double** precomp_ptsy = (double**)(calloc(((int64_t)(n_theta)), 8));
    double* precomp_miny = (double*)(calloc(((int64_t)(n_theta)), 8));
    double* precomp_maxx = (double*)(calloc(((int64_t)(n_theta)), 8));
    int32_t i = 0;
    while (i < n_theta) {
        thetas[i] = (((PI / 2.0) * ((double)(i))) / ((double)((n_theta - 1))));
        precomp_ptsx[i] = calloc(5, 8);
        precomp_ptsy[i] = calloc(5, 8);
        rotate_points_ptr_f64_ptr_f64_ptr_f64_ptr_f64_f64(px, py, precomp_ptsx[i], precomp_ptsy[i], thetas[i]);
        double mn_y = 1e308;
        double mx_x = (-1e308);
        int32_t j = 0;
        while (j < 5) {
            if (precomp_ptsy[i][j] < mn_y) {
                mn_y = precomp_ptsy[i][j];
            }
            if (precomp_ptsx[i][j] > mx_x) {
                mx_x = precomp_ptsx[i][j];
            }
            j = (j + 1);
        }
        precomp_miny[i] = mn_y;
        precomp_maxx[i] = mx_x;
        i = (i + 1);
    }
    double lo = 0.0;
    double hi = 2.0;
    int32_t expanding = 1;
    while (expanding == 1) {
        double mc = min_clearance_ptr_f64_ptr_f64_ptr_ptr_f64_ptr_ptr_f64_ptr_f64_ptr_f64_ptr_f64_i32_f64_f64_i32_i32(px, py, precomp_ptsx, precomp_ptsy, precomp_miny, precomp_maxx, thetas, n_theta, hi, eps_y, 3, 22);
        if (mc < (-1e-13)) {
            break;
        }
        hi = (hi * 1.3);
        if (hi > 50.0) {
            break;
        }
    }
    int32_t iter = 0;
    while (iter < bisection_iters) {
        double mid = ((lo + hi) * 0.5);
        double mc = min_clearance_ptr_f64_ptr_f64_ptr_ptr_f64_ptr_ptr_f64_ptr_f64_ptr_f64_ptr_f64_i32_f64_f64_i32_i32(px, py, precomp_ptsx, precomp_ptsy, precomp_miny, precomp_maxx, thetas, n_theta, mid, eps_y, 3, 22);
        if (mc >= (-1e-13)) {
            lo = mid;
        } else {
            hi = mid;
        }
        iter = (iter + 1);
    }
    int32_t ci = 0;
    while (ci < n_theta) {
        free(((void*)(precomp_ptsx[ci])));
        free(((void*)(precomp_ptsy[ci])));
        ci = (ci + 1);
    }
    free(((void*)(thetas)));
    free(((void*)(precomp_ptsx)));
    free(((void*)(precomp_ptsy)));
    free(((void*)(precomp_miny)));
    free(((void*)(precomp_maxx)));
    return lo;
}

double objective_f64_i32_i32_f64(double r, int32_t n_theta, int32_t bisection_iters, double eps_y) {
    double* px = (double*)(calloc(5, 8));
    double* py = (double*)(calloc(5, 8));
    if (build_unit_pentagon_f64_ptr_f64_ptr_f64(r, px, py) == 0) {
        free(((void*)(px)));
        free(((void*)(py)));
        return (-1.0);
    }
    double s = max_scale_ptr_f64_ptr_f64_i32_i32_f64(px, py, n_theta, bisection_iters, eps_y);
    double area = ((base_area_f64(r) * s) * s);
    free(((void*)(px)));
    free(((void*)(py)));
    return area;
}

double cache_get_f64(double key) {
    int32_t i = 0;
    while (i < cache_count) {
        if (fabs((cache_keys[i] - key)) < 1e-15) {
            return cache_vals[i];
        }
        i = (i + 1);
    }
    double val = objective_f64_i32_i32_f64(key, 1400, 55, 1e-14);
    if (cache_count < 10000) {
        cache_keys[cache_count] = key;
        cache_vals[cache_count] = val;
        cache_count = (cache_count + 1);
    }
    return val;
}

double golden_max_mid_f64_f64_i32(double a, double b, int32_t iters) {
    double c = (b - ((b - a) * PHI));
    double d = (a + ((b - a) * PHI));
    double fc = cache_get_f64(c);
    double fd = cache_get_f64(d);
    int32_t i = 0;
    while (i < iters) {
        if (fc > fd) {
            b = d;
            d = c;
            fd = fc;
            c = (b - ((b - a) * PHI));
            fc = cache_get_f64(c);
        } else {
            a = c;
            c = d;
            fc = fd;
            d = (a + ((b - a) * PHI));
            fd = cache_get_f64(d);
        }
        i = (i + 1);
    }
    if (fc > fd) {
        return c;
    }
    return d;
}

int32_t main(void) {
    double rmin = 0.75;
    double rmax = 1.05;
    int32_t steps = 240;
    double best_r = 0.0;
    double best_val = (-1.0);
    int32_t i = 0;
    while (i <= steps) {
        double r = (rmin + (((rmax - rmin) * ((double)(i))) / ((double)(steps))));
        double val = objective_f64_i32_i32_f64(r, 450, 35, 1e-12);
        if (val > best_val) {
            best_val = val;
            best_r = r;
        }
        i = (i + 1);
    }
    cache_keys = calloc(10000, 8);
    cache_vals = calloc(10000, 8);
    cache_count = 0;
    double a = (best_r - 0.02);
    double b = (best_r + 0.02);
    double r1 = golden_max_mid_f64_f64_i32(a, b, 26);
    double a2 = (r1 - 0.002);
    double b2 = (r1 + 0.002);
    double r2 = golden_max_mid_f64_f64_i32(a2, b2, 35);
    double final_area = objective_f64_i32_i32_f64(r2, 8000, 75, 1e-15);
    free(((void*)(cache_keys)));
    free(((void*)(cache_vals)));
    printf("%.10f\n", final_area);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%.10f\n\00") {addr_space = 0 : i32} : !llvm.array<7 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 @cos(f64) -> f64
  func.func private @sin(f64) -> f64
  func.func private @fabs(f64) -> f64
  // Constant: PI
  llvm.mlir.global internal constant @PI(3.14159265358979323846 : f64) : f64
  // Constant: PHI
  llvm.mlir.global internal constant @PHI(0.61803398874989484820 : f64) : f64
  func.func @heron(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 {
    %0 = arith.addf %arg0, %arg1 : f64
    %1 = arith.addf %0, %arg2 : f64
    %2 = arith.constant 0.5 : f32
    %4 = arith.extf %2 : f32 to f64
    %3 = arith.mulf %1, %4 : f64
    %5 = arith.subf %3, %arg0 : f64
    %6 = arith.mulf %3, %5 : f64
    %7 = arith.subf %3, %arg1 : f64
    %8 = arith.mulf %6, %7 : f64
    %9 = arith.subf %3, %arg2 : f64
    %10 = arith.mulf %8, %9 : f64
    %11 = arith.constant 0.0 : f32
    %13 = arith.extf %11 : f32 to f64
    %12 = arith.cmpf ogt, %10, %13 : f64
    cf.cond_br %12, ^bb0, ^bb1
    ^bb0:
      %14 = math.sqrt %10 : f64
      func.return %14 : f64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %15 = arith.constant 0.0 : f32
    %16 = arith.extf %15 : f32 to f64
    func.return %16 : f64
  }
  func.func @base_area(%arg0: f64) -> f64 {
    %17 = arith.constant 2.0 : f32
    %19 = arith.constant 1.0 : f32
    %20 = arith.constant 1.0 : f32
    %21 = arith.extf %19 : f32 to f64
    %22 = arith.extf %20 : f32 to f64
    %18 = func.call @heron(%21, %22, %arg0) : (f64, f64, f64) -> f64
    %24 = arith.extf %17 : f32 to f64
    %23 = arith.mulf %24, %18 : f64
    %26 = arith.constant 1.0 : f32
    %27 = arith.extf %26 : f32 to f64
    %25 = func.call @heron(%arg0, %arg0, %27) : (f64, f64, f64) -> f64
    %28 = arith.addf %23, %25 : f64
    func.return %28 : f64
  }
  func.func @build_unit_pentagon(%arg0: f64, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> i32 {
    %29 = arith.constant 0.5 : f32
    %31 = arith.extf %29 : f32 to f64
    %30 = arith.cmpf ogt, %arg0, %31 : f64
    %32 = scf.if %30 -> (i1) {
      %33 = arith.constant 2.0 : f32
      %35 = arith.extf %33 : f32 to f64
      %34 = arith.cmpf olt, %arg0, %35 : f64
      scf.yield %34 : i1
    } else {
      %36 = arith.constant false
      scf.yield %36 : i1
    }
    %38 = arith.constant 1 : i1
    %37 = arith.xori %32, %38 : i1
    cf.cond_br %37, ^bb3, ^bb4
    ^bb3:
      %40 = arith.constant 0 : i32
      func.return %40 : i32
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %41 = arith.mulf %arg0, %arg0 : f64
    %42 = arith.constant 0.25 : f32
    %44 = arith.extf %42 : f32 to f64
    %43 = arith.subf %41, %44 : f64
    %45 = arith.constant 0.0 : f32
    %47 = arith.extf %45 : f32 to f64
    %46 = arith.cmpf ole, %43, %47 : f64
    cf.cond_br %46, ^bb6, ^bb7
    ^bb6:
      %48 = arith.constant 0 : i32
      func.return %48 : i32
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %49 = math.sqrt %43 : f64
    %50 = arith.constant 2.0 : f32
    %52 = arith.extf %50 : f32 to f64
    %51 = arith.cmpf oge, %arg0, %52 : f64
    cf.cond_br %51, ^bb9, ^bb10
    ^bb9:
      %53 = arith.constant 0 : i32
      func.return %53 : i32
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %54 = arith.constant 1.0 : f32
    %55 = arith.constant 0.5 : f32
    %57 = arith.extf %55 : f32 to f64
    %56 = arith.mulf %arg0, %57 : f64
    %58 = arith.constant 0.5 : f32
    %60 = arith.extf %58 : f32 to f64
    %59 = arith.mulf %arg0, %60 : f64
    %61 = arith.mulf %56, %59 : f64
    %63 = arith.extf %54 : f32 to f64
    %62 = arith.subf %63, %61 : f64
    %64 = arith.constant 0.0 : f32
    %66 = arith.extf %64 : f32 to f64
    %65 = arith.cmpf ole, %62, %66 : f64
    cf.cond_br %65, ^bb12, ^bb13
    ^bb12:
      %67 = arith.constant 0 : i32
      func.return %67 : i32
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %68 = math.sqrt %62 : f64
    %69 = arith.constant 0.25 : f32
    %70 = arith.extf %69 : f32 to f64
    %71 = arith.constant 0.5 : f32
    %73 = arith.extf %71 : f32 to f64
    %72 = arith.mulf %49, %73 : f64
    %74 = arith.negf %49 : f64
    %75 = arith.divf %74, %arg0 : f64
    %76 = arith.constant 0.5 : f32
    %78 = arith.extf %76 : f32 to f64
    %77 = arith.divf %78, %arg0 : f64
    %79 = arith.mulf %68, %75 : f64
    %80 = arith.addf %70, %79 : f64
    %81 = arith.mulf %68, %77 : f64
    %82 = arith.addf %72, %81 : f64
    %83 = arith.constant 0.0 : f32
    %84 = arith.constant 0 : i32
    %85 = arith.extf %83 : f32 to f64
    %86 = arith.extsi %84 : i32 to i64
    %87 = llvm.getelementptr %arg1[%86] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %85, %87 : f64, !llvm.ptr
    %88 = arith.constant 0.0 : f32
    %89 = arith.constant 0 : i32
    %90 = arith.extf %88 : f32 to f64
    %91 = arith.extsi %89 : i32 to i64
    %92 = llvm.getelementptr %arg2[%91] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %90, %92 : f64, !llvm.ptr
    %93 = arith.constant 1 : i32
    %94 = arith.extsi %93 : i32 to i64
    %95 = llvm.getelementptr %arg1[%94] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %80, %95 : f64, !llvm.ptr
    %96 = arith.constant 1 : i32
    %97 = arith.extsi %96 : i32 to i64
    %98 = llvm.getelementptr %arg2[%97] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %82, %98 : f64, !llvm.ptr
    %99 = arith.constant 0.5 : f32
    %100 = arith.constant 2 : i32
    %101 = arith.extf %99 : f32 to f64
    %102 = arith.extsi %100 : i32 to i64
    %103 = llvm.getelementptr %arg1[%102] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %101, %103 : f64, !llvm.ptr
    %104 = arith.constant 2 : i32
    %105 = arith.extsi %104 : i32 to i64
    %106 = llvm.getelementptr %arg2[%105] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %49, %106 : f64, !llvm.ptr
    %107 = arith.constant 1.0 : f32
    %109 = arith.extf %107 : f32 to f64
    %108 = arith.subf %109, %80 : f64
    %110 = arith.constant 3 : i32
    %111 = arith.extsi %110 : i32 to i64
    %112 = llvm.getelementptr %arg1[%111] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %108, %112 : f64, !llvm.ptr
    %113 = arith.constant 3 : i32
    %114 = arith.extsi %113 : i32 to i64
    %115 = llvm.getelementptr %arg2[%114] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %82, %115 : f64, !llvm.ptr
    %116 = arith.constant 1.0 : f32
    %117 = arith.constant 4 : i32
    %118 = arith.extf %116 : f32 to f64
    %119 = arith.extsi %117 : i32 to i64
    %120 = llvm.getelementptr %arg1[%119] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %118, %120 : f64, !llvm.ptr
    %121 = arith.constant 0.0 : f32
    %122 = arith.constant 4 : i32
    %123 = arith.extf %121 : f32 to f64
    %124 = arith.extsi %122 : i32 to i64
    %125 = llvm.getelementptr %arg2[%124] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %123, %125 : f64, !llvm.ptr
    %126 = arith.constant 1 : i32
    func.return %126 : i32
  }
  func.func @rotate_points(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: f64) -> () {
    %127 = math.cos %arg4 : f64
    %128 = math.sin %arg4 : f64
    %129 = arith.constant 0 : i32
    %130 = llvm.mlir.constant(1 : i64) : i64
    %131 = llvm.alloca %130 x i32 : (i64) -> !llvm.ptr
    llvm.store %129, %131 : i32, !llvm.ptr
    cf.br ^bb15
    ^bb15:
    %132 = llvm.load %131 : !llvm.ptr -> i32
    %133 = arith.constant 5 : i32
    %134 = arith.cmpi slt, %132, %133 : i32
    cf.cond_br %134, ^bb16, ^bb17
    ^bb16:
      %136 = llvm.load %131 : !llvm.ptr -> i32
      %137 = arith.extsi %136 : i32 to i64
      %138 = llvm.getelementptr %arg0[%137] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %135 = llvm.load %138 : !llvm.ptr -> f64
      %139 = arith.mulf %127, %135 : f64
      %141 = llvm.load %131 : !llvm.ptr -> i32
      %142 = arith.extsi %141 : i32 to i64
      %143 = llvm.getelementptr %arg1[%142] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %140 = llvm.load %143 : !llvm.ptr -> f64
      %144 = arith.mulf %128, %140 : f64
      %145 = arith.subf %139, %144 : f64
      %146 = llvm.load %131 : !llvm.ptr -> i32
      %147 = arith.extsi %146 : i32 to i64
      %148 = llvm.getelementptr %arg2[%147] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %145, %148 : f64, !llvm.ptr
      %150 = llvm.load %131 : !llvm.ptr -> i32
      %151 = arith.extsi %150 : i32 to i64
      %152 = llvm.getelementptr %arg0[%151] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %149 = llvm.load %152 : !llvm.ptr -> f64
      %153 = arith.mulf %128, %149 : f64
      %155 = llvm.load %131 : !llvm.ptr -> i32
      %156 = arith.extsi %155 : i32 to i64
      %157 = llvm.getelementptr %arg1[%156] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %154 = llvm.load %157 : !llvm.ptr -> f64
      %158 = arith.mulf %127, %154 : f64
      %159 = arith.addf %153, %158 : f64
      %160 = llvm.load %131 : !llvm.ptr -> i32
      %161 = arith.extsi %160 : i32 to i64
      %162 = llvm.getelementptr %arg3[%161] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %159, %162 : f64, !llvm.ptr
      %163 = llvm.load %131 : !llvm.ptr -> i32
      %164 = arith.constant 1 : i32
      %165 = arith.addi %163, %164 : i32
      llvm.store %165, %131 : i32, !llvm.ptr
      cf.br ^bb15
    ^bb17:
    func.return
  }
  func.func @min_x_above_y(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: f64) -> f64 {
    %166 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
    %167 = arith.extf %166 : f32 to f64
    %168 = llvm.mlir.constant(1 : i64) : i64
    %169 = llvm.alloca %168 x f64 : (i64) -> !llvm.ptr
    llvm.store %167, %169 : f64, !llvm.ptr
    %170 = arith.constant 0 : i32
    %171 = llvm.mlir.constant(1 : i64) : i64
    %172 = llvm.alloca %171 x i32 : (i64) -> !llvm.ptr
    llvm.store %170, %172 : i32, !llvm.ptr
    cf.br ^bb18
    ^bb18:
    %173 = llvm.load %172 : !llvm.ptr -> i32
    %174 = arith.constant 5 : i32
    %175 = arith.cmpi slt, %173, %174 : i32
    cf.cond_br %175, ^bb19, ^bb20
    ^bb19:
      %177 = llvm.load %172 : !llvm.ptr -> i32
      %178 = arith.extsi %177 : i32 to i64
      %179 = llvm.getelementptr %arg0[%178] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %176 = llvm.load %179 : !llvm.ptr -> f64
      %181 = llvm.load %172 : !llvm.ptr -> i32
      %182 = arith.extsi %181 : i32 to i64
      %183 = llvm.getelementptr %arg1[%182] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %180 = llvm.load %183 : !llvm.ptr -> f64
      %184 = llvm.load %172 : !llvm.ptr -> i32
      %185 = arith.constant 1 : i32
      %186 = arith.addi %184, %185 : i32
      %187 = arith.constant 5 : i32
      %188 = arith.remsi %186, %187 : i32
      %190 = arith.extsi %188 : i32 to i64
      %191 = llvm.getelementptr %arg0[%190] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %189 = llvm.load %191 : !llvm.ptr -> f64
      %193 = arith.extsi %188 : i32 to i64
      %194 = llvm.getelementptr %arg1[%193] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %192 = llvm.load %194 : !llvm.ptr -> f64
      %195 = arith.cmpf oge, %180, %arg2 : f64
      %196 = scf.if %195 -> (i1) {
        %197 = llvm.load %169 : !llvm.ptr -> f64
        %198 = arith.cmpf olt, %176, %197 : f64
        scf.yield %198 : i1
      } else {
        %199 = arith.constant false
        scf.yield %199 : i1
      }
      cf.cond_br %196, ^bb21, ^bb22
      ^bb21:
        llvm.store %176, %169 : f64, !llvm.ptr
        cf.br ^bb23
      ^bb22:
        cf.br ^bb23
      ^bb23:
      %200 = arith.cmpf oge, %192, %arg2 : f64
      %201 = scf.if %200 -> (i1) {
        %202 = llvm.load %169 : !llvm.ptr -> f64
        %203 = arith.cmpf olt, %189, %202 : f64
        scf.yield %203 : i1
      } else {
        %204 = arith.constant false
        scf.yield %204 : i1
      }
      cf.cond_br %201, ^bb24, ^bb25
      ^bb24:
        llvm.store %189, %169 : f64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        cf.br ^bb26
      ^bb26:
      %205 = arith.subf %192, %180 : f64
      %206 = arith.constant 0.0 : f32
      %208 = arith.extf %206 : f32 to f64
      %207 = arith.cmpf oeq, %205, %208 : f64
      cf.cond_br %207, ^bb27, ^bb28
      ^bb27:
        %209 = llvm.load %172 : !llvm.ptr -> i32
        %210 = arith.constant 1 : i32
        %211 = arith.addi %209, %210 : i32
        llvm.store %211, %172 : i32, !llvm.ptr
        cf.br ^bb18
      ^bb28:
        cf.br ^bb29
      ^bb29:
      %212 = arith.subf %arg2, %180 : f64
      %213 = arith.divf %212, %205 : f64
      %214 = arith.constant 0.0 : f32
      %216 = arith.extf %214 : f32 to f64
      %215 = arith.cmpf oge, %213, %216 : f64
      %217 = scf.if %215 -> (i1) {
        %218 = arith.constant 1.0 : f32
        %220 = arith.extf %218 : f32 to f64
        %219 = arith.cmpf ole, %213, %220 : f64
        scf.yield %219 : i1
      } else {
        %221 = arith.constant false
        scf.yield %221 : i1
      }
      cf.cond_br %217, ^bb30, ^bb31
      ^bb30:
        %222 = arith.subf %189, %176 : f64
        %223 = arith.mulf %222, %213 : f64
        %224 = arith.addf %176, %223 : f64
        %225 = llvm.load %169 : !llvm.ptr -> f64
        %226 = arith.cmpf olt, %224, %225 : f64
        cf.cond_br %226, ^bb33, ^bb34
        ^bb33:
          llvm.store %224, %169 : f64, !llvm.ptr
          cf.br ^bb35
        ^bb34:
          cf.br ^bb35
        ^bb35:
        cf.br ^bb32
      ^bb31:
        cf.br ^bb32
      ^bb32:
      %227 = llvm.load %172 : !llvm.ptr -> i32
      %228 = arith.constant 1 : i32
      %229 = arith.addi %227, %228 : i32
      llvm.store %229, %172 : i32, !llvm.ptr
      cf.br ^bb18
    ^bb20:
    %230 = llvm.load %169 : !llvm.ptr -> f64
    func.return %230 : f64
  }
  func.func @clearance_for_theta(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: f64, %arg3: f64, %arg4: f64, %arg5: f64) -> f64 {
    %231 = arith.constant 1.0 : f32
    %233 = arith.extf %231 : f32 to f64
    %232 = arith.addf %233, %arg5 : f64
    %234 = arith.divf %232, %arg4 : f64
    %235 = arith.addf %arg2, %234 : f64
    %236 = func.call @min_x_above_y(%arg0, %arg1, %235) : (!llvm.ptr, !llvm.ptr, f64) -> f64
    %237 = arith.constant 100000000000000006172783352786715688699437231096301125831005285053881337653967155894253917094446479669431045845149126131034590785433956171738211535366987228554259102109161882186134743033813753627273385960246277244994846257890348030815401124236704201912132575831851305036088950921132601507840 : f32
    %239 = arith.extf %237 : f32 to f64
    %238 = arith.cmpf ogt, %236, %239 : f64
    cf.cond_br %238, ^bb36, ^bb37
    ^bb36:
      %240 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %241 = arith.extf %240 : f32 to f64
      func.return %241 : f64
    ^bb37:
      cf.br ^bb38
    ^bb38:
    %242 = arith.constant 1.0 : f32
    %243 = arith.subf %236, %arg3 : f64
    %244 = arith.mulf %arg4, %243 : f64
    %246 = arith.extf %242 : f32 to f64
    %245 = arith.addf %246, %244 : f64
    func.return %245 : f64
  }
  func.func @min_clearance(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: i32, %arg8: f64, %arg9: f64, %arg10: i32, %arg11: i32) -> f64 {
    %248 = arith.extsi %arg7 : i32 to i64
    %249 = arith.constant 8 : i32
    %250 = arith.extsi %249 : i32 to i64
    %247 = func.call @calloc(%248, %250) : (i64, i64) -> !llvm.ptr
    %251 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
    %252 = arith.extf %251 : f32 to f64
    %253 = llvm.mlir.constant(1 : i64) : i64
    %254 = llvm.alloca %253 x f64 : (i64) -> !llvm.ptr
    llvm.store %252, %254 : f64, !llvm.ptr
    %255 = arith.constant 0 : i32
    %256 = llvm.mlir.constant(1 : i64) : i64
    %257 = llvm.alloca %256 x i32 : (i64) -> !llvm.ptr
    llvm.store %255, %257 : i32, !llvm.ptr
    cf.br ^bb39
    ^bb39:
    %258 = llvm.load %257 : !llvm.ptr -> i32
    %259 = arith.cmpi slt, %258, %arg7 : i32
    cf.cond_br %259, ^bb40, ^bb41
    ^bb40:
      %262 = llvm.load %257 : !llvm.ptr -> i32
      %263 = arith.extsi %262 : i32 to i64
      %264 = llvm.getelementptr %arg2[%263] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %261 = llvm.load %264 : !llvm.ptr -> !llvm.ptr
      %266 = llvm.load %257 : !llvm.ptr -> i32
      %267 = arith.extsi %266 : i32 to i64
      %268 = llvm.getelementptr %arg3[%267] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %265 = llvm.load %268 : !llvm.ptr -> !llvm.ptr
      %270 = llvm.load %257 : !llvm.ptr -> i32
      %271 = arith.extsi %270 : i32 to i64
      %272 = llvm.getelementptr %arg4[%271] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %269 = llvm.load %272 : !llvm.ptr -> f64
      %274 = llvm.load %257 : !llvm.ptr -> i32
      %275 = arith.extsi %274 : i32 to i64
      %276 = llvm.getelementptr %arg5[%275] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %273 = llvm.load %276 : !llvm.ptr -> f64
      %260 = func.call @clearance_for_theta(%261, %265, %269, %273, %arg8, %arg9) : (!llvm.ptr, !llvm.ptr, f64, f64, f64, f64) -> f64
      %277 = llvm.load %257 : !llvm.ptr -> i32
      %278 = arith.extsi %277 : i32 to i64
      %279 = llvm.getelementptr %247[%278] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %260, %279 : f64, !llvm.ptr
      %281 = llvm.load %257 : !llvm.ptr -> i32
      %282 = arith.extsi %281 : i32 to i64
      %283 = llvm.getelementptr %247[%282] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %280 = llvm.load %283 : !llvm.ptr -> f64
      %284 = llvm.load %254 : !llvm.ptr -> f64
      %285 = arith.cmpf olt, %280, %284 : f64
      cf.cond_br %285, ^bb42, ^bb43
      ^bb42:
        %287 = llvm.load %257 : !llvm.ptr -> i32
        %288 = arith.extsi %287 : i32 to i64
        %289 = llvm.getelementptr %247[%288] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %286 = llvm.load %289 : !llvm.ptr -> f64
        llvm.store %286, %254 : f64, !llvm.ptr
        cf.br ^bb44
      ^bb43:
        cf.br ^bb44
      ^bb44:
      %290 = llvm.load %257 : !llvm.ptr -> i32
      %291 = arith.constant 1 : i32
      %292 = arith.addi %290, %291 : i32
      llvm.store %292, %257 : i32, !llvm.ptr
      cf.br ^bb39
    ^bb41:
    %294 = arith.extsi %arg7 : i32 to i64
    %295 = arith.constant 4 : i32
    %296 = arith.extsi %295 : i32 to i64
    %293 = func.call @calloc(%294, %296) : (i64, i64) -> !llvm.ptr
    %297 = arith.constant 0 : i32
    %298 = llvm.mlir.constant(1 : i64) : i64
    %299 = llvm.alloca %298 x i32 : (i64) -> !llvm.ptr
    llvm.store %297, %299 : i32, !llvm.ptr
    cf.br ^bb45
    ^bb45:
    %300 = llvm.load %299 : !llvm.ptr -> i32
    %301 = arith.cmpi slt, %300, %arg7 : i32
    cf.cond_br %301, ^bb46, ^bb47
    ^bb46:
      %302 = llvm.load %299 : !llvm.ptr -> i32
      %303 = llvm.load %299 : !llvm.ptr -> i32
      %304 = arith.extsi %303 : i32 to i64
      %305 = llvm.getelementptr %293[%304] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %302, %305 : i32, !llvm.ptr
      %306 = llvm.load %299 : !llvm.ptr -> i32
      %307 = arith.constant 1 : i32
      %308 = arith.addi %306, %307 : i32
      llvm.store %308, %299 : i32, !llvm.ptr
      cf.br ^bb45
    ^bb47:
    %309 = arith.constant 0 : i32
    %310 = llvm.mlir.constant(1 : i64) : i64
    %311 = llvm.alloca %310 x i32 : (i64) -> !llvm.ptr
    llvm.store %309, %311 : i32, !llvm.ptr
    cf.br ^bb48
    ^bb48:
    %312 = llvm.load %311 : !llvm.ptr -> i32
    %313 = arith.cmpi slt, %312, %arg10 : i32
    %314 = scf.if %313 -> (i1) {
      %315 = llvm.load %311 : !llvm.ptr -> i32
      %316 = arith.cmpi slt, %315, %arg7 : i32
      scf.yield %316 : i1
    } else {
      %317 = arith.constant false
      scf.yield %317 : i1
    }
    cf.cond_br %314, ^bb49, ^bb50
    ^bb49:
      %318 = llvm.load %311 : !llvm.ptr -> i32
      %319 = llvm.mlir.constant(1 : i64) : i64
      %320 = llvm.alloca %319 x i32 : (i64) -> !llvm.ptr
      llvm.store %318, %320 : i32, !llvm.ptr
      %321 = llvm.load %311 : !llvm.ptr -> i32
      %322 = arith.constant 1 : i32
      %323 = arith.addi %321, %322 : i32
      %324 = llvm.mlir.constant(1 : i64) : i64
      %325 = llvm.alloca %324 x i32 : (i64) -> !llvm.ptr
      llvm.store %323, %325 : i32, !llvm.ptr
      cf.br ^bb51
      ^bb51:
      %326 = llvm.load %325 : !llvm.ptr -> i32
      %327 = arith.cmpi slt, %326, %arg7 : i32
      cf.cond_br %327, ^bb52, ^bb53
      ^bb52:
        %330 = llvm.load %325 : !llvm.ptr -> i32
        %331 = arith.extsi %330 : i32 to i64
        %332 = llvm.getelementptr %293[%331] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %329 = llvm.load %332 : !llvm.ptr -> i32
        %333 = arith.extsi %329 : i32 to i64
        %334 = llvm.getelementptr %247[%333] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %328 = llvm.load %334 : !llvm.ptr -> f64
        %337 = llvm.load %320 : !llvm.ptr -> i32
        %338 = arith.extsi %337 : i32 to i64
        %339 = llvm.getelementptr %293[%338] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %336 = llvm.load %339 : !llvm.ptr -> i32
        %340 = arith.extsi %336 : i32 to i64
        %341 = llvm.getelementptr %247[%340] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %335 = llvm.load %341 : !llvm.ptr -> f64
        %342 = arith.cmpf olt, %328, %335 : f64
        cf.cond_br %342, ^bb54, ^bb55
        ^bb54:
          %343 = llvm.load %325 : !llvm.ptr -> i32
          llvm.store %343, %320 : i32, !llvm.ptr
          cf.br ^bb56
        ^bb55:
          cf.br ^bb56
        ^bb56:
        %344 = llvm.load %325 : !llvm.ptr -> i32
        %345 = arith.constant 1 : i32
        %346 = arith.addi %344, %345 : i32
        llvm.store %346, %325 : i32, !llvm.ptr
        cf.br ^bb51
      ^bb53:
      %348 = llvm.load %311 : !llvm.ptr -> i32
      %349 = arith.extsi %348 : i32 to i64
      %350 = llvm.getelementptr %293[%349] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %347 = llvm.load %350 : !llvm.ptr -> i32
      %352 = llvm.load %320 : !llvm.ptr -> i32
      %353 = arith.extsi %352 : i32 to i64
      %354 = llvm.getelementptr %293[%353] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %351 = llvm.load %354 : !llvm.ptr -> i32
      %355 = llvm.load %311 : !llvm.ptr -> i32
      %356 = arith.extsi %355 : i32 to i64
      %357 = llvm.getelementptr %293[%356] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %351, %357 : i32, !llvm.ptr
      %358 = llvm.load %320 : !llvm.ptr -> i32
      %359 = arith.extsi %358 : i32 to i64
      %360 = llvm.getelementptr %293[%359] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %347, %360 : i32, !llvm.ptr
      %361 = llvm.load %311 : !llvm.ptr -> i32
      %362 = arith.constant 1 : i32
      %363 = arith.addi %361, %362 : i32
      llvm.store %363, %311 : i32, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    %364 = arith.constant 0 : i32
    %365 = llvm.mlir.constant(1 : i64) : i64
    %366 = llvm.alloca %365 x i32 : (i64) -> !llvm.ptr
    llvm.store %364, %366 : i32, !llvm.ptr
    cf.br ^bb57
    ^bb57:
    %367 = llvm.load %366 : !llvm.ptr -> i32
    %368 = arith.cmpi slt, %367, %arg10 : i32
    %369 = scf.if %368 -> (i1) {
      %370 = llvm.load %366 : !llvm.ptr -> i32
      %371 = arith.cmpi slt, %370, %arg7 : i32
      scf.yield %371 : i1
    } else {
      %372 = arith.constant false
      scf.yield %372 : i1
    }
    cf.cond_br %369, ^bb58, ^bb59
    ^bb58:
      %374 = llvm.load %366 : !llvm.ptr -> i32
      %375 = arith.extsi %374 : i32 to i64
      %376 = llvm.getelementptr %293[%375] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %373 = llvm.load %376 : !llvm.ptr -> i32
      %378 = arith.constant 0 : i32
      %379 = arith.cmpi sgt, %373, %378 : i32
      %380 = scf.if %379 -> (i32) {
        %381 = arith.constant 1 : i32
        %382 = arith.subi %373, %381 : i32
        scf.yield %382 : i32
      } else {
        %383 = arith.constant 0 : i32
        scf.yield %383 : i32
      }
      %384 = arith.extsi %380 : i32 to i64
      %385 = llvm.getelementptr %arg6[%384] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %377 = llvm.load %385 : !llvm.ptr -> f64
      %387 = arith.constant 1 : i32
      %388 = arith.subi %arg7, %387 : i32
      %389 = arith.cmpi slt, %373, %388 : i32
      %390 = scf.if %389 -> (i32) {
        %391 = arith.constant 1 : i32
        %392 = arith.addi %373, %391 : i32
        scf.yield %392 : i32
      } else {
        %393 = arith.constant 1 : i32
        %394 = arith.subi %arg7, %393 : i32
        scf.yield %394 : i32
      }
      %395 = arith.extsi %390 : i32 to i64
      %396 = llvm.getelementptr %arg6[%395] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %386 = llvm.load %396 : !llvm.ptr -> f64
      %397 = arith.subf %386, %377 : f64
      %398 = arith.constant 0 : f32
      %400 = arith.extf %398 : f32 to f64
      %399 = arith.cmpf ole, %397, %400 : f64
      cf.cond_br %399, ^bb60, ^bb61
      ^bb60:
        %401 = llvm.load %366 : !llvm.ptr -> i32
        %402 = arith.constant 1 : i32
        %403 = arith.addi %401, %402 : i32
        llvm.store %403, %366 : i32, !llvm.ptr
        cf.br ^bb57
      ^bb61:
        cf.br ^bb62
      ^bb62:
      %404 = arith.subf %386, %377 : f64
      %405 = llvm.mlir.addressof @PHI : !llvm.ptr
      %406 = llvm.load %405 : !llvm.ptr -> f64
      %407 = arith.mulf %404, %406 : f64
      %408 = arith.subf %386, %407 : f64
      %409 = llvm.mlir.constant(1 : i64) : i64
      %410 = llvm.alloca %409 x f64 : (i64) -> !llvm.ptr
      llvm.store %408, %410 : f64, !llvm.ptr
      %411 = arith.subf %386, %377 : f64
      %412 = llvm.mlir.addressof @PHI : !llvm.ptr
      %413 = llvm.load %412 : !llvm.ptr -> f64
      %414 = arith.mulf %411, %413 : f64
      %415 = arith.addf %377, %414 : f64
      %416 = llvm.mlir.constant(1 : i64) : i64
      %417 = llvm.alloca %416 x f64 : (i64) -> !llvm.ptr
      llvm.store %415, %417 : f64, !llvm.ptr
      %419 = arith.constant 5 : i32
      %420 = arith.constant 8 : i32
      %421 = arith.extsi %419 : i32 to i64
      %422 = arith.extsi %420 : i32 to i64
      %418 = func.call @calloc(%421, %422) : (i64, i64) -> !llvm.ptr
      %424 = arith.constant 5 : i32
      %425 = arith.constant 8 : i32
      %426 = arith.extsi %424 : i32 to i64
      %427 = arith.extsi %425 : i32 to i64
      %423 = func.call @calloc(%426, %427) : (i64, i64) -> !llvm.ptr
      %429 = arith.constant 5 : i32
      %430 = arith.constant 8 : i32
      %431 = arith.extsi %429 : i32 to i64
      %432 = arith.extsi %430 : i32 to i64
      %428 = func.call @calloc(%431, %432) : (i64, i64) -> !llvm.ptr
      %434 = arith.constant 5 : i32
      %435 = arith.constant 8 : i32
      %436 = arith.extsi %434 : i32 to i64
      %437 = arith.extsi %435 : i32 to i64
      %433 = func.call @calloc(%436, %437) : (i64, i64) -> !llvm.ptr
      %439 = llvm.load %410 : !llvm.ptr -> f64
      func.call @rotate_points(%arg0, %arg1, %418, %423, %439) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, f64) -> ()
      %441 = llvm.load %417 : !llvm.ptr -> f64
      func.call @rotate_points(%arg0, %arg1, %428, %433, %441) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, f64) -> ()
      %442 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %443 = arith.extf %442 : f32 to f64
      %444 = llvm.mlir.constant(1 : i64) : i64
      %445 = llvm.alloca %444 x f64 : (i64) -> !llvm.ptr
      llvm.store %443, %445 : f64, !llvm.ptr
      %446 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %447 = arith.negf %446 : f32
      %448 = arith.extf %447 : f32 to f64
      %449 = llvm.mlir.constant(1 : i64) : i64
      %450 = llvm.alloca %449 x f64 : (i64) -> !llvm.ptr
      llvm.store %448, %450 : f64, !llvm.ptr
      %451 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %452 = arith.extf %451 : f32 to f64
      %453 = llvm.mlir.constant(1 : i64) : i64
      %454 = llvm.alloca %453 x f64 : (i64) -> !llvm.ptr
      llvm.store %452, %454 : f64, !llvm.ptr
      %455 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %456 = arith.negf %455 : f32
      %457 = arith.extf %456 : f32 to f64
      %458 = llvm.mlir.constant(1 : i64) : i64
      %459 = llvm.alloca %458 x f64 : (i64) -> !llvm.ptr
      llvm.store %457, %459 : f64, !llvm.ptr
      %460 = arith.constant 0 : i32
      %461 = llvm.mlir.constant(1 : i64) : i64
      %462 = llvm.alloca %461 x i32 : (i64) -> !llvm.ptr
      llvm.store %460, %462 : i32, !llvm.ptr
      cf.br ^bb63
      ^bb63:
      %463 = llvm.load %462 : !llvm.ptr -> i32
      %464 = arith.constant 5 : i32
      %465 = arith.cmpi slt, %463, %464 : i32
      cf.cond_br %465, ^bb64, ^bb65
      ^bb64:
        %467 = llvm.load %462 : !llvm.ptr -> i32
        %468 = arith.extsi %467 : i32 to i64
        %469 = llvm.getelementptr %423[%468] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %466 = llvm.load %469 : !llvm.ptr -> f64
        %470 = llvm.load %445 : !llvm.ptr -> f64
        %471 = arith.cmpf olt, %466, %470 : f64
        cf.cond_br %471, ^bb66, ^bb67
        ^bb66:
          %473 = llvm.load %462 : !llvm.ptr -> i32
          %474 = arith.extsi %473 : i32 to i64
          %475 = llvm.getelementptr %423[%474] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %472 = llvm.load %475 : !llvm.ptr -> f64
          llvm.store %472, %445 : f64, !llvm.ptr
          cf.br ^bb68
        ^bb67:
          cf.br ^bb68
        ^bb68:
        %477 = llvm.load %462 : !llvm.ptr -> i32
        %478 = arith.extsi %477 : i32 to i64
        %479 = llvm.getelementptr %418[%478] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %476 = llvm.load %479 : !llvm.ptr -> f64
        %480 = llvm.load %450 : !llvm.ptr -> f64
        %481 = arith.cmpf ogt, %476, %480 : f64
        cf.cond_br %481, ^bb69, ^bb70
        ^bb69:
          %483 = llvm.load %462 : !llvm.ptr -> i32
          %484 = arith.extsi %483 : i32 to i64
          %485 = llvm.getelementptr %418[%484] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %482 = llvm.load %485 : !llvm.ptr -> f64
          llvm.store %482, %450 : f64, !llvm.ptr
          cf.br ^bb71
        ^bb70:
          cf.br ^bb71
        ^bb71:
        %487 = llvm.load %462 : !llvm.ptr -> i32
        %488 = arith.extsi %487 : i32 to i64
        %489 = llvm.getelementptr %433[%488] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %486 = llvm.load %489 : !llvm.ptr -> f64
        %490 = llvm.load %454 : !llvm.ptr -> f64
        %491 = arith.cmpf olt, %486, %490 : f64
        cf.cond_br %491, ^bb72, ^bb73
        ^bb72:
          %493 = llvm.load %462 : !llvm.ptr -> i32
          %494 = arith.extsi %493 : i32 to i64
          %495 = llvm.getelementptr %433[%494] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %492 = llvm.load %495 : !llvm.ptr -> f64
          llvm.store %492, %454 : f64, !llvm.ptr
          cf.br ^bb74
        ^bb73:
          cf.br ^bb74
        ^bb74:
        %497 = llvm.load %462 : !llvm.ptr -> i32
        %498 = arith.extsi %497 : i32 to i64
        %499 = llvm.getelementptr %428[%498] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %496 = llvm.load %499 : !llvm.ptr -> f64
        %500 = llvm.load %459 : !llvm.ptr -> f64
        %501 = arith.cmpf ogt, %496, %500 : f64
        cf.cond_br %501, ^bb75, ^bb76
        ^bb75:
          %503 = llvm.load %462 : !llvm.ptr -> i32
          %504 = arith.extsi %503 : i32 to i64
          %505 = llvm.getelementptr %428[%504] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %502 = llvm.load %505 : !llvm.ptr -> f64
          llvm.store %502, %459 : f64, !llvm.ptr
          cf.br ^bb77
        ^bb76:
          cf.br ^bb77
        ^bb77:
        %506 = llvm.load %462 : !llvm.ptr -> i32
        %507 = arith.constant 1 : i32
        %508 = arith.addi %506, %507 : i32
        llvm.store %508, %462 : i32, !llvm.ptr
        cf.br ^bb63
      ^bb65:
      %510 = llvm.load %445 : !llvm.ptr -> f64
      %511 = llvm.load %450 : !llvm.ptr -> f64
      %509 = func.call @clearance_for_theta(%418, %423, %510, %511, %arg8, %arg9) : (!llvm.ptr, !llvm.ptr, f64, f64, f64, f64) -> f64
      %512 = llvm.mlir.constant(1 : i64) : i64
      %513 = llvm.alloca %512 x f64 : (i64) -> !llvm.ptr
      llvm.store %509, %513 : f64, !llvm.ptr
      %515 = llvm.load %454 : !llvm.ptr -> f64
      %516 = llvm.load %459 : !llvm.ptr -> f64
      %514 = func.call @clearance_for_theta(%428, %433, %515, %516, %arg8, %arg9) : (!llvm.ptr, !llvm.ptr, f64, f64, f64, f64) -> f64
      %517 = llvm.mlir.constant(1 : i64) : i64
      %518 = llvm.alloca %517 x f64 : (i64) -> !llvm.ptr
      llvm.store %514, %518 : f64, !llvm.ptr
      %519 = arith.constant 0 : i32
      %520 = llvm.mlir.constant(1 : i64) : i64
      %521 = llvm.alloca %520 x i32 : (i64) -> !llvm.ptr
      llvm.store %519, %521 : i32, !llvm.ptr
      cf.br ^bb78(%386, %377 : f64, f64)
      ^bb78(%522: f64, %523: f64):
      %524 = llvm.load %521 : !llvm.ptr -> i32
      %525 = arith.cmpi slt, %524, %arg11 : i32
      cf.cond_br %525, ^bb79(%522, %523 : f64, f64), ^bb80(%522, %523 : f64, f64)
      ^bb79(%526: f64, %527: f64):
        %528 = llvm.load %513 : !llvm.ptr -> f64
        %529 = llvm.load %518 : !llvm.ptr -> f64
        %530 = arith.cmpf olt, %528, %529 : f64
        cf.cond_br %530, ^bb81, ^bb82
        ^bb81:
          %531 = llvm.load %417 : !llvm.ptr -> f64
          %532 = llvm.load %410 : !llvm.ptr -> f64
          llvm.store %532, %417 : f64, !llvm.ptr
          %533 = llvm.load %513 : !llvm.ptr -> f64
          llvm.store %533, %518 : f64, !llvm.ptr
          %534 = arith.subf %531, %527 : f64
          %535 = llvm.mlir.addressof @PHI : !llvm.ptr
          %536 = llvm.load %535 : !llvm.ptr -> f64
          %537 = arith.mulf %534, %536 : f64
          %538 = arith.subf %531, %537 : f64
          llvm.store %538, %410 : f64, !llvm.ptr
          %540 = llvm.load %410 : !llvm.ptr -> f64
          func.call @rotate_points(%arg0, %arg1, %418, %423, %540) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, f64) -> ()
          %541 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
          %542 = arith.extf %541 : f32 to f64
          llvm.store %542, %445 : f64, !llvm.ptr
          %543 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
          %544 = arith.negf %543 : f32
          %545 = arith.extf %544 : f32 to f64
          llvm.store %545, %450 : f64, !llvm.ptr
          %546 = arith.constant 0 : i32
          %547 = llvm.mlir.constant(1 : i64) : i64
          %548 = llvm.alloca %547 x i32 : (i64) -> !llvm.ptr
          llvm.store %546, %548 : i32, !llvm.ptr
          cf.br ^bb84
          ^bb84:
          %549 = llvm.load %548 : !llvm.ptr -> i32
          %550 = arith.constant 5 : i32
          %551 = arith.cmpi slt, %549, %550 : i32
          cf.cond_br %551, ^bb85, ^bb86
          ^bb85:
            %553 = llvm.load %548 : !llvm.ptr -> i32
            %554 = arith.extsi %553 : i32 to i64
            %555 = llvm.getelementptr %423[%554] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %552 = llvm.load %555 : !llvm.ptr -> f64
            %556 = llvm.load %445 : !llvm.ptr -> f64
            %557 = arith.cmpf olt, %552, %556 : f64
            cf.cond_br %557, ^bb87, ^bb88
            ^bb87:
              %559 = llvm.load %548 : !llvm.ptr -> i32
              %560 = arith.extsi %559 : i32 to i64
              %561 = llvm.getelementptr %423[%560] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %558 = llvm.load %561 : !llvm.ptr -> f64
              llvm.store %558, %445 : f64, !llvm.ptr
              cf.br ^bb89
            ^bb88:
              cf.br ^bb89
            ^bb89:
            %563 = llvm.load %548 : !llvm.ptr -> i32
            %564 = arith.extsi %563 : i32 to i64
            %565 = llvm.getelementptr %418[%564] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %562 = llvm.load %565 : !llvm.ptr -> f64
            %566 = llvm.load %450 : !llvm.ptr -> f64
            %567 = arith.cmpf ogt, %562, %566 : f64
            cf.cond_br %567, ^bb90, ^bb91
            ^bb90:
              %569 = llvm.load %548 : !llvm.ptr -> i32
              %570 = arith.extsi %569 : i32 to i64
              %571 = llvm.getelementptr %418[%570] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %568 = llvm.load %571 : !llvm.ptr -> f64
              llvm.store %568, %450 : f64, !llvm.ptr
              cf.br ^bb92
            ^bb91:
              cf.br ^bb92
            ^bb92:
            %572 = llvm.load %548 : !llvm.ptr -> i32
            %573 = arith.constant 1 : i32
            %574 = arith.addi %572, %573 : i32
            llvm.store %574, %548 : i32, !llvm.ptr
            cf.br ^bb84
          ^bb86:
          %576 = llvm.load %445 : !llvm.ptr -> f64
          %577 = llvm.load %450 : !llvm.ptr -> f64
          %575 = func.call @clearance_for_theta(%418, %423, %576, %577, %arg8, %arg9) : (!llvm.ptr, !llvm.ptr, f64, f64, f64, f64) -> f64
          llvm.store %575, %513 : f64, !llvm.ptr
          cf.br ^bb83(%531, %527 : f64, f64)
        ^bb82:
          %578 = llvm.load %410 : !llvm.ptr -> f64
          %579 = llvm.load %417 : !llvm.ptr -> f64
          llvm.store %579, %410 : f64, !llvm.ptr
          %580 = llvm.load %518 : !llvm.ptr -> f64
          llvm.store %580, %513 : f64, !llvm.ptr
          %581 = arith.subf %526, %578 : f64
          %582 = llvm.mlir.addressof @PHI : !llvm.ptr
          %583 = llvm.load %582 : !llvm.ptr -> f64
          %584 = arith.mulf %581, %583 : f64
          %585 = arith.addf %578, %584 : f64
          llvm.store %585, %417 : f64, !llvm.ptr
          %587 = llvm.load %417 : !llvm.ptr -> f64
          func.call @rotate_points(%arg0, %arg1, %428, %433, %587) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, f64) -> ()
          %588 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
          %589 = arith.extf %588 : f32 to f64
          llvm.store %589, %454 : f64, !llvm.ptr
          %590 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
          %591 = arith.negf %590 : f32
          %592 = arith.extf %591 : f32 to f64
          llvm.store %592, %459 : f64, !llvm.ptr
          %593 = arith.constant 0 : i32
          %594 = llvm.mlir.constant(1 : i64) : i64
          %595 = llvm.alloca %594 x i32 : (i64) -> !llvm.ptr
          llvm.store %593, %595 : i32, !llvm.ptr
          cf.br ^bb93
          ^bb93:
          %596 = llvm.load %595 : !llvm.ptr -> i32
          %597 = arith.constant 5 : i32
          %598 = arith.cmpi slt, %596, %597 : i32
          cf.cond_br %598, ^bb94, ^bb95
          ^bb94:
            %600 = llvm.load %595 : !llvm.ptr -> i32
            %601 = arith.extsi %600 : i32 to i64
            %602 = llvm.getelementptr %433[%601] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %599 = llvm.load %602 : !llvm.ptr -> f64
            %603 = llvm.load %454 : !llvm.ptr -> f64
            %604 = arith.cmpf olt, %599, %603 : f64
            cf.cond_br %604, ^bb96, ^bb97
            ^bb96:
              %606 = llvm.load %595 : !llvm.ptr -> i32
              %607 = arith.extsi %606 : i32 to i64
              %608 = llvm.getelementptr %433[%607] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %605 = llvm.load %608 : !llvm.ptr -> f64
              llvm.store %605, %454 : f64, !llvm.ptr
              cf.br ^bb98
            ^bb97:
              cf.br ^bb98
            ^bb98:
            %610 = llvm.load %595 : !llvm.ptr -> i32
            %611 = arith.extsi %610 : i32 to i64
            %612 = llvm.getelementptr %428[%611] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %609 = llvm.load %612 : !llvm.ptr -> f64
            %613 = llvm.load %459 : !llvm.ptr -> f64
            %614 = arith.cmpf ogt, %609, %613 : f64
            cf.cond_br %614, ^bb99, ^bb100
            ^bb99:
              %616 = llvm.load %595 : !llvm.ptr -> i32
              %617 = arith.extsi %616 : i32 to i64
              %618 = llvm.getelementptr %428[%617] : (!llvm.ptr, i64) -> !llvm.ptr, f64
              %615 = llvm.load %618 : !llvm.ptr -> f64
              llvm.store %615, %459 : f64, !llvm.ptr
              cf.br ^bb101
            ^bb100:
              cf.br ^bb101
            ^bb101:
            %619 = llvm.load %595 : !llvm.ptr -> i32
            %620 = arith.constant 1 : i32
            %621 = arith.addi %619, %620 : i32
            llvm.store %621, %595 : i32, !llvm.ptr
            cf.br ^bb93
          ^bb95:
          %623 = llvm.load %454 : !llvm.ptr -> f64
          %624 = llvm.load %459 : !llvm.ptr -> f64
          %622 = func.call @clearance_for_theta(%428, %433, %623, %624, %arg8, %arg9) : (!llvm.ptr, !llvm.ptr, f64, f64, f64, f64) -> f64
          llvm.store %622, %518 : f64, !llvm.ptr
          cf.br ^bb83(%526, %578 : f64, f64)
        ^bb83(%625: f64, %626: f64):
        %627 = llvm.load %521 : !llvm.ptr -> i32
        %628 = arith.constant 1 : i32
        %629 = arith.addi %627, %628 : i32
        llvm.store %629, %521 : i32, !llvm.ptr
        cf.br ^bb78(%625, %626 : f64, f64)
      ^bb80(%630: f64, %631: f64):
      %632 = llvm.load %513 : !llvm.ptr -> f64
      %633 = llvm.load %254 : !llvm.ptr -> f64
      %634 = arith.cmpf olt, %632, %633 : f64
      cf.cond_br %634, ^bb102, ^bb103
      ^bb102:
        %635 = llvm.load %513 : !llvm.ptr -> f64
        llvm.store %635, %254 : f64, !llvm.ptr
        cf.br ^bb104
      ^bb103:
        cf.br ^bb104
      ^bb104:
      %636 = llvm.load %518 : !llvm.ptr -> f64
      %637 = llvm.load %254 : !llvm.ptr -> f64
      %638 = arith.cmpf olt, %636, %637 : f64
      cf.cond_br %638, ^bb105, ^bb106
      ^bb105:
        %639 = llvm.load %518 : !llvm.ptr -> f64
        llvm.store %639, %254 : f64, !llvm.ptr
        cf.br ^bb107
      ^bb106:
        cf.br ^bb107
      ^bb107:
      func.call @free(%418) : (!llvm.ptr) -> ()
      func.call @free(%423) : (!llvm.ptr) -> ()
      func.call @free(%428) : (!llvm.ptr) -> ()
      func.call @free(%433) : (!llvm.ptr) -> ()
      %644 = llvm.load %366 : !llvm.ptr -> i32
      %645 = arith.constant 1 : i32
      %646 = arith.addi %644, %645 : i32
      llvm.store %646, %366 : i32, !llvm.ptr
      cf.br ^bb57
    ^bb59:
    func.call @free(%247) : (!llvm.ptr) -> ()
    func.call @free(%293) : (!llvm.ptr) -> ()
    %649 = llvm.load %254 : !llvm.ptr -> f64
    func.return %649 : f64
  }
  func.func @max_scale(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i32, %arg4: f64) -> f64 {
    %651 = arith.extsi %arg2 : i32 to i64
    %652 = arith.constant 8 : i32
    %653 = arith.extsi %652 : i32 to i64
    %650 = func.call @calloc(%651, %653) : (i64, i64) -> !llvm.ptr
    %655 = arith.extsi %arg2 : i32 to i64
    %656 = arith.constant 8 : i32
    %657 = arith.extsi %656 : i32 to i64
    %654 = func.call @calloc(%655, %657) : (i64, i64) -> !llvm.ptr
    %659 = arith.extsi %arg2 : i32 to i64
    %660 = arith.constant 8 : i32
    %661 = arith.extsi %660 : i32 to i64
    %658 = func.call @calloc(%659, %661) : (i64, i64) -> !llvm.ptr
    %663 = arith.extsi %arg2 : i32 to i64
    %664 = arith.constant 8 : i32
    %665 = arith.extsi %664 : i32 to i64
    %662 = func.call @calloc(%663, %665) : (i64, i64) -> !llvm.ptr
    %667 = arith.extsi %arg2 : i32 to i64
    %668 = arith.constant 8 : i32
    %669 = arith.extsi %668 : i32 to i64
    %666 = func.call @calloc(%667, %669) : (i64, i64) -> !llvm.ptr
    %670 = arith.constant 0 : i32
    %671 = llvm.mlir.constant(1 : i64) : i64
    %672 = llvm.alloca %671 x i32 : (i64) -> !llvm.ptr
    llvm.store %670, %672 : i32, !llvm.ptr
    cf.br ^bb108
    ^bb108:
    %673 = llvm.load %672 : !llvm.ptr -> i32
    %674 = arith.cmpi slt, %673, %arg2 : i32
    cf.cond_br %674, ^bb109, ^bb110
    ^bb109:
      %675 = llvm.mlir.addressof @PI : !llvm.ptr
      %676 = llvm.load %675 : !llvm.ptr -> f64
      %677 = arith.constant 2.0 : f32
      %679 = arith.extf %677 : f32 to f64
      %678 = arith.divf %676, %679 : f64
      %680 = llvm.load %672 : !llvm.ptr -> i32
      %681 = arith.sitofp %680 : i32 to f64
      %682 = arith.mulf %678, %681 : f64
      %683 = arith.constant 1 : i32
      %684 = arith.subi %arg2, %683 : i32
      %685 = arith.sitofp %684 : i32 to f64
      %686 = arith.divf %682, %685 : f64
      %687 = llvm.load %672 : !llvm.ptr -> i32
      %688 = arith.extsi %687 : i32 to i64
      %689 = llvm.getelementptr %650[%688] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %686, %689 : f64, !llvm.ptr
      %691 = arith.constant 5 : i32
      %692 = arith.constant 8 : i32
      %693 = arith.extsi %691 : i32 to i64
      %694 = arith.extsi %692 : i32 to i64
      %690 = func.call @calloc(%693, %694) : (i64, i64) -> !llvm.ptr
      %695 = llvm.load %672 : !llvm.ptr -> i32
      %696 = arith.extsi %695 : i32 to i64
      %697 = llvm.getelementptr %654[%696] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      llvm.store %690, %697 : !llvm.ptr, !llvm.ptr
      %699 = arith.constant 5 : i32
      %700 = arith.constant 8 : i32
      %701 = arith.extsi %699 : i32 to i64
      %702 = arith.extsi %700 : i32 to i64
      %698 = func.call @calloc(%701, %702) : (i64, i64) -> !llvm.ptr
      %703 = llvm.load %672 : !llvm.ptr -> i32
      %704 = arith.extsi %703 : i32 to i64
      %705 = llvm.getelementptr %658[%704] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      llvm.store %698, %705 : !llvm.ptr, !llvm.ptr
      %708 = llvm.load %672 : !llvm.ptr -> i32
      %709 = arith.extsi %708 : i32 to i64
      %710 = llvm.getelementptr %654[%709] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %707 = llvm.load %710 : !llvm.ptr -> !llvm.ptr
      %712 = llvm.load %672 : !llvm.ptr -> i32
      %713 = arith.extsi %712 : i32 to i64
      %714 = llvm.getelementptr %658[%713] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %711 = llvm.load %714 : !llvm.ptr -> !llvm.ptr
      %716 = llvm.load %672 : !llvm.ptr -> i32
      %717 = arith.extsi %716 : i32 to i64
      %718 = llvm.getelementptr %650[%717] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %715 = llvm.load %718 : !llvm.ptr -> f64
      func.call @rotate_points(%arg0, %arg1, %707, %711, %715) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, f64) -> ()
      %719 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %720 = arith.extf %719 : f32 to f64
      %721 = llvm.mlir.constant(1 : i64) : i64
      %722 = llvm.alloca %721 x f64 : (i64) -> !llvm.ptr
      llvm.store %720, %722 : f64, !llvm.ptr
      %723 = arith.constant 100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336 : f32
      %724 = arith.negf %723 : f32
      %725 = arith.extf %724 : f32 to f64
      %726 = llvm.mlir.constant(1 : i64) : i64
      %727 = llvm.alloca %726 x f64 : (i64) -> !llvm.ptr
      llvm.store %725, %727 : f64, !llvm.ptr
      %728 = arith.constant 0 : i32
      %729 = llvm.mlir.constant(1 : i64) : i64
      %730 = llvm.alloca %729 x i32 : (i64) -> !llvm.ptr
      llvm.store %728, %730 : i32, !llvm.ptr
      cf.br ^bb111
      ^bb111:
      %731 = llvm.load %730 : !llvm.ptr -> i32
      %732 = arith.constant 5 : i32
      %733 = arith.cmpi slt, %731, %732 : i32
      cf.cond_br %733, ^bb112, ^bb113
      ^bb112:
        %736 = llvm.load %672 : !llvm.ptr -> i32
        %737 = arith.extsi %736 : i32 to i64
        %738 = llvm.getelementptr %658[%737] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
        %735 = llvm.load %738 : !llvm.ptr -> !llvm.ptr
        %739 = llvm.load %730 : !llvm.ptr -> i32
        %740 = arith.extsi %739 : i32 to i64
        %741 = llvm.getelementptr %735[%740] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %734 = llvm.load %741 : !llvm.ptr -> f64
        %742 = llvm.load %722 : !llvm.ptr -> f64
        %743 = arith.cmpf olt, %734, %742 : f64
        cf.cond_br %743, ^bb114, ^bb115
        ^bb114:
          %746 = llvm.load %672 : !llvm.ptr -> i32
          %747 = arith.extsi %746 : i32 to i64
          %748 = llvm.getelementptr %658[%747] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
          %745 = llvm.load %748 : !llvm.ptr -> !llvm.ptr
          %749 = llvm.load %730 : !llvm.ptr -> i32
          %750 = arith.extsi %749 : i32 to i64
          %751 = llvm.getelementptr %745[%750] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %744 = llvm.load %751 : !llvm.ptr -> f64
          llvm.store %744, %722 : f64, !llvm.ptr
          cf.br ^bb116
        ^bb115:
          cf.br ^bb116
        ^bb116:
        %754 = llvm.load %672 : !llvm.ptr -> i32
        %755 = arith.extsi %754 : i32 to i64
        %756 = llvm.getelementptr %654[%755] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
        %753 = llvm.load %756 : !llvm.ptr -> !llvm.ptr
        %757 = llvm.load %730 : !llvm.ptr -> i32
        %758 = arith.extsi %757 : i32 to i64
        %759 = llvm.getelementptr %753[%758] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %752 = llvm.load %759 : !llvm.ptr -> f64
        %760 = llvm.load %727 : !llvm.ptr -> f64
        %761 = arith.cmpf ogt, %752, %760 : f64
        cf.cond_br %761, ^bb117, ^bb118
        ^bb117:
          %764 = llvm.load %672 : !llvm.ptr -> i32
          %765 = arith.extsi %764 : i32 to i64
          %766 = llvm.getelementptr %654[%765] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
          %763 = llvm.load %766 : !llvm.ptr -> !llvm.ptr
          %767 = llvm.load %730 : !llvm.ptr -> i32
          %768 = arith.extsi %767 : i32 to i64
          %769 = llvm.getelementptr %763[%768] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %762 = llvm.load %769 : !llvm.ptr -> f64
          llvm.store %762, %727 : f64, !llvm.ptr
          cf.br ^bb119
        ^bb118:
          cf.br ^bb119
        ^bb119:
        %770 = llvm.load %730 : !llvm.ptr -> i32
        %771 = arith.constant 1 : i32
        %772 = arith.addi %770, %771 : i32
        llvm.store %772, %730 : i32, !llvm.ptr
        cf.br ^bb111
      ^bb113:
      %773 = llvm.load %722 : !llvm.ptr -> f64
      %774 = llvm.load %672 : !llvm.ptr -> i32
      %775 = arith.extsi %774 : i32 to i64
      %776 = llvm.getelementptr %662[%775] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %773, %776 : f64, !llvm.ptr
      %777 = llvm.load %727 : !llvm.ptr -> f64
      %778 = llvm.load %672 : !llvm.ptr -> i32
      %779 = arith.extsi %778 : i32 to i64
      %780 = llvm.getelementptr %666[%779] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %777, %780 : f64, !llvm.ptr
      %781 = llvm.load %672 : !llvm.ptr -> i32
      %782 = arith.constant 1 : i32
      %783 = arith.addi %781, %782 : i32
      llvm.store %783, %672 : i32, !llvm.ptr
      cf.br ^bb108
    ^bb110:
    %784 = arith.constant 0.0 : f32
    %785 = arith.extf %784 : f32 to f64
    %786 = llvm.mlir.constant(1 : i64) : i64
    %787 = llvm.alloca %786 x f64 : (i64) -> !llvm.ptr
    llvm.store %785, %787 : f64, !llvm.ptr
    %788 = arith.constant 2.0 : f32
    %789 = arith.extf %788 : f32 to f64
    %790 = llvm.mlir.constant(1 : i64) : i64
    %791 = llvm.alloca %790 x f64 : (i64) -> !llvm.ptr
    llvm.store %789, %791 : f64, !llvm.ptr
    %792 = arith.constant 1 : i32
    %793 = llvm.mlir.constant(1 : i64) : i64
    %794 = llvm.alloca %793 x i32 : (i64) -> !llvm.ptr
    llvm.store %792, %794 : i32, !llvm.ptr
    cf.br ^bb120
    ^bb120:
    %795 = llvm.load %794 : !llvm.ptr -> i32
    %796 = arith.constant 1 : i32
    %797 = arith.cmpi eq, %795, %796 : i32
    cf.cond_br %797, ^bb121, ^bb122
    ^bb121:
      %799 = llvm.load %791 : !llvm.ptr -> f64
      %800 = arith.constant 3 : i32
      %801 = arith.constant 22 : i32
      %798 = func.call @min_clearance(%arg0, %arg1, %654, %658, %662, %666, %650, %arg2, %799, %arg4, %800, %801) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32, f64, f64, i32, i32) -> f64
      %802 = arith.constant 0 : f32
      %803 = arith.negf %802 : f32
      %805 = arith.extf %803 : f32 to f64
      %804 = arith.cmpf olt, %798, %805 : f64
      cf.cond_br %804, ^bb123, ^bb124
      ^bb123:
        cf.br ^bb122
      ^bb124:
        cf.br ^bb125
      ^bb125:
      %806 = llvm.load %791 : !llvm.ptr -> f64
      %807 = arith.constant 1.3 : f32
      %809 = arith.extf %807 : f32 to f64
      %808 = arith.mulf %806, %809 : f64
      llvm.store %808, %791 : f64, !llvm.ptr
      %810 = llvm.load %791 : !llvm.ptr -> f64
      %811 = arith.constant 50.0 : f32
      %813 = arith.extf %811 : f32 to f64
      %812 = arith.cmpf ogt, %810, %813 : f64
      cf.cond_br %812, ^bb126, ^bb127
      ^bb126:
        cf.br ^bb122
      ^bb127:
        cf.br ^bb128
      ^bb128:
      cf.br ^bb120
    ^bb122:
    %814 = arith.constant 0 : i32
    %815 = llvm.mlir.constant(1 : i64) : i64
    %816 = llvm.alloca %815 x i32 : (i64) -> !llvm.ptr
    llvm.store %814, %816 : i32, !llvm.ptr
    cf.br ^bb129
    ^bb129:
    %817 = llvm.load %816 : !llvm.ptr -> i32
    %818 = arith.cmpi slt, %817, %arg3 : i32
    cf.cond_br %818, ^bb130, ^bb131
    ^bb130:
      %819 = llvm.load %787 : !llvm.ptr -> f64
      %820 = llvm.load %791 : !llvm.ptr -> f64
      %821 = arith.addf %819, %820 : f64
      %822 = arith.constant 0.5 : f32
      %824 = arith.extf %822 : f32 to f64
      %823 = arith.mulf %821, %824 : f64
      %826 = arith.constant 3 : i32
      %827 = arith.constant 22 : i32
      %825 = func.call @min_clearance(%arg0, %arg1, %654, %658, %662, %666, %650, %arg2, %823, %arg4, %826, %827) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32, f64, f64, i32, i32) -> f64
      %828 = arith.constant 0 : f32
      %829 = arith.negf %828 : f32
      %831 = arith.extf %829 : f32 to f64
      %830 = arith.cmpf oge, %825, %831 : f64
      cf.cond_br %830, ^bb132, ^bb133
      ^bb132:
        llvm.store %823, %787 : f64, !llvm.ptr
        cf.br ^bb134
      ^bb133:
        llvm.store %823, %791 : f64, !llvm.ptr
        cf.br ^bb134
      ^bb134:
      %832 = llvm.load %816 : !llvm.ptr -> i32
      %833 = arith.constant 1 : i32
      %834 = arith.addi %832, %833 : i32
      llvm.store %834, %816 : i32, !llvm.ptr
      cf.br ^bb129
    ^bb131:
    %835 = arith.constant 0 : i32
    %836 = llvm.mlir.constant(1 : i64) : i64
    %837 = llvm.alloca %836 x i32 : (i64) -> !llvm.ptr
    llvm.store %835, %837 : i32, !llvm.ptr
    cf.br ^bb135
    ^bb135:
    %838 = llvm.load %837 : !llvm.ptr -> i32
    %839 = arith.cmpi slt, %838, %arg2 : i32
    cf.cond_br %839, ^bb136, ^bb137
    ^bb136:
      %842 = llvm.load %837 : !llvm.ptr -> i32
      %843 = arith.extsi %842 : i32 to i64
      %844 = llvm.getelementptr %654[%843] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %841 = llvm.load %844 : !llvm.ptr -> !llvm.ptr
      func.call @free(%841) : (!llvm.ptr) -> ()
      %847 = llvm.load %837 : !llvm.ptr -> i32
      %848 = arith.extsi %847 : i32 to i64
      %849 = llvm.getelementptr %658[%848] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %846 = llvm.load %849 : !llvm.ptr -> !llvm.ptr
      func.call @free(%846) : (!llvm.ptr) -> ()
      %850 = llvm.load %837 : !llvm.ptr -> i32
      %851 = arith.constant 1 : i32
      %852 = arith.addi %850, %851 : i32
      llvm.store %852, %837 : i32, !llvm.ptr
      cf.br ^bb135
    ^bb137:
    func.call @free(%650) : (!llvm.ptr) -> ()
    func.call @free(%654) : (!llvm.ptr) -> ()
    func.call @free(%658) : (!llvm.ptr) -> ()
    func.call @free(%662) : (!llvm.ptr) -> ()
    func.call @free(%666) : (!llvm.ptr) -> ()
    %858 = llvm.load %787 : !llvm.ptr -> f64
    func.return %858 : f64
  }
  func.func @objective(%arg0: f64, %arg1: i32, %arg2: i32, %arg3: f64) -> f64 {
    %860 = arith.constant 5 : i32
    %861 = arith.constant 8 : i32
    %862 = arith.extsi %860 : i32 to i64
    %863 = arith.extsi %861 : i32 to i64
    %859 = func.call @calloc(%862, %863) : (i64, i64) -> !llvm.ptr
    %865 = arith.constant 5 : i32
    %866 = arith.constant 8 : i32
    %867 = arith.extsi %865 : i32 to i64
    %868 = arith.extsi %866 : i32 to i64
    %864 = func.call @calloc(%867, %868) : (i64, i64) -> !llvm.ptr
    %869 = func.call @build_unit_pentagon(%arg0, %859, %864) : (f64, !llvm.ptr, !llvm.ptr) -> i32
    %870 = arith.constant 0 : i32
    %871 = arith.cmpi eq, %869, %870 : i32
    cf.cond_br %871, ^bb138, ^bb139
    ^bb138:
      func.call @free(%859) : (!llvm.ptr) -> ()
      func.call @free(%864) : (!llvm.ptr) -> ()
      %874 = arith.constant 1.0 : f32
      %875 = arith.negf %874 : f32
      %876 = arith.extf %875 : f32 to f64
      func.return %876 : f64
    ^bb139:
      cf.br ^bb140
    ^bb140:
    %877 = func.call @max_scale(%859, %864, %arg1, %arg2, %arg3) : (!llvm.ptr, !llvm.ptr, i32, i32, f64) -> f64
    %878 = func.call @base_area(%arg0) : (f64) -> f64
    %879 = arith.mulf %878, %877 : f64
    %880 = arith.mulf %879, %877 : f64
    func.call @free(%859) : (!llvm.ptr) -> ()
    func.call @free(%864) : (!llvm.ptr) -> ()
    func.return %880 : f64
  }
  // Module static: cache_keys
  llvm.mlir.global internal @cache_keys() {addr_space = 0 : i32} : !llvm.ptr {
    %883 = llvm.mlir.zero : !llvm.ptr
    llvm.return %883 : !llvm.ptr
  }
  // Module static: cache_vals
  llvm.mlir.global internal @cache_vals() {addr_space = 0 : i32} : !llvm.ptr {
    %884 = llvm.mlir.zero : !llvm.ptr
    llvm.return %884 : !llvm.ptr
  }
  // Module static: cache_count
  llvm.mlir.global internal @cache_count(0 : i32) : i32
  func.func @cache_get(%arg0: f64) -> f64 {
    %885 = arith.constant 0 : i32
    %886 = llvm.mlir.constant(1 : i64) : i64
    %887 = llvm.alloca %886 x i32 : (i64) -> !llvm.ptr
    llvm.store %885, %887 : i32, !llvm.ptr
    cf.br ^bb141
    ^bb141:
    %888 = llvm.load %887 : !llvm.ptr -> i32
    %889 = llvm.mlir.addressof @cache_count : !llvm.ptr
    %890 = llvm.load %889 : !llvm.ptr -> i32
    %891 = arith.cmpi slt, %888, %890 : i32
    cf.cond_br %891, ^bb142, ^bb143
    ^bb142:
      %893 = llvm.mlir.addressof @cache_keys : !llvm.ptr
      %894 = llvm.load %893 : !llvm.ptr -> !llvm.ptr
      %895 = llvm.load %887 : !llvm.ptr -> i32
      %896 = arith.extsi %895 : i32 to i64
      %897 = llvm.getelementptr %894[%896] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %892 = llvm.load %897 : !llvm.ptr -> f64
      %898 = arith.subf %892, %arg0 : f64
      %899 = math.absf %898 : f64
      %900 = arith.constant 0 : f32
      %902 = arith.extf %900 : f32 to f64
      %901 = arith.cmpf olt, %899, %902 : f64
      cf.cond_br %901, ^bb144, ^bb145
      ^bb144:
        %904 = llvm.mlir.addressof @cache_vals : !llvm.ptr
        %905 = llvm.load %904 : !llvm.ptr -> !llvm.ptr
        %906 = llvm.load %887 : !llvm.ptr -> i32
        %907 = arith.extsi %906 : i32 to i64
        %908 = llvm.getelementptr %905[%907] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %903 = llvm.load %908 : !llvm.ptr -> f64
        func.return %903 : f64
      ^bb145:
        cf.br ^bb146
      ^bb146:
      %909 = llvm.load %887 : !llvm.ptr -> i32
      %910 = arith.constant 1 : i32
      %911 = arith.addi %909, %910 : i32
      llvm.store %911, %887 : i32, !llvm.ptr
      cf.br ^bb141
    ^bb143:
    %913 = arith.constant 1400 : i32
    %914 = arith.constant 55 : i32
    %915 = arith.constant 0 : f32
    %916 = arith.extf %915 : f32 to f64
    %912 = func.call @objective(%arg0, %913, %914, %916) : (f64, i32, i32, f64) -> f64
    %917 = llvm.mlir.addressof @cache_count : !llvm.ptr
    %918 = llvm.load %917 : !llvm.ptr -> i32
    %919 = arith.constant 10000 : i32
    %920 = arith.cmpi slt, %918, %919 : i32
    cf.cond_br %920, ^bb147, ^bb148
    ^bb147:
      %921 = llvm.mlir.addressof @cache_keys : !llvm.ptr
      %922 = llvm.load %921 : !llvm.ptr -> !llvm.ptr
      %923 = llvm.mlir.addressof @cache_count : !llvm.ptr
      %924 = llvm.load %923 : !llvm.ptr -> i32
      %925 = arith.extsi %924 : i32 to i64
      %926 = llvm.getelementptr %922[%925] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %arg0, %926 : f64, !llvm.ptr
      %927 = llvm.mlir.addressof @cache_vals : !llvm.ptr
      %928 = llvm.load %927 : !llvm.ptr -> !llvm.ptr
      %929 = llvm.mlir.addressof @cache_count : !llvm.ptr
      %930 = llvm.load %929 : !llvm.ptr -> i32
      %931 = arith.extsi %930 : i32 to i64
      %932 = llvm.getelementptr %928[%931] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %912, %932 : f64, !llvm.ptr
      %933 = llvm.mlir.addressof @cache_count : !llvm.ptr
      %934 = llvm.load %933 : !llvm.ptr -> i32
      %935 = arith.constant 1 : i32
      %936 = arith.addi %934, %935 : i32
      %937 = llvm.mlir.addressof @cache_count : !llvm.ptr
      llvm.store %936, %937 : i32, !llvm.ptr
      cf.br ^bb149
    ^bb148:
      cf.br ^bb149
    ^bb149:
    func.return %912 : f64
  }
  func.func @golden_max_mid(%arg0: f64, %arg1: f64, %arg2: i32) -> f64 {
    %938 = arith.subf %arg1, %arg0 : f64
    %939 = llvm.mlir.addressof @PHI : !llvm.ptr
    %940 = llvm.load %939 : !llvm.ptr -> f64
    %941 = arith.mulf %938, %940 : f64
    %942 = arith.subf %arg1, %941 : f64
    %943 = llvm.mlir.constant(1 : i64) : i64
    %944 = llvm.alloca %943 x f64 : (i64) -> !llvm.ptr
    llvm.store %942, %944 : f64, !llvm.ptr
    %945 = arith.subf %arg1, %arg0 : f64
    %946 = llvm.mlir.addressof @PHI : !llvm.ptr
    %947 = llvm.load %946 : !llvm.ptr -> f64
    %948 = arith.mulf %945, %947 : f64
    %949 = arith.addf %arg0, %948 : f64
    %950 = llvm.mlir.constant(1 : i64) : i64
    %951 = llvm.alloca %950 x f64 : (i64) -> !llvm.ptr
    llvm.store %949, %951 : f64, !llvm.ptr
    %953 = llvm.load %944 : !llvm.ptr -> f64
    %952 = func.call @cache_get(%953) : (f64) -> f64
    %954 = llvm.mlir.constant(1 : i64) : i64
    %955 = llvm.alloca %954 x f64 : (i64) -> !llvm.ptr
    llvm.store %952, %955 : f64, !llvm.ptr
    %957 = llvm.load %951 : !llvm.ptr -> f64
    %956 = func.call @cache_get(%957) : (f64) -> f64
    %958 = llvm.mlir.constant(1 : i64) : i64
    %959 = llvm.alloca %958 x f64 : (i64) -> !llvm.ptr
    llvm.store %956, %959 : f64, !llvm.ptr
    %960 = arith.constant 0 : i32
    %961 = llvm.mlir.constant(1 : i64) : i64
    %962 = llvm.alloca %961 x i32 : (i64) -> !llvm.ptr
    llvm.store %960, %962 : i32, !llvm.ptr
    cf.br ^bb150(%arg1, %arg0 : f64, f64)
    ^bb150(%963: f64, %964: f64):
    %965 = llvm.load %962 : !llvm.ptr -> i32
    %966 = arith.cmpi slt, %965, %arg2 : i32
    cf.cond_br %966, ^bb151(%963, %964 : f64, f64), ^bb152(%963, %964 : f64, f64)
    ^bb151(%967: f64, %968: f64):
      %969 = llvm.load %955 : !llvm.ptr -> f64
      %970 = llvm.load %959 : !llvm.ptr -> f64
      %971 = arith.cmpf ogt, %969, %970 : f64
      %972, %973 = scf.if %971 -> (f64, f64) {
        %974 = llvm.load %951 : !llvm.ptr -> f64
        %975 = llvm.load %944 : !llvm.ptr -> f64
        llvm.store %975, %951 : f64, !llvm.ptr
        %976 = llvm.load %955 : !llvm.ptr -> f64
        llvm.store %976, %959 : f64, !llvm.ptr
        %977 = arith.subf %974, %968 : f64
        %978 = llvm.mlir.addressof @PHI : !llvm.ptr
        %979 = llvm.load %978 : !llvm.ptr -> f64
        %980 = arith.mulf %977, %979 : f64
        %981 = arith.subf %974, %980 : f64
        llvm.store %981, %944 : f64, !llvm.ptr
        %983 = llvm.load %944 : !llvm.ptr -> f64
        %982 = func.call @cache_get(%983) : (f64) -> f64
        llvm.store %982, %955 : f64, !llvm.ptr
        scf.yield %974, %968 : f64, f64
      } else {
        %984 = llvm.load %944 : !llvm.ptr -> f64
        %985 = llvm.load %951 : !llvm.ptr -> f64
        llvm.store %985, %944 : f64, !llvm.ptr
        %986 = llvm.load %959 : !llvm.ptr -> f64
        llvm.store %986, %955 : f64, !llvm.ptr
        %987 = arith.subf %967, %984 : f64
        %988 = llvm.mlir.addressof @PHI : !llvm.ptr
        %989 = llvm.load %988 : !llvm.ptr -> f64
        %990 = arith.mulf %987, %989 : f64
        %991 = arith.addf %984, %990 : f64
        llvm.store %991, %951 : f64, !llvm.ptr
        %993 = llvm.load %951 : !llvm.ptr -> f64
        %992 = func.call @cache_get(%993) : (f64) -> f64
        llvm.store %992, %959 : f64, !llvm.ptr
        scf.yield %967, %984 : f64, f64
      }
      %994 = llvm.load %962 : !llvm.ptr -> i32
      %995 = arith.constant 1 : i32
      %996 = arith.addi %994, %995 : i32
      llvm.store %996, %962 : i32, !llvm.ptr
      cf.br ^bb150(%972, %973 : f64, f64)
    ^bb152(%997: f64, %998: f64):
    %999 = llvm.load %955 : !llvm.ptr -> f64
    %1000 = llvm.load %959 : !llvm.ptr -> f64
    %1001 = arith.cmpf ogt, %999, %1000 : f64
    cf.cond_br %1001, ^bb153, ^bb154
    ^bb153:
      %1002 = llvm.load %944 : !llvm.ptr -> f64
      func.return %1002 : f64
    ^bb154:
      cf.br ^bb155
    ^bb155:
    %1003 = llvm.load %951 : !llvm.ptr -> f64
    func.return %1003 : f64
  }
  func.func @main() -> i32 {
    %1004 = arith.constant 0.75 : f32
    %1005 = arith.extf %1004 : f32 to f64
    %1006 = arith.constant 1.05 : f32
    %1007 = arith.extf %1006 : f32 to f64
    %1008 = arith.constant 240 : i32
    %1009 = arith.constant 0.0 : f32
    %1010 = arith.extf %1009 : f32 to f64
    %1011 = llvm.mlir.constant(1 : i64) : i64
    %1012 = llvm.alloca %1011 x f64 : (i64) -> !llvm.ptr
    llvm.store %1010, %1012 : f64, !llvm.ptr
    %1013 = arith.constant 1.0 : f32
    %1014 = arith.negf %1013 : f32
    %1015 = arith.extf %1014 : f32 to f64
    %1016 = llvm.mlir.constant(1 : i64) : i64
    %1017 = llvm.alloca %1016 x f64 : (i64) -> !llvm.ptr
    llvm.store %1015, %1017 : f64, !llvm.ptr
    %1018 = arith.constant 0 : i32
    %1019 = llvm.mlir.constant(1 : i64) : i64
    %1020 = llvm.alloca %1019 x i32 : (i64) -> !llvm.ptr
    llvm.store %1018, %1020 : i32, !llvm.ptr
    cf.br ^bb156
    ^bb156:
    %1021 = llvm.load %1020 : !llvm.ptr -> i32
    %1022 = arith.cmpi sle, %1021, %1008 : i32
    cf.cond_br %1022, ^bb157, ^bb158
    ^bb157:
      %1023 = arith.subf %1007, %1005 : f64
      %1024 = llvm.load %1020 : !llvm.ptr -> i32
      %1025 = arith.sitofp %1024 : i32 to f64
      %1026 = arith.mulf %1023, %1025 : f64
      %1027 = arith.sitofp %1008 : i32 to f64
      %1028 = arith.divf %1026, %1027 : f64
      %1029 = arith.addf %1005, %1028 : f64
      %1031 = arith.constant 450 : i32
      %1032 = arith.constant 35 : i32
      %1033 = arith.constant 0 : f32
      %1034 = arith.extf %1033 : f32 to f64
      %1030 = func.call @objective(%1029, %1031, %1032, %1034) : (f64, i32, i32, f64) -> f64
      %1035 = llvm.load %1017 : !llvm.ptr -> f64
      %1036 = arith.cmpf ogt, %1030, %1035 : f64
      cf.cond_br %1036, ^bb159, ^bb160
      ^bb159:
        llvm.store %1030, %1017 : f64, !llvm.ptr
        llvm.store %1029, %1012 : f64, !llvm.ptr
        cf.br ^bb161
      ^bb160:
        cf.br ^bb161
      ^bb161:
      %1037 = llvm.load %1020 : !llvm.ptr -> i32
      %1038 = arith.constant 1 : i32
      %1039 = arith.addi %1037, %1038 : i32
      llvm.store %1039, %1020 : i32, !llvm.ptr
      cf.br ^bb156
    ^bb158:
    %1041 = arith.constant 10000 : i32
    %1042 = arith.constant 8 : i32
    %1043 = arith.extsi %1041 : i32 to i64
    %1044 = arith.extsi %1042 : i32 to i64
    %1040 = func.call @calloc(%1043, %1044) : (i64, i64) -> !llvm.ptr
    %1045 = llvm.mlir.addressof @cache_keys : !llvm.ptr
    llvm.store %1040, %1045 : !llvm.ptr, !llvm.ptr
    %1047 = arith.constant 10000 : i32
    %1048 = arith.constant 8 : i32
    %1049 = arith.extsi %1047 : i32 to i64
    %1050 = arith.extsi %1048 : i32 to i64
    %1046 = func.call @calloc(%1049, %1050) : (i64, i64) -> !llvm.ptr
    %1051 = llvm.mlir.addressof @cache_vals : !llvm.ptr
    llvm.store %1046, %1051 : !llvm.ptr, !llvm.ptr
    %1052 = arith.constant 0 : i32
    %1053 = llvm.mlir.addressof @cache_count : !llvm.ptr
    llvm.store %1052, %1053 : i32, !llvm.ptr
    %1054 = llvm.load %1012 : !llvm.ptr -> f64
    %1055 = arith.constant 0.02 : f32
    %1057 = arith.extf %1055 : f32 to f64
    %1056 = arith.subf %1054, %1057 : f64
    %1058 = llvm.load %1012 : !llvm.ptr -> f64
    %1059 = arith.constant 0.02 : f32
    %1061 = arith.extf %1059 : f32 to f64
    %1060 = arith.addf %1058, %1061 : f64
    %1063 = arith.constant 26 : i32
    %1062 = func.call @golden_max_mid(%1056, %1060, %1063) : (f64, f64, i32) -> f64
    %1064 = arith.constant 0.002 : f32
    %1066 = arith.extf %1064 : f32 to f64
    %1065 = arith.subf %1062, %1066 : f64
    %1067 = arith.constant 0.002 : f32
    %1069 = arith.extf %1067 : f32 to f64
    %1068 = arith.addf %1062, %1069 : f64
    %1071 = arith.constant 35 : i32
    %1070 = func.call @golden_max_mid(%1065, %1068, %1071) : (f64, f64, i32) -> f64
    %1073 = arith.constant 8000 : i32
    %1074 = arith.constant 75 : i32
    %1075 = arith.constant 0 : f32
    %1076 = arith.extf %1075 : f32 to f64
    %1072 = func.call @objective(%1070, %1073, %1074, %1076) : (f64, i32, i32, f64) -> f64
    %1078 = llvm.mlir.addressof @cache_keys : !llvm.ptr
    %1079 = llvm.load %1078 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1079) : (!llvm.ptr) -> ()
    %1081 = llvm.mlir.addressof @cache_vals : !llvm.ptr
    %1082 = llvm.load %1081 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1082) : (!llvm.ptr) -> ()
    %1083 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1084 = llvm.call @printf(%1083, %1072) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
    %1085 = arith.constant 0 : i32
    func.return %1085 : i32
  }
}