Problem 471

Triangle Inscribed in Ellipse — G(10^11) via harmonic closed forms.

Answer1.895093981e31
Output1.895093981e31
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(1) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(1)O(n^2)
Space complexityO(1)O(n^2)
ApproachFlow solutionBottom-up DP
VerdictOptimal

Flow source

# Project Euler 471
# Triangle Inscribed in Ellipse — G(10^11) via harmonic closed forms.

extern {
    function log(x: f64) -> f64
    function log10(x: f64) -> f64
    function exp(x: f64) -> f64
    function floor(x: f64) -> f64
    function pow(x: f64, y: f64) -> f64
}

function harmonic(n: i64) -> f64 {
    if n <= 0 { return 0.0 }
    let N: f64 = n as f64
    let inv: f64 = 1.0 / N
    let inv2: f64 = inv * inv
    let inv4: f64 = inv2 * inv2
    let inv6: f64 = inv4 * inv2
    let inv8: f64 = inv4 * inv4
    let inv10: f64 = inv8 * inv2
    let GAMMA: f64 = 0.5772156649015328606
    return log(N) + GAMMA + inv / 2.0 - inv2 / 12.0 + inv4 / 120.0 - inv6 / 252.0 + inv8 / 240.0 - inv10 / 132.0
}

function main() -> i32 {
    let n: i64 = 100000000000
    let ne: i64 = n / 2
    let no: i64 = (n - 1) / 2
    # P = 3*(T2(ne)-T1(ne)) + 3*T2(no) + 2*T1(no)
    let T1ne: f64 = (ne as f64) * ((ne + 1) as f64) / 2.0
    let T2ne: f64 = (ne as f64) * ((ne + 1) as f64) * ((2 * ne + 1) as f64) / 6.0
    let T1no: f64 = (no as f64) * ((no + 1) as f64) / 2.0
    let T2no: f64 = (no as f64) * ((no + 1) as f64) * ((2 * no + 1) as f64) / 6.0
    let P: f64 = 3.0 * (T2ne - T1ne) + 3.0 * T2no + 2.0 * T1no

    let mA: i64 = n - 1
    let HA: f64 = harmonic(mA)
    let md: f64 = mA as f64
    let S0A: f64 = (md + 1.0) * HA - md
    let S1A: f64 = (md * (md + 1.0) / 2.0) * HA - md * (md - 1.0) / 4.0
    let S2A: f64 = (md * (md + 1.0) * (2.0 * md + 1.0) / 6.0) * HA - md * (4.0 * md * md - 3.0 * md - 1.0) / 36.0
    let A: f64 = S2A + 2.0 * S1A + S0A - 4.0

    let m: i64 = ne
    let Hm: f64 = harmonic(m)
    let m1: i64 = m - 1
    let Hm1: f64 = harmonic(m1)
    let md1: f64 = m1 as f64
    let S0: f64 = (md1 + 1.0) * Hm1 - md1
    let S1: f64 = (md1 * (md1 + 1.0) / 2.0) * Hm1 - md1 * (md1 - 1.0) / 4.0
    let S2: f64 = (md1 * (md1 + 1.0) * (2.0 * md1 + 1.0) / 6.0) * Hm1 - md1 * (4.0 * md1 * md1 - 3.0 * md1 - 1.0) / 36.0
    let B: f64 = 8.0 * S2 + 4.0 * S1 + S0 - 4.0 + (4.0 * (m as f64) * (m as f64)) * Hm

    let ans: f64 = P - A + B
    let log10e: f64 = log10(exp(1.0))
    let log10x: f64 = log(ans) * log10e
    let expv: i64 = floor(log10x) as i64
    let frac: f64 = log10x - (expv as f64)
    let mut mant: f64 = pow(10.0, frac)
    let mut mant_r: f64 = floor(mant * 1000000000.0 + 0.5) / 1000000000.0
    let mut exp_out: i64 = expv
    if mant_r >= 10.0 {
        mant_r = mant_r / 10.0
        exp_out = exp_out + 1
    }
    printf("%.9fe%lld\n", mant_r, exp_out)
    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 harmonic_i64(int64_t n);
int32_t main(void);






double harmonic_i64(int64_t n) {
    if (n <= 0) {
        return 0.0;
    }
    double N = ((double)(n));
    double inv = (1.0 / N);
    double inv2 = (inv * inv);
    double inv4 = (inv2 * inv2);
    double inv6 = (inv4 * inv2);
    double inv8 = (inv4 * inv4);
    double inv10 = (inv8 * inv2);
    double GAMMA = 0.5772156649015328606;
    return (((((((log(N) + GAMMA) + (inv / 2.0)) - (inv2 / 12.0)) + (inv4 / 120.0)) - (inv6 / 252.0)) + (inv8 / 240.0)) - (inv10 / 132.0));
}

int32_t main(void) {
    int64_t n = 100000000000;
    int64_t ne = FLOW_CHECKED_DIV((n), (2));
    int64_t no = FLOW_CHECKED_DIV(((n - 1)), (2));
    double T1ne = ((((double)(ne)) * ((double)((ne + 1)))) / 2.0);
    double T2ne = (((((double)(ne)) * ((double)((ne + 1)))) * ((double)(((2 * ne) + 1)))) / 6.0);
    double T1no = ((((double)(no)) * ((double)((no + 1)))) / 2.0);
    double T2no = (((((double)(no)) * ((double)((no + 1)))) * ((double)(((2 * no) + 1)))) / 6.0);
    double P = (((3.0 * (T2ne - T1ne)) + (3.0 * T2no)) + (2.0 * T1no));
    int64_t mA = (n - 1);
    double HA = harmonic_i64(mA);
    double md = ((double)(mA));
    double S0A = (((md + 1.0) * HA) - md);
    double S1A = ((((md * (md + 1.0)) / 2.0) * HA) - ((md * (md - 1.0)) / 4.0));
    double S2A = (((((md * (md + 1.0)) * ((2.0 * md) + 1.0)) / 6.0) * HA) - ((md * ((((4.0 * md) * md) - (3.0 * md)) - 1.0)) / 36.0));
    double A = (((S2A + (2.0 * S1A)) + S0A) - 4.0);
    int64_t m = ne;
    double Hm = harmonic_i64(m);
    int64_t m1 = (m - 1);
    double Hm1 = harmonic_i64(m1);
    double md1 = ((double)(m1));
    double S0 = (((md1 + 1.0) * Hm1) - md1);
    double S1 = ((((md1 * (md1 + 1.0)) / 2.0) * Hm1) - ((md1 * (md1 - 1.0)) / 4.0));
    double S2 = (((((md1 * (md1 + 1.0)) * ((2.0 * md1) + 1.0)) / 6.0) * Hm1) - ((md1 * ((((4.0 * md1) * md1) - (3.0 * md1)) - 1.0)) / 36.0));
    double B = (((((8.0 * S2) + (4.0 * S1)) + S0) - 4.0) + (((4.0 * ((double)(m))) * ((double)(m))) * Hm));
    double ans = ((P - A) + B);
    double log10e = log10(exp(1.0));
    double log10x = (log(ans) * log10e);
    int64_t expv = ((int64_t)(floor(log10x)));
    double frac = (log10x - ((double)(expv)));
    double mant = pow(10.0, frac);
    double mant_r = (floor(((mant * 1000000000.0) + 0.5)) / 1000000000.0);
    int64_t exp_out = expv;
    if (mant_r >= 10.0) {
        mant_r = (mant_r / 10.0);
        exp_out = (exp_out + 1);
    }
    printf("%.9fe%lld\n", mant_r, exp_out);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%.9fe%lld\n\00") {addr_space = 0 : i32} : !llvm.array<11 x i8>
  func.func private @log(f64) -> f64
  func.func private @log10(f64) -> f64
  func.func private @exp(f64) -> f64
  func.func private @floor(f64) -> f64
  func.func private @pow(f64, f64) -> f64
  func.func @harmonic(%arg0: i64) -> f64 {
    %0 = arith.constant 0 : i32
    %2 = arith.extsi %0 : i32 to i64
    %1 = arith.cmpi sle, %arg0, %2 : i64
    cf.cond_br %1, ^bb0, ^bb1
    ^bb0:
      %3 = arith.constant 0.0 : f32
      %4 = arith.extf %3 : f32 to f64
      func.return %4 : f64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %5 = arith.sitofp %arg0 : i64 to f64
    %6 = arith.constant 1.0 : f32
    %8 = arith.extf %6 : f32 to f64
    %7 = arith.divf %8, %5 : f64
    %9 = arith.mulf %7, %7 : f64
    %10 = arith.mulf %9, %9 : f64
    %11 = arith.mulf %10, %9 : f64
    %12 = arith.mulf %10, %10 : f64
    %13 = arith.mulf %12, %9 : f64
    %14 = arith.constant 0.5772156649015328606 : f32
    %15 = arith.extf %14 : f32 to f64
    %16 = math.log %5 : f64
    %17 = arith.addf %16, %15 : f64
    %18 = arith.constant 2.0 : f32
    %20 = arith.extf %18 : f32 to f64
    %19 = arith.divf %7, %20 : f64
    %21 = arith.addf %17, %19 : f64
    %22 = arith.constant 12.0 : f32
    %24 = arith.extf %22 : f32 to f64
    %23 = arith.divf %9, %24 : f64
    %25 = arith.subf %21, %23 : f64
    %26 = arith.constant 120.0 : f32
    %28 = arith.extf %26 : f32 to f64
    %27 = arith.divf %10, %28 : f64
    %29 = arith.addf %25, %27 : f64
    %30 = arith.constant 252.0 : f32
    %32 = arith.extf %30 : f32 to f64
    %31 = arith.divf %11, %32 : f64
    %33 = arith.subf %29, %31 : f64
    %34 = arith.constant 240.0 : f32
    %36 = arith.extf %34 : f32 to f64
    %35 = arith.divf %12, %36 : f64
    %37 = arith.addf %33, %35 : f64
    %38 = arith.constant 132.0 : f32
    %40 = arith.extf %38 : f32 to f64
    %39 = arith.divf %13, %40 : f64
    %41 = arith.subf %37, %39 : f64
    func.return %41 : f64
  }
  func.func @main() -> i32 {
    %42 = arith.constant 95705032704 : i32
    %43 = arith.extsi %42 : i32 to i64
    %44 = arith.constant 2 : i32
    %46 = arith.extsi %44 : i32 to i64
    %45 = arith.divsi %43, %46 : i64
    %47 = arith.constant 1 : i32
    %49 = arith.extsi %47 : i32 to i64
    %48 = arith.subi %43, %49 : i64
    %50 = arith.constant 2 : i32
    %52 = arith.extsi %50 : i32 to i64
    %51 = arith.divsi %48, %52 : i64
    %53 = arith.sitofp %45 : i64 to f64
    %54 = arith.constant 1 : i32
    %56 = arith.extsi %54 : i32 to i64
    %55 = arith.addi %45, %56 : i64
    %57 = arith.sitofp %55 : i64 to f64
    %58 = arith.mulf %53, %57 : f64
    %59 = arith.constant 2.0 : f32
    %61 = arith.extf %59 : f32 to f64
    %60 = arith.divf %58, %61 : f64
    %62 = arith.sitofp %45 : i64 to f64
    %63 = arith.constant 1 : i32
    %65 = arith.extsi %63 : i32 to i64
    %64 = arith.addi %45, %65 : i64
    %66 = arith.sitofp %64 : i64 to f64
    %67 = arith.mulf %62, %66 : f64
    %68 = arith.constant 2 : i32
    %70 = arith.extsi %68 : i32 to i64
    %69 = arith.muli %70, %45 : i64
    %71 = arith.constant 1 : i32
    %73 = arith.extsi %71 : i32 to i64
    %72 = arith.addi %69, %73 : i64
    %74 = arith.sitofp %72 : i64 to f64
    %75 = arith.mulf %67, %74 : f64
    %76 = arith.constant 6.0 : f32
    %78 = arith.extf %76 : f32 to f64
    %77 = arith.divf %75, %78 : f64
    %79 = arith.sitofp %51 : i64 to f64
    %80 = arith.constant 1 : i32
    %82 = arith.extsi %80 : i32 to i64
    %81 = arith.addi %51, %82 : i64
    %83 = arith.sitofp %81 : i64 to f64
    %84 = arith.mulf %79, %83 : f64
    %85 = arith.constant 2.0 : f32
    %87 = arith.extf %85 : f32 to f64
    %86 = arith.divf %84, %87 : f64
    %88 = arith.sitofp %51 : i64 to f64
    %89 = arith.constant 1 : i32
    %91 = arith.extsi %89 : i32 to i64
    %90 = arith.addi %51, %91 : i64
    %92 = arith.sitofp %90 : i64 to f64
    %93 = arith.mulf %88, %92 : f64
    %94 = arith.constant 2 : i32
    %96 = arith.extsi %94 : i32 to i64
    %95 = arith.muli %96, %51 : i64
    %97 = arith.constant 1 : i32
    %99 = arith.extsi %97 : i32 to i64
    %98 = arith.addi %95, %99 : i64
    %100 = arith.sitofp %98 : i64 to f64
    %101 = arith.mulf %93, %100 : f64
    %102 = arith.constant 6.0 : f32
    %104 = arith.extf %102 : f32 to f64
    %103 = arith.divf %101, %104 : f64
    %105 = arith.constant 3.0 : f32
    %106 = arith.subf %77, %60 : f64
    %108 = arith.extf %105 : f32 to f64
    %107 = arith.mulf %108, %106 : f64
    %109 = arith.constant 3.0 : f32
    %111 = arith.extf %109 : f32 to f64
    %110 = arith.mulf %111, %103 : f64
    %112 = arith.addf %107, %110 : f64
    %113 = arith.constant 2.0 : f32
    %115 = arith.extf %113 : f32 to f64
    %114 = arith.mulf %115, %86 : f64
    %116 = arith.addf %112, %114 : f64
    %117 = arith.constant 1 : i32
    %119 = arith.extsi %117 : i32 to i64
    %118 = arith.subi %43, %119 : i64
    %120 = func.call @harmonic(%118) : (i64) -> f64
    %121 = arith.sitofp %118 : i64 to f64
    %122 = arith.constant 1.0 : f32
    %124 = arith.extf %122 : f32 to f64
    %123 = arith.addf %121, %124 : f64
    %125 = arith.mulf %123, %120 : f64
    %126 = arith.subf %125, %121 : f64
    %127 = arith.constant 1.0 : f32
    %129 = arith.extf %127 : f32 to f64
    %128 = arith.addf %121, %129 : f64
    %130 = arith.mulf %121, %128 : f64
    %131 = arith.constant 2.0 : f32
    %133 = arith.extf %131 : f32 to f64
    %132 = arith.divf %130, %133 : f64
    %134 = arith.mulf %132, %120 : f64
    %135 = arith.constant 1.0 : f32
    %137 = arith.extf %135 : f32 to f64
    %136 = arith.subf %121, %137 : f64
    %138 = arith.mulf %121, %136 : f64
    %139 = arith.constant 4.0 : f32
    %141 = arith.extf %139 : f32 to f64
    %140 = arith.divf %138, %141 : f64
    %142 = arith.subf %134, %140 : f64
    %143 = arith.constant 1.0 : f32
    %145 = arith.extf %143 : f32 to f64
    %144 = arith.addf %121, %145 : f64
    %146 = arith.mulf %121, %144 : f64
    %147 = arith.constant 2.0 : f32
    %149 = arith.extf %147 : f32 to f64
    %148 = arith.mulf %149, %121 : f64
    %150 = arith.constant 1.0 : f32
    %152 = arith.extf %150 : f32 to f64
    %151 = arith.addf %148, %152 : f64
    %153 = arith.mulf %146, %151 : f64
    %154 = arith.constant 6.0 : f32
    %156 = arith.extf %154 : f32 to f64
    %155 = arith.divf %153, %156 : f64
    %157 = arith.mulf %155, %120 : f64
    %158 = arith.constant 4.0 : f32
    %160 = arith.extf %158 : f32 to f64
    %159 = arith.mulf %160, %121 : f64
    %161 = arith.mulf %159, %121 : f64
    %162 = arith.constant 3.0 : f32
    %164 = arith.extf %162 : f32 to f64
    %163 = arith.mulf %164, %121 : f64
    %165 = arith.subf %161, %163 : f64
    %166 = arith.constant 1.0 : f32
    %168 = arith.extf %166 : f32 to f64
    %167 = arith.subf %165, %168 : f64
    %169 = arith.mulf %121, %167 : f64
    %170 = arith.constant 36.0 : f32
    %172 = arith.extf %170 : f32 to f64
    %171 = arith.divf %169, %172 : f64
    %173 = arith.subf %157, %171 : f64
    %174 = arith.constant 2.0 : f32
    %176 = arith.extf %174 : f32 to f64
    %175 = arith.mulf %176, %142 : f64
    %177 = arith.addf %173, %175 : f64
    %178 = arith.addf %177, %126 : f64
    %179 = arith.constant 4.0 : f32
    %181 = arith.extf %179 : f32 to f64
    %180 = arith.subf %178, %181 : f64
    %182 = func.call @harmonic(%45) : (i64) -> f64
    %183 = arith.constant 1 : i32
    %185 = arith.extsi %183 : i32 to i64
    %184 = arith.subi %45, %185 : i64
    %186 = func.call @harmonic(%184) : (i64) -> f64
    %187 = arith.sitofp %184 : i64 to f64
    %188 = arith.constant 1.0 : f32
    %190 = arith.extf %188 : f32 to f64
    %189 = arith.addf %187, %190 : f64
    %191 = arith.mulf %189, %186 : f64
    %192 = arith.subf %191, %187 : f64
    %193 = arith.constant 1.0 : f32
    %195 = arith.extf %193 : f32 to f64
    %194 = arith.addf %187, %195 : f64
    %196 = arith.mulf %187, %194 : f64
    %197 = arith.constant 2.0 : f32
    %199 = arith.extf %197 : f32 to f64
    %198 = arith.divf %196, %199 : f64
    %200 = arith.mulf %198, %186 : f64
    %201 = arith.constant 1.0 : f32
    %203 = arith.extf %201 : f32 to f64
    %202 = arith.subf %187, %203 : f64
    %204 = arith.mulf %187, %202 : f64
    %205 = arith.constant 4.0 : f32
    %207 = arith.extf %205 : f32 to f64
    %206 = arith.divf %204, %207 : f64
    %208 = arith.subf %200, %206 : f64
    %209 = arith.constant 1.0 : f32
    %211 = arith.extf %209 : f32 to f64
    %210 = arith.addf %187, %211 : f64
    %212 = arith.mulf %187, %210 : f64
    %213 = arith.constant 2.0 : f32
    %215 = arith.extf %213 : f32 to f64
    %214 = arith.mulf %215, %187 : f64
    %216 = arith.constant 1.0 : f32
    %218 = arith.extf %216 : f32 to f64
    %217 = arith.addf %214, %218 : f64
    %219 = arith.mulf %212, %217 : f64
    %220 = arith.constant 6.0 : f32
    %222 = arith.extf %220 : f32 to f64
    %221 = arith.divf %219, %222 : f64
    %223 = arith.mulf %221, %186 : f64
    %224 = arith.constant 4.0 : f32
    %226 = arith.extf %224 : f32 to f64
    %225 = arith.mulf %226, %187 : f64
    %227 = arith.mulf %225, %187 : f64
    %228 = arith.constant 3.0 : f32
    %230 = arith.extf %228 : f32 to f64
    %229 = arith.mulf %230, %187 : f64
    %231 = arith.subf %227, %229 : f64
    %232 = arith.constant 1.0 : f32
    %234 = arith.extf %232 : f32 to f64
    %233 = arith.subf %231, %234 : f64
    %235 = arith.mulf %187, %233 : f64
    %236 = arith.constant 36.0 : f32
    %238 = arith.extf %236 : f32 to f64
    %237 = arith.divf %235, %238 : f64
    %239 = arith.subf %223, %237 : f64
    %240 = arith.constant 8.0 : f32
    %242 = arith.extf %240 : f32 to f64
    %241 = arith.mulf %242, %239 : f64
    %243 = arith.constant 4.0 : f32
    %245 = arith.extf %243 : f32 to f64
    %244 = arith.mulf %245, %208 : f64
    %246 = arith.addf %241, %244 : f64
    %247 = arith.addf %246, %192 : f64
    %248 = arith.constant 4.0 : f32
    %250 = arith.extf %248 : f32 to f64
    %249 = arith.subf %247, %250 : f64
    %251 = arith.constant 4.0 : f32
    %252 = arith.sitofp %45 : i64 to f64
    %254 = arith.extf %251 : f32 to f64
    %253 = arith.mulf %254, %252 : f64
    %255 = arith.sitofp %45 : i64 to f64
    %256 = arith.mulf %253, %255 : f64
    %257 = arith.mulf %256, %182 : f64
    %258 = arith.addf %249, %257 : f64
    %259 = arith.subf %116, %180 : f64
    %260 = arith.addf %259, %258 : f64
    %262 = arith.constant 1.0 : f32
    %263 = math.exp %262 : f32
    %264 = arith.extf %263 : f32 to f64
    %261 = func.call @log10(%264) : (f64) -> f64
    %265 = math.log %260 : f64
    %266 = arith.mulf %265, %261 : f64
    %267 = func.call @floor(%266) : (f64) -> f64
    %268 = arith.fptosi %267 : f64 to i64
    %269 = arith.sitofp %268 : i64 to f64
    %270 = arith.subf %266, %269 : f64
    %272 = arith.constant 10.0 : f32
    %273 = arith.extf %272 : f32 to f64
    %271 = func.call @pow(%273, %270) : (f64, f64) -> f64
    %274 = llvm.mlir.constant(1 : i64) : i64
    %275 = llvm.alloca %274 x f64 : (i64) -> !llvm.ptr
    llvm.store %271, %275 : f64, !llvm.ptr
    %277 = llvm.load %275 : !llvm.ptr -> f64
    %278 = arith.constant 1000000000.0 : f32
    %280 = arith.extf %278 : f32 to f64
    %279 = arith.mulf %277, %280 : f64
    %281 = arith.constant 0.5 : f32
    %283 = arith.extf %281 : f32 to f64
    %282 = arith.addf %279, %283 : f64
    %276 = func.call @floor(%282) : (f64) -> f64
    %284 = arith.constant 1000000000.0 : f32
    %286 = arith.extf %284 : f32 to f64
    %285 = arith.divf %276, %286 : f64
    %287 = llvm.mlir.constant(1 : i64) : i64
    %288 = llvm.alloca %287 x f64 : (i64) -> !llvm.ptr
    llvm.store %285, %288 : f64, !llvm.ptr
    %289 = llvm.mlir.constant(1 : i64) : i64
    %290 = llvm.alloca %289 x i64 : (i64) -> !llvm.ptr
    llvm.store %268, %290 : i64, !llvm.ptr
    %291 = llvm.load %288 : !llvm.ptr -> f64
    %292 = arith.constant 10.0 : f32
    %294 = arith.extf %292 : f32 to f64
    %293 = arith.cmpf oge, %291, %294 : f64
    cf.cond_br %293, ^bb3, ^bb4
    ^bb3:
      %295 = llvm.load %288 : !llvm.ptr -> f64
      %296 = arith.constant 10.0 : f32
      %298 = arith.extf %296 : f32 to f64
      %297 = arith.divf %295, %298 : f64
      llvm.store %297, %288 : f64, !llvm.ptr
      %299 = llvm.load %290 : !llvm.ptr -> i64
      %300 = arith.constant 1 : i32
      %302 = arith.extsi %300 : i32 to i64
      %301 = arith.addi %299, %302 : i64
      llvm.store %301, %290 : i64, !llvm.ptr
      cf.br ^bb5
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %303 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %304 = llvm.load %288 : !llvm.ptr -> f64
    %305 = llvm.load %290 : !llvm.ptr -> i64
    %306 = llvm.call @printf(%303, %304, %305) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64, i64) -> i32
    %307 = arith.constant 0 : i32
    func.return %307 : i32
  }
}