Problem 133

Sum of primes below 100000 that never divide R(10^k).

Answer453647705
Output453647705
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(n) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n)O(n log log n)
Space complexityO(1)O(n)
ApproachFlow solutionSieve of Eratosthenes
VerdictOptimal

Flow source

# Project Euler 133
# Sum of primes below 100000 that never divide R(10^k).

function mod_pow(base: i64, exp: i64, mod: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = base % mod
    let mut e: i64 = exp
    while e > 0 {
        if e % 2 == 1 { r = (r * b) % mod }
        b = (b * b) % mod
        e = e / 2
    }
    return r
}

function divides_some_R10k(p: i64) -> bool {
    # 2,3,5 never divide R(10^n): 2/5 end in 1; R(10^n) ≡ 1 (mod 3).
    if p == 2 || p == 3 || p == 5 { return false }
    # multiplicative order of 10 modulo p
    let mut ord: i64 = p - 1
    let mut n: i64 = p - 1
    let mut f: i64 = 2
    while f * f <= n {
        if n % f == 0 {
            while n % f == 0 { n = n / f }
            while ord % f == 0 && mod_pow(10, ord / f, p) == 1 {
                ord = ord / f
            }
        }
        f = f + 1
    }
    if n > 1 {
        while ord % n == 0 && mod_pow(10, ord / n, p) == 1 {
            ord = ord / n
        }
    }
    while ord % 2 == 0 { ord = ord / 2 }
    while ord % 5 == 0 { ord = ord / 5 }
    return ord == 1
}

function main() -> i32 {
    let mut total: i64 = 0
    let mut n: i64 = 2
    while n < 100000 {
        let mut prime: bool = true
        if n >= 4 && n % 2 == 0 { prime = false }
        let mut d: i64 = 3
        while prime && d * d <= n {
            if n % d == 0 { prime = false }
            d = d + 2
        }
        if prime {
            if !divides_some_R10k(n) {
                total = total + n
            }
        }
        n = n + 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 mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool divides_some_R10k_i64(int64_t p);
int32_t main(void);

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    int64_t r = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            r = FLOW_CHECKED_MOD(((r * b)), (mod));
        }
        b = FLOW_CHECKED_MOD(((b * b)), (mod));
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return r;
}

bool divides_some_R10k_i64(int64_t p) {
    if (((p == 2 || p == 3) || p == 5)) {
        return 0;
    }
    int64_t ord = (p - 1);
    int64_t n = (p - 1);
    int64_t f = 2;
    while ((f * f) <= n) {
        if (FLOW_CHECKED_MOD((n), (f)) == 0) {
            while (FLOW_CHECKED_MOD((n), (f)) == 0) {
                n = FLOW_CHECKED_DIV((n), (f));
            }
            while ((FLOW_CHECKED_MOD((ord), (f)) == 0 && mod_pow_i64_i64_i64(10, FLOW_CHECKED_DIV((ord), (f)), p) == 1)) {
                ord = FLOW_CHECKED_DIV((ord), (f));
            }
        }
        f = (f + 1);
    }
    if (n > 1) {
        while ((FLOW_CHECKED_MOD((ord), (n)) == 0 && mod_pow_i64_i64_i64(10, FLOW_CHECKED_DIV((ord), (n)), p) == 1)) {
            ord = FLOW_CHECKED_DIV((ord), (n));
        }
    }
    while (FLOW_CHECKED_MOD((ord), (2)) == 0) {
        ord = FLOW_CHECKED_DIV((ord), (2));
    }
    while (FLOW_CHECKED_MOD((ord), (5)) == 0) {
        ord = FLOW_CHECKED_DIV((ord), (5));
    }
    return ord == 1;
}

