Problem 575
Wandering Robots Average stationary prob on square-index rooms for two move rules, n=1000.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n) | O(n * s) |
| Space complexity | O(1) | O(s) |
| Approach | Flow solution | Path counting DP |
| Verdict | Unknown |
Flow source
# Project Euler 575
# Wandering Robots
# Average stationary prob on square-index rooms for two move rules, n=1000.
function gcd(a0: i64, b0: i64) -> i64 {
let mut a: i64 = a0
let mut b: i64 = b0
if a < 0 { a = -a }
if b < 0 { b = -b }
while b != 0 {
let t: i64 = a % b
a = b
b = t
}
return a
}
function stationary_num(n: i64, rule: i64) -> i64 {
let mut interior: i64 = 0
let mut edge: i64 = 0
let mut corner: i64 = 0
let mut s: i64 = 1
while s <= n {
let x: i64 = s * s
let r: i64 = (x - 1) / n + 1
let c: i64 = (x - 1) % n + 1
let tb: bool = (r == 1) || (r == n)
let lr: bool = (c == 1) || (c == n)
if tb && lr {
corner = corner + 1
} elif tb || lr {
edge = edge + 1
} else {
interior = interior + 1
}
s = s + 1
}
let mut w_i: i64 = 4
let mut w_e: i64 = 3
let mut w_c: i64 = 2
if rule == 1 {
w_i = 5
w_e = 4
w_c = 3
}
return interior * w_i + edge * w_e + corner * w_c
}
function stationary_den(n: i64, rule: i64) -> i64 {
let mut w_i: i64 = 4
let mut w_e: i64 = 3
let mut w_c: i64 = 2
if rule == 1 {
w_i = 5
w_e = 4
w_c = 3
}
return w_i * (n - 2) * (n - 2) + w_e * 4 * (n - 2) + w_c * 4
}
function main() -> i32 {
let n: i64 = 1000
let n1: i64 = stationary_num(n, 1)
let d1: i64 = stationary_den(n, 1)
let n2: i64 = stationary_num(n, 2)
let d2: i64 = stationary_den(n, 2)
let mut num: i64 = n1 * d2 + n2 * d1
let mut den: i64 = d1 * d2 * 2
let g: i64 = gcd(num, den)
num = num / g
den = den / g
let scale: i64 = 1000000000000
let scaled: i64 = num * scale
let mut q: i64 = scaled / den
let r: i64 = scaled % den
if 2 * r >= den {
q = q + 1
}
let ip: i64 = q / scale
let fp: i64 = q % scale
printf("%lld.%012lld\n", ip, fp)
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 gcd_i64_i64(int64_t a0, int64_t b0);
int64_t stationary_num_i64_i64(int64_t n, int64_t rule);
int64_t stationary_den_i64_i64(int64_t n, int64_t rule);
int32_t main(void);
int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
if (a < 0) {
a = (-a);
}
if (b < 0) {
b = (-b);
}
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t stationary_num_i64_i64(int64_t n, int64_t rule) {
int64_t interior = 0;
int64_t edge = 0;
int64_t corner = 0;
int64_t s = 1;
while (s <= n) {
int64_t x = (s * s);
int64_t r = (FLOW_CHECKED_DIV(((x - 1)), (n)) + 1);
int64_t c = (FLOW_CHECKED_MOD(((x - 1)), (n)) + 1);
bool tb = (r == 1 || r == n);
bool lr = (c == 1 || c == n);
if ((tb && lr)) {
corner = (corner + 1);
} else if ((tb || lr)) {
edge = (edge + 1);
} else {
interior = (interior + 1);
}
s = (s + 1);
}
int64_t w_i = 4;
int64_t w_e = 3;
int64_t w_c = 2;
if (rule == 1) {
w_i = 5;
w_e = 4;
w_c = 3;
}
return (((interior * w_i) + (edge * w_e)) + (corner * w_c));
}
int64_t stationary_den_i64_i64(int64_t n, int64_t rule) {
int64_t w_i = 4;
int64_t w_e = 3;
int64_t w_c = 2;
if (rule == 1) {
w_i = 5;
w_e = 4;
w_c = 3;
}
return ((((w_i * (n - 2)) * (n - 2)) + ((w_e * 4) * (n - 2))) + (w_c * 4));
}
int32_t main(void) {
int64_t n = 1000;
int64_t n1 = stationary_num_i64_i64(n, 1);
int64_t d1 = stationary_den_i64_i64(n, 1);
int64_t n2 = stationary_num_i64_i64(n, 2);
int64_t d2 = stationary_den_i64_i64(n, 2);
int64_t num = ((n1 * d2) + (n2 * d1));
int64_t den = ((d1 * d2) * 2);
int64_t g = gcd_i64_i64(num, den);
num = FLOW_CHECKED_DIV((num), (g));
den = FLOW_CHECKED_DIV((den), (g));
int64_t scale = 1000000000000;
int64_t scaled = (num * scale);
int64_t q = FLOW_CHECKED_DIV((scaled), (den));
int64_t r = FLOW_CHECKED_MOD((scaled), (den));
if ((2 * r) >= den) {
q = (q + 1);
}
int64_t ip = FLOW_CHECKED_DIV((q), (scale));
int64_t fp = FLOW_CHECKED_MOD((q), (scale));
printf("%lld.%012lld\n", ip, fp);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld.%012lld\n\00") {addr_space = 0 : i32} : !llvm.array<14 x i8>
func.func @gcd(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %3 : i64, !llvm.ptr
%4 = llvm.load %1 : !llvm.ptr -> i64
%5 = arith.constant 0 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.cmpi slt, %4, %7 : i64
cf.cond_br %6, ^bb0, ^bb1
^bb0:
%8 = llvm.load %1 : !llvm.ptr -> i64
%10 = arith.constant 0 : i64
%9 = arith.subi %10, %8 : i64
llvm.store %9, %1 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
%11 = llvm.load %3 : !llvm.ptr -> i64
%12 = arith.constant 0 : i32
%14 = arith.extsi %12 : i32 to i64
%13 = arith.cmpi slt, %11, %14 : i64
cf.cond_br %13, ^bb3, ^bb4
^bb3:
%15 = llvm.load %3 : !llvm.ptr -> i64
%17 = arith.constant 0 : i64
%16 = arith.subi %17, %15 : i64
llvm.store %16, %3 : i64, !llvm.ptr
cf.br ^bb5
^bb4:
cf.br ^bb5
^bb5:
cf.br ^bb6
^bb6:
%18 = llvm.load %3 : !llvm.ptr -> i64
%19 = arith.constant 0 : i32
%21 = arith.extsi %19 : i32 to i64
%20 = arith.cmpi ne, %18, %21 : i64
cf.cond_br %20, ^bb7, ^bb8
^bb7:
%22 = llvm.load %1 : !llvm.ptr -> i64
%23 = llvm.load %3 : !llvm.ptr -> i64
%24 = arith.remsi %22, %23 : i64
%25 = llvm.load %3 : !llvm.ptr -> i64
llvm.store %25, %1 : i64, !llvm.ptr
llvm.store %24, %3 : i64, !llvm.ptr
cf.br ^bb6
^bb8:
%26 = llvm.load %1 : !llvm.ptr -> i64
func.return %26 : i64
}
func.func @stationary_num(%arg0: i64, %arg1: i64) -> i64 {
%27 = arith.constant 0 : i32
%28 = arith.extsi %27 : i32 to i64
%29 = llvm.mlir.constant(1 : i64) : i64
%30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
llvm.store %28, %30 : i64, !llvm.ptr
%31 = arith.constant 0 : i32
%32 = arith.extsi %31 : i32 to i64
%33 = llvm.mlir.constant(1 : i64) : i64
%34 = llvm.alloca %33 x i64 : (i64) -> !llvm.ptr
llvm.store %32, %34 : i64, !llvm.ptr
%35 = arith.constant 0 : i32
%36 = arith.extsi %35 : i32 to i64
%37 = llvm.mlir.constant(1 : i64) : i64
%38 = llvm.alloca %37 x i64 : (i64) -> !llvm.ptr
llvm.store %36, %38 : i64, !llvm.ptr
%39 = arith.constant 1 : i32
%40 = arith.extsi %39 : i32 to i64
%41 = llvm.mlir.constant(1 : i64) : i64
%42 = llvm.alloca %41 x i64 : (i64) -> !llvm.ptr
llvm.store %40, %42 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%43 = llvm.load %42 : !llvm.ptr -> i64
%44 = arith.cmpi sle, %43, %arg0 : i64
cf.cond_br %44, ^bb10, ^bb11
^bb10:
%45 = llvm.load %42 : !llvm.ptr -> i64
%46 = llvm.load %42 : !llvm.ptr -> i64
%47 = arith.muli %45, %46 : i64
%48 = arith.constant 1 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.subi %47, %50 : i64
%51 = arith.divsi %49, %arg0 : i64
%52 = arith.constant 1 : i32
%54 = arith.extsi %52 : i32 to i64
%53 = arith.addi %51, %54 : i64
%55 = arith.constant 1 : i32
%57 = arith.extsi %55 : i32 to i64
%56 = arith.subi %47, %57 : i64
%58 = arith.remsi %56, %arg0 : i64
%59 = arith.constant 1 : i32
%61 = arith.extsi %59 : i32 to i64
%60 = arith.addi %58, %61 : i64
%62 = arith.constant 1 : i32
%64 = arith.extsi %62 : i32 to i64
%63 = arith.cmpi eq, %53, %64 : i64
%65 = scf.if %63 -> (i1) {
%66 = arith.constant true
scf.yield %66 : i1
} else {
%67 = arith.cmpi eq, %53, %arg0 : i64
scf.yield %67 : i1
}
%68 = arith.constant 1 : i32
%70 = arith.extsi %68 : i32 to i64
%69 = arith.cmpi eq, %60, %70 : i64
%71 = scf.if %69 -> (i1) {
%72 = arith.constant true
scf.yield %72 : i1
} else {
%73 = arith.cmpi eq, %60, %arg0 : i64
scf.yield %73 : i1
}
%74 = scf.if %65 -> (i1) {
scf.yield %71 : i1
} else {
%75 = arith.constant false
scf.yield %75 : i1
}
cf.cond_br %74, ^bb12, ^bb13
^bb12:
%76 = llvm.load %38 : !llvm.ptr -> i64
%77 = arith.constant 1 : i32
%79 = arith.extsi %77 : i32 to i64
%78 = arith.addi %76, %79 : i64
llvm.store %78, %38 : i64, !llvm.ptr
cf.br ^bb14
^bb13:
%80 = scf.if %65 -> (i1) {
%81 = arith.constant true
scf.yield %81 : i1
} else {
scf.yield %71 : i1
}
cf.cond_br %80, ^bb16, ^bb15
^bb16:
%82 = llvm.load %34 : !llvm.ptr -> i64
%83 = arith.constant 1 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.addi %82, %85 : i64
llvm.store %84, %34 : i64, !llvm.ptr
cf.br ^bb14
^bb15:
%86 = llvm.load %30 : !llvm.ptr -> i64
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.addi %86, %89 : i64
llvm.store %88, %30 : i64, !llvm.ptr
cf.br ^bb14
^bb14:
%90 = llvm.load %42 : !llvm.ptr -> i64
%91 = arith.constant 1 : i32
%93 = arith.extsi %91 : i32 to i64
%92 = arith.addi %90, %93 : i64
llvm.store %92, %42 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%94 = arith.constant 4 : i32
%95 = arith.extsi %94 : i32 to i64
%96 = llvm.mlir.constant(1 : i64) : i64
%97 = llvm.alloca %96 x i64 : (i64) -> !llvm.ptr
llvm.store %95, %97 : i64, !llvm.ptr
%98 = arith.constant 3 : 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 2 : i32
%103 = arith.extsi %102 : i32 to i64
%104 = llvm.mlir.constant(1 : i64) : i64
%105 = llvm.alloca %104 x i64 : (i64) -> !llvm.ptr
llvm.store %103, %105 : i64, !llvm.ptr
%106 = arith.constant 1 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.cmpi eq, %arg1, %108 : i64
cf.cond_br %107, ^bb17, ^bb18
^bb17:
%109 = arith.constant 5 : i32
%110 = arith.extsi %109 : i32 to i64
llvm.store %110, %97 : i64, !llvm.ptr
%111 = arith.constant 4 : i32
%112 = arith.extsi %111 : i32 to i64
llvm.store %112, %101 : i64, !llvm.ptr
%113 = arith.constant 3 : i32
%114 = arith.extsi %113 : i32 to i64
llvm.store %114, %105 : i64, !llvm.ptr
cf.br ^bb19
^bb18:
cf.br ^bb19
^bb19:
%115 = llvm.load %30 : !llvm.ptr -> i64
%116 = llvm.load %97 : !llvm.ptr -> i64
%117 = arith.muli %115, %116 : i64
%118 = llvm.load %34 : !llvm.ptr -> i64
%119 = llvm.load %101 : !llvm.ptr -> i64
%120 = arith.muli %118, %119 : i64
%121 = arith.addi %117, %120 : i64
%122 = llvm.load %38 : !llvm.ptr -> i64
%123 = llvm.load %105 : !llvm.ptr -> i64
%124 = arith.muli %122, %123 : i64
%125 = arith.addi %121, %124 : i64
func.return %125 : i64
}
func.func @stationary_den(%arg0: i64, %arg1: i64) -> i64 {
%126 = arith.constant 4 : i32
%127 = arith.extsi %126 : i32 to i64
%128 = llvm.mlir.constant(1 : i64) : i64
%129 = llvm.alloca %128 x i64 : (i64) -> !llvm.ptr
llvm.store %127, %129 : i64, !llvm.ptr
%130 = arith.constant 3 : i32
%131 = arith.extsi %130 : i32 to i64
%132 = llvm.mlir.constant(1 : i64) : i64
%133 = llvm.alloca %132 x i64 : (i64) -> !llvm.ptr
llvm.store %131, %133 : i64, !llvm.ptr
%134 = arith.constant 2 : i32
%135 = arith.extsi %134 : i32 to i64
%136 = llvm.mlir.constant(1 : i64) : i64
%137 = llvm.alloca %136 x i64 : (i64) -> !llvm.ptr
llvm.store %135, %137 : i64, !llvm.ptr
%138 = arith.constant 1 : i32
%140 = arith.extsi %138 : i32 to i64
%139 = arith.cmpi eq, %arg1, %140 : i64
cf.cond_br %139, ^bb20, ^bb21
^bb20:
%141 = arith.constant 5 : i32
%142 = arith.extsi %141 : i32 to i64
llvm.store %142, %129 : i64, !llvm.ptr
%143 = arith.constant 4 : i32
%144 = arith.extsi %143 : i32 to i64
llvm.store %144, %133 : i64, !llvm.ptr
%145 = arith.constant 3 : i32
%146 = arith.extsi %145 : i32 to i64
llvm.store %146, %137 : i64, !llvm.ptr
cf.br ^bb22
^bb21:
cf.br ^bb22
^bb22:
%147 = llvm.load %129 : !llvm.ptr -> i64
%148 = arith.constant 2 : i32
%150 = arith.extsi %148 : i32 to i64
%149 = arith.subi %arg0, %150 : i64
%151 = arith.muli %147, %149 : i64
%152 = arith.constant 2 : i32
%154 = arith.extsi %152 : i32 to i64
%153 = arith.subi %arg0, %154 : i64
%155 = arith.muli %151, %153 : i64
%156 = llvm.load %133 : !llvm.ptr -> i64
%157 = arith.constant 4 : i32
%159 = arith.extsi %157 : i32 to i64
%158 = arith.muli %156, %159 : i64
%160 = arith.constant 2 : i32
%162 = arith.extsi %160 : i32 to i64
%161 = arith.subi %arg0, %162 : i64
%163 = arith.muli %158, %161 : i64
%164 = arith.addi %155, %163 : i64
%165 = llvm.load %137 : !llvm.ptr -> i64
%166 = arith.constant 4 : i32
%168 = arith.extsi %166 : i32 to i64
%167 = arith.muli %165, %168 : i64
%169 = arith.addi %164, %167 : i64
func.return %169 : i64
}
func.func @main() -> i32 {
%170 = arith.constant 1000 : i32
%171 = arith.extsi %170 : i32 to i64
%173 = arith.constant 1 : i32
%174 = arith.extsi %173 : i32 to i64
%172 = func.call @stationary_num(%171, %174) : (i64, i64) -> i64
%176 = arith.constant 1 : i32
%177 = arith.extsi %176 : i32 to i64
%175 = func.call @stationary_den(%171, %177) : (i64, i64) -> i64
%179 = arith.constant 2 : i32
%180 = arith.extsi %179 : i32 to i64
%178 = func.call @stationary_num(%171, %180) : (i64, i64) -> i64
%182 = arith.constant 2 : i32
%183 = arith.extsi %182 : i32 to i64
%181 = func.call @stationary_den(%171, %183) : (i64, i64) -> i64
%184 = arith.muli %172, %181 : i64
%185 = arith.muli %178, %175 : i64
%186 = arith.addi %184, %185 : i64
%187 = llvm.mlir.constant(1 : i64) : i64
%188 = llvm.alloca %187 x i64 : (i64) -> !llvm.ptr
llvm.store %186, %188 : i64, !llvm.ptr
%189 = arith.muli %175, %181 : i64
%190 = arith.constant 2 : i32
%192 = arith.extsi %190 : i32 to i64
%191 = arith.muli %189, %192 : i64
%193 = llvm.mlir.constant(1 : i64) : i64
%194 = llvm.alloca %193 x i64 : (i64) -> !llvm.ptr
llvm.store %191, %194 : i64, !llvm.ptr
%196 = llvm.load %188 : !llvm.ptr -> i64
%197 = llvm.load %194 : !llvm.ptr -> i64
%195 = func.call @gcd(%196, %197) : (i64, i64) -> i64
%198 = llvm.load %188 : !llvm.ptr -> i64
%199 = arith.divsi %198, %195 : i64
llvm.store %199, %188 : i64, !llvm.ptr
%200 = llvm.load %194 : !llvm.ptr -> i64
%201 = arith.divsi %200, %195 : i64
llvm.store %201, %194 : i64, !llvm.ptr
%202 = arith.constant 995705032704 : i32
%203 = arith.extsi %202 : i32 to i64
%204 = llvm.load %188 : !llvm.ptr -> i64
%205 = arith.muli %204, %203 : i64
%206 = llvm.load %194 : !llvm.ptr -> i64
%207 = arith.divsi %205, %206 : 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 = llvm.load %194 : !llvm.ptr -> i64
%211 = arith.remsi %205, %210 : i64
%212 = arith.constant 2 : i32
%214 = arith.extsi %212 : i32 to i64
%213 = arith.muli %214, %211 : i64
%215 = llvm.load %194 : !llvm.ptr -> i64
%216 = arith.cmpi sge, %213, %215 : i64
cf.cond_br %216, ^bb23, ^bb24
^bb23:
%217 = llvm.load %209 : !llvm.ptr -> i64
%218 = arith.constant 1 : i32
%220 = arith.extsi %218 : i32 to i64
%219 = arith.addi %217, %220 : i64
llvm.store %219, %209 : i64, !llvm.ptr
cf.br ^bb25
^bb24:
cf.br ^bb25
^bb25:
%221 = llvm.load %209 : !llvm.ptr -> i64
%222 = arith.divsi %221, %203 : i64
%223 = llvm.load %209 : !llvm.ptr -> i64
%224 = arith.remsi %223, %203 : i64
%225 = llvm.mlir.addressof @str_0 : !llvm.ptr
%226 = llvm.call @printf(%225, %222, %224) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64, i64) -> i32
%227 = arith.constant 0 : i32
func.return %227 : i32
}
}