Problem 617

Mirror Power Sequence: D(10^18) = sum C(n) for n=2..10^18. Valid n = t^(e^a) + t^(e^b) with t>1 primitive (not an e-th power), 0≤a<b. For b=1: count primitive t with t+t^e ≤ N via integer roots. For b≥2: enumerate t (search space is tiny since t^(e^b) grows fast).

Answer1001133757
Output1001133757
StatusPASS
Native helperno
Runtime0 ms
Peak memory1120 KB
Time complexityO(n^3) (estimated)
Space complexityO(n) (estimated)

Performance comparison

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

Flow source

# Project Euler 617
# Mirror Power Sequence: D(10^18) = sum C(n) for n=2..10^18.
# Valid n = t^(e^a) + t^(e^b) with t>1 primitive (not an e-th power), 0≤a<b.
# For b=1: count primitive t with t+t^e ≤ N via integer roots.
# For b≥2: enumerate t (search space is tiny since t^(e^b) grows fast).

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

# min(base^exp, cap+1) with early stop
function pow_capped(base0: i64, exp0: i64, cap: i64) -> i64 {
    let mut result: i128 = 1 as i128
    let mut a: i128 = base0 as i128
    let mut e: i64 = exp0
    let cap128: i128 = cap as i128
    while e > 0 {
        if e % 2 == 1 {
            result = result * a
            if result > cap128 { return cap + 1 }
        }
        e = e / 2
        if e > 0 {
            a = a * a
            if a > cap128 { a = cap128 + 1 }
        }
    }
    return result as i64
}

# floor(n^(1/k)) via binary search
function int_nth_root(n: i64, k: i64) -> i64 {
    if k <= 1 { return n }
    if n < 2 { return n }
    let mut lo: i64 = 1
    let mut hi: i64 = 2
    while pow_capped(hi, k, n) <= n { hi = hi * 2 }
    while lo + 1 < hi {
        let mid: i64 = (lo + hi) / 2
        if pow_capped(mid, k, n) <= n { lo = mid }
        if pow_capped(mid, k, n) > n { hi = mid }
    }
    return lo
}

# Largest t with t + t^e ≤ N
function max_t_for_b1(N: i64, e: i64) -> i64 {
    if N < 4 { return 1 }
    let mut hi: i64 = int_nth_root(N, e) + 1
    let mut lo: i64 = 1
    while lo + 1 < hi {
        let mid: i64 = (lo + hi) / 2
        if mid + pow_capped(mid, e, N) <= N { lo = mid }
        if mid + pow_capped(mid, e, N) > N { hi = mid }
    }
    return lo
}

function ipow(base0: i64, exp0: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = base0
    let mut e: i64 = exp0
    while e > 0 {
        if e % 2 == 1 { r = r * b }
        b = b * b
        e = e / 2
    }
    return r
}

function count_for_exponent(N: i64, e: i64) -> i64 {
    let mut total: i64 = 0

    # b=1: n = t + t^e, count primitive t (not exact e-th powers)
    let t_max: i64 = max_t_for_b1(N, e)
    total = total + t_max - int_nth_root(t_max, e)

    if N <= 4 { return total }

    # b≥2: enumerate. Find max b such that 2^(e^b) ≤ N-2
    # max_exp = floor(log2(N-2))
    let mut max_exp: i64 = 0
    let mut tmp: i64 = N - 2
    while tmp > 1 { max_exp = max_exp + 1; tmp = tmp / 2 }

    # Collect valid b values
    let MAXB: i64 = 64
    let bs: ptr<i64> = calloc(MAXB, 8)
    if bs == null { return -1 }
    let mut nbs: i64 = 0
    let mut b: i64 = 2
    while nbs < MAXB {
        let exp: i64 = ipow(e, b)
        if exp > max_exp { break }
        if 2 + ((1 as i64) << exp) > N { break }
        bs[nbs] = b
        nbs = nbs + 1
        b = b + 1
    }

    if nbs == 0 { free(bs); return total }

    # Precompute non-primitive set (exact e-th powers up to max t)
    let mut max_t_limit: i64 = 0
    for bi in 0..nbs {
        let exp: i64 = ipow(e, bs[bi])
        let tl: i64 = int_nth_root(N - 2, exp)
        if tl > max_t_limit { max_t_limit = tl }
    }

    let u_max: i64 = int_nth_root(max_t_limit, e)
    # Mark e-th powers in a set (use a hash or array)
    let non_prim: ptr<i8> = calloc(max_t_limit + 1, 1)
    if non_prim == null { free(bs); return -1 }
    for u in 2..(u_max + 1) {
        let pk: i64 = ipow(u, e)
        if pk <= max_t_limit { non_prim[pk] = 1 }
    }

    # For each b, enumerate primitive t
    for bi in 0..nbs {
        let bval: i64 = bs[bi]
        let exp: i64 = ipow(e, bval)
        let t_limit: i64 = int_nth_root(N - 2, exp)
        for t in 2..(t_limit + 1) {
            if non_prim[t] == 0 {
                # Build power tower p[0..b], p[k] = t^(e^k)
                # Count valid a in [0..b-1] with p[a] + p[b] ≤ N
                let top: i64 = pow_capped(t, exp, N)
                let mut pa: i64 = 1  # p[0] = t^1 = t
                let mut ek: i64 = 1  # e^0 = 1
                for a in 0..bval {
                    if pa + top <= N {
                        total = total + bval
                    }
                    ek = ek * e
                    pa = pow_capped(t, ek, N)
                }
            }
        }
    }

    free(non_prim)
    free(bs)
    return total
}