int32_t main(void) {
    int64_t total = 0;
    int64_t n = 2;
    while (n < 100000) {
        bool prime = 1;
        if ((n >= 4 && FLOW_CHECKED_MOD((n), (2)) == 0)) {
            prime = 0;
        }
        int64_t d = 3;
        while ((prime && (d * d) <= n)) {
            if (FLOW_CHECKED_MOD((n), (d)) == 0) {
                prime = 0;
            }
            d = (d + 2);
        }
        if (prime) {
            if ((!(divides_some_R10k_i64(n)))) {
                total = (total + n);
            }
        }
        n = (n + 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 @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %0 = arith.constant 1 : i32
    %1 = arith.extsi %0 : i32 to i64
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
    llvm.store %1, %3 : i64, !llvm.ptr
    %4 = arith.remsi %arg0, %arg2 : i64
    %5 = llvm.mlir.constant(1 : i64) : i64
    %6 = llvm.alloca %5 x i64 : (i64) -> !llvm.ptr
    llvm.store %4, %6 : i64, !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
    cf.br ^bb0
    ^bb0:
    %9 = llvm.load %8 : !llvm.ptr -> i64
    %10 = arith.constant 0 : i32
    %12 = arith.extsi %10 : i32 to i64
    %11 = arith.cmpi sgt, %9, %12 : i64
    cf.cond_br %11, ^bb1, ^bb2
    ^bb1:
      %13 = llvm.load %8 : !llvm.ptr -> i64
      %14 = arith.constant 2 : i32
      %16 = arith.extsi %14 : i32 to i64
      %15 = arith.remsi %13, %16 : i64
      %17 = arith.constant 1 : i32
      %19 = arith.extsi %17 : i32 to i64
      %18 = arith.cmpi eq, %15, %19 : i64
      cf.cond_br %18, ^bb3, ^bb4
      ^bb3:
        %20 = llvm.load %3 : !llvm.ptr -> i64
        %21 = llvm.load %6 : !llvm.ptr -> i64
        %22 = arith.muli %20, %21 : i64
        %23 = arith.remsi %22, %arg2 : i64
        llvm.store %23, %3 : i64, !llvm.ptr
        cf.br ^bb5
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %24 = llvm.load %6 : !llvm.ptr -> i64
      %25 = llvm.load %6 : !llvm.ptr -> i64
      %26 = arith.muli %24, %25 : i64
      %27 = arith.remsi %26, %arg2 : i64
      llvm.store %27, %6 : i64, !llvm.ptr
      %28 = llvm.load %8 : !llvm.ptr -> i64
      %29 = arith.constant 2 : i32
      %31 = arith.extsi %29 : i32 to i64
      %30 = arith.divsi %28, %31 : i64
      llvm.store %30, %8 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %32 = llvm.load %3 : !llvm.ptr -> i64
    func.return %32 : i64
  }
  func.func @divides_some_R10k(%arg0: i64) -> i1 {
    %33 = arith.constant 2 : i32
    %35 = arith.extsi %33 : i32 to i64
    %34 = arith.cmpi eq, %arg0, %35 : i64
    %36 = scf.if %34 -> (i1) {
      %37 = arith.constant true
      scf.yield %37 : i1
    } else {
      %38 = arith.constant 3 : i32
      %40 = arith.extsi %38 : i32 to i64
      %39 = arith.cmpi eq, %arg0, %40 : i64
      scf.yield %39 : i1
    }
    %41 = scf.if %36 -> (i1) {
      %42 = arith.constant true
      scf.yield %42 : i1
    } else {
      %43 = arith.constant 5 : i32
      %45 = arith.extsi %43 : i32 to i64
      %44 = arith.cmpi eq, %arg0, %45 : i64
      scf.yield %44 : i1
    }
    cf.cond_br %41, ^bb6, ^bb7
    ^bb6:
      %46 = arith.constant 0 : i1
      func.return %46 : i1
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %47 = arith.constant 1 : i32
    %49 = arith.extsi %47 : i32 to i64
    %48 = arith.subi %arg0, %49 : i64
    %50 = llvm.mlir.constant(1 : i64) : i64
    %51 = llvm.alloca %50 x i64 : (i64) -> !llvm.ptr
    llvm.store %48, %51 : i64, !llvm.ptr
    %52 = arith.constant 1 : i32
    %54 = arith.extsi %52 : i32 to i64
    %53 = arith.subi %arg0, %54 : i64
    %55 = llvm.mlir.constant(1 : i64) : i64
    %56 = llvm.alloca %55 x i64 : (i64) -> !llvm.ptr
    llvm.store %53, %56 : i64, !llvm.ptr
    %57 = arith.constant 2 : i32
    %58 = arith.extsi %57 : i32 to i64
    %59 = llvm.mlir.constant(1 : i64) : i64
    %60 = llvm.alloca %59 x i64 : (i64) -> !llvm.ptr
    llvm.store %58, %60 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %61 = llvm.load %60 : !llvm.ptr -> i64
    %62 = llvm.load %60 : !llvm.ptr -> i64
    %63 = arith.muli %61, %62 : i64
    %64 = llvm.load %56 : !llvm.ptr -> i64
    %65 = arith.cmpi sle, %63, %64 : i64
    cf.cond_br %65, ^bb10, ^bb11
    ^bb10:
      %66 = llvm.load %56 : !llvm.ptr -> i64
      %67 = llvm.load %60 : !llvm.ptr -> i64
      %68 = arith.remsi %66, %67 : i64
      %69 = arith.constant 0 : i32
      %71 = arith.extsi %69 : i32 to i64
      %70 = arith.cmpi eq, %68, %71 : i64
      cf.cond_br %70, ^bb12, ^bb13
      ^bb12:
        cf.br ^bb15
        ^bb15:
        %72 = llvm.load %56 : !llvm.ptr -> i64
        %73 = llvm.load %60 : !llvm.ptr -> i64
        %74 = arith.remsi %72, %73 : i64
        %75 = arith.constant 0 : i32
        %77 = arith.extsi %75 : i32 to i64
        %76 = arith.cmpi eq, %74, %77 : i64
        cf.cond_br %76, ^bb16, ^bb17
        ^bb16:
          %78 = llvm.load %56 : !llvm.ptr -> i64
          %79 = llvm.load %60 : !llvm.ptr -> i64
          %80 = arith.divsi %78, %79 : i64
          llvm.store %80, %56 : i64, !llvm.ptr
          cf.br ^bb15
        ^bb17:
        cf.br ^bb18
        ^bb18:
        %81 = llvm.load %51 : !llvm.ptr -> i64
        %82 = llvm.load %60 : !llvm.ptr -> i64
        %83 = arith.remsi %81, %82 : i64
        %84 = arith.constant 0 : i32
        %86 = arith.extsi %84 : i32 to i64
        %85 = arith.cmpi eq, %83, %86 : i64
        %87 = scf.if %85 -> (i1) {
          %89 = arith.constant 10 : i32
          %90 = llvm.load %51 : !llvm.ptr -> i64
          %91 = llvm.load %60 : !llvm.ptr -> i64
          %92 = arith.divsi %90, %91 : i64
          %93 = arith.extsi %89 : i32 to i64
          %88 = func.call @mod_pow(%93, %92, %arg0) : (i64, i64, i64) -> i64
          %94 = arith.constant 1 : i32
          %96 = arith.extsi %94 : i32 to i64
          %95 = arith.cmpi eq, %88, %96 : i64
          scf.yield %95 : i1
        } else {
          %97 = arith.constant false
          scf.yield %97 : i1
        }
        cf.cond_br %87, ^bb19, ^bb20
        ^bb19:
          %98 = llvm.load %51 : !llvm.ptr -> i64
          %99 = llvm.load %60 : !llvm.ptr -> i64
          %100 = arith.divsi %98, %99 : i64
          llvm.store %100, %51 : i64, !llvm.ptr
          cf.br ^bb18
        ^bb20:
        cf.br ^bb14
      ^bb13:
        cf.br ^bb14
      ^bb14:
      %101 = llvm.load %60 : !llvm.ptr -> i64
      %102 = arith.constant 1 : i32
      %104 = arith.extsi %102 : i32 to i64
      %103 = arith.addi %101, %104 : i64
      llvm.store %103, %60 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %105 = llvm.load %56 : !llvm.ptr -> i64
    %106 = arith.constant 1 : i32
    %108 = arith.extsi %106 : i32 to i64
    %107 = arith.cmpi sgt, %105, %108 : i64
    cf.cond_br %107, ^bb21, ^bb22
    ^bb21:
      cf.br ^bb24
      ^bb24:
      %109 = llvm.load %51 : !llvm.ptr -> i64
      %110 = llvm.load %56 : !llvm.ptr -> i64
      %111 = arith.remsi %109, %110 : i64
      %112 = arith.constant 0 : i32
      %114 = arith.extsi %112 : i32 to i64
      %113 = arith.cmpi eq, %111, %114 : i64
      %115 = scf.if %113 -> (i1) {
        %117 = arith.constant 10 : i32
        %118 = llvm.load %51 : !llvm.ptr -> i64
        %119 = llvm.load %56 : !llvm.ptr -> i64
        %120 = arith.divsi %118, %119 : i64
        %121 = arith.extsi %117 : i32 to i64
        %116 = func.call @mod_pow(%121, %120, %arg0) : (i64, i64, i64) -> i64
        %122 = arith.constant 1 : i32
        %124 = arith.extsi %122 : i32 to i64
        %123 = arith.cmpi eq, %116, %124 : i64
        scf.yield %123 : i1
      } else {
        %125 = arith.constant false
        scf.yield %125 : i1
      }
      cf.cond_br %115, ^bb25, ^bb26
      ^bb25:
        %126 = llvm.load %51 : !llvm.ptr -> i64
        %127 = llvm.load %56 : !llvm.ptr -> i64
        %128 = arith.divsi %126, %127 : i64
        llvm.store %128, %51 : i64, !llvm.ptr
        cf.br ^bb24
      ^bb26:
      cf.br ^bb23
    ^bb22:
      cf.br ^bb23
    ^bb23:
    cf.br ^bb27
    ^bb27:
    %129 = llvm.load %51 : !llvm.ptr -> i64
    %130 = arith.constant 2 : i32
    %132 = arith.extsi %130 : i32 to i64
    %131 = arith.remsi %129, %132 : i64
    %133 = arith.constant 0 : i32
    %135 = arith.extsi %133 : i32 to i64
    %134 = arith.cmpi eq, %131, %135 : i64
    cf.cond_br %134, ^bb28, ^bb29
    ^bb28:
      %136 = llvm.load %51 : !llvm.ptr -> i64
      %137 = arith.constant 2 : i32
      %139 = arith.extsi %137 : i32 to i64
      %138 = arith.divsi %136, %139 : i64
      llvm.store %138, %51 : i64, !llvm.ptr
      cf.br ^bb27
    ^bb29:
    cf.br ^bb30
    ^bb30:
    %140 = llvm.load %51 : !llvm.ptr -> i64
    %141 = arith.constant 5 : i32
    %143 = arith.extsi %141 : i32 to i64
    %142 = arith.remsi %140, %143 : i64
    %144 = arith.constant 0 : i32
    %146 = arith.extsi %144 : i32 to i64
    %145 = arith.cmpi eq, %142, %146 : i64
    cf.cond_br %145, ^bb31, ^bb32
    ^bb31:
      %147 = llvm.load %51 : !llvm.ptr -> i64
      %148 = arith.constant 5 : i32
      %150 = arith.extsi %148 : i32 to i64
      %149 = arith.divsi %147, %150 : i64
      llvm.store %149, %51 : i64, !llvm.ptr
      cf.br ^bb30
    ^bb32:
    %151 = llvm.load %51 : !llvm.ptr -> i64
    %152 = arith.constant 1 : i32
    %154 = arith.extsi %152 : i32 to i64
    %153 = arith.cmpi eq, %151, %154 : i64
    func.return %153 : i1
  }
  func.func @main() -> i32 {
    %155 = arith.constant 0 : i32
    %156 = arith.extsi %155 : i32 to i64
    %157 = llvm.mlir.constant(1 : i64) : i64
    %158 = llvm.alloca %157 x i64 : (i64) -> !llvm.ptr
    llvm.store %156, %158 : i64, !llvm.ptr
    %159 = arith.constant 2 : i32
    %160 = arith.extsi %159 : i32 to i64
    %161 = llvm.mlir.constant(1 : i64) : i64
    %162 = llvm.alloca %161 x i64 : (i64) -> !llvm.ptr
    llvm.store %160, %162 : i64, !llvm.ptr
    cf.br ^bb33
    ^bb33:
    %163 = llvm.load %162 : !llvm.ptr -> i64
    %164 = arith.constant 100000 : i32
    %166 = arith.extsi %164 : i32 to i64
    %165 = arith.cmpi slt, %163, %166 : i64
    cf.cond_br %165, ^bb34, ^bb35
    ^bb34:
      %167 = arith.constant 1 : i1
      %168 = llvm.mlir.constant(1 : i64) : i64
      %169 = llvm.alloca %168 x i1 : (i64) -> !llvm.ptr
      llvm.store %167, %169 : i1, !llvm.ptr
      %170 = llvm.load %162 : !llvm.ptr -> i64
      %171 = arith.constant 4 : i32
      %173 = arith.extsi %171 : i32 to i64
      %172 = arith.cmpi sge, %170, %173 : i64
      %174 = scf.if %172 -> (i1) {
        %175 = llvm.load %162 : !llvm.ptr -> i64
        %176 = arith.constant 2 : i32
        %178 = arith.extsi %176 : i32 to i64
        %177 = arith.remsi %175, %178 : i64
        %179 = arith.constant 0 : i32
        %181 = arith.extsi %179 : i32 to i64
        %180 = arith.cmpi eq, %177, %181 : i64
        scf.yield %180 : i1
      } else {
        %182 = arith.constant false
        scf.yield %182 : i1
      }
      cf.cond_br %174, ^bb36, ^bb37
      ^bb36:
        %183 = arith.constant 0 : i1
        llvm.store %183, %169 : i1, !llvm.ptr
        cf.br ^bb38
      ^bb37:
        cf.br ^bb38
      ^bb38:
      %184 = arith.constant 3 : i32
      %185 = arith.extsi %184 : i32 to i64
      %186 = llvm.mlir.constant(1 : i64) : i64
      %187 = llvm.alloca %186 x i64 : (i64) -> !llvm.ptr
      llvm.store %185, %187 : i64, !llvm.ptr
      cf.br ^bb39
      ^bb39:
      %188 = llvm.load %169 : !llvm.ptr -> i1
      %189 = scf.if %188 -> (i1) {
        %190 = llvm.load %187 : !llvm.ptr -> i64
        %191 = llvm.load %187 : !llvm.ptr -> i64
        %192 = arith.muli %190, %191 : i64
        %193 = llvm.load %162 : !llvm.ptr -> i64
        %194 = arith.cmpi sle, %192, %193 : i64
        scf.yield %194 : i1
      } else {
        %195 = arith.constant false
        scf.yield %195 : i1
      }
      cf.cond_br %189, ^bb40, ^bb41
      ^bb40:
        %196 = llvm.load %162 : !llvm.ptr -> i64
        %197 = llvm.load %187 : !llvm.ptr -> i64
        %198 = arith.remsi %196, %197 : i64
        %199 = arith.constant 0 : i32
        %201 = arith.extsi %199 : i32 to i64
        %200 = arith.cmpi eq, %198, %201 : i64
        cf.cond_br %200, ^bb42, ^bb43
        ^bb42:
          %202 = arith.constant 0 : i1
          llvm.store %202, %169 : i1, !llvm.ptr
          cf.br ^bb44
        ^bb43:
          cf.br ^bb44
        ^bb44:
        %203 = llvm.load %187 : !llvm.ptr -> i64
        %204 = arith.constant 2 : i32
        %206 = arith.extsi %204 : i32 to i64
        %205 = arith.addi %203, %206 : i64
        llvm.store %205, %187 : i64, !llvm.ptr
        cf.br ^bb39
      ^bb41:
      %207 = llvm.load %169 : !llvm.ptr -> i1
      cf.cond_br %207, ^bb45, ^bb46
      ^bb45:
        %209 = llvm.load %162 : !llvm.ptr -> i64
        %208 = func.call @divides_some_R10k(%209) : (i64) -> i1
        %211 = arith.constant 1 : i1
        %210 = arith.xori %208, %211 : i1
        cf.cond_br %210, ^bb48, ^bb49
        ^bb48:
          %213 = llvm.load %158 : !llvm.ptr -> i64
          %214 = llvm.load %162 : !llvm.ptr -> i64
          %215 = arith.addi %213, %214 : i64
          llvm.store %215, %158 : i64, !llvm.ptr
          cf.br ^bb50
        ^bb49:
          cf.br ^bb50
        ^bb50:
        cf.br ^bb47
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %216 = llvm.load %162 : !llvm.ptr -> i64
      %217 = arith.constant 1 : i32
      %219 = arith.extsi %217 : i32 to i64
      %218 = arith.addi %216, %219 : i64
      llvm.store %218, %162 : i64, !llvm.ptr
      cf.br ^bb33
    ^bb35:
    %220 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %221 = llvm.load %158 : !llvm.ptr -> i64
    %222 = llvm.call @printf(%220, %221) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %223 = arith.constant 0 : i32
    func.return %223 : i32
  }
}