Problem 098
Largest square number formed by anagramic word pair digit substitution.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^3) | O(n!) |
| Space complexity | O(n) | O(n) |
| Approach | Flow solution | Permutation enumeration or constraint search |
| Verdict | Optimal |
Flow source
# Project Euler 098
# Largest square number formed by anagramic word pair digit substitution.
extern {
function fopen(path: string, mode: string) -> ptr<void>
function fgetc(f: ptr<void>) -> i32
function fclose(f: ptr<void>) -> i32
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function word_len(words: ptr<i8>, row: i32, width: i32) -> i32 {
let mut i: i32 = 0
while i < width {
if words[row * width + i] == 0 { return i }
i = i + 1
}
return width
}
function same_anagram(words: ptr<i8>, a: i32, b: i32, width: i32) -> bool {
let ca: array<i32, 26> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
let cb: array<i32, 26> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
let mut i: i32 = 0
while i < width {
let xa: i32 = words[a * width + i] as i32
let xb: i32 = words[b * width + i] as i32
if xa == 0 && xb == 0 { break }
if xa == 0 || xb == 0 { return false }
ca[xa - 65] = ca[xa - 65] + 1
cb[xb - 65] = cb[xb - 65] + 1
i = i + 1
}
i = 0
while i < 26 {
if ca[i] != cb[i] { return false }
i = i + 1
}
return true
}
function is_square(n: i64) -> bool {
if n <= 0 { return false }
let mut x: i64 = n
while x > 1 {
let y: i64 = (x + n / x) / 2
if y >= x { break }
x = y
}
let mut r: i64 = x
while r * r > n { r = r - 1 }
while (r + 1) * (r + 1) <= n { r = r + 1 }
return r * r == n
}
function pow10(n: i32) -> i64 {
let mut r: i64 = 1
for i in 0..n {
r = r * 10
}
return r
}
function main() -> i32 {
let width: i32 = 16
let maxw: i32 = 3000
let words: ptr<i8> = calloc((maxw * width) as i64, 1)
if words == null { return 1 }
let f: ptr<void> = fopen("data/p098.txt", "r")
if f == null {
printf("failed to read data/p098.txt\n")
return 1
}
let mut count: i32 = 0
let mut blen: i32 = 0
let mut in_w: bool = false
let mut ch: i32 = fgetc(f)
while ch >= 0 {
if ch == 34 {
if in_w {
words[count * width + blen] = 0
count = count + 1
blen = 0
in_w = false
} else {
in_w = true
blen = 0
}
} elif in_w {
if blen < width - 1 {
words[count * width + blen] = ch as i8
blen = blen + 1
}
}
ch = fgetc(f)
}
fclose(f)
let mut best: i64 = 0
for i in 0..count {
let li: i32 = word_len(words, i, width)
for j in (i + 1)..count {
let lj: i32 = word_len(words, j, width)
if li == lj && li >= 1 && same_anagram(words, i, j, width) {
# try square mappings
let lo: i64 = pow10(li - 1)
let hi: i64 = pow10(li) - 1
let mut r: i64 = 1
while r * r < lo {
r = r + 1
}
while r * r <= hi {
let sq: i64 = r * r
# map letters of word i from digits of sq
let mapc: array<i32, 26> = [0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1]
let mapd: array<i32, 10> = [0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1, 0 - 1]
let mut digits: array<i32, 16> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
let mut tmp: i64 = sq
let mut k: i32 = li - 1
while k >= 0 {
digits[k] = (tmp % 10) as i32
tmp = tmp / 10
k = k - 1
}
let mut ok: bool = true
k = 0
while k < li {
let letter: i32 = words[i * width + k] as i32 - 65
let dig: i32 = digits[k]
if mapc[letter] == 0 - 1 && mapd[dig] == 0 - 1 {
mapc[letter] = dig
mapd[dig] = letter
} elif mapc[letter] != dig || mapd[dig] != letter {
ok = false
break
}
k = k + 1
}
if ok {
# form number for word j
let mut val: i64 = 0
k = 0
while k < li {
let letter: i32 = words[j * width + k] as i32 - 65
let dig: i32 = mapc[letter]
if k == 0 && dig == 0 {
ok = false
break
}
val = val * 10 + (dig as i64)
k = k + 1
}
if ok && is_square(val) {
if sq > best { best = sq }
if val > best { best = val }
}
}
r = r + 1
}
}
}
}
printf("%lld\n", best)
free(words)
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; }
int32_t word_len_ptr_i8_i32_i32(int8_t* words, int32_t row, int32_t width);
bool same_anagram_ptr_i8_i32_i32_i32(int8_t* words, int32_t a, int32_t b, int32_t width);
bool is_square_i64(int64_t n);
int64_t pow10_i32(int32_t n);
int32_t main(void);
int32_t word_len_ptr_i8_i32_i32(int8_t* words, int32_t row, int32_t width) {
int32_t i = 0;
while (i < width) {
if (words[((row * width) + i)] == 0) {
return i;
}
i = (i + 1);
}
return width;
}
bool same_anagram_ptr_i8_i32_i32_i32(int8_t* words, int32_t a, int32_t b, int32_t width) {
int32_t ca[26] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int32_t cb[26] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int32_t i = 0;
while (i < width) {
int32_t xa = ((int32_t)(words[((a * width) + i)]));
int32_t xb = ((int32_t)(words[((b * width) + i)]));
if ((xa == 0 && xb == 0)) {
break;
}
if ((xa == 0 || xb == 0)) {
return 0;
}
ca[(xa - 65)] = ((((unsigned)((xa - 65)) < 26) ? ca[(xa - 65)] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)((xa - 65)), 26), flow_fault_handler("array index out of bounds"), ca[0])) + 1);
cb[(xb - 65)] = ((((unsigned)((xb - 65)) < 26) ? cb[(xb - 65)] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)((xb - 65)), 26), flow_fault_handler("array index out of bounds"), cb[0])) + 1);
i = (i + 1);
}
i = 0;
while (i < 26) {
if ((((unsigned)(i) < 26) ? ca[i] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(i), 26), flow_fault_handler("array index out of bounds"), ca[0])) != (((unsigned)(i) < 26) ? cb[i] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(i), 26), flow_fault_handler("array index out of bounds"), cb[0]))) {
return 0;
}
i = (i + 1);
}
return 1;
}
bool is_square_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t x = n;
while (x > 1) {
int64_t y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
if (y >= x) {
break;
}
x = y;
}
int64_t r = x;
while ((r * r) > n) {
r = (r - 1);
}
while (((r + 1) * (r + 1)) <= n) {
r = (r + 1);
}
return (r * r) == n;
}
int64_t pow10_i32(int32_t n) {
int64_t r = 1;
int32_t __flow_step_1 = 1;
for (int32_t i = 0; (0 <= n) ? i < n : i > n; i += (0 <= n) ? 1 : -1) {
r = (r * 10);
}
return r;
}
int32_t main(void) {
int32_t width = 16;
int32_t maxw = 3000;
int8_t* words = (int8_t*)(calloc(((int64_t)((maxw * width))), 1));
if (words == NULL) {
return 1;
}
void* f = (void*)(fopen("data/p098.txt", "r"));
if (f == NULL) {
printf("failed to read data/p098.txt\n");
return 1;
}
int32_t count = 0;
int32_t blen = 0;
bool in_w = 0;
int32_t ch = fgetc(f);
while (ch >= 0) {
if (ch == 34) {
if (in_w) {
words[((count * width) + blen)] = 0;
count = (count + 1);
blen = 0;
in_w = 0;
} else {
in_w = 1;
blen = 0;
}
} else if (in_w) {
if (blen < (width - 1)) {
words[((count * width) + blen)] = ((int8_t)(ch));
blen = (blen + 1);
}
}
ch = fgetc(f);
}
fclose(f);
int64_t best = 0;
int32_t __flow_step_2 = 1;
for (int32_t i = 0; (0 <= count) ? i < count : i > count; i += (0 <= count) ? 1 : -1) {
int32_t li = word_len_ptr_i8_i32_i32(words, i, width);
int32_t __flow_step_3 = 1;
for (int32_t j = (i + 1); ((i + 1) <= count) ? j < count : j > count; j += ((i + 1) <= count) ? 1 : -1) {
int32_t lj = word_len_ptr_i8_i32_i32(words, j, width);
if (((li == lj && li >= 1) && same_anagram_ptr_i8_i32_i32_i32(words, i, j, width))) {
int64_t lo = pow10_i32((li - 1));
int64_t hi = (pow10_i32(li) - 1);
int64_t r = 1;
while ((r * r) < lo) {
r = (r + 1);
}
while ((r * r) <= hi) {
int64_t sq = (r * r);
int32_t mapc[26] = { (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1) };
int32_t mapd[10] = { (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1), (0 - 1) };
int32_t digits[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int64_t tmp = sq;
int32_t k = (li - 1);
while (k >= 0) {
digits[k] = ((int32_t)(FLOW_CHECKED_MOD((tmp), (10))));
tmp = FLOW_CHECKED_DIV((tmp), (10));
k = (k - 1);
}
bool ok = 1;
k = 0;
while (k < li) {
int32_t letter = (((int32_t)(words[((i * width) + k)])) - 65);
int32_t dig = (((unsigned)(k) < 16) ? digits[k] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(k), 16), flow_fault_handler("array index out of bounds"), digits[0]));
if (((((unsigned)(letter) < 26) ? mapc[letter] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(letter), 26), flow_fault_handler("array index out of bounds"), mapc[0])) == (0 - 1) && (((unsigned)(dig) < 10) ? mapd[dig] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(dig), 10), flow_fault_handler("array index out of bounds"), mapd[0])) == (0 - 1))) {
mapc[letter] = dig;
mapd[dig] = letter;
} else if (((((unsigned)(letter) < 26) ? mapc[letter] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(letter), 26), flow_fault_handler("array index out of bounds"), mapc[0])) != dig || (((unsigned)(dig) < 10) ? mapd[dig] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(dig), 10), flow_fault_handler("array index out of bounds"), mapd[0])) != letter)) {
ok = 0;
break;
}
k = (k + 1);
}
if (ok) {
int64_t val = 0;
k = 0;
while (k < li) {
int32_t letter = (((int32_t)(words[((j * width) + k)])) - 65);
int32_t dig = (((unsigned)(letter) < 26) ? mapc[letter] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(letter), 26), flow_fault_handler("array index out of bounds"), mapc[0]));
if ((k == 0 && dig == 0)) {
ok = 0;
break;
}
val = ((val * 10) + ((int64_t)(dig)));
k = (k + 1);
}
if ((ok && is_square_i64(val))) {
if (sq > best) {
best = sq;
}
if (val > best) {
best = val;
}
}
}
r = (r + 1);
}
}
}
}
printf("%lld\n", best);
free(words);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("data/p098.txt\00") {addr_space = 0 : i32} : !llvm.array<14 x i8>
llvm.mlir.global internal constant @str_1("r\00") {addr_space = 0 : i32} : !llvm.array<2 x i8>
llvm.mlir.global internal constant @str_2("failed to read data/p098.txt\n\00") {addr_space = 0 : i32} : !llvm.array<30 x i8>
llvm.mlir.global internal constant @str_3("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func private @fopen(!llvm.ptr, !llvm.ptr) -> !llvm.ptr
func.func private @fgetc(!llvm.ptr) -> i32
func.func private @fclose(!llvm.ptr) -> i32
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @word_len(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> i32 {
%0 = arith.constant 0 : i32
%1 = llvm.mlir.constant(1 : i64) : i64
%2 = llvm.alloca %1 x i32 : (i64) -> !llvm.ptr
llvm.store %0, %2 : i32, !llvm.ptr
cf.br ^bb0
^bb0:
%3 = llvm.load %2 : !llvm.ptr -> i32
%4 = arith.cmpi slt, %3, %arg2 : i32
cf.cond_br %4, ^bb1, ^bb2
^bb1:
%6 = arith.muli %arg1, %arg2 : i32
%7 = llvm.load %2 : !llvm.ptr -> i32
%8 = arith.addi %6, %7 : i32
%9 = arith.extsi %8 : i32 to i64
%10 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%5 = llvm.load %10 : !llvm.ptr -> i8
%11 = arith.constant 0 : i32
%13 = arith.extsi %5 : i8 to i32
%12 = arith.cmpi eq, %13, %11 : i32
cf.cond_br %12, ^bb3, ^bb4
^bb3:
%14 = llvm.load %2 : !llvm.ptr -> i32
func.return %14 : i32
^bb4:
cf.br ^bb5
^bb5:
%15 = llvm.load %2 : !llvm.ptr -> i32
%16 = arith.constant 1 : i32
%17 = arith.addi %15, %16 : i32
llvm.store %17, %2 : i32, !llvm.ptr
cf.br ^bb0
^bb2:
func.return %arg2 : i32
}
func.func @same_anagram(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 {
%19 = arith.constant 0 : i32
%20 = arith.constant 0 : i32
%21 = arith.constant 0 : i32
%22 = arith.constant 0 : i32
%23 = arith.constant 0 : i32
%24 = arith.constant 0 : i32
%25 = arith.constant 0 : i32
%26 = arith.constant 0 : i32
%27 = arith.constant 0 : i32
%28 = arith.constant 0 : i32
%29 = arith.constant 0 : i32
%30 = arith.constant 0 : i32
%31 = arith.constant 0 : i32
%32 = arith.constant 0 : i32
%33 = arith.constant 0 : i32
%34 = arith.constant 0 : i32
%35 = arith.constant 0 : i32
%36 = arith.constant 0 : i32
%37 = arith.constant 0 : i32
%38 = arith.constant 0 : i32
%39 = arith.constant 0 : i32
%40 = arith.constant 0 : i32
%41 = arith.constant 0 : i32
%42 = arith.constant 0 : i32
%43 = arith.constant 0 : i32
%44 = arith.constant 0 : i32
%45 = llvm.mlir.constant(1 : i64) : i64
%46 = llvm.alloca %45 x !llvm.array<26 x i32> : (i64) -> !llvm.ptr
%47 = llvm.mlir.zero : !llvm.array<26 x i32>
llvm.store %47, %46 : !llvm.array<26 x i32>, !llvm.ptr
%48 = llvm.mlir.constant(0 : i64) : i64
%49 = llvm.getelementptr %46[0, %48] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %19, %49 : i32, !llvm.ptr
%50 = llvm.mlir.constant(1 : i64) : i64
%51 = llvm.getelementptr %46[0, %50] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %20, %51 : i32, !llvm.ptr
%52 = llvm.mlir.constant(2 : i64) : i64
%53 = llvm.getelementptr %46[0, %52] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %21, %53 : i32, !llvm.ptr
%54 = llvm.mlir.constant(3 : i64) : i64
%55 = llvm.getelementptr %46[0, %54] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %22, %55 : i32, !llvm.ptr
%56 = llvm.mlir.constant(4 : i64) : i64
%57 = llvm.getelementptr %46[0, %56] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %23, %57 : i32, !llvm.ptr
%58 = llvm.mlir.constant(5 : i64) : i64
%59 = llvm.getelementptr %46[0, %58] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %24, %59 : i32, !llvm.ptr
%60 = llvm.mlir.constant(6 : i64) : i64
%61 = llvm.getelementptr %46[0, %60] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %25, %61 : i32, !llvm.ptr
%62 = llvm.mlir.constant(7 : i64) : i64
%63 = llvm.getelementptr %46[0, %62] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %26, %63 : i32, !llvm.ptr
%64 = llvm.mlir.constant(8 : i64) : i64
%65 = llvm.getelementptr %46[0, %64] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %27, %65 : i32, !llvm.ptr
%66 = llvm.mlir.constant(9 : i64) : i64
%67 = llvm.getelementptr %46[0, %66] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %28, %67 : i32, !llvm.ptr
%68 = llvm.mlir.constant(10 : i64) : i64
%69 = llvm.getelementptr %46[0, %68] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %29, %69 : i32, !llvm.ptr
%70 = llvm.mlir.constant(11 : i64) : i64
%71 = llvm.getelementptr %46[0, %70] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %30, %71 : i32, !llvm.ptr
%72 = llvm.mlir.constant(12 : i64) : i64
%73 = llvm.getelementptr %46[0, %72] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %31, %73 : i32, !llvm.ptr
%74 = llvm.mlir.constant(13 : i64) : i64
%75 = llvm.getelementptr %46[0, %74] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %32, %75 : i32, !llvm.ptr
%76 = llvm.mlir.constant(14 : i64) : i64
%77 = llvm.getelementptr %46[0, %76] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %33, %77 : i32, !llvm.ptr
%78 = llvm.mlir.constant(15 : i64) : i64
%79 = llvm.getelementptr %46[0, %78] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %34, %79 : i32, !llvm.ptr
%80 = llvm.mlir.constant(16 : i64) : i64
%81 = llvm.getelementptr %46[0, %80] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %35, %81 : i32, !llvm.ptr
%82 = llvm.mlir.constant(17 : i64) : i64
%83 = llvm.getelementptr %46[0, %82] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %36, %83 : i32, !llvm.ptr
%84 = llvm.mlir.constant(18 : i64) : i64
%85 = llvm.getelementptr %46[0, %84] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %37, %85 : i32, !llvm.ptr
%86 = llvm.mlir.constant(19 : i64) : i64
%87 = llvm.getelementptr %46[0, %86] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %38, %87 : i32, !llvm.ptr
%88 = llvm.mlir.constant(20 : i64) : i64
%89 = llvm.getelementptr %46[0, %88] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %39, %89 : i32, !llvm.ptr
%90 = llvm.mlir.constant(21 : i64) : i64
%91 = llvm.getelementptr %46[0, %90] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %40, %91 : i32, !llvm.ptr
%92 = llvm.mlir.constant(22 : i64) : i64
%93 = llvm.getelementptr %46[0, %92] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %41, %93 : i32, !llvm.ptr
%94 = llvm.mlir.constant(23 : i64) : i64
%95 = llvm.getelementptr %46[0, %94] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %42, %95 : i32, !llvm.ptr
%96 = llvm.mlir.constant(24 : i64) : i64
%97 = llvm.getelementptr %46[0, %96] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %43, %97 : i32, !llvm.ptr
%98 = llvm.mlir.constant(25 : i64) : i64
%99 = llvm.getelementptr %46[0, %98] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %44, %99 : i32, !llvm.ptr
%101 = arith.constant 0 : i32
%102 = arith.constant 0 : i32
%103 = arith.constant 0 : i32
%104 = arith.constant 0 : i32
%105 = arith.constant 0 : i32
%106 = arith.constant 0 : i32
%107 = arith.constant 0 : i32
%108 = arith.constant 0 : i32
%109 = arith.constant 0 : i32
%110 = arith.constant 0 : i32
%111 = arith.constant 0 : i32
%112 = arith.constant 0 : i32
%113 = arith.constant 0 : i32
%114 = arith.constant 0 : i32
%115 = arith.constant 0 : i32
%116 = arith.constant 0 : i32
%117 = arith.constant 0 : i32
%118 = arith.constant 0 : i32
%119 = arith.constant 0 : i32
%120 = arith.constant 0 : i32
%121 = arith.constant 0 : i32
%122 = arith.constant 0 : i32
%123 = arith.constant 0 : i32
%124 = arith.constant 0 : i32
%125 = arith.constant 0 : i32
%126 = arith.constant 0 : i32
%127 = llvm.mlir.constant(1 : i64) : i64
%128 = llvm.alloca %127 x !llvm.array<26 x i32> : (i64) -> !llvm.ptr
%129 = llvm.mlir.zero : !llvm.array<26 x i32>
llvm.store %129, %128 : !llvm.array<26 x i32>, !llvm.ptr
%130 = llvm.mlir.constant(0 : i64) : i64
%131 = llvm.getelementptr %128[0, %130] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %101, %131 : i32, !llvm.ptr
%132 = llvm.mlir.constant(1 : i64) : i64
%133 = llvm.getelementptr %128[0, %132] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %102, %133 : i32, !llvm.ptr
%134 = llvm.mlir.constant(2 : i64) : i64
%135 = llvm.getelementptr %128[0, %134] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %103, %135 : i32, !llvm.ptr
%136 = llvm.mlir.constant(3 : i64) : i64
%137 = llvm.getelementptr %128[0, %136] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %104, %137 : i32, !llvm.ptr
%138 = llvm.mlir.constant(4 : i64) : i64
%139 = llvm.getelementptr %128[0, %138] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %105, %139 : i32, !llvm.ptr
%140 = llvm.mlir.constant(5 : i64) : i64
%141 = llvm.getelementptr %128[0, %140] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %106, %141 : i32, !llvm.ptr
%142 = llvm.mlir.constant(6 : i64) : i64
%143 = llvm.getelementptr %128[0, %142] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %107, %143 : i32, !llvm.ptr
%144 = llvm.mlir.constant(7 : i64) : i64
%145 = llvm.getelementptr %128[0, %144] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %108, %145 : i32, !llvm.ptr
%146 = llvm.mlir.constant(8 : i64) : i64
%147 = llvm.getelementptr %128[0, %146] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %109, %147 : i32, !llvm.ptr
%148 = llvm.mlir.constant(9 : i64) : i64
%149 = llvm.getelementptr %128[0, %148] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %110, %149 : i32, !llvm.ptr
%150 = llvm.mlir.constant(10 : i64) : i64
%151 = llvm.getelementptr %128[0, %150] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %111, %151 : i32, !llvm.ptr
%152 = llvm.mlir.constant(11 : i64) : i64
%153 = llvm.getelementptr %128[0, %152] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %112, %153 : i32, !llvm.ptr
%154 = llvm.mlir.constant(12 : i64) : i64
%155 = llvm.getelementptr %128[0, %154] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %113, %155 : i32, !llvm.ptr
%156 = llvm.mlir.constant(13 : i64) : i64
%157 = llvm.getelementptr %128[0, %156] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %114, %157 : i32, !llvm.ptr
%158 = llvm.mlir.constant(14 : i64) : i64
%159 = llvm.getelementptr %128[0, %158] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %115, %159 : i32, !llvm.ptr
%160 = llvm.mlir.constant(15 : i64) : i64
%161 = llvm.getelementptr %128[0, %160] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %116, %161 : i32, !llvm.ptr
%162 = llvm.mlir.constant(16 : i64) : i64
%163 = llvm.getelementptr %128[0, %162] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %117, %163 : i32, !llvm.ptr
%164 = llvm.mlir.constant(17 : i64) : i64
%165 = llvm.getelementptr %128[0, %164] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %118, %165 : i32, !llvm.ptr
%166 = llvm.mlir.constant(18 : i64) : i64
%167 = llvm.getelementptr %128[0, %166] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %119, %167 : i32, !llvm.ptr
%168 = llvm.mlir.constant(19 : i64) : i64
%169 = llvm.getelementptr %128[0, %168] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %120, %169 : i32, !llvm.ptr
%170 = llvm.mlir.constant(20 : i64) : i64
%171 = llvm.getelementptr %128[0, %170] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %121, %171 : i32, !llvm.ptr
%172 = llvm.mlir.constant(21 : i64) : i64
%173 = llvm.getelementptr %128[0, %172] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %122, %173 : i32, !llvm.ptr
%174 = llvm.mlir.constant(22 : i64) : i64
%175 = llvm.getelementptr %128[0, %174] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %123, %175 : i32, !llvm.ptr
%176 = llvm.mlir.constant(23 : i64) : i64
%177 = llvm.getelementptr %128[0, %176] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %124, %177 : i32, !llvm.ptr
%178 = llvm.mlir.constant(24 : i64) : i64
%179 = llvm.getelementptr %128[0, %178] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %125, %179 : i32, !llvm.ptr
%180 = llvm.mlir.constant(25 : i64) : i64
%181 = llvm.getelementptr %128[0, %180] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %126, %181 : i32, !llvm.ptr
%182 = arith.constant 0 : i32
%183 = llvm.mlir.constant(1 : i64) : i64
%184 = llvm.alloca %183 x i32 : (i64) -> !llvm.ptr
llvm.store %182, %184 : i32, !llvm.ptr
cf.br ^bb6
^bb6:
%185 = llvm.load %184 : !llvm.ptr -> i32
%186 = arith.cmpi slt, %185, %arg3 : i32
cf.cond_br %186, ^bb7, ^bb8
^bb7:
%188 = arith.muli %arg1, %arg3 : i32
%189 = llvm.load %184 : !llvm.ptr -> i32
%190 = arith.addi %188, %189 : i32
%191 = arith.extsi %190 : i32 to i64
%192 = llvm.getelementptr %arg0[%191] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%187 = llvm.load %192 : !llvm.ptr -> i8
%193 = arith.extsi %187 : i8 to i32
%195 = arith.muli %arg2, %arg3 : i32
%196 = llvm.load %184 : !llvm.ptr -> i32
%197 = arith.addi %195, %196 : i32
%198 = arith.extsi %197 : i32 to i64
%199 = llvm.getelementptr %arg0[%198] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%194 = llvm.load %199 : !llvm.ptr -> i8
%200 = arith.extsi %194 : i8 to i32
%201 = arith.constant 0 : i32
%202 = arith.cmpi eq, %193, %201 : i32
%203 = scf.if %202 -> (i1) {
%204 = arith.constant 0 : i32
%205 = arith.cmpi eq, %200, %204 : i32
scf.yield %205 : i1
} else {
%206 = arith.constant false
scf.yield %206 : i1
}
cf.cond_br %203, ^bb9, ^bb10
^bb9:
cf.br ^bb8
^bb10:
cf.br ^bb11
^bb11:
%207 = arith.constant 0 : i32
%208 = arith.cmpi eq, %193, %207 : i32
%209 = scf.if %208 -> (i1) {
%210 = arith.constant true
scf.yield %210 : i1
} else {
%211 = arith.constant 0 : i32
%212 = arith.cmpi eq, %200, %211 : i32
scf.yield %212 : i1
}
cf.cond_br %209, ^bb12, ^bb13
^bb12:
%213 = arith.constant 0 : i1
func.return %213 : i1
^bb13:
cf.br ^bb14
^bb14:
%215 = arith.constant 65 : i32
%216 = arith.subi %193, %215 : i32
%217 = arith.extsi %216 : i32 to i64
%218 = llvm.getelementptr %46[0, %217] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%214 = llvm.load %218 : !llvm.ptr -> i32
%219 = arith.constant 1 : i32
%220 = arith.addi %214, %219 : i32
%221 = arith.constant 65 : i32
%222 = arith.subi %193, %221 : i32
%223 = arith.extsi %222 : i32 to i64
%224 = llvm.getelementptr %46[0, %223] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %220, %224 : i32, !llvm.ptr
%226 = arith.constant 65 : i32
%227 = arith.subi %200, %226 : i32
%228 = arith.extsi %227 : i32 to i64
%229 = llvm.getelementptr %128[0, %228] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%225 = llvm.load %229 : !llvm.ptr -> i32
%230 = arith.constant 1 : i32
%231 = arith.addi %225, %230 : i32
%232 = arith.constant 65 : i32
%233 = arith.subi %200, %232 : i32
%234 = arith.extsi %233 : i32 to i64
%235 = llvm.getelementptr %128[0, %234] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %231, %235 : i32, !llvm.ptr
%236 = llvm.load %184 : !llvm.ptr -> i32
%237 = arith.constant 1 : i32
%238 = arith.addi %236, %237 : i32
llvm.store %238, %184 : i32, !llvm.ptr
cf.br ^bb6
^bb8:
%239 = arith.constant 0 : i32
llvm.store %239, %184 : i32, !llvm.ptr
cf.br ^bb15
^bb15:
%240 = llvm.load %184 : !llvm.ptr -> i32
%241 = arith.constant 26 : i32
%242 = arith.cmpi slt, %240, %241 : i32
cf.cond_br %242, ^bb16, ^bb17
^bb16:
%244 = llvm.load %184 : !llvm.ptr -> i32
%245 = arith.extsi %244 : i32 to i64
%246 = llvm.getelementptr %46[0, %245] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%243 = llvm.load %246 : !llvm.ptr -> i32
%248 = llvm.load %184 : !llvm.ptr -> i32
%249 = arith.extsi %248 : i32 to i64
%250 = llvm.getelementptr %128[0, %249] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%247 = llvm.load %250 : !llvm.ptr -> i32
%251 = arith.cmpi ne, %243, %247 : i32
cf.cond_br %251, ^bb18, ^bb19
^bb18:
%252 = arith.constant 0 : i1
func.return %252 : i1
^bb19:
cf.br ^bb20
^bb20:
%253 = llvm.load %184 : !llvm.ptr -> i32
%254 = arith.constant 1 : i32
%255 = arith.addi %253, %254 : i32
llvm.store %255, %184 : i32, !llvm.ptr
cf.br ^bb15
^bb17:
%256 = arith.constant 1 : i1
func.return %256 : i1
}
func.func @is_square(%arg0: i64) -> i1 {
%257 = arith.constant 0 : i32
%259 = arith.extsi %257 : i32 to i64
%258 = arith.cmpi sle, %arg0, %259 : i64
cf.cond_br %258, ^bb21, ^bb22
^bb21:
%260 = arith.constant 0 : i1
func.return %260 : i1
^bb22:
cf.br ^bb23
^bb23:
%261 = llvm.mlir.constant(1 : i64) : i64
%262 = llvm.alloca %261 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %262 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%263 = llvm.load %262 : !llvm.ptr -> i64
%264 = arith.constant 1 : i32
%266 = arith.extsi %264 : i32 to i64
%265 = arith.cmpi sgt, %263, %266 : i64
cf.cond_br %265, ^bb25, ^bb26
^bb25:
%267 = llvm.load %262 : !llvm.ptr -> i64
%268 = llvm.load %262 : !llvm.ptr -> i64
%269 = arith.divsi %arg0, %268 : i64
%270 = arith.addi %267, %269 : i64
%271 = arith.constant 2 : i32
%273 = arith.extsi %271 : i32 to i64
%272 = arith.divsi %270, %273 : i64
%274 = llvm.load %262 : !llvm.ptr -> i64
%275 = arith.cmpi sge, %272, %274 : i64
cf.cond_br %275, ^bb27, ^bb28
^bb27:
cf.br ^bb26
^bb28:
cf.br ^bb29
^bb29:
llvm.store %272, %262 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
%276 = llvm.load %262 : !llvm.ptr -> i64
%277 = llvm.mlir.constant(1 : i64) : i64
%278 = llvm.alloca %277 x i64 : (i64) -> !llvm.ptr
llvm.store %276, %278 : i64, !llvm.ptr
cf.br ^bb30
^bb30:
%279 = llvm.load %278 : !llvm.ptr -> i64
%280 = llvm.load %278 : !llvm.ptr -> i64
%281 = arith.muli %279, %280 : i64
%282 = arith.cmpi sgt, %281, %arg0 : i64
cf.cond_br %282, ^bb31, ^bb32
^bb31:
%283 = llvm.load %278 : !llvm.ptr -> i64
%284 = arith.constant 1 : i32
%286 = arith.extsi %284 : i32 to i64
%285 = arith.subi %283, %286 : i64
llvm.store %285, %278 : i64, !llvm.ptr
cf.br ^bb30
^bb32:
cf.br ^bb33
^bb33:
%287 = llvm.load %278 : !llvm.ptr -> i64
%288 = arith.constant 1 : i32
%290 = arith.extsi %288 : i32 to i64
%289 = arith.addi %287, %290 : i64
%291 = llvm.load %278 : !llvm.ptr -> i64
%292 = arith.constant 1 : i32
%294 = arith.extsi %292 : i32 to i64
%293 = arith.addi %291, %294 : i64
%295 = arith.muli %289, %293 : i64
%296 = arith.cmpi sle, %295, %arg0 : i64
cf.cond_br %296, ^bb34, ^bb35
^bb34:
%297 = llvm.load %278 : !llvm.ptr -> i64
%298 = arith.constant 1 : i32
%300 = arith.extsi %298 : i32 to i64
%299 = arith.addi %297, %300 : i64
llvm.store %299, %278 : i64, !llvm.ptr
cf.br ^bb33
^bb35:
%301 = llvm.load %278 : !llvm.ptr -> i64
%302 = llvm.load %278 : !llvm.ptr -> i64
%303 = arith.muli %301, %302 : i64
%304 = arith.cmpi eq, %303, %arg0 : i64
func.return %304 : i1
}
func.func @pow10(%arg0: i32) -> i64 {
%305 = arith.constant 1 : i32
%306 = arith.extsi %305 : i32 to i64
%307 = llvm.mlir.constant(1 : i64) : i64
%308 = llvm.alloca %307 x i64 : (i64) -> !llvm.ptr
llvm.store %306, %308 : i64, !llvm.ptr
%309 = arith.constant 0 : i32
%310 = arith.index_cast %309 : i32 to index
%311 = arith.index_cast %arg0 : i32 to index
%313 = arith.constant 1 : index
%314 = arith.constant -1 : index
%315 = arith.cmpi sle, %310, %311 : index
%312 = arith.select %315, %313, %314 : index
cf.br ^bb36(%310 : index)
^bb36(%316: index):
%317 = arith.cmpi slt, %316, %311 : index
%318 = arith.cmpi sgt, %316, %311 : index
%319 = arith.select %315, %317, %318 : i1
cf.cond_br %319, ^bb37(%316 : index), ^bb38(%316 : index)
^bb37(%320: index):
%321 = llvm.load %308 : !llvm.ptr -> i64
%322 = arith.constant 10 : i32
%324 = arith.extsi %322 : i32 to i64
%323 = arith.muli %321, %324 : i64
llvm.store %323, %308 : i64, !llvm.ptr
%325 = arith.addi %320, %312 : index
cf.br ^bb36(%325 : index)
^bb38(%326: index):
%327 = llvm.load %308 : !llvm.ptr -> i64
func.return %327 : i64
}
func.func @main() -> i32 {
%328 = arith.constant 16 : i32
%329 = arith.constant 3000 : i32
%331 = arith.muli %329, %328 : i32
%332 = arith.extsi %331 : i32 to i64
%333 = arith.constant 1 : i32
%334 = arith.extsi %333 : i32 to i64
%330 = func.call @calloc(%332, %334) : (i64, i64) -> !llvm.ptr
%335 = llvm.mlir.zero : !llvm.ptr
%336 = llvm.icmp "eq" %330, %335 : !llvm.ptr
cf.cond_br %336, ^bb39, ^bb40
^bb39:
%337 = arith.constant 1 : i32
func.return %337 : i32
^bb40:
cf.br ^bb41
^bb41:
%339 = llvm.mlir.addressof @str_0 : !llvm.ptr
%340 = llvm.mlir.addressof @str_1 : !llvm.ptr
%338 = func.call @fopen(%339, %340) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr
%341 = llvm.mlir.zero : !llvm.ptr
%342 = llvm.icmp "eq" %338, %341 : !llvm.ptr
cf.cond_br %342, ^bb42, ^bb43
^bb42:
%343 = llvm.mlir.addressof @str_2 : !llvm.ptr
%344 = llvm.call @printf(%343) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr) -> i32
%345 = arith.constant 1 : i32
func.return %345 : i32
^bb43:
cf.br ^bb44
^bb44:
%346 = arith.constant 0 : i32
%347 = llvm.mlir.constant(1 : i64) : i64
%348 = llvm.alloca %347 x i32 : (i64) -> !llvm.ptr
llvm.store %346, %348 : i32, !llvm.ptr
%349 = arith.constant 0 : i32
%350 = llvm.mlir.constant(1 : i64) : i64
%351 = llvm.alloca %350 x i32 : (i64) -> !llvm.ptr
llvm.store %349, %351 : i32, !llvm.ptr
%352 = arith.constant 0 : i1
%353 = llvm.mlir.constant(1 : i64) : i64
%354 = llvm.alloca %353 x i1 : (i64) -> !llvm.ptr
llvm.store %352, %354 : i1, !llvm.ptr
%355 = func.call @fgetc(%338) : (!llvm.ptr) -> i32
%356 = llvm.mlir.constant(1 : i64) : i64
%357 = llvm.alloca %356 x i32 : (i64) -> !llvm.ptr
llvm.store %355, %357 : i32, !llvm.ptr
cf.br ^bb45
^bb45:
%358 = llvm.load %357 : !llvm.ptr -> i32
%359 = arith.constant 0 : i32
%360 = arith.cmpi sge, %358, %359 : i32
cf.cond_br %360, ^bb46, ^bb47
^bb46:
%361 = llvm.load %357 : !llvm.ptr -> i32
%362 = arith.constant 34 : i32
%363 = arith.cmpi eq, %361, %362 : i32
cf.cond_br %363, ^bb48, ^bb49
^bb48:
%364 = llvm.load %354 : !llvm.ptr -> i1
cf.cond_br %364, ^bb51, ^bb52
^bb51:
%365 = arith.constant 0 : i32
%366 = llvm.load %348 : !llvm.ptr -> i32
%367 = arith.muli %366, %328 : i32
%368 = llvm.load %351 : !llvm.ptr -> i32
%369 = arith.addi %367, %368 : i32
%370 = arith.trunci %365 : i32 to i8
%371 = arith.extsi %369 : i32 to i64
%372 = llvm.getelementptr %330[%371] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %370, %372 : i8, !llvm.ptr
%373 = llvm.load %348 : !llvm.ptr -> i32
%374 = arith.constant 1 : i32
%375 = arith.addi %373, %374 : i32
llvm.store %375, %348 : i32, !llvm.ptr
%376 = arith.constant 0 : i32
llvm.store %376, %351 : i32, !llvm.ptr
%377 = arith.constant 0 : i1
llvm.store %377, %354 : i1, !llvm.ptr
cf.br ^bb53
^bb52:
%378 = arith.constant 1 : i1
llvm.store %378, %354 : i1, !llvm.ptr
%379 = arith.constant 0 : i32
llvm.store %379, %351 : i32, !llvm.ptr
cf.br ^bb53
^bb53:
cf.br ^bb50
^bb49:
%380 = llvm.load %354 : !llvm.ptr -> i1
cf.cond_br %380, ^bb54, ^bb50
^bb54:
%381 = llvm.load %351 : !llvm.ptr -> i32
%382 = arith.constant 1 : i32
%383 = arith.subi %328, %382 : i32
%384 = arith.cmpi slt, %381, %383 : i32
cf.cond_br %384, ^bb55, ^bb56
^bb55:
%385 = llvm.load %357 : !llvm.ptr -> i32
%386 = arith.trunci %385 : i32 to i8
%387 = llvm.load %348 : !llvm.ptr -> i32
%388 = arith.muli %387, %328 : i32
%389 = llvm.load %351 : !llvm.ptr -> i32
%390 = arith.addi %388, %389 : i32
%391 = arith.extsi %390 : i32 to i64
%392 = llvm.getelementptr %330[%391] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %386, %392 : i8, !llvm.ptr
%393 = llvm.load %351 : !llvm.ptr -> i32
%394 = arith.constant 1 : i32
%395 = arith.addi %393, %394 : i32
llvm.store %395, %351 : i32, !llvm.ptr
cf.br ^bb57
^bb56:
cf.br ^bb57
^bb57:
cf.br ^bb50
^bb50:
%396 = func.call @fgetc(%338) : (!llvm.ptr) -> i32
llvm.store %396, %357 : i32, !llvm.ptr
cf.br ^bb45
^bb47:
%397 = func.call @fclose(%338) : (!llvm.ptr) -> i32
%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 0 : i32
%403 = llvm.load %348 : !llvm.ptr -> i32
%404 = arith.index_cast %402 : i32 to index
%405 = arith.index_cast %403 : i32 to index
%407 = arith.constant 1 : index
%408 = arith.constant -1 : index
%409 = arith.cmpi sle, %404, %405 : index
%406 = arith.select %409, %407, %408 : index
cf.br ^bb58(%404 : index)
^bb58(%410: index):
%411 = arith.cmpi slt, %410, %405 : index
%412 = arith.cmpi sgt, %410, %405 : index
%413 = arith.select %409, %411, %412 : i1
cf.cond_br %413, ^bb59(%410 : index), ^bb60(%410 : index)
^bb59(%414: index):
%416 = arith.index_cast %414 : index to i32
%415 = func.call @word_len(%330, %416, %328) : (!llvm.ptr, i32, i32) -> i32
%417 = arith.constant 1 : i32
%419 = arith.index_cast %414 : index to i32
%418 = arith.addi %419, %417 : i32
%420 = llvm.load %348 : !llvm.ptr -> i32
%421 = arith.index_cast %418 : i32 to index
%422 = arith.index_cast %420 : i32 to index
%424 = arith.constant 1 : index
%425 = arith.constant -1 : index
%426 = arith.cmpi sle, %421, %422 : index
%423 = arith.select %426, %424, %425 : index
cf.br ^bb61(%421 : index)
^bb61(%427: index):
%428 = arith.cmpi slt, %427, %422 : index
%429 = arith.cmpi sgt, %427, %422 : index
%430 = arith.select %426, %428, %429 : i1
cf.cond_br %430, ^bb62(%427 : index), ^bb63(%427 : index)
^bb62(%431: index):
%433 = arith.index_cast %431 : index to i32
%432 = func.call @word_len(%330, %433, %328) : (!llvm.ptr, i32, i32) -> i32
%434 = arith.cmpi eq, %415, %432 : i32
%435 = scf.if %434 -> (i1) {
%436 = arith.constant 1 : i32
%437 = arith.cmpi sge, %415, %436 : i32
scf.yield %437 : i1
} else {
%438 = arith.constant false
scf.yield %438 : i1
}
%439 = scf.if %435 -> (i1) {
%441 = arith.index_cast %414 : index to i32
%442 = arith.index_cast %431 : index to i32
%440 = func.call @same_anagram(%330, %441, %442, %328) : (!llvm.ptr, i32, i32, i32) -> i1
scf.yield %440 : i1
} else {
%443 = arith.constant false
scf.yield %443 : i1
}
cf.cond_br %439, ^bb64, ^bb65
^bb64:
%445 = arith.constant 1 : i32
%446 = arith.subi %415, %445 : i32
%444 = func.call @pow10(%446) : (i32) -> i64
%447 = func.call @pow10(%415) : (i32) -> i64
%448 = arith.constant 1 : i32
%450 = arith.extsi %448 : i32 to i64
%449 = arith.subi %447, %450 : i64
%451 = arith.constant 1 : i32
%452 = arith.extsi %451 : i32 to i64
%453 = llvm.mlir.constant(1 : i64) : i64
%454 = llvm.alloca %453 x i64 : (i64) -> !llvm.ptr
llvm.store %452, %454 : i64, !llvm.ptr
cf.br ^bb67
^bb67:
%455 = llvm.load %454 : !llvm.ptr -> i64
%456 = llvm.load %454 : !llvm.ptr -> i64
%457 = arith.muli %455, %456 : i64
%458 = arith.cmpi slt, %457, %444 : i64
cf.cond_br %458, ^bb68, ^bb69
^bb68:
%459 = llvm.load %454 : !llvm.ptr -> i64
%460 = arith.constant 1 : i32
%462 = arith.extsi %460 : i32 to i64
%461 = arith.addi %459, %462 : i64
llvm.store %461, %454 : i64, !llvm.ptr
cf.br ^bb67
^bb69:
cf.br ^bb70
^bb70:
%463 = llvm.load %454 : !llvm.ptr -> i64
%464 = llvm.load %454 : !llvm.ptr -> i64
%465 = arith.muli %463, %464 : i64
%466 = arith.cmpi sle, %465, %449 : i64
cf.cond_br %466, ^bb71, ^bb72
^bb71:
%467 = llvm.load %454 : !llvm.ptr -> i64
%468 = llvm.load %454 : !llvm.ptr -> i64
%469 = arith.muli %467, %468 : i64
%471 = arith.constant 0 : i32
%472 = arith.constant 1 : i32
%473 = arith.subi %471, %472 : i32
%474 = arith.constant 0 : i32
%475 = arith.constant 1 : i32
%476 = arith.subi %474, %475 : i32
%477 = arith.constant 0 : i32
%478 = arith.constant 1 : i32
%479 = arith.subi %477, %478 : i32
%480 = arith.constant 0 : i32
%481 = arith.constant 1 : i32
%482 = arith.subi %480, %481 : i32
%483 = arith.constant 0 : i32
%484 = arith.constant 1 : i32
%485 = arith.subi %483, %484 : i32
%486 = arith.constant 0 : i32
%487 = arith.constant 1 : i32
%488 = arith.subi %486, %487 : i32
%489 = arith.constant 0 : i32
%490 = arith.constant 1 : i32
%491 = arith.subi %489, %490 : i32
%492 = arith.constant 0 : i32
%493 = arith.constant 1 : i32
%494 = arith.subi %492, %493 : i32
%495 = arith.constant 0 : i32
%496 = arith.constant 1 : i32
%497 = arith.subi %495, %496 : i32
%498 = arith.constant 0 : i32
%499 = arith.constant 1 : i32
%500 = arith.subi %498, %499 : i32
%501 = arith.constant 0 : i32
%502 = arith.constant 1 : i32
%503 = arith.subi %501, %502 : i32
%504 = arith.constant 0 : i32
%505 = arith.constant 1 : i32
%506 = arith.subi %504, %505 : i32
%507 = arith.constant 0 : i32
%508 = arith.constant 1 : i32
%509 = arith.subi %507, %508 : i32
%510 = arith.constant 0 : i32
%511 = arith.constant 1 : i32
%512 = arith.subi %510, %511 : i32
%513 = arith.constant 0 : i32
%514 = arith.constant 1 : i32
%515 = arith.subi %513, %514 : i32
%516 = arith.constant 0 : i32
%517 = arith.constant 1 : i32
%518 = arith.subi %516, %517 : i32
%519 = arith.constant 0 : i32
%520 = arith.constant 1 : i32
%521 = arith.subi %519, %520 : i32
%522 = arith.constant 0 : i32
%523 = arith.constant 1 : i32
%524 = arith.subi %522, %523 : i32
%525 = arith.constant 0 : i32
%526 = arith.constant 1 : i32
%527 = arith.subi %525, %526 : i32
%528 = arith.constant 0 : i32
%529 = arith.constant 1 : i32
%530 = arith.subi %528, %529 : i32
%531 = arith.constant 0 : i32
%532 = arith.constant 1 : i32
%533 = arith.subi %531, %532 : i32
%534 = arith.constant 0 : i32
%535 = arith.constant 1 : i32
%536 = arith.subi %534, %535 : i32
%537 = arith.constant 0 : i32
%538 = arith.constant 1 : i32
%539 = arith.subi %537, %538 : i32
%540 = arith.constant 0 : i32
%541 = arith.constant 1 : i32
%542 = arith.subi %540, %541 : i32
%543 = arith.constant 0 : i32
%544 = arith.constant 1 : i32
%545 = arith.subi %543, %544 : i32
%546 = arith.constant 0 : i32
%547 = arith.constant 1 : i32
%548 = arith.subi %546, %547 : i32
%549 = llvm.mlir.constant(1 : i64) : i64
%550 = llvm.alloca %549 x !llvm.array<26 x i32> : (i64) -> !llvm.ptr
%551 = llvm.mlir.zero : !llvm.array<26 x i32>
llvm.store %551, %550 : !llvm.array<26 x i32>, !llvm.ptr
%552 = llvm.mlir.constant(0 : i64) : i64
%553 = llvm.getelementptr %550[0, %552] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %473, %553 : i32, !llvm.ptr
%554 = llvm.mlir.constant(1 : i64) : i64
%555 = llvm.getelementptr %550[0, %554] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %476, %555 : i32, !llvm.ptr
%556 = llvm.mlir.constant(2 : i64) : i64
%557 = llvm.getelementptr %550[0, %556] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %479, %557 : i32, !llvm.ptr
%558 = llvm.mlir.constant(3 : i64) : i64
%559 = llvm.getelementptr %550[0, %558] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %482, %559 : i32, !llvm.ptr
%560 = llvm.mlir.constant(4 : i64) : i64
%561 = llvm.getelementptr %550[0, %560] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %485, %561 : i32, !llvm.ptr
%562 = llvm.mlir.constant(5 : i64) : i64
%563 = llvm.getelementptr %550[0, %562] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %488, %563 : i32, !llvm.ptr
%564 = llvm.mlir.constant(6 : i64) : i64
%565 = llvm.getelementptr %550[0, %564] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %491, %565 : i32, !llvm.ptr
%566 = llvm.mlir.constant(7 : i64) : i64
%567 = llvm.getelementptr %550[0, %566] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %494, %567 : i32, !llvm.ptr
%568 = llvm.mlir.constant(8 : i64) : i64
%569 = llvm.getelementptr %550[0, %568] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %497, %569 : i32, !llvm.ptr
%570 = llvm.mlir.constant(9 : i64) : i64
%571 = llvm.getelementptr %550[0, %570] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %500, %571 : i32, !llvm.ptr
%572 = llvm.mlir.constant(10 : i64) : i64
%573 = llvm.getelementptr %550[0, %572] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %503, %573 : i32, !llvm.ptr
%574 = llvm.mlir.constant(11 : i64) : i64
%575 = llvm.getelementptr %550[0, %574] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %506, %575 : i32, !llvm.ptr
%576 = llvm.mlir.constant(12 : i64) : i64
%577 = llvm.getelementptr %550[0, %576] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %509, %577 : i32, !llvm.ptr
%578 = llvm.mlir.constant(13 : i64) : i64
%579 = llvm.getelementptr %550[0, %578] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %512, %579 : i32, !llvm.ptr
%580 = llvm.mlir.constant(14 : i64) : i64
%581 = llvm.getelementptr %550[0, %580] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %515, %581 : i32, !llvm.ptr
%582 = llvm.mlir.constant(15 : i64) : i64
%583 = llvm.getelementptr %550[0, %582] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %518, %583 : i32, !llvm.ptr
%584 = llvm.mlir.constant(16 : i64) : i64
%585 = llvm.getelementptr %550[0, %584] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %521, %585 : i32, !llvm.ptr
%586 = llvm.mlir.constant(17 : i64) : i64
%587 = llvm.getelementptr %550[0, %586] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %524, %587 : i32, !llvm.ptr
%588 = llvm.mlir.constant(18 : i64) : i64
%589 = llvm.getelementptr %550[0, %588] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %527, %589 : i32, !llvm.ptr
%590 = llvm.mlir.constant(19 : i64) : i64
%591 = llvm.getelementptr %550[0, %590] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %530, %591 : i32, !llvm.ptr
%592 = llvm.mlir.constant(20 : i64) : i64
%593 = llvm.getelementptr %550[0, %592] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %533, %593 : i32, !llvm.ptr
%594 = llvm.mlir.constant(21 : i64) : i64
%595 = llvm.getelementptr %550[0, %594] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %536, %595 : i32, !llvm.ptr
%596 = llvm.mlir.constant(22 : i64) : i64
%597 = llvm.getelementptr %550[0, %596] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %539, %597 : i32, !llvm.ptr
%598 = llvm.mlir.constant(23 : i64) : i64
%599 = llvm.getelementptr %550[0, %598] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %542, %599 : i32, !llvm.ptr
%600 = llvm.mlir.constant(24 : i64) : i64
%601 = llvm.getelementptr %550[0, %600] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %545, %601 : i32, !llvm.ptr
%602 = llvm.mlir.constant(25 : i64) : i64
%603 = llvm.getelementptr %550[0, %602] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %548, %603 : i32, !llvm.ptr
%605 = arith.constant 0 : i32
%606 = arith.constant 1 : i32
%607 = arith.subi %605, %606 : i32
%608 = arith.constant 0 : i32
%609 = arith.constant 1 : i32
%610 = arith.subi %608, %609 : i32
%611 = arith.constant 0 : i32
%612 = arith.constant 1 : i32
%613 = arith.subi %611, %612 : i32
%614 = arith.constant 0 : i32
%615 = arith.constant 1 : i32
%616 = arith.subi %614, %615 : i32
%617 = arith.constant 0 : i32
%618 = arith.constant 1 : i32
%619 = arith.subi %617, %618 : i32
%620 = arith.constant 0 : i32
%621 = arith.constant 1 : i32
%622 = arith.subi %620, %621 : i32
%623 = arith.constant 0 : i32
%624 = arith.constant 1 : i32
%625 = arith.subi %623, %624 : i32
%626 = arith.constant 0 : i32
%627 = arith.constant 1 : i32
%628 = arith.subi %626, %627 : i32
%629 = arith.constant 0 : i32
%630 = arith.constant 1 : i32
%631 = arith.subi %629, %630 : i32
%632 = arith.constant 0 : i32
%633 = arith.constant 1 : i32
%634 = arith.subi %632, %633 : i32
%635 = llvm.mlir.constant(1 : i64) : i64
%636 = llvm.alloca %635 x !llvm.array<10 x i32> : (i64) -> !llvm.ptr
%637 = llvm.mlir.zero : !llvm.array<10 x i32>
llvm.store %637, %636 : !llvm.array<10 x i32>, !llvm.ptr
%638 = llvm.mlir.constant(0 : i64) : i64
%639 = llvm.getelementptr %636[0, %638] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %607, %639 : i32, !llvm.ptr
%640 = llvm.mlir.constant(1 : i64) : i64
%641 = llvm.getelementptr %636[0, %640] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %610, %641 : i32, !llvm.ptr
%642 = llvm.mlir.constant(2 : i64) : i64
%643 = llvm.getelementptr %636[0, %642] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %613, %643 : i32, !llvm.ptr
%644 = llvm.mlir.constant(3 : i64) : i64
%645 = llvm.getelementptr %636[0, %644] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %616, %645 : i32, !llvm.ptr
%646 = llvm.mlir.constant(4 : i64) : i64
%647 = llvm.getelementptr %636[0, %646] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %619, %647 : i32, !llvm.ptr
%648 = llvm.mlir.constant(5 : i64) : i64
%649 = llvm.getelementptr %636[0, %648] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %622, %649 : i32, !llvm.ptr
%650 = llvm.mlir.constant(6 : i64) : i64
%651 = llvm.getelementptr %636[0, %650] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %625, %651 : i32, !llvm.ptr
%652 = llvm.mlir.constant(7 : i64) : i64
%653 = llvm.getelementptr %636[0, %652] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %628, %653 : i32, !llvm.ptr
%654 = llvm.mlir.constant(8 : i64) : i64
%655 = llvm.getelementptr %636[0, %654] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %631, %655 : i32, !llvm.ptr
%656 = llvm.mlir.constant(9 : i64) : i64
%657 = llvm.getelementptr %636[0, %656] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %634, %657 : i32, !llvm.ptr
%659 = arith.constant 0 : i32
%660 = arith.constant 0 : i32
%661 = arith.constant 0 : i32
%662 = arith.constant 0 : i32
%663 = arith.constant 0 : i32
%664 = arith.constant 0 : i32
%665 = arith.constant 0 : i32
%666 = arith.constant 0 : i32
%667 = arith.constant 0 : i32
%668 = arith.constant 0 : i32
%669 = arith.constant 0 : i32
%670 = arith.constant 0 : i32
%671 = arith.constant 0 : i32
%672 = arith.constant 0 : i32
%673 = arith.constant 0 : i32
%674 = arith.constant 0 : i32
%675 = llvm.mlir.constant(1 : i64) : i64
%676 = llvm.alloca %675 x !llvm.array<16 x i32> : (i64) -> !llvm.ptr
%677 = llvm.mlir.zero : !llvm.array<16 x i32>
llvm.store %677, %676 : !llvm.array<16 x i32>, !llvm.ptr
%678 = llvm.mlir.constant(0 : i64) : i64
%679 = llvm.getelementptr %676[0, %678] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %659, %679 : i32, !llvm.ptr
%680 = llvm.mlir.constant(1 : i64) : i64
%681 = llvm.getelementptr %676[0, %680] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %660, %681 : i32, !llvm.ptr
%682 = llvm.mlir.constant(2 : i64) : i64
%683 = llvm.getelementptr %676[0, %682] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %661, %683 : i32, !llvm.ptr
%684 = llvm.mlir.constant(3 : i64) : i64
%685 = llvm.getelementptr %676[0, %684] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %662, %685 : i32, !llvm.ptr
%686 = llvm.mlir.constant(4 : i64) : i64
%687 = llvm.getelementptr %676[0, %686] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %663, %687 : i32, !llvm.ptr
%688 = llvm.mlir.constant(5 : i64) : i64
%689 = llvm.getelementptr %676[0, %688] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %664, %689 : i32, !llvm.ptr
%690 = llvm.mlir.constant(6 : i64) : i64
%691 = llvm.getelementptr %676[0, %690] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %665, %691 : i32, !llvm.ptr
%692 = llvm.mlir.constant(7 : i64) : i64
%693 = llvm.getelementptr %676[0, %692] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %666, %693 : i32, !llvm.ptr
%694 = llvm.mlir.constant(8 : i64) : i64
%695 = llvm.getelementptr %676[0, %694] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %667, %695 : i32, !llvm.ptr
%696 = llvm.mlir.constant(9 : i64) : i64
%697 = llvm.getelementptr %676[0, %696] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %668, %697 : i32, !llvm.ptr
%698 = llvm.mlir.constant(10 : i64) : i64
%699 = llvm.getelementptr %676[0, %698] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %669, %699 : i32, !llvm.ptr
%700 = llvm.mlir.constant(11 : i64) : i64
%701 = llvm.getelementptr %676[0, %700] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %670, %701 : i32, !llvm.ptr
%702 = llvm.mlir.constant(12 : i64) : i64
%703 = llvm.getelementptr %676[0, %702] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %671, %703 : i32, !llvm.ptr
%704 = llvm.mlir.constant(13 : i64) : i64
%705 = llvm.getelementptr %676[0, %704] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %672, %705 : i32, !llvm.ptr
%706 = llvm.mlir.constant(14 : i64) : i64
%707 = llvm.getelementptr %676[0, %706] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %673, %707 : i32, !llvm.ptr
%708 = llvm.mlir.constant(15 : i64) : i64
%709 = llvm.getelementptr %676[0, %708] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %674, %709 : i32, !llvm.ptr
%710 = llvm.mlir.constant(1 : i64) : i64
%711 = llvm.alloca %710 x i64 : (i64) -> !llvm.ptr
llvm.store %469, %711 : i64, !llvm.ptr
%712 = arith.constant 1 : i32
%713 = arith.subi %415, %712 : i32
%714 = llvm.mlir.constant(1 : i64) : i64
%715 = llvm.alloca %714 x i32 : (i64) -> !llvm.ptr
llvm.store %713, %715 : i32, !llvm.ptr
cf.br ^bb73
^bb73:
%716 = llvm.load %715 : !llvm.ptr -> i32
%717 = arith.constant 0 : i32
%718 = arith.cmpi sge, %716, %717 : i32
cf.cond_br %718, ^bb74, ^bb75
^bb74:
%719 = llvm.load %711 : !llvm.ptr -> i64
%720 = arith.constant 10 : i32
%722 = arith.extsi %720 : i32 to i64
%721 = arith.remsi %719, %722 : i64
%723 = arith.trunci %721 : i64 to i32
%724 = llvm.load %715 : !llvm.ptr -> i32
%725 = arith.extsi %724 : i32 to i64
%726 = llvm.getelementptr %676[0, %725] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
llvm.store %723, %726 : i32, !llvm.ptr
%727 = llvm.load %711 : !llvm.ptr -> i64
%728 = arith.constant 10 : i32
%730 = arith.extsi %728 : i32 to i64
%729 = arith.divsi %727, %730 : i64
llvm.store %729, %711 : i64, !llvm.ptr
%731 = llvm.load %715 : !llvm.ptr -> i32
%732 = arith.constant 1 : i32
%733 = arith.subi %731, %732 : i32
llvm.store %733, %715 : i32, !llvm.ptr
cf.br ^bb73
^bb75:
%734 = arith.constant 1 : i1
%735 = llvm.mlir.constant(1 : i64) : i64
%736 = llvm.alloca %735 x i1 : (i64) -> !llvm.ptr
llvm.store %734, %736 : i1, !llvm.ptr
%737 = arith.constant 0 : i32
llvm.store %737, %715 : i32, !llvm.ptr
cf.br ^bb76
^bb76:
%738 = llvm.load %715 : !llvm.ptr -> i32
%739 = arith.cmpi slt, %738, %415 : i32
cf.cond_br %739, ^bb77, ^bb78
^bb77:
%742 = arith.index_cast %414 : index to i32
%741 = arith.muli %742, %328 : i32
%743 = llvm.load %715 : !llvm.ptr -> i32
%744 = arith.addi %741, %743 : i32
%745 = arith.extsi %744 : i32 to i64
%746 = llvm.getelementptr %330[%745] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%740 = llvm.load %746 : !llvm.ptr -> i8
%747 = arith.extsi %740 : i8 to i32
%748 = arith.constant 65 : i32
%749 = arith.subi %747, %748 : i32
%751 = llvm.load %715 : !llvm.ptr -> i32
%752 = arith.extsi %751 : i32 to i64
%753 = llvm.getelementptr %676[0, %752] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
%750 = llvm.load %753 : !llvm.ptr -> i32
%755 = arith.extsi %749 : i32 to i64
%756 = llvm.getelementptr %550[0, %755] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%754 = llvm.load %756 : !llvm.ptr -> i32
%757 = arith.constant 0 : i32
%758 = arith.constant 1 : i32
%759 = arith.subi %757, %758 : i32
%760 = arith.cmpi eq, %754, %759 : i32
%761 = scf.if %760 -> (i1) {
%763 = arith.extsi %750 : i32 to i64
%764 = llvm.getelementptr %636[0, %763] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
%762 = llvm.load %764 : !llvm.ptr -> i32
%765 = arith.constant 0 : i32
%766 = arith.constant 1 : i32
%767 = arith.subi %765, %766 : i32
%768 = arith.cmpi eq, %762, %767 : i32
scf.yield %768 : i1
} else {
%769 = arith.constant false
scf.yield %769 : i1
}
cf.cond_br %761, ^bb79, ^bb80
^bb79:
%770 = arith.extsi %749 : i32 to i64
%771 = llvm.getelementptr %550[0, %770] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
llvm.store %750, %771 : i32, !llvm.ptr
%772 = arith.extsi %750 : i32 to i64
%773 = llvm.getelementptr %636[0, %772] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
llvm.store %749, %773 : i32, !llvm.ptr
cf.br ^bb81
^bb80:
%775 = arith.extsi %749 : i32 to i64
%776 = llvm.getelementptr %550[0, %775] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%774 = llvm.load %776 : !llvm.ptr -> i32
%777 = arith.cmpi ne, %774, %750 : i32
%778 = scf.if %777 -> (i1) {
%779 = arith.constant true
scf.yield %779 : i1
} else {
%781 = arith.extsi %750 : i32 to i64
%782 = llvm.getelementptr %636[0, %781] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<10 x i32>
%780 = llvm.load %782 : !llvm.ptr -> i32
%783 = arith.cmpi ne, %780, %749 : i32
scf.yield %783 : i1
}
cf.cond_br %778, ^bb82, ^bb81
^bb82:
%784 = arith.constant 0 : i1
llvm.store %784, %736 : i1, !llvm.ptr
cf.br ^bb78
^bb81:
%785 = llvm.load %715 : !llvm.ptr -> i32
%786 = arith.constant 1 : i32
%787 = arith.addi %785, %786 : i32
llvm.store %787, %715 : i32, !llvm.ptr
cf.br ^bb76
^bb78:
%788 = llvm.load %736 : !llvm.ptr -> i1
cf.cond_br %788, ^bb83, ^bb84
^bb83:
%789 = arith.constant 0 : i32
%790 = arith.extsi %789 : i32 to i64
%791 = llvm.mlir.constant(1 : i64) : i64
%792 = llvm.alloca %791 x i64 : (i64) -> !llvm.ptr
llvm.store %790, %792 : i64, !llvm.ptr
%793 = arith.constant 0 : i32
llvm.store %793, %715 : i32, !llvm.ptr
cf.br ^bb86
^bb86:
%794 = llvm.load %715 : !llvm.ptr -> i32
%795 = arith.cmpi slt, %794, %415 : i32
cf.cond_br %795, ^bb87, ^bb88
^bb87:
%798 = arith.index_cast %431 : index to i32
%797 = arith.muli %798, %328 : i32
%799 = llvm.load %715 : !llvm.ptr -> i32
%800 = arith.addi %797, %799 : i32
%801 = arith.extsi %800 : i32 to i64
%802 = llvm.getelementptr %330[%801] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%796 = llvm.load %802 : !llvm.ptr -> i8
%803 = arith.extsi %796 : i8 to i32
%804 = arith.constant 65 : i32
%805 = arith.subi %803, %804 : i32
%807 = arith.extsi %805 : i32 to i64
%808 = llvm.getelementptr %550[0, %807] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<26 x i32>
%806 = llvm.load %808 : !llvm.ptr -> i32
%809 = llvm.load %715 : !llvm.ptr -> i32
%810 = arith.constant 0 : i32
%811 = arith.cmpi eq, %809, %810 : i32
%812 = scf.if %811 -> (i1) {
%813 = arith.constant 0 : i32
%814 = arith.cmpi eq, %806, %813 : i32
scf.yield %814 : i1
} else {
%815 = arith.constant false
scf.yield %815 : i1
}
cf.cond_br %812, ^bb89, ^bb90
^bb89:
%816 = arith.constant 0 : i1
llvm.store %816, %736 : i1, !llvm.ptr
cf.br ^bb88
^bb90:
cf.br ^bb91
^bb91:
%817 = llvm.load %792 : !llvm.ptr -> i64
%818 = arith.constant 10 : i32
%820 = arith.extsi %818 : i32 to i64
%819 = arith.muli %817, %820 : i64
%821 = arith.extsi %806 : i32 to i64
%822 = arith.addi %819, %821 : i64
llvm.store %822, %792 : i64, !llvm.ptr
%823 = llvm.load %715 : !llvm.ptr -> i32
%824 = arith.constant 1 : i32
%825 = arith.addi %823, %824 : i32
llvm.store %825, %715 : i32, !llvm.ptr
cf.br ^bb86
^bb88:
%826 = llvm.load %736 : !llvm.ptr -> i1
%827 = scf.if %826 -> (i1) {
%829 = llvm.load %792 : !llvm.ptr -> i64
%828 = func.call @is_square(%829) : (i64) -> i1
scf.yield %828 : i1
} else {
%830 = arith.constant false
scf.yield %830 : i1
}
cf.cond_br %827, ^bb92, ^bb93
^bb92:
%831 = llvm.load %401 : !llvm.ptr -> i64
%832 = arith.cmpi sgt, %469, %831 : i64
cf.cond_br %832, ^bb95, ^bb96
^bb95:
llvm.store %469, %401 : i64, !llvm.ptr
cf.br ^bb97
^bb96:
cf.br ^bb97
^bb97:
%833 = llvm.load %792 : !llvm.ptr -> i64
%834 = llvm.load %401 : !llvm.ptr -> i64
%835 = arith.cmpi sgt, %833, %834 : i64
cf.cond_br %835, ^bb98, ^bb99
^bb98:
%836 = llvm.load %792 : !llvm.ptr -> i64
llvm.store %836, %401 : i64, !llvm.ptr
cf.br ^bb100
^bb99:
cf.br ^bb100
^bb100:
cf.br ^bb94
^bb93:
cf.br ^bb94
^bb94:
cf.br ^bb85
^bb84:
cf.br ^bb85
^bb85:
%837 = llvm.load %454 : !llvm.ptr -> i64
%838 = arith.constant 1 : i32
%840 = arith.extsi %838 : i32 to i64
%839 = arith.addi %837, %840 : i64
llvm.store %839, %454 : i64, !llvm.ptr
cf.br ^bb70
^bb72:
cf.br ^bb66
^bb65:
cf.br ^bb66
^bb66:
%841 = arith.addi %431, %423 : index
cf.br ^bb61(%841 : index)
^bb63(%842: index):
%843 = arith.addi %414, %406 : index
cf.br ^bb58(%843 : index)
^bb60(%844: index):
%845 = llvm.mlir.addressof @str_3 : !llvm.ptr
%846 = llvm.load %401 : !llvm.ptr -> i64
%847 = llvm.call @printf(%845, %846) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%330) : (!llvm.ptr) -> ()
%849 = arith.constant 0 : i32
func.return %849 : i32
}
}