function main() -> i32 {
    let N: i64 = 1000000000000000000
    let mut total: i64 = 0
    let mut e: i64 = 2
    while 2 + ((1 as i64) << e) <= N {
        total = total + count_for_exponent(N, e)
        e = e + 1
    }
    printf("%lld\n", total)
    return 0
}

Generated C

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

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

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

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

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

#include <math.h>

void* _ui_state = NULL;

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

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

int64_t pow_capped_i64_i64_i64(int64_t base0, int64_t exp0, int64_t cap);
int64_t int_nth_root_i64_i64(int64_t n, int64_t k);
int64_t max_t_for_b1_i64_i64(int64_t N, int64_t e);
int64_t ipow_i64_i64(int64_t base0, int64_t exp0);
int64_t count_for_exponent_i64_i64(int64_t N, int64_t e);
int32_t main(void);



int64_t pow_capped_i64_i64_i64(int64_t base0, int64_t exp0, int64_t cap) {
    __int128 result = ((__int128)(1));
    __int128 a = ((__int128)(base0));
    int64_t e = exp0;
    __int128 cap128 = ((__int128)(cap));
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            result = (result * a);
            if (result > cap128) {
                return (cap + 1);
            }
        }
        e = FLOW_CHECKED_DIV((e), (2));
        if (e > 0) {
            a = (a * a);
            if (a > cap128) {
                a = (cap128 + 1);
            }
        }
    }
    return ((int64_t)(result));
}

int64_t int_nth_root_i64_i64(int64_t n, int64_t k) {
    if (k <= 1) {
        return n;
    }
    if (n < 2) {
        return n;
    }
    int64_t lo = 1;
    int64_t hi = 2;
    while (pow_capped_i64_i64_i64(hi, k, n) <= n) {
        hi = (hi * 2);
    }
    while ((lo + 1) < hi) {
        int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
        if (pow_capped_i64_i64_i64(mid, k, n) <= n) {
            lo = mid;
        }
        if (pow_capped_i64_i64_i64(mid, k, n) > n) {
            hi = mid;
        }
    }
    return lo;
}

int64_t max_t_for_b1_i64_i64(int64_t N, int64_t e) {
    if (N < 4) {
        return 1;
    }
    int64_t hi = (int_nth_root_i64_i64(N, e) + 1);
    int64_t lo = 1;
    while ((lo + 1) < hi) {
        int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
        if ((mid + pow_capped_i64_i64_i64(mid, e, N)) <= N) {
            lo = mid;
        }
        if ((mid + pow_capped_i64_i64_i64(mid, e, N)) > N) {
            hi = mid;
        }
    }
    return lo;
}

int64_t ipow_i64_i64(int64_t base0, int64_t exp0) {
    int64_t r = 1;
    int64_t b = base0;
    int64_t e = exp0;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            r = (r * b);
        }
        b = (b * b);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return r;
}

int64_t count_for_exponent_i64_i64(int64_t N, int64_t e) {
    int64_t total = 0;
    int64_t t_max = max_t_for_b1_i64_i64(N, e);
    total = ((total + t_max) - int_nth_root_i64_i64(t_max, e));
    if (N <= 4) {
        return total;
    }
    int64_t max_exp = 0;
    int64_t tmp = (N - 2);
    while (tmp > 1) {
        max_exp = (max_exp + 1);
        tmp = FLOW_CHECKED_DIV((tmp), (2));
    }
    int64_t MAXB = 64;
    int64_t* bs = (int64_t*)(calloc(MAXB, 8));
    if (bs == NULL) {
        return (-1);
    }
    int64_t nbs = 0;
    int64_t b = 2;
    while (nbs < MAXB) {
        int64_t exp = ipow_i64_i64(e, b);
        if (exp > max_exp) {
            break;
        }
        if ((2 + FLOW_CHECKED_SHL((((int64_t)(1))), (exp))) > N) {
            break;
        }
        bs[nbs] = b;
        nbs = (nbs + 1);
        b = (b + 1);
    }
    if (nbs == 0) {
        free(bs);
        return total;
    }
    int64_t max_t_limit = 0;
    int32_t __flow_step_1 = 1;
    for (int32_t bi = 0; (0 <= nbs) ? bi < nbs : bi > nbs; bi += (0 <= nbs) ? 1 : -1) {
        int64_t exp = ipow_i64_i64(e, bs[bi]);
        int64_t tl = int_nth_root_i64_i64((N - 2), exp);
        if (tl > max_t_limit) {
            max_t_limit = tl;
        }
    }
    int64_t u_max = int_nth_root_i64_i64(max_t_limit, e);
    int8_t* non_prim = (int8_t*)(calloc((max_t_limit + 1), 1));
    if (non_prim == NULL) {
        free(bs);
        return (-1);
    }
    int32_t __flow_step_2 = 1;
    for (int32_t u = 2; (2 <= (u_max + 1)) ? u < (u_max + 1) : u > (u_max + 1); u += (2 <= (u_max + 1)) ? 1 : -1) {
        int64_t pk = ipow_i64_i64(u, e);
        if (pk <= max_t_limit) {
            non_prim[pk] = 1;
        }
    }
    int32_t __flow_step_3 = 1;
    for (int32_t bi = 0; (0 <= nbs) ? bi < nbs : bi > nbs; bi += (0 <= nbs) ? 1 : -1) {
        int64_t bval = bs[bi];
        int64_t exp = ipow_i64_i64(e, bval);
        int64_t t_limit = int_nth_root_i64_i64((N - 2), exp);
        int32_t __flow_step_4 = 1;
        for (int32_t t = 2; (2 <= (t_limit + 1)) ? t < (t_limit + 1) : t > (t_limit + 1); t += (2 <= (t_limit + 1)) ? 1 : -1) {
            if (non_prim[t] == 0) {
                int64_t top = pow_capped_i64_i64_i64(t, exp, N);
                int64_t pa = 1;
                int64_t ek = 1;
                int32_t __flow_step_5 = 1;
                for (int32_t a = 0; (0 <= bval) ? a < bval : a > bval; a += (0 <= bval) ? 1 : -1) {
                    if ((pa + top) <= N) {
                        total = (total + bval);
                    }
                    ek = (ek * e);
                    pa = pow_capped_i64_i64_i64(t, ek, N);
                }
            }
        }
    }
    free(non_prim);
    free(bs);
    return total;
}

