← All problems
Problem 733
Ascending sequences: S(10^6) mod 1e9+7 for a_i = 153^i mod 10000019. Method: rank the distinct values with a direct-address table, then use six Fenwick trees over ranks holding the count and term-sum of ascending subsequences of length 1..3 that end strictly below the current value. Each new term extends those to lengths 2..4; length-4 sums accumulate into the answer. Verified against S(6) and S(100) from the statement.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n)O(n log log n)
Space complexity O(n^2)O(n)
Approach Flow solution Sieve or enumeration
Verdict Optimal
Flow source
# Project Euler 733
# Ascending sequences: S(10^6) mod 1e9+7 for a_i = 153^i mod 10000019.
# Method: rank the distinct values with a direct-address table, then use
# six Fenwick trees over ranks holding the count and term-sum of ascending
# subsequences of length 1..3 that end strictly below the current value.
# Each new term extends those to lengths 2..4; length-4 sums accumulate
# into the answer. Verified against S(6) and S(100) from the statement.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function bit_query(t: ptr<i64>, i0: i64) -> i64 {
let mut i: i64 = i0
let mut r: i64 = 0
while i > 0 {
r = r + t[i]
i = i - (i & (0 - i))
}
return r % 1000000007
}
function bit_update(t: ptr<i64>, i0: i64, d: i64, size: i64) -> i64 {
let mut i: i64 = i0
while i <= size {
t[i] = (t[i] + d) % 1000000007
i = i + (i & (0 - i))
}
return 0
}
function main() -> i32 {
let p: i64 = 10000019
let m: i64 = 1000000007
let n: i64 = 1000000
let a: ptr<i64> = calloc(n, 8)
let rank: ptr<i32> = calloc(p, 4)
let c1: ptr<i64> = calloc(n + 1, 8)
let c2: ptr<i64> = calloc(n + 1, 8)
let c3: ptr<i64> = calloc(n + 1, 8)
let s1: ptr<i64> = calloc(n + 1, 8)
let s2: ptr<i64> = calloc(n + 1, 8)
let s3: ptr<i64> = calloc(n + 1, 8)
let mut x: i64 = 1
for i in 0..n {
x = (x * 153) % p
a[i] = x
rank[x] = 1
}
let mut r: i64 = 0
for v in 0..p {
if rank[v] != 0 {
r = r + 1
rank[v] = (r as i32)
}
}
let mut total: i64 = 0
for i in 0..n {
let v: i64 = a[i]
let idx: i64 = (rank[v] as i64)
let q: i64 = idx - 1
let qc1: i64 = bit_query(c1, q)
let qc2: i64 = bit_query(c2, q)
let qc3: i64 = bit_query(c3, q)
let qs1: i64 = bit_query(s1, q)
let qs2: i64 = bit_query(s2, q)
let qs3: i64 = bit_query(s3, q)
let sum2: i64 = (qs1 + v * qc1) % m
let sum3: i64 = (qs2 + v * qc2) % m
let sum4: i64 = (qs3 + v * qc3) % m
total = (total + sum4) % m
bit_update(c1, idx, 1, n)
bit_update(c2, idx, qc1, n)
bit_update(c3, idx, qc2, n)
bit_update(s1, idx, v, n)
bit_update(s2, idx, sum2, n)
bit_update(s3, idx, sum3, n)
}
free(a)
free(rank)
free(c1)
free(c2)
free(c3)
free(s1)
free(s2)
free(s3)
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 bit_query_ptr_i64_i64(int64_t* t, int64_t i0);
int64_t bit_update_ptr_i64_i64_i64_i64(int64_t* t, int64_t i0, int64_t d, int64_t size);
int32_t main(void);
int64_t bit_query_ptr_i64_i64(int64_t* t, int64_t i0) {
int64_t i = i0;
int64_t r = 0;
while (i > 0) {
r = (r + t[i]);
i = (i - (i & (0 - i)));
}
return FLOW_CHECKED_MOD((r), (1000000007));
}
int64_t bit_update_ptr_i64_i64_i64_i64(int64_t* t, int64_t i0, int64_t d, int64_t size) {
int64_t i = i0;
while (i <= size) {
t[i] = FLOW_CHECKED_MOD(((t[i] + d)), (1000000007));
i = (i + (i & (0 - i)));
}
return 0;
}
int32_t main(void) {
int64_t p = 10000019;
int64_t m = 1000000007;
int64_t n = 1000000;
int64_t* a = (int64_t*)(calloc(n, 8));
int32_t* rank = (int32_t*)(calloc(p, 4));
int64_t* c1 = (int64_t*)(calloc((n + 1), 8));
int64_t* c2 = (int64_t*)(calloc((n + 1), 8));
int64_t* c3 = (int64_t*)(calloc((n + 1), 8));
int64_t* s1 = (int64_t*)(calloc((n + 1), 8));
int64_t* s2 = (int64_t*)(calloc((n + 1), 8));
int64_t* s3 = (int64_t*)(calloc((n + 1), 8));
int64_t x = 1;
int32_t __flow_step_1 = 1;
for (int32_t i = 0; (0 <= n) ? i < n : i > n; i += (0 <= n) ? 1 : -1) {
x = FLOW_CHECKED_MOD(((x * 153)), (p));
a[i] = x;
rank[x] = 1;
}
int64_t r = 0;
int32_t __flow_step_2 = 1;
for (int32_t v = 0; (0 <= p) ? v < p : v > p; v += (0 <= p) ? 1 : -1) {
if (rank[v] != 0) {
r = (r + 1);
rank[v] = ((int32_t)(r));
}
}
int64_t total = 0;
int32_t __flow_step_3 = 1;
for (int32_t i = 0; (0 <= n) ? i < n : i > n; i += (0 <= n) ? 1 : -1) {
int64_t v = a[i];
int64_t idx = ((int64_t)(rank[v]));
int64_t q = (idx - 1);
int64_t qc1 = bit_query_ptr_i64_i64(c1, q);
int64_t qc2 = bit_query_ptr_i64_i64(c2, q);
int64_t qc3 = bit_query_ptr_i64_i64(c3, q);
int64_t qs1 = bit_query_ptr_i64_i64(s1, q);
int64_t qs2 = bit_query_ptr_i64_i64(s2, q);
int64_t qs3 = bit_query_ptr_i64_i64(s3, q);
int64_t sum2 = FLOW_CHECKED_MOD(((qs1 + (v * qc1))), (m));
int64_t sum3 = FLOW_CHECKED_MOD(((qs2 + (v * qc2))), (m));
int64_t sum4 = FLOW_CHECKED_MOD(((qs3 + (v * qc3))), (m));
total = FLOW_CHECKED_MOD(((total + sum4)), (m));
bit_update_ptr_i64_i64_i64_i64(c1, idx, 1, n);
bit_update_ptr_i64_i64_i64_i64(c2, idx, qc1, n);
bit_update_ptr_i64_i64_i64_i64(c3, idx, qc2, n);
bit_update_ptr_i64_i64_i64_i64(s1, idx, v, n);
bit_update_ptr_i64_i64_i64_i64(s2, idx, sum2, n);
bit_update_ptr_i64_i64_i64_i64(s3, idx, sum3, n);
}
free(a);
free(rank);
free(c1);
free(c2);
free(c3);
free(s1);
free(s2);
free(s3);
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 @bit_query(%arg0: !llvm.ptr, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %1 : i64, !llvm.ptr
%2 = arith.constant 0 : i32
%3 = arith.extsi %2 : i32 to i64
%4 = llvm.mlir.constant(1 : i64) : i64
%5 = llvm.alloca %4 x i64 : (i64) -> !llvm.ptr
llvm.store %3, %5 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%6 = llvm.load %1 : !llvm.ptr -> i64
%7 = arith.constant 0 : i32
%9 = arith.extsi %7 : i32 to i64
%8 = arith.cmpi sgt, %6, %9 : i64
cf.cond_br %8, ^bb1, ^bb2
^bb1:
%10 = llvm.load %5 : !llvm.ptr -> i64
%12 = llvm.load %1 : !llvm.ptr -> i64
%13 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%11 = llvm.load %13 : !llvm.ptr -> i64
%14 = arith.addi %10, %11 : i64
llvm.store %14, %5 : i64, !llvm.ptr
%15 = llvm.load %1 : !llvm.ptr -> i64
%16 = llvm.load %1 : !llvm.ptr -> i64
%17 = arith.constant 0 : i32
%18 = llvm.load %1 : !llvm.ptr -> i64
%20 = arith.extsi %17 : i32 to i64
%19 = arith.subi %20, %18 : i64
%21 = arith.andi %16, %19 : i64
%22 = arith.subi %15, %21 : i64
llvm.store %22, %1 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%23 = llvm.load %5 : !llvm.ptr -> i64
%24 = arith.constant 1000000007 : i32
%26 = arith.extsi %24 : i32 to i64
%25 = arith.remsi %23, %26 : i64
func.return %25 : i64
}
func.func @bit_update(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: i64) -> i64 {
%27 = llvm.mlir.constant(1 : i64) : i64
%28 = llvm.alloca %27 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %28 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%29 = llvm.load %28 : !llvm.ptr -> i64
%30 = arith.cmpi sle, %29, %arg3 : i64
cf.cond_br %30, ^bb4, ^bb5
^bb4:
%32 = llvm.load %28 : !llvm.ptr -> i64
%33 = llvm.getelementptr %arg0[%32] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%31 = llvm.load %33 : !llvm.ptr -> i64
%34 = arith.addi %31, %arg2 : i64
%35 = arith.constant 1000000007 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.remsi %34, %37 : i64
%38 = llvm.load %28 : !llvm.ptr -> i64
%39 = llvm.getelementptr %arg0[%38] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %36, %39 : i64, !llvm.ptr
%40 = llvm.load %28 : !llvm.ptr -> i64
%41 = llvm.load %28 : !llvm.ptr -> i64
%42 = arith.constant 0 : i32
%43 = llvm.load %28 : !llvm.ptr -> i64
%45 = arith.extsi %42 : i32 to i64
%44 = arith.subi %45, %43 : i64
%46 = arith.andi %41, %44 : i64
%47 = arith.addi %40, %46 : i64
llvm.store %47, %28 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
%48 = arith.constant 0 : i32
%49 = arith.extsi %48 : i32 to i64
func.return %49 : i64
}
func.func @main() -> i32 {
%50 = arith.constant 10000019 : i32
%51 = arith.extsi %50 : i32 to i64
%52 = arith.constant 1000000007 : i32
%53 = arith.extsi %52 : i32 to i64
%54 = arith.constant 1000000 : i32
%55 = arith.extsi %54 : i32 to i64
%57 = arith.constant 8 : i32
%58 = arith.extsi %57 : i32 to i64
%56 = func.call @calloc(%55, %58) : (i64, i64) -> !llvm.ptr
%60 = arith.constant 4 : i32
%61 = arith.extsi %60 : i32 to i64
%59 = func.call @calloc(%51, %61) : (i64, i64) -> !llvm.ptr
%63 = arith.constant 1 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.addi %55, %65 : i64
%66 = arith.constant 8 : i32
%67 = arith.extsi %66 : i32 to i64
%62 = func.call @calloc(%64, %67) : (i64, i64) -> !llvm.ptr
%69 = arith.constant 1 : i32
%71 = arith.extsi %69 : i32 to i64
%70 = arith.addi %55, %71 : i64
%72 = arith.constant 8 : i32
%73 = arith.extsi %72 : i32 to i64
%68 = func.call @calloc(%70, %73) : (i64, i64) -> !llvm.ptr
%75 = arith.constant 1 : i32
%77 = arith.extsi %75 : i32 to i64
%76 = arith.addi %55, %77 : i64
%78 = arith.constant 8 : i32
%79 = arith.extsi %78 : i32 to i64
%74 = func.call @calloc(%76, %79) : (i64, i64) -> !llvm.ptr
%81 = arith.constant 1 : i32
%83 = arith.extsi %81 : i32 to i64
%82 = arith.addi %55, %83 : i64
%84 = arith.constant 8 : i32
%85 = arith.extsi %84 : i32 to i64
%80 = func.call @calloc(%82, %85) : (i64, i64) -> !llvm.ptr
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.addi %55, %89 : i64
%90 = arith.constant 8 : i32
%91 = arith.extsi %90 : i32 to i64
%86 = func.call @calloc(%88, %91) : (i64, i64) -> !llvm.ptr
%93 = arith.constant 1 : i32
%95 = arith.extsi %93 : i32 to i64
%94 = arith.addi %55, %95 : i64
%96 = arith.constant 8 : i32
%97 = arith.extsi %96 : i32 to i64
%92 = func.call @calloc(%94, %97) : (i64, i64) -> !llvm.ptr
%98 = arith.constant 1 : i32
%99 = arith.extsi %98 : i32 to i64
%100 = llvm.mlir.constant(1 : i64) : i64
%101 = llvm.alloca %100 x i64 : (i64) -> !llvm.ptr
llvm.store %99, %101 : i64, !llvm.ptr
%102 = arith.constant 0 : i32
%103 = arith.index_cast %102 : i32 to index
%104 = arith.index_cast %55 : i32 to index
%106 = arith.constant 1 : index
%107 = arith.constant -1 : index
%108 = arith.cmpi sle, %103, %104 : index
%105 = arith.select %108, %106, %107 : index
cf.br ^bb6(%103 : index)
^bb6(%109: index):
%110 = arith.cmpi slt, %109, %104 : index
%111 = arith.cmpi sgt, %109, %104 : index
%112 = arith.select %108, %110, %111 : i1
cf.cond_br %112, ^bb7(%109 : index), ^bb8(%109 : index)
^bb7(%113: index):
%114 = llvm.load %101 : !llvm.ptr -> i64
%115 = arith.constant 153 : i32
%117 = arith.extsi %115 : i32 to i64
%116 = arith.muli %114, %117 : i64
%118 = arith.remsi %116, %51 : i64
llvm.store %118, %101 : i64, !llvm.ptr
%119 = llvm.load %101 : !llvm.ptr -> i64
%120 = arith.index_cast %113 : index to i64
%121 = llvm.getelementptr %56[%120] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %119, %121 : i64, !llvm.ptr
%122 = arith.constant 1 : i32
%123 = llvm.load %101 : !llvm.ptr -> i64
%124 = llvm.getelementptr %59[%123] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %122, %124 : i32, !llvm.ptr
%125 = arith.addi %113, %105 : index
cf.br ^bb6(%125 : index)
^bb8(%126: index):
%127 = arith.constant 0 : i32
%128 = arith.extsi %127 : i32 to i64
%129 = llvm.mlir.constant(1 : i64) : i64
%130 = llvm.alloca %129 x i64 : (i64) -> !llvm.ptr
llvm.store %128, %130 : i64, !llvm.ptr
%131 = arith.constant 0 : i32
%132 = arith.index_cast %131 : i32 to index
%133 = arith.index_cast %51 : i32 to index
%135 = arith.constant 1 : index
%136 = arith.constant -1 : index
%137 = arith.cmpi sle, %132, %133 : index
%134 = arith.select %137, %135, %136 : index
cf.br ^bb9(%132 : index)
^bb9(%138: index):
%139 = arith.cmpi slt, %138, %133 : index
%140 = arith.cmpi sgt, %138, %133 : index
%141 = arith.select %137, %139, %140 : i1
cf.cond_br %141, ^bb10(%138 : index), ^bb11(%138 : index)
^bb10(%142: index):
%144 = arith.index_cast %142 : index to i64
%145 = llvm.getelementptr %59[%144] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%143 = llvm.load %145 : !llvm.ptr -> i32
%146 = arith.constant 0 : i32
%147 = arith.cmpi ne, %143, %146 : i32
cf.cond_br %147, ^bb12, ^bb13
^bb12:
%148 = llvm.load %130 : !llvm.ptr -> i64
%149 = arith.constant 1 : i32
%151 = arith.extsi %149 : i32 to i64
%150 = arith.addi %148, %151 : i64
llvm.store %150, %130 : i64, !llvm.ptr
%152 = llvm.load %130 : !llvm.ptr -> i64
%153 = arith.trunci %152 : i64 to i32
%154 = arith.index_cast %142 : index to i64
%155 = llvm.getelementptr %59[%154] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %153, %155 : i32, !llvm.ptr
cf.br ^bb14
^bb13:
cf.br ^bb14
^bb14:
%156 = arith.addi %142, %134 : index
cf.br ^bb9(%156 : index)
^bb11(%157: index):
%158 = arith.constant 0 : i32
%159 = arith.extsi %158 : i32 to i64
%160 = llvm.mlir.constant(1 : i64) : i64
%161 = llvm.alloca %160 x i64 : (i64) -> !llvm.ptr
llvm.store %159, %161 : i64, !llvm.ptr
%162 = arith.constant 0 : i32
%163 = arith.index_cast %162 : i32 to index
%164 = arith.index_cast %55 : i32 to index
%166 = arith.constant 1 : index
%167 = arith.constant -1 : index
%168 = arith.cmpi sle, %163, %164 : index
%165 = arith.select %168, %166, %167 : index
cf.br ^bb15(%163 : index)
^bb15(%169: index):
%170 = arith.cmpi slt, %169, %164 : index
%171 = arith.cmpi sgt, %169, %164 : index
%172 = arith.select %168, %170, %171 : i1
cf.cond_br %172, ^bb16(%169 : index), ^bb17(%169 : index)
^bb16(%173: index):
%175 = arith.index_cast %173 : index to i64
%176 = llvm.getelementptr %56[%175] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%174 = llvm.load %176 : !llvm.ptr -> i64
%178 = llvm.getelementptr %59[%174] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%177 = llvm.load %178 : !llvm.ptr -> i32
%179 = arith.extsi %177 : i32 to i64
%180 = arith.constant 1 : i32
%182 = arith.extsi %180 : i32 to i64
%181 = arith.subi %179, %182 : i64
%183 = func.call @bit_query(%62, %181) : (!llvm.ptr, i64) -> i64
%184 = func.call @bit_query(%68, %181) : (!llvm.ptr, i64) -> i64
%185 = func.call @bit_query(%74, %181) : (!llvm.ptr, i64) -> i64
%186 = func.call @bit_query(%80, %181) : (!llvm.ptr, i64) -> i64
%187 = func.call @bit_query(%86, %181) : (!llvm.ptr, i64) -> i64
%188 = func.call @bit_query(%92, %181) : (!llvm.ptr, i64) -> i64
%189 = arith.muli %174, %183 : i64
%190 = arith.addi %186, %189 : i64
%191 = arith.remsi %190, %53 : i64
%192 = arith.muli %174, %184 : i64
%193 = arith.addi %187, %192 : i64
%194 = arith.remsi %193, %53 : i64
%195 = arith.muli %174, %185 : i64
%196 = arith.addi %188, %195 : i64
%197 = arith.remsi %196, %53 : i64
%198 = llvm.load %161 : !llvm.ptr -> i64
%199 = arith.addi %198, %197 : i64
%200 = arith.remsi %199, %53 : i64
llvm.store %200, %161 : i64, !llvm.ptr
%202 = arith.constant 1 : i32
%203 = arith.extsi %202 : i32 to i64
%201 = func.call @bit_update(%62, %179, %203, %55) : (!llvm.ptr, i64, i64, i64) -> i64
%204 = func.call @bit_update(%68, %179, %183, %55) : (!llvm.ptr, i64, i64, i64) -> i64
%205 = func.call @bit_update(%74, %179, %184, %55) : (!llvm.ptr, i64, i64, i64) -> i64
%206 = func.call @bit_update(%80, %179, %174, %55) : (!llvm.ptr, i64, i64, i64) -> i64
%207 = func.call @bit_update(%86, %179, %191, %55) : (!llvm.ptr, i64, i64, i64) -> i64
%208 = func.call @bit_update(%92, %179, %194, %55) : (!llvm.ptr, i64, i64, i64) -> i64
%209 = arith.addi %173, %165 : index
cf.br ^bb15(%209 : index)
^bb17(%210: index):
func.call @free(%56) : (!llvm.ptr) -> ()
func.call @free(%59) : (!llvm.ptr) -> ()
func.call @free(%62) : (!llvm.ptr) -> ()
func.call @free(%68) : (!llvm.ptr) -> ()
func.call @free(%74) : (!llvm.ptr) -> ()
func.call @free(%80) : (!llvm.ptr) -> ()
func.call @free(%86) : (!llvm.ptr) -> ()
func.call @free(%92) : (!llvm.ptr) -> ()
%219 = llvm.mlir.addressof @str_0 : !llvm.ptr
%220 = llvm.load %161 : !llvm.ptr -> i64
%221 = llvm.call @printf(%219, %220) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%222 = arith.constant 0 : i32
func.return %222 : i32
}
}