Problem 199

Uncovered area fraction after 10 Descartes circle iterations.

Answer0.00396087
Output0.00396087
StatusPASS
Native helperno
Runtime0 ms
Peak memory14800 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n)
Space complexityO(n^2)O(1)
ApproachFlow solutionNumerical iteration
VerdictSuboptimal

Flow source

# Project Euler 199
# Uncovered area fraction after 10 Descartes circle iterations.

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

function new_k(k1: f64, k2: f64, k3: f64) -> f64 {
    return k1 + k2 + k3 + 2.0 * sqrt(k1 * k2 + k1 * k3 + k2 * k3)
}

function main() -> i32 {
    let SQRT3: f64 = sqrt(3.0)
    let k_outer: f64 = 3.0 - 2.0 * SQRT3
    # gaps stored as triples; max gaps after 10 iters: 4 * 3^10 = 236196
    let MAX: i64 = 300000
    let g1: ptr<f64> = calloc(MAX, 8)
    let g2: ptr<f64> = calloc(MAX, 8)
    let g3: ptr<f64> = calloc(MAX, 8)
    let n1: ptr<f64> = calloc(MAX, 8)
    let n2: ptr<f64> = calloc(MAX, 8)
    let n3: ptr<f64> = calloc(MAX, 8)
    if g1 == null || g2 == null || g3 == null || n1 == null || n2 == null || n3 == null {
        return 1
    }
    let mut gc: i64 = 0
    g1[0] = 1.0; g2[0] = 1.0; g3[0] = 1.0; gc = 1
    let mut t: i64 = 0
    while t < 3 {
        g1[gc] = 1.0; g2[gc] = 1.0; g3[gc] = k_outer
        gc = gc + 1
        t = t + 1
    }
    let mut covered: f64 = 3.0
    let outer_area: f64 = 1.0 / (k_outer * k_outer)
    let mut iter: i32 = 0
    while iter < 10 {
        let mut nc: i64 = 0
        let mut i: i64 = 0
        while i < gc {
            let k4: f64 = new_k(g1[i], g2[i], g3[i])
            covered = covered + 1.0 / (k4 * k4)
            n1[nc] = g1[i]; n2[nc] = g2[i]; n3[nc] = k4; nc = nc + 1
            n1[nc] = g1[i]; n2[nc] = g3[i]; n3[nc] = k4; nc = nc + 1
            n1[nc] = g2[i]; n2[nc] = g3[i]; n3[nc] = k4; nc = nc + 1
            i = i + 1
        }
        # swap
        i = 0
        while i < nc {
            g1[i] = n1[i]
            g2[i] = n2[i]
            g3[i] = n3[i]
            i = i + 1
        }
        gc = nc
        iter = iter + 1
    }
    let frac: f64 = 1.0 - covered / outer_area
    printf("%.8f\n", frac)
    free(g1); free(g2); free(g3); free(n1); free(n2); free(n3)
    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 new_k_f64_f64_f64(double k1, double k2, double k3);
int32_t main(void);




double new_k_f64_f64_f64(double k1, double k2, double k3) {
    return (((k1 + k2) + k3) + (2.0 * sqrt((((k1 * k2) + (k1 * k3)) + (k2 * k3)))));
}

int32_t main(void) {
    double SQRT3 = sqrt(3.0);
    double k_outer = (3.0 - (2.0 * SQRT3));
    int64_t MAX = 300000;
    double* g1 = (double*)(calloc(MAX, 8));
    double* g2 = (double*)(calloc(MAX, 8));
    double* g3 = (double*)(calloc(MAX, 8));
    double* n1 = (double*)(calloc(MAX, 8));
    double* n2 = (double*)(calloc(MAX, 8));
    double* n3 = (double*)(calloc(MAX, 8));
    if ((((((g1 == NULL || g2 == NULL) || g3 == NULL) || n1 == NULL) || n2 == NULL) || n3 == NULL)) {
        return 1;
    }
    int64_t gc = 0;
    g1[0] = 1.0;
    g2[0] = 1.0;
    g3[0] = 1.0;
    gc = 1;
    int64_t t = 0;
    while (t < 3) {
        g1[gc] = 1.0;
        g2[gc] = 1.0;
        g3[gc] = k_outer;
        gc = (gc + 1);
        t = (t + 1);
    }
    double covered = 3.0;
    double outer_area = (1.0 / (k_outer * k_outer));
    int32_t iter = 0;
    while (iter < 10) {
        int64_t nc = 0;
        int64_t i = 0;
        while (i < gc) {
            double k4 = new_k_f64_f64_f64(g1[i], g2[i], g3[i]);
            covered = (covered + (1.0 / (k4 * k4)));
            n1[nc] = g1[i];
            n2[nc] = g2[i];
            n3[nc] = k4;
            nc = (nc + 1);
            n1[nc] = g1[i];
            n2[nc] = g3[i];
            n3[nc] = k4;
            nc = (nc + 1);
            n1[nc] = g2[i];
            n2[nc] = g3[i];
            n3[nc] = k4;
            nc = (nc + 1);
            i = (i + 1);
        }
        i = 0;
        while (i < nc) {
            g1[i] = n1[i];
            g2[i] = n2[i];
            g3[i] = n3[i];
            i = (i + 1);
        }
        gc = nc;
        iter = (iter + 1);
    }
    double frac = (1.0 - (covered / outer_area));
    printf("%.8f\n", frac);
    free(g1);
    free(g2);
    free(g3);
    free(n1);
    free(n2);
    free(n3);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%.8f\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @sqrt(f64) -> f64
  func.func @new_k(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 {
    %0 = arith.addf %arg0, %arg1 : f64
    %1 = arith.addf %0, %arg2 : f64
    %2 = arith.constant 2.0 : f32
    %3 = arith.mulf %arg0, %arg1 : f64
    %4 = arith.mulf %arg0, %arg2 : f64
    %5 = arith.addf %3, %4 : f64
    %6 = arith.mulf %arg1, %arg2 : f64
    %7 = arith.addf %5, %6 : f64
    %8 = math.sqrt %7 : f64
    %10 = arith.extf %2 : f32 to f64
    %9 = arith.mulf %10, %8 : f64
    %11 = arith.addf %1, %9 : f64
    func.return %11 : f64
  }
  func.func @main() -> i32 {
    %12 = arith.constant 3.0 : f32
    %13 = math.sqrt %12 : f32
    %14 = arith.extf %13 : f32 to f64
    %15 = arith.constant 3.0 : f32
    %16 = arith.constant 2.0 : f32
    %18 = arith.extf %16 : f32 to f64
    %17 = arith.mulf %18, %14 : f64
    %20 = arith.extf %15 : f32 to f64
    %19 = arith.subf %20, %17 : f64
    %21 = arith.constant 300000 : i32
    %22 = arith.extsi %21 : i32 to i64
    %24 = arith.constant 8 : i32
    %25 = arith.extsi %24 : i32 to i64
    %23 = func.call @calloc(%22, %25) : (i64, i64) -> !llvm.ptr
    %27 = arith.constant 8 : i32
    %28 = arith.extsi %27 : i32 to i64
    %26 = func.call @calloc(%22, %28) : (i64, i64) -> !llvm.ptr
    %30 = arith.constant 8 : i32
    %31 = arith.extsi %30 : i32 to i64
    %29 = func.call @calloc(%22, %31) : (i64, i64) -> !llvm.ptr
    %33 = arith.constant 8 : i32
    %34 = arith.extsi %33 : i32 to i64
    %32 = func.call @calloc(%22, %34) : (i64, i64) -> !llvm.ptr
    %36 = arith.constant 8 : i32
    %37 = arith.extsi %36 : i32 to i64
    %35 = func.call @calloc(%22, %37) : (i64, i64) -> !llvm.ptr
    %39 = arith.constant 8 : i32
    %40 = arith.extsi %39 : i32 to i64
    %38 = func.call @calloc(%22, %40) : (i64, i64) -> !llvm.ptr
    %41 = llvm.mlir.zero : !llvm.ptr
    %42 = llvm.icmp "eq" %23, %41 : !llvm.ptr
    %43 = scf.if %42 -> (i1) {
      %44 = arith.constant true
      scf.yield %44 : i1
    } else {
      %45 = llvm.mlir.zero : !llvm.ptr
      %46 = llvm.icmp "eq" %26, %45 : !llvm.ptr
      scf.yield %46 : i1
    }
    %47 = scf.if %43 -> (i1) {
      %48 = arith.constant true
      scf.yield %48 : i1
    } else {
      %49 = llvm.mlir.zero : !llvm.ptr
      %50 = llvm.icmp "eq" %29, %49 : !llvm.ptr
      scf.yield %50 : i1
    }
    %51 = scf.if %47 -> (i1) {
      %52 = arith.constant true
      scf.yield %52 : i1
    } else {
      %53 = llvm.mlir.zero : !llvm.ptr
      %54 = llvm.icmp "eq" %32, %53 : !llvm.ptr
      scf.yield %54 : i1
    }
    %55 = scf.if %51 -> (i1) {
      %56 = arith.constant true
      scf.yield %56 : i1
    } else {
      %57 = llvm.mlir.zero : !llvm.ptr
      %58 = llvm.icmp "eq" %35, %57 : !llvm.ptr
      scf.yield %58 : i1
    }
    %59 = scf.if %55 -> (i1) {
      %60 = arith.constant true
      scf.yield %60 : i1
    } else {
      %61 = llvm.mlir.zero : !llvm.ptr
      %62 = llvm.icmp "eq" %38, %61 : !llvm.ptr
      scf.yield %62 : i1
    }
    cf.cond_br %59, ^bb0, ^bb1
    ^bb0:
      %63 = arith.constant 1 : i32
      func.return %63 : i32
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %64 = arith.constant 0 : i32
    %65 = arith.extsi %64 : i32 to i64
    %66 = llvm.mlir.constant(1 : i64) : i64
    %67 = llvm.alloca %66 x i64 : (i64) -> !llvm.ptr
    llvm.store %65, %67 : i64, !llvm.ptr
    %68 = arith.constant 1.0 : f32
    %69 = arith.constant 0 : i32
    %70 = arith.extf %68 : f32 to f64
    %71 = arith.extsi %69 : i32 to i64
    %72 = llvm.getelementptr %23[%71] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %70, %72 : f64, !llvm.ptr
    %73 = arith.constant 1.0 : f32
    %74 = arith.constant 0 : i32
    %75 = arith.extf %73 : f32 to f64
    %76 = arith.extsi %74 : i32 to i64
    %77 = llvm.getelementptr %26[%76] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %75, %77 : f64, !llvm.ptr
    %78 = arith.constant 1.0 : f32
    %79 = arith.constant 0 : i32
    %80 = arith.extf %78 : f32 to f64
    %81 = arith.extsi %79 : i32 to i64
    %82 = llvm.getelementptr %29[%81] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %80, %82 : f64, !llvm.ptr
    %83 = arith.constant 1 : i32
    %84 = arith.extsi %83 : i32 to i64
    llvm.store %84, %67 : i64, !llvm.ptr
    %85 = arith.constant 0 : i32
    %86 = arith.extsi %85 : i32 to i64
    %87 = llvm.mlir.constant(1 : i64) : i64
    %88 = llvm.alloca %87 x i64 : (i64) -> !llvm.ptr
    llvm.store %86, %88 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %89 = llvm.load %88 : !llvm.ptr -> i64
    %90 = arith.constant 3 : i32
    %92 = arith.extsi %90 : i32 to i64
    %91 = arith.cmpi slt, %89, %92 : i64
    cf.cond_br %91, ^bb4, ^bb5
    ^bb4:
      %93 = arith.constant 1.0 : f32
      %94 = llvm.load %67 : !llvm.ptr -> i64
      %95 = arith.extf %93 : f32 to f64
      %96 = llvm.getelementptr %23[%94] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %95, %96 : f64, !llvm.ptr
      %97 = arith.constant 1.0 : f32
      %98 = llvm.load %67 : !llvm.ptr -> i64
      %99 = arith.extf %97 : f32 to f64
      %100 = llvm.getelementptr %26[%98] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %99, %100 : f64, !llvm.ptr
      %101 = llvm.load %67 : !llvm.ptr -> i64
      %102 = llvm.getelementptr %29[%101] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %19, %102 : f64, !llvm.ptr
      %103 = llvm.load %67 : !llvm.ptr -> i64
      %104 = arith.constant 1 : i32
      %106 = arith.extsi %104 : i32 to i64
      %105 = arith.addi %103, %106 : i64
      llvm.store %105, %67 : i64, !llvm.ptr
      %107 = llvm.load %88 : !llvm.ptr -> i64
      %108 = arith.constant 1 : i32
      %110 = arith.extsi %108 : i32 to i64
      %109 = arith.addi %107, %110 : i64
      llvm.store %109, %88 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %111 = arith.constant 3.0 : f32
    %112 = arith.extf %111 : f32 to f64
    %113 = llvm.mlir.constant(1 : i64) : i64
    %114 = llvm.alloca %113 x f64 : (i64) -> !llvm.ptr
    llvm.store %112, %114 : f64, !llvm.ptr
    %115 = arith.constant 1.0 : f32
    %116 = arith.mulf %19, %19 : f64
    %118 = arith.extf %115 : f32 to f64
    %117 = arith.divf %118, %116 : f64
    %119 = arith.constant 0 : i32
    %120 = llvm.mlir.constant(1 : i64) : i64
    %121 = llvm.alloca %120 x i32 : (i64) -> !llvm.ptr
    llvm.store %119, %121 : i32, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %122 = llvm.load %121 : !llvm.ptr -> i32
    %123 = arith.constant 10 : i32
    %124 = arith.cmpi slt, %122, %123 : i32
    cf.cond_br %124, ^bb7, ^bb8
    ^bb7:
      %125 = arith.constant 0 : i32
      %126 = arith.extsi %125 : i32 to i64
      %127 = llvm.mlir.constant(1 : i64) : i64
      %128 = llvm.alloca %127 x i64 : (i64) -> !llvm.ptr
      llvm.store %126, %128 : i64, !llvm.ptr
      %129 = arith.constant 0 : i32
      %130 = arith.extsi %129 : i32 to i64
      %131 = llvm.mlir.constant(1 : i64) : i64
      %132 = llvm.alloca %131 x i64 : (i64) -> !llvm.ptr
      llvm.store %130, %132 : i64, !llvm.ptr
      cf.br ^bb9
      ^bb9:
      %133 = llvm.load %132 : !llvm.ptr -> i64
      %134 = llvm.load %67 : !llvm.ptr -> i64
      %135 = arith.cmpi slt, %133, %134 : i64
      cf.cond_br %135, ^bb10, ^bb11
      ^bb10:
        %138 = llvm.load %132 : !llvm.ptr -> i64
        %139 = llvm.getelementptr %23[%138] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %137 = llvm.load %139 : !llvm.ptr -> f64
        %141 = llvm.load %132 : !llvm.ptr -> i64
        %142 = llvm.getelementptr %26[%141] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %140 = llvm.load %142 : !llvm.ptr -> f64
        %144 = llvm.load %132 : !llvm.ptr -> i64
        %145 = llvm.getelementptr %29[%144] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %143 = llvm.load %145 : !llvm.ptr -> f64
        %136 = func.call @new_k(%137, %140, %143) : (f64, f64, f64) -> f64
        %146 = llvm.load %114 : !llvm.ptr -> f64
        %147 = arith.constant 1.0 : f32
        %148 = arith.mulf %136, %136 : f64
        %150 = arith.extf %147 : f32 to f64
        %149 = arith.divf %150, %148 : f64
        %151 = arith.addf %146, %149 : f64
        llvm.store %151, %114 : f64, !llvm.ptr
        %153 = llvm.load %132 : !llvm.ptr -> i64
        %154 = llvm.getelementptr %23[%153] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %152 = llvm.load %154 : !llvm.ptr -> f64
        %155 = llvm.load %128 : !llvm.ptr -> i64
        %156 = llvm.getelementptr %32[%155] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %152, %156 : f64, !llvm.ptr
        %158 = llvm.load %132 : !llvm.ptr -> i64
        %159 = llvm.getelementptr %26[%158] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %157 = llvm.load %159 : !llvm.ptr -> f64
        %160 = llvm.load %128 : !llvm.ptr -> i64
        %161 = llvm.getelementptr %35[%160] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %157, %161 : f64, !llvm.ptr
        %162 = llvm.load %128 : !llvm.ptr -> i64
        %163 = llvm.getelementptr %38[%162] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %136, %163 : f64, !llvm.ptr
        %164 = llvm.load %128 : !llvm.ptr -> i64
        %165 = arith.constant 1 : i32
        %167 = arith.extsi %165 : i32 to i64
        %166 = arith.addi %164, %167 : i64
        llvm.store %166, %128 : i64, !llvm.ptr
        %169 = llvm.load %132 : !llvm.ptr -> i64
        %170 = llvm.getelementptr %23[%169] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %168 = llvm.load %170 : !llvm.ptr -> f64
        %171 = llvm.load %128 : !llvm.ptr -> i64
        %172 = llvm.getelementptr %32[%171] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %168, %172 : f64, !llvm.ptr
        %174 = llvm.load %132 : !llvm.ptr -> i64
        %175 = llvm.getelementptr %29[%174] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %173 = llvm.load %175 : !llvm.ptr -> f64
        %176 = llvm.load %128 : !llvm.ptr -> i64
        %177 = llvm.getelementptr %35[%176] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %173, %177 : f64, !llvm.ptr
        %178 = llvm.load %128 : !llvm.ptr -> i64
        %179 = llvm.getelementptr %38[%178] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %136, %179 : f64, !llvm.ptr
        %180 = llvm.load %128 : !llvm.ptr -> i64
        %181 = arith.constant 1 : i32
        %183 = arith.extsi %181 : i32 to i64
        %182 = arith.addi %180, %183 : i64
        llvm.store %182, %128 : i64, !llvm.ptr
        %185 = llvm.load %132 : !llvm.ptr -> i64
        %186 = llvm.getelementptr %26[%185] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %184 = llvm.load %186 : !llvm.ptr -> f64
        %187 = llvm.load %128 : !llvm.ptr -> i64
        %188 = llvm.getelementptr %32[%187] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %184, %188 : f64, !llvm.ptr
        %190 = llvm.load %132 : !llvm.ptr -> i64
        %191 = llvm.getelementptr %29[%190] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %189 = llvm.load %191 : !llvm.ptr -> f64
        %192 = llvm.load %128 : !llvm.ptr -> i64
        %193 = llvm.getelementptr %35[%192] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %189, %193 : f64, !llvm.ptr
        %194 = llvm.load %128 : !llvm.ptr -> i64
        %195 = llvm.getelementptr %38[%194] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %136, %195 : f64, !llvm.ptr
        %196 = llvm.load %128 : !llvm.ptr -> i64
        %197 = arith.constant 1 : i32
        %199 = arith.extsi %197 : i32 to i64
        %198 = arith.addi %196, %199 : i64
        llvm.store %198, %128 : i64, !llvm.ptr
        %200 = llvm.load %132 : !llvm.ptr -> i64
        %201 = arith.constant 1 : i32
        %203 = arith.extsi %201 : i32 to i64
        %202 = arith.addi %200, %203 : i64
        llvm.store %202, %132 : i64, !llvm.ptr
        cf.br ^bb9
      ^bb11:
      %204 = arith.constant 0 : i32
      %205 = arith.extsi %204 : i32 to i64
      llvm.store %205, %132 : i64, !llvm.ptr
      cf.br ^bb12
      ^bb12:
      %206 = llvm.load %132 : !llvm.ptr -> i64
      %207 = llvm.load %128 : !llvm.ptr -> i64
      %208 = arith.cmpi slt, %206, %207 : i64
      cf.cond_br %208, ^bb13, ^bb14
      ^bb13:
        %210 = llvm.load %132 : !llvm.ptr -> i64
        %211 = llvm.getelementptr %32[%210] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %209 = llvm.load %211 : !llvm.ptr -> f64
        %212 = llvm.load %132 : !llvm.ptr -> i64
        %213 = llvm.getelementptr %23[%212] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %209, %213 : f64, !llvm.ptr
        %215 = llvm.load %132 : !llvm.ptr -> i64
        %216 = llvm.getelementptr %35[%215] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %214 = llvm.load %216 : !llvm.ptr -> f64
        %217 = llvm.load %132 : !llvm.ptr -> i64
        %218 = llvm.getelementptr %26[%217] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %214, %218 : f64, !llvm.ptr
        %220 = llvm.load %132 : !llvm.ptr -> i64
        %221 = llvm.getelementptr %38[%220] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %219 = llvm.load %221 : !llvm.ptr -> f64
        %222 = llvm.load %132 : !llvm.ptr -> i64
        %223 = llvm.getelementptr %29[%222] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        llvm.store %219, %223 : f64, !llvm.ptr
        %224 = llvm.load %132 : !llvm.ptr -> i64
        %225 = arith.constant 1 : i32
        %227 = arith.extsi %225 : i32 to i64
        %226 = arith.addi %224, %227 : i64
        llvm.store %226, %132 : i64, !llvm.ptr
        cf.br ^bb12
      ^bb14:
      %228 = llvm.load %128 : !llvm.ptr -> i64
      llvm.store %228, %67 : i64, !llvm.ptr
      %229 = llvm.load %121 : !llvm.ptr -> i32
      %230 = arith.constant 1 : i32
      %231 = arith.addi %229, %230 : i32
      llvm.store %231, %121 : i32, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %232 = arith.constant 1.0 : f32
    %233 = llvm.load %114 : !llvm.ptr -> f64
    %234 = arith.divf %233, %117 : f64
    %236 = arith.extf %232 : f32 to f64
    %235 = arith.subf %236, %234 : f64
    %237 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %238 = llvm.call @printf(%237, %235) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
    func.call @free(%23) : (!llvm.ptr) -> ()
    func.call @free(%26) : (!llvm.ptr) -> ()
    func.call @free(%29) : (!llvm.ptr) -> ()
    func.call @free(%32) : (!llvm.ptr) -> ()
    func.call @free(%35) : (!llvm.ptr) -> ()
    func.call @free(%38) : (!llvm.ptr) -> ()
    %245 = arith.constant 0 : i32
    func.return %245 : i32
  }
}