int32_t main(void) {
    int64_t N = 1000000000000000000;
    int64_t total = 0;
    int64_t e = 2;
    while ((2 + FLOW_CHECKED_SHL((((int64_t)(1))), (e))) <= N) {
        total = (total + count_for_exponent_i64_i64(N, e));
        e = (e + 1);
    }
    printf("%lld\n", total);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\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 @pow_capped(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %0 = arith.constant 1 : i32
    %1 = arith.extsi %0 : i32 to i128
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i128 : (i64) -> !llvm.ptr
    llvm.store %1, %3 : i128, !llvm.ptr
    %4 = arith.extsi %arg0 : i64 to i128
    %5 = llvm.mlir.constant(1 : i64) : i64
    %6 = llvm.alloca %5 x i128 : (i64) -> !llvm.ptr
    llvm.store %4, %6 : i128, !llvm.ptr
    %7 = llvm.mlir.constant(1 : i64) : i64
    %8 = llvm.alloca %7 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %8 : i64, !llvm.ptr
    %9 = arith.extsi %arg2 : i64 to i128
    cf.br ^bb0
    ^bb0:
    %10 = llvm.load %8 : !llvm.ptr -> i64
    %11 = arith.constant 0 : i32
    %13 = arith.extsi %11 : i32 to i64
    %12 = arith.cmpi sgt, %10, %13 : i64
    cf.cond_br %12, ^bb1, ^bb2
    ^bb1:
      %14 = llvm.load %8 : !llvm.ptr -> i64
      %15 = arith.constant 2 : i32
      %17 = arith.extsi %15 : i32 to i64
      %16 = arith.remsi %14, %17 : i64
      %18 = arith.constant 1 : i32
      %20 = arith.extsi %18 : i32 to i64
      %19 = arith.cmpi eq, %16, %20 : i64
      cf.cond_br %19, ^bb3, ^bb4
      ^bb3:
        %21 = llvm.load %3 : !llvm.ptr -> i128
        %22 = llvm.load %6 : !llvm.ptr -> i128
        %24 = arith.trunci %21 : i128 to i64
        %25 = arith.trunci %22 : i128 to i64
        %23 = arith.muli %24, %25 : i64
        %26 = arith.extsi %23 : i64 to i128
        llvm.store %26, %3 : i128, !llvm.ptr
        %27 = llvm.load %3 : !llvm.ptr -> i128
        %29 = arith.trunci %27 : i128 to i64
        %30 = arith.trunci %9 : i128 to i64
        %28 = arith.cmpi sgt, %29, %30 : i64
        cf.cond_br %28, ^bb6, ^bb7
        ^bb6:
          %31 = arith.constant 1 : i32
          %33 = arith.extsi %31 : i32 to i64
          %32 = arith.addi %arg2, %33 : i64
          func.return %32 : i64
        ^bb7:
          cf.br ^bb8
        ^bb8:
        cf.br ^bb5
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %34 = llvm.load %8 : !llvm.ptr -> i64
      %35 = arith.constant 2 : i32
      %37 = arith.extsi %35 : i32 to i64
      %36 = arith.divsi %34, %37 : i64
      llvm.store %36, %8 : i64, !llvm.ptr
      %38 = llvm.load %8 : !llvm.ptr -> i64
      %39 = arith.constant 0 : i32
      %41 = arith.extsi %39 : i32 to i64
      %40 = arith.cmpi sgt, %38, %41 : i64
      cf.cond_br %40, ^bb9, ^bb10
      ^bb9:
        %42 = llvm.load %6 : !llvm.ptr -> i128
        %43 = llvm.load %6 : !llvm.ptr -> i128
        %45 = arith.trunci %42 : i128 to i64
        %46 = arith.trunci %43 : i128 to i64
        %44 = arith.muli %45, %46 : i64
        %47 = arith.extsi %44 : i64 to i128
        llvm.store %47, %6 : i128, !llvm.ptr
        %48 = llvm.load %6 : !llvm.ptr -> i128
        %50 = arith.trunci %48 : i128 to i64
        %51 = arith.trunci %9 : i128 to i64
        %49 = arith.cmpi sgt, %50, %51 : i64
        cf.cond_br %49, ^bb12, ^bb13
        ^bb12:
          %52 = arith.constant 1 : i32
          %54 = arith.trunci %9 : i128 to i64
          %55 = arith.extsi %52 : i32 to i64
          %53 = arith.addi %54, %55 : i64
          %56 = arith.extsi %53 : i64 to i128
          llvm.store %56, %6 : i128, !llvm.ptr
          cf.br ^bb14
        ^bb13:
          cf.br ^bb14
        ^bb14:
        cf.br ^bb11
      ^bb10:
        cf.br ^bb11
      ^bb11:
      cf.br ^bb0
    ^bb2:
    %57 = llvm.load %3 : !llvm.ptr -> i128
    %58 = arith.trunci %57 : i128 to i64
    func.return %58 : i64
  }
  func.func @int_nth_root(%arg0: i64, %arg1: i64) -> i64 {
    %59 = arith.constant 1 : i32
    %61 = arith.extsi %59 : i32 to i64
    %60 = arith.cmpi sle, %arg1, %61 : i64
    cf.cond_br %60, ^bb15, ^bb16
    ^bb15:
      func.return %arg0 : i64
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %62 = arith.constant 2 : i32
    %64 = arith.extsi %62 : i32 to i64
    %63 = arith.cmpi slt, %arg0, %64 : i64
    cf.cond_br %63, ^bb18, ^bb19
    ^bb18:
      func.return %arg0 : i64
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %65 = arith.constant 1 : i32
    %66 = arith.extsi %65 : i32 to i64
    %67 = llvm.mlir.constant(1 : i64) : i64
    %68 = llvm.alloca %67 x i64 : (i64) -> !llvm.ptr
    llvm.store %66, %68 : i64, !llvm.ptr
    %69 = arith.constant 2 : i32
    %70 = arith.extsi %69 : i32 to i64
    %71 = llvm.mlir.constant(1 : i64) : i64
    %72 = llvm.alloca %71 x i64 : (i64) -> !llvm.ptr
    llvm.store %70, %72 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %74 = llvm.load %72 : !llvm.ptr -> i64
    %73 = func.call @pow_capped(%74, %arg1, %arg0) : (i64, i64, i64) -> i64
    %75 = arith.cmpi sle, %73, %arg0 : i64
    cf.cond_br %75, ^bb22, ^bb23
    ^bb22:
      %76 = llvm.load %72 : !llvm.ptr -> i64
      %77 = arith.constant 2 : i32
      %79 = arith.extsi %77 : i32 to i64
      %78 = arith.muli %76, %79 : i64
      llvm.store %78, %72 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    cf.br ^bb24
    ^bb24:
    %80 = llvm.load %68 : !llvm.ptr -> i64
    %81 = arith.constant 1 : i32
    %83 = arith.extsi %81 : i32 to i64
    %82 = arith.addi %80, %83 : i64
    %84 = llvm.load %72 : !llvm.ptr -> i64
    %85 = arith.cmpi slt, %82, %84 : i64
    cf.cond_br %85, ^bb25, ^bb26
    ^bb25:
      %86 = llvm.load %68 : !llvm.ptr -> i64
      %87 = llvm.load %72 : !llvm.ptr -> i64
      %88 = arith.addi %86, %87 : i64
      %89 = arith.constant 2 : i32
      %91 = arith.extsi %89 : i32 to i64
      %90 = arith.divsi %88, %91 : i64
      %92 = func.call @pow_capped(%90, %arg1, %arg0) : (i64, i64, i64) -> i64
      %93 = arith.cmpi sle, %92, %arg0 : i64
      cf.cond_br %93, ^bb27, ^bb28
      ^bb27:
        llvm.store %90, %68 : i64, !llvm.ptr
        cf.br ^bb29
      ^bb28:
        cf.br ^bb29
      ^bb29:
      %94 = func.call @pow_capped(%90, %arg1, %arg0) : (i64, i64, i64) -> i64
      %95 = arith.cmpi sgt, %94, %arg0 : i64
      cf.cond_br %95, ^bb30, ^bb31
      ^bb30:
        llvm.store %90, %72 : i64, !llvm.ptr
        cf.br ^bb32
      ^bb31:
        cf.br ^bb32
      ^bb32:
      cf.br ^bb24
    ^bb26:
    %96 = llvm.load %68 : !llvm.ptr -> i64
    func.return %96 : i64
  }
  func.func @max_t_for_b1(%arg0: i64, %arg1: i64) -> i64 {
    %97 = arith.constant 4 : i32
    %99 = arith.extsi %97 : i32 to i64
    %98 = arith.cmpi slt, %arg0, %99 : i64
    cf.cond_br %98, ^bb33, ^bb34
    ^bb33:
      %100 = arith.constant 1 : i32
      %101 = arith.extsi %100 : i32 to i64
      func.return %101 : i64
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %102 = func.call @int_nth_root(%arg0, %arg1) : (i64, i64) -> i64
    %103 = arith.constant 1 : i32
    %105 = arith.extsi %103 : i32 to i64
    %104 = arith.addi %102, %105 : i64
    %106 = llvm.mlir.constant(1 : i64) : i64
    %107 = llvm.alloca %106 x i64 : (i64) -> !llvm.ptr
    llvm.store %104, %107 : i64, !llvm.ptr
    %108 = arith.constant 1 : i32
    %109 = arith.extsi %108 : i32 to i64
    %110 = llvm.mlir.constant(1 : i64) : i64
    %111 = llvm.alloca %110 x i64 : (i64) -> !llvm.ptr
    llvm.store %109, %111 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %112 = llvm.load %111 : !llvm.ptr -> i64
    %113 = arith.constant 1 : i32
    %115 = arith.extsi %113 : i32 to i64
    %114 = arith.addi %112, %115 : i64
    %116 = llvm.load %107 : !llvm.ptr -> i64
    %117 = arith.cmpi slt, %114, %116 : i64
    cf.cond_br %117, ^bb37, ^bb38
    ^bb37:
      %118 = llvm.load %111 : !llvm.ptr -> i64
      %119 = llvm.load %107 : !llvm.ptr -> i64
      %120 = arith.addi %118, %119 : i64
      %121 = arith.constant 2 : i32
      %123 = arith.extsi %121 : i32 to i64
      %122 = arith.divsi %120, %123 : i64
      %124 = func.call @pow_capped(%122, %arg1, %arg0) : (i64, i64, i64) -> i64
      %125 = arith.addi %122, %124 : i64
      %126 = arith.cmpi sle, %125, %arg0 : i64
      cf.cond_br %126, ^bb39, ^bb40
      ^bb39:
        llvm.store %122, %111 : i64, !llvm.ptr
        cf.br ^bb41
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %127 = func.call @pow_capped(%122, %arg1, %arg0) : (i64, i64, i64) -> i64
      %128 = arith.addi %122, %127 : i64
      %129 = arith.cmpi sgt, %128, %arg0 : i64
      cf.cond_br %129, ^bb42, ^bb43
      ^bb42:
        llvm.store %122, %107 : i64, !llvm.ptr
        cf.br ^bb44
      ^bb43:
        cf.br ^bb44
      ^bb44:
      cf.br ^bb36
    ^bb38:
    %130 = llvm.load %111 : !llvm.ptr -> i64
    func.return %130 : i64
  }
  func.func @ipow(%arg0: i64, %arg1: i64) -> i64 {
    %131 = arith.constant 1 : i32
    %132 = arith.extsi %131 : i32 to i64
    %133 = llvm.mlir.constant(1 : i64) : i64
    %134 = llvm.alloca %133 x i64 : (i64) -> !llvm.ptr
    llvm.store %132, %134 : i64, !llvm.ptr
    %135 = llvm.mlir.constant(1 : i64) : i64
    %136 = llvm.alloca %135 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %136 : i64, !llvm.ptr
    %137 = llvm.mlir.constant(1 : i64) : i64
    %138 = llvm.alloca %137 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %138 : i64, !llvm.ptr
    cf.br ^bb45
    ^bb45:
    %139 = llvm.load %138 : !llvm.ptr -> i64
    %140 = arith.constant 0 : i32
    %142 = arith.extsi %140 : i32 to i64
    %141 = arith.cmpi sgt, %139, %142 : i64
    cf.cond_br %141, ^bb46, ^bb47
    ^bb46:
      %143 = llvm.load %138 : !llvm.ptr -> i64
      %144 = arith.constant 2 : i32
      %146 = arith.extsi %144 : i32 to i64
      %145 = arith.remsi %143, %146 : i64
      %147 = arith.constant 1 : i32
      %149 = arith.extsi %147 : i32 to i64
      %148 = arith.cmpi eq, %145, %149 : i64
      cf.cond_br %148, ^bb48, ^bb49
      ^bb48:
        %150 = llvm.load %134 : !llvm.ptr -> i64
        %151 = llvm.load %136 : !llvm.ptr -> i64
        %152 = arith.muli %150, %151 : i64
        llvm.store %152, %134 : i64, !llvm.ptr
        cf.br ^bb50
      ^bb49:
        cf.br ^bb50
      ^bb50:
      %153 = llvm.load %136 : !llvm.ptr -> i64
      %154 = llvm.load %136 : !llvm.ptr -> i64
      %155 = arith.muli %153, %154 : i64
      llvm.store %155, %136 : i64, !llvm.ptr
      %156 = llvm.load %138 : !llvm.ptr -> i64
      %157 = arith.constant 2 : i32
      %159 = arith.extsi %157 : i32 to i64
      %158 = arith.divsi %156, %159 : i64
      llvm.store %158, %138 : i64, !llvm.ptr
      cf.br ^bb45
    ^bb47:
    %160 = llvm.load %134 : !llvm.ptr -> i64
    func.return %160 : i64
  }
  func.func @count_for_exponent(%arg0: i64, %arg1: i64) -> i64 {
    %161 = arith.constant 0 : i32
    %162 = arith.extsi %161 : i32 to i64
    %163 = llvm.mlir.constant(1 : i64) : i64
    %164 = llvm.alloca %163 x i64 : (i64) -> !llvm.ptr
    llvm.store %162, %164 : i64, !llvm.ptr
    %165 = func.call @max_t_for_b1(%arg0, %arg1) : (i64, i64) -> i64
    %166 = llvm.load %164 : !llvm.ptr -> i64
    %167 = arith.addi %166, %165 : i64
    %168 = func.call @int_nth_root(%165, %arg1) : (i64, i64) -> i64
    %169 = arith.subi %167, %168 : i64
    llvm.store %169, %164 : i64, !llvm.ptr
    %170 = arith.constant 4 : i32
    %172 = arith.extsi %170 : i32 to i64
    %171 = arith.cmpi sle, %arg0, %172 : i64
    cf.cond_br %171, ^bb51, ^bb52
    ^bb51:
      %173 = llvm.load %164 : !llvm.ptr -> i64
      func.return %173 : i64
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %174 = arith.constant 0 : i32
    %175 = arith.extsi %174 : i32 to i64
    %176 = llvm.mlir.constant(1 : i64) : i64
    %177 = llvm.alloca %176 x i64 : (i64) -> !llvm.ptr
    llvm.store %175, %177 : i64, !llvm.ptr
    %178 = arith.constant 2 : i32
    %180 = arith.extsi %178 : i32 to i64
    %179 = arith.subi %arg0, %180 : i64
    %181 = llvm.mlir.constant(1 : i64) : i64
    %182 = llvm.alloca %181 x i64 : (i64) -> !llvm.ptr
    llvm.store %179, %182 : i64, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %183 = llvm.load %182 : !llvm.ptr -> i64
    %184 = arith.constant 1 : i32
    %186 = arith.extsi %184 : i32 to i64
    %185 = arith.cmpi sgt, %183, %186 : i64
    cf.cond_br %185, ^bb55, ^bb56
    ^bb55:
      %187 = llvm.load %177 : !llvm.ptr -> i64
      %188 = arith.constant 1 : i32
      %190 = arith.extsi %188 : i32 to i64
      %189 = arith.addi %187, %190 : i64
      llvm.store %189, %177 : i64, !llvm.ptr
      %191 = llvm.load %182 : !llvm.ptr -> i64
      %192 = arith.constant 2 : i32
      %194 = arith.extsi %192 : i32 to i64
      %193 = arith.divsi %191, %194 : i64
      llvm.store %193, %182 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %195 = arith.constant 64 : i32
    %196 = arith.extsi %195 : i32 to i64
    %198 = arith.constant 8 : i32
    %199 = arith.extsi %198 : i32 to i64
    %197 = func.call @calloc(%196, %199) : (i64, i64) -> !llvm.ptr
    %200 = llvm.mlir.zero : !llvm.ptr
    %201 = llvm.icmp "eq" %197, %200 : !llvm.ptr
    cf.cond_br %201, ^bb57, ^bb58
    ^bb57:
      %202 = arith.constant 1 : i32
      %204 = arith.constant 0 : i32
      %203 = arith.subi %204, %202 : i32
      %205 = arith.extsi %203 : i32 to i64
      func.return %205 : i64
    ^bb58:
      cf.br ^bb59
    ^bb59:
    %206 = arith.constant 0 : i32
    %207 = arith.extsi %206 : i32 to i64
    %208 = llvm.mlir.constant(1 : i64) : i64
    %209 = llvm.alloca %208 x i64 : (i64) -> !llvm.ptr
    llvm.store %207, %209 : i64, !llvm.ptr
    %210 = arith.constant 2 : i32
    %211 = arith.extsi %210 : i32 to i64
    %212 = llvm.mlir.constant(1 : i64) : i64
    %213 = llvm.alloca %212 x i64 : (i64) -> !llvm.ptr
    llvm.store %211, %213 : i64, !llvm.ptr
    cf.br ^bb60
    ^bb60:
    %214 = llvm.load %209 : !llvm.ptr -> i64
    %215 = arith.cmpi slt, %214, %196 : i64
    cf.cond_br %215, ^bb61, ^bb62
    ^bb61:
      %217 = llvm.load %213 : !llvm.ptr -> i64
      %216 = func.call @ipow(%arg1, %217) : (i64, i64) -> i64
      %218 = llvm.load %177 : !llvm.ptr -> i64
      %219 = arith.cmpi sgt, %216, %218 : i64
      cf.cond_br %219, ^bb63, ^bb64
      ^bb63:
        cf.br ^bb62
      ^bb64:
        cf.br ^bb65
      ^bb65:
      %220 = arith.constant 2 : i32
      %221 = arith.constant 1 : i32
      %222 = arith.extsi %221 : i32 to i64
      %223 = arith.shli %222, %216 : i64
      %225 = arith.extsi %220 : i32 to i64
      %224 = arith.addi %225, %223 : i64
      %226 = arith.cmpi sgt, %224, %arg0 : i64
      cf.cond_br %226, ^bb66, ^bb67
      ^bb66:
        cf.br ^bb62
      ^bb67:
        cf.br ^bb68
      ^bb68:
      %227 = llvm.load %213 : !llvm.ptr -> i64
      %228 = llvm.load %209 : !llvm.ptr -> i64
      %229 = llvm.getelementptr %197[%228] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %227, %229 : i64, !llvm.ptr
      %230 = llvm.load %209 : !llvm.ptr -> i64
      %231 = arith.constant 1 : i32
      %233 = arith.extsi %231 : i32 to i64
      %232 = arith.addi %230, %233 : i64
      llvm.store %232, %209 : i64, !llvm.ptr
      %234 = llvm.load %213 : !llvm.ptr -> i64
      %235 = arith.constant 1 : i32
      %237 = arith.extsi %235 : i32 to i64
      %236 = arith.addi %234, %237 : i64
      llvm.store %236, %213 : i64, !llvm.ptr
      cf.br ^bb60
    ^bb62:
    %238 = llvm.load %209 : !llvm.ptr -> i64
    %239 = arith.constant 0 : i32
    %241 = arith.extsi %239 : i32 to i64
    %240 = arith.cmpi eq, %238, %241 : i64
    cf.cond_br %240, ^bb69, ^bb70
    ^bb69:
      func.call @free(%197) : (!llvm.ptr) -> ()
      %243 = llvm.load %164 : !llvm.ptr -> i64
      func.return %243 : i64
    ^bb70:
      cf.br ^bb71
    ^bb71:
    %244 = arith.constant 0 : i32
    %245 = arith.extsi %244 : i32 to i64
    %246 = llvm.mlir.constant(1 : i64) : i64
    %247 = llvm.alloca %246 x i64 : (i64) -> !llvm.ptr
    llvm.store %245, %247 : i64, !llvm.ptr
    %248 = arith.constant 0 : i32
    %249 = llvm.load %209 : !llvm.ptr -> i64
    %250 = arith.index_cast %248 : i32 to index
    %251 = arith.index_cast %249 : i32 to index
    %253 = arith.constant 1 : index
    %254 = arith.constant -1 : index
    %255 = arith.cmpi sle, %250, %251 : index
    %252 = arith.select %255, %253, %254 : index
    cf.br ^bb72(%250 : index)
    ^bb72(%256: index):
    %257 = arith.cmpi slt, %256, %251 : index
    %258 = arith.cmpi sgt, %256, %251 : index
    %259 = arith.select %255, %257, %258 : i1
    cf.cond_br %259, ^bb73(%256 : index), ^bb74(%256 : index)
    ^bb73(%260: index):
      %263 = arith.index_cast %260 : index to i64
      %264 = llvm.getelementptr %197[%263] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %262 = llvm.load %264 : !llvm.ptr -> i64
      %261 = func.call @ipow(%arg1, %262) : (i64, i64) -> i64
      %266 = arith.constant 2 : i32
      %268 = arith.extsi %266 : i32 to i64
      %267 = arith.subi %arg0, %268 : i64
      %265 = func.call @int_nth_root(%267, %261) : (i64, i64) -> i64
      %269 = llvm.load %247 : !llvm.ptr -> i64
      %270 = arith.cmpi sgt, %265, %269 : i64
      cf.cond_br %270, ^bb75, ^bb76
      ^bb75:
        llvm.store %265, %247 : i64, !llvm.ptr
        cf.br ^bb77
      ^bb76:
        cf.br ^bb77
      ^bb77:
      %271 = arith.addi %260, %252 : index
      cf.br ^bb72(%271 : index)
    ^bb74(%272: index):
    %274 = llvm.load %247 : !llvm.ptr -> i64
    %273 = func.call @int_nth_root(%274, %arg1) : (i64, i64) -> i64
    %276 = llvm.load %247 : !llvm.ptr -> i64
    %277 = arith.constant 1 : i32
    %279 = arith.extsi %277 : i32 to i64
    %278 = arith.addi %276, %279 : i64
    %280 = arith.constant 1 : i32
    %281 = arith.extsi %280 : i32 to i64
    %275 = func.call @calloc(%278, %281) : (i64, i64) -> !llvm.ptr
    %282 = llvm.mlir.zero : !llvm.ptr
    %283 = llvm.icmp "eq" %275, %282 : !llvm.ptr
    cf.cond_br %283, ^bb78, ^bb79
    ^bb78:
      func.call @free(%197) : (!llvm.ptr) -> ()
      %285 = arith.constant 1 : i32
      %287 = arith.constant 0 : i32
      %286 = arith.subi %287, %285 : i32
      %288 = arith.extsi %286 : i32 to i64
      func.return %288 : i64
    ^bb79:
      cf.br ^bb80
    ^bb80:
    %289 = arith.constant 2 : i32
    %290 = arith.constant 1 : i32
    %292 = arith.extsi %290 : i32 to i64
    %291 = arith.addi %273, %292 : i64
    %293 = arith.index_cast %289 : i32 to index
    %294 = arith.index_cast %291 : i32 to index
    %296 = arith.constant 1 : index
    %297 = arith.constant -1 : index
    %298 = arith.cmpi sle, %293, %294 : index
    %295 = arith.select %298, %296, %297 : index
    cf.br ^bb81(%293 : index)
    ^bb81(%299: index):
    %300 = arith.cmpi slt, %299, %294 : index
    %301 = arith.cmpi sgt, %299, %294 : index
    %302 = arith.select %298, %300, %301 : i1
    cf.cond_br %302, ^bb82(%299 : index), ^bb83(%299 : index)
    ^bb82(%303: index):
      %305 = arith.index_cast %303 : index to i64
      %304 = func.call @ipow(%305, %arg1) : (i64, i64) -> i64
      %306 = llvm.load %247 : !llvm.ptr -> i64
      %307 = arith.cmpi sle, %304, %306 : i64
      cf.cond_br %307, ^bb84, ^bb85
      ^bb84:
        %308 = arith.constant 1 : i32
        %309 = arith.trunci %308 : i32 to i8
        %310 = llvm.getelementptr %275[%304] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %309, %310 : i8, !llvm.ptr
        cf.br ^bb86
      ^bb85:
        cf.br ^bb86
      ^bb86:
      %311 = arith.addi %303, %295 : index
      cf.br ^bb81(%311 : index)
    ^bb83(%312: index):
    %313 = arith.constant 0 : i32
    %314 = llvm.load %209 : !llvm.ptr -> i64
    %315 = arith.index_cast %313 : i32 to index
    %316 = arith.index_cast %314 : i32 to index
    %318 = arith.constant 1 : index
    %319 = arith.constant -1 : index
    %320 = arith.cmpi sle, %315, %316 : index
    %317 = arith.select %320, %318, %319 : index
    cf.br ^bb87(%315 : index)
    ^bb87(%321: index):
    %322 = arith.cmpi slt, %321, %316 : index
    %323 = arith.cmpi sgt, %321, %316 : index
    %324 = arith.select %320, %322, %323 : i1
    cf.cond_br %324, ^bb88(%321 : index), ^bb89(%321 : index)
    ^bb88(%325: index):
      %327 = arith.index_cast %325 : index to i64
      %328 = llvm.getelementptr %197[%327] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %326 = llvm.load %328 : !llvm.ptr -> i64
      %329 = func.call @ipow(%arg1, %326) : (i64, i64) -> i64
      %331 = arith.constant 2 : i32
      %333 = arith.extsi %331 : i32 to i64
      %332 = arith.subi %arg0, %333 : i64
      %330 = func.call @int_nth_root(%332, %329) : (i64, i64) -> i64
      %334 = arith.constant 2 : i32
      %335 = arith.constant 1 : i32
      %337 = arith.extsi %335 : i32 to i64
      %336 = arith.addi %330, %337 : i64
      %338 = arith.index_cast %334 : i32 to index
      %339 = arith.index_cast %336 : i32 to index
      %341 = arith.constant 1 : index
      %342 = arith.constant -1 : index
      %343 = arith.cmpi sle, %338, %339 : index
      %340 = arith.select %343, %341, %342 : index
      cf.br ^bb90(%338 : index)
      ^bb90(%344: index):
      %345 = arith.cmpi slt, %344, %339 : index
      %346 = arith.cmpi sgt, %344, %339 : index
      %347 = arith.select %343, %345, %346 : i1
      cf.cond_br %347, ^bb91(%344 : index), ^bb92(%344 : index)
      ^bb91(%348: index):
        %350 = arith.index_cast %348 : index to i64
        %351 = llvm.getelementptr %275[%350] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        %349 = llvm.load %351 : !llvm.ptr -> i8
        %352 = arith.constant 0 : i32
        %354 = arith.extsi %349 : i8 to i32
        %353 = arith.cmpi eq, %354, %352 : i32
        cf.cond_br %353, ^bb93, ^bb94
        ^bb93:
          %356 = arith.index_cast %348 : index to i64
          %355 = func.call @pow_capped(%356, %329, %arg0) : (i64, i64, i64) -> i64
          %357 = arith.constant 1 : i32
          %358 = arith.extsi %357 : i32 to i64
          %359 = llvm.mlir.constant(1 : i64) : i64
          %360 = llvm.alloca %359 x i64 : (i64) -> !llvm.ptr
          llvm.store %358, %360 : i64, !llvm.ptr
          %361 = arith.constant 1 : i32
          %362 = arith.extsi %361 : i32 to i64
          %363 = llvm.mlir.constant(1 : i64) : i64
          %364 = llvm.alloca %363 x i64 : (i64) -> !llvm.ptr
          llvm.store %362, %364 : i64, !llvm.ptr
          %365 = arith.constant 0 : i32
          %366 = arith.index_cast %365 : i32 to index
          %367 = arith.index_cast %326 : i32 to index
          %369 = arith.constant 1 : index
          %370 = arith.constant -1 : index
          %371 = arith.cmpi sle, %366, %367 : index
          %368 = arith.select %371, %369, %370 : index
          cf.br ^bb96(%366 : index)
          ^bb96(%372: index):
          %373 = arith.cmpi slt, %372, %367 : index
          %374 = arith.cmpi sgt, %372, %367 : index
          %375 = arith.select %371, %373, %374 : i1
          cf.cond_br %375, ^bb97(%372 : index), ^bb98(%372 : index)
          ^bb97(%376: index):
            %377 = llvm.load %360 : !llvm.ptr -> i64
            %378 = arith.addi %377, %355 : i64
            %379 = arith.cmpi sle, %378, %arg0 : i64
            cf.cond_br %379, ^bb99, ^bb100
            ^bb99:
              %380 = llvm.load %164 : !llvm.ptr -> i64
              %381 = arith.addi %380, %326 : i64
              llvm.store %381, %164 : i64, !llvm.ptr
              cf.br ^bb101
            ^bb100:
              cf.br ^bb101
            ^bb101:
            %382 = llvm.load %364 : !llvm.ptr -> i64
            %383 = arith.muli %382, %arg1 : i64
            llvm.store %383, %364 : i64, !llvm.ptr
            %385 = llvm.load %364 : !llvm.ptr -> i64
            %386 = arith.index_cast %348 : index to i64
            %384 = func.call @pow_capped(%386, %385, %arg0) : (i64, i64, i64) -> i64
            llvm.store %384, %360 : i64, !llvm.ptr
            %387 = arith.addi %376, %368 : index
            cf.br ^bb96(%387 : index)
          ^bb98(%388: index):
          cf.br ^bb95
        ^bb94:
          cf.br ^bb95
        ^bb95:
        %389 = arith.addi %348, %340 : index
        cf.br ^bb90(%389 : index)
      ^bb92(%390: index):
      %391 = arith.addi %325, %317 : index
      cf.br ^bb87(%391 : index)
    ^bb89(%392: index):
    func.call @free(%275) : (!llvm.ptr) -> ()
    func.call @free(%197) : (!llvm.ptr) -> ()
    %395 = llvm.load %164 : !llvm.ptr -> i64
    func.return %395 : i64
  }
  func.func @main() -> i32 {
    %396 = arith.constant 999999995705032704 : i32
    %397 = arith.extsi %396 : i32 to i64
    %398 = arith.constant 0 : i32
    %399 = arith.extsi %398 : i32 to i64
    %400 = llvm.mlir.constant(1 : i64) : i64
    %401 = llvm.alloca %400 x i64 : (i64) -> !llvm.ptr
    llvm.store %399, %401 : i64, !llvm.ptr
    %402 = arith.constant 2 : i32
    %403 = arith.extsi %402 : i32 to i64
    %404 = llvm.mlir.constant(1 : i64) : i64
    %405 = llvm.alloca %404 x i64 : (i64) -> !llvm.ptr
    llvm.store %403, %405 : i64, !llvm.ptr
    cf.br ^bb102
    ^bb102:
    %406 = arith.constant 2 : i32
    %407 = arith.constant 1 : i32
    %408 = arith.extsi %407 : i32 to i64
    %409 = llvm.load %405 : !llvm.ptr -> i64
    %410 = arith.shli %408, %409 : i64
    %412 = arith.extsi %406 : i32 to i64
    %411 = arith.addi %412, %410 : i64
    %413 = arith.cmpi sle, %411, %397 : i64
    cf.cond_br %413, ^bb103, ^bb104
    ^bb103:
      %414 = llvm.load %401 : !llvm.ptr -> i64
      %416 = llvm.load %405 : !llvm.ptr -> i64
      %415 = func.call @count_for_exponent(%397, %416) : (i64, i64) -> i64
      %417 = arith.addi %414, %415 : i64
      llvm.store %417, %401 : i64, !llvm.ptr
      %418 = llvm.load %405 : !llvm.ptr -> i64
      %419 = arith.constant 1 : i32
      %421 = arith.extsi %419 : i32 to i64
      %420 = arith.addi %418, %421 : i64
      llvm.store %420, %405 : i64, !llvm.ptr
      cf.br ^bb102
    ^bb104:
    %422 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %423 = llvm.load %401 : !llvm.ptr -> i64
    %424 = llvm.call @printf(%422, %423) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %425 = arith.constant 0 : i32
    func.return %425 : i32
  }
}