Problem 177
Count non-similar integer-angled convex quadrilaterals.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^3) | O(n log log n) |
| Space complexity | O(n^2) | O(n) |
| Approach | Flow solution | Sieve or enumeration |
| Verdict | Suboptimal |
Flow source
# Project Euler 177
# Count non-similar integer-angled convex quadrilaterals.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function sin(x: f64) -> f64
function fabs(x: f64) -> f64
}
function pack8(a1: i32, a2: i32, b1: i32, b2: i32, c1: i32, c2: i32, d1: i32, d2: i32) -> i64 {
# pack into i64 with 8 bits each (angles < 180)
let mut v: i64 = a1 as i64
v = (v << 8) | (a2 as i64)
v = (v << 8) | (b1 as i64)
v = (v << 8) | (b2 as i64)
v = (v << 8) | (c1 as i64)
v = (v << 8) | (c2 as i64)
v = (v << 8) | (d1 as i64)
v = (v << 8) | (d2 as i64)
return v
}
function canon(a1: i32, a2: i32, b1: i32, b2: i32, c1: i32, c2: i32, d1: i32, d2: i32) -> i64 {
let r0: i64 = pack8(a1,a2,b1,b2,c1,c2,d1,d2)
let r1: i64 = pack8(b1,b2,c1,c2,d1,d2,a1,a2)
let r2: i64 = pack8(c1,c2,d1,d2,a1,a2,b1,b2)
let r3: i64 = pack8(d1,d2,a1,a2,b1,b2,c1,c2)
let f0: i64 = pack8(a2,a1,d2,d1,c2,c1,b2,b1)
let f1: i64 = pack8(b2,b1,a2,a1,d2,d1,c2,c1)
let f2: i64 = pack8(c2,c1,b2,b1,a2,a1,d2,d1)
let f3: i64 = pack8(d2,d1,c2,c1,b2,b1,a2,a1)
let mut m: i64 = r0
if r1 < m { m = r1 }
if r2 < m { m = r2 }
if r3 < m { m = r3 }
if f0 < m { m = f0 }
if f1 < m { m = f1 }
if f2 < m { m = f2 }
if f3 < m { m = f3 }
return m
}
function main() -> i32 {
let PI: f64 = 3.141592653589793
let sinv: ptr<f64> = calloc(181, 8)
if sinv == null { return 1 }
let mut i: i32 = 0
while i <= 180 {
sinv[i] = sin((i as f64) * PI / 180.0)
i = i + 1
}
let SCALE: f64 = 100000000000.0
let tol: f64 = 0.000000000001
# hash set for canon keys
let HS: i64 = 1 << 21
let hkey: ptr<i64> = calloc(HS, 8)
let hused: ptr<i8> = calloc(HS, 1)
if hkey == null || hused == null { return 1 }
let mut count: i64 = 0
# M_map: for each key store list of c2; use parallel arrays with chaining via next
# Simpler: for each a2,b1 rebuild map as open arrays
let map_key: ptr<i64> = calloc(400, 8)
let map_c2: ptr<i32> = calloc(400, 4)
let map_n: ptr<i32> = calloc(400, 4) # unused
let L_b2: ptr<i32> = calloc(200, 4)
let L_c1: ptr<i32> = calloc(200, 4)
let L_inv: ptr<f64> = calloc(200, 8)
let L_sb2: ptr<f64> = calloc(200, 8)
let L_sc1: ptr<f64> = calloc(200, 8)
let mut a2: i32 = 1
while a2 < 179 {
let sin_a2: f64 = sinv[a2]
let mut b1: i32 = 1
while b1 < 179 - a2 {
let sin_b1: f64 = sinv[b1]
let max_b2: i32 = 179 - a2 - b1
if max_b2 <= 0 {
b1 = b1 + 1
continue
}
let max_c2: i32 = a2 + b1 - 1
if max_c2 <= 0 {
b1 = b1 + 1
continue
}
# build M_map as list of (key, c2), then sort by key for binary search groups
let mut mc: i32 = 0
let mut c2: i32 = 1
while c2 <= max_c2 {
let d1: i32 = a2 + b1 - c2
let key: i64 = ((sinv[d1] / sinv[c2]) * SCALE + 0.5) as i64
map_key[mc] = key
map_c2[mc] = c2
mc = mc + 1
c2 = c2 + 1
}
# sort by key (insertion sort - mc < 360)
let mut ii: i32 = 1
while ii < mc {
let ktmp: i64 = map_key[ii]
let ctmp: i32 = map_c2[ii]
let mut jj: i32 = ii
while jj > 0 && map_key[jj - 1] > ktmp {
map_key[jj] = map_key[jj - 1]
map_c2[jj] = map_c2[jj - 1]
jj = jj - 1
}
map_key[jj] = ktmp
map_c2[jj] = ctmp
ii = ii + 1
}
let mut lc: i32 = 0
let mut b2: i32 = 1
while b2 <= max_b2 {
let c1: i32 = 180 - a2 - b1 - b2
L_b2[lc] = b2
L_c1[lc] = c1
L_inv[lc] = sinv[b2] / sinv[c1]
L_sb2[lc] = sinv[b2]
L_sc1[lc] = sinv[c1]
lc = lc + 1
b2 = b2 + 1
}
let max_a1: i32 = 179 - a2 - b1
let mut a1: i32 = 1
while a1 <= max_a1 {
let sin_a1: f64 = sinv[a1]
let d2: i32 = 180 - a1 - a2 - b1
let sin_d2: f64 = sinv[d2]
let R_scaled: f64 = (sin_a2 * sin_d2) / (sin_a1 * sin_b1) * SCALE
let mut li: i32 = 0
while li < lc {
let needed: i64 = (R_scaled * L_inv[li] + 0.5) as i64
# binary search for needed in map_key
let mut lo: i32 = 0
let mut hi: i32 = mc
while lo < hi {
let mid: i32 = (lo + hi) / 2
if map_key[mid] < needed { lo = mid + 1 }
else { hi = mid }
}
let mut k: i32 = lo
while k < mc && map_key[k] == needed {
c2 = map_c2[k]
if a1 + c2 < 180 {
let d1: i32 = a2 + b1 - c2
let b2v: i32 = L_b2[li]
let c1v: i32 = L_c1[li]
let lhs: f64 = L_sc1[li] * sinv[d1] * sin_a1 * sin_b1
let rhs: f64 = sin_a2 * L_sb2[li] * sinv[c2] * sin_d2
if fabs(lhs - rhs) <= tol {
if a1 + a2 < 180 && b1 + b2v < 180 && c1v + c2 < 180 && d1 + d2 < 180 {
let keyc: i64 = canon(a1, a2, b1, b2v, c1v, c2, d1, d2)
let mut h: i64 = keyc % HS
if h < 0 { h = 0 - h }
let mut found: bool = false
while hused[h] == 1 {
if hkey[h] == keyc { found = true; break }
h = h + 1
if h >= HS { h = 0 }
}
if !found {
hused[h] = 1
hkey[h] = keyc
count = count + 1
}
}
}
}
k = k + 1
}
li = li + 1
}
a1 = a1 + 1
}
b1 = b1 + 1
}
a2 = a2 + 1
}
printf("%lld\n", count)
free(sinv); free(hkey); free(hused)
free(map_key); free(map_c2); free(map_n)
free(L_b2); free(L_c1); free(L_inv); free(L_sb2); free(L_sc1)
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 pack8_i32_i32_i32_i32_i32_i32_i32_i32(int32_t a1, int32_t a2, int32_t b1, int32_t b2, int32_t c1, int32_t c2, int32_t d1, int32_t d2);
int64_t canon_i32_i32_i32_i32_i32_i32_i32_i32(int32_t a1, int32_t a2, int32_t b1, int32_t b2, int32_t c1, int32_t c2, int32_t d1, int32_t d2);
int32_t main(void);
int64_t pack8_i32_i32_i32_i32_i32_i32_i32_i32(int32_t a1, int32_t a2, int32_t b1, int32_t b2, int32_t c1, int32_t c2, int32_t d1, int32_t d2) {
int64_t v = ((int64_t)(a1));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(a2)));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(b1)));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(b2)));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(c1)));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(c2)));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(d1)));
v = (FLOW_CHECKED_SHL((v), (8)) | ((int64_t)(d2)));
return v;
}
int64_t canon_i32_i32_i32_i32_i32_i32_i32_i32(int32_t a1, int32_t a2, int32_t b1, int32_t b2, int32_t c1, int32_t c2, int32_t d1, int32_t d2) {
int64_t r0 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(a1, a2, b1, b2, c1, c2, d1, d2);
int64_t r1 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(b1, b2, c1, c2, d1, d2, a1, a2);
int64_t r2 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(c1, c2, d1, d2, a1, a2, b1, b2);
int64_t r3 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(d1, d2, a1, a2, b1, b2, c1, c2);
int64_t f0 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(a2, a1, d2, d1, c2, c1, b2, b1);
int64_t f1 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(b2, b1, a2, a1, d2, d1, c2, c1);
int64_t f2 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(c2, c1, b2, b1, a2, a1, d2, d1);
int64_t f3 = pack8_i32_i32_i32_i32_i32_i32_i32_i32(d2, d1, c2, c1, b2, b1, a2, a1);
int64_t m = r0;
if (r1 < m) {
m = r1;
}
if (r2 < m) {
m = r2;
}
if (r3 < m) {
m = r3;
}
if (f0 < m) {
m = f0;
}
if (f1 < m) {
m = f1;
}
if (f2 < m) {
m = f2;
}
if (f3 < m) {
m = f3;
}
return m;
}
int32_t main(void) {
double PI = 3.141592653589793;
double* sinv = (double*)(calloc(181, 8));
if (sinv == NULL) {
return 1;
}
int32_t i = 0;
while (i <= 180) {
sinv[i] = sin(((((double)(i)) * PI) / 180.0));
i = (i + 1);
}
double SCALE = 100000000000.0;
double tol = 0.000000000001;
int64_t HS = FLOW_CHECKED_SHL((1), (21));
int64_t* hkey = (int64_t*)(calloc(HS, 8));
int8_t* hused = (int8_t*)(calloc(HS, 1));
if ((hkey == NULL || hused == NULL)) {
return 1;
}
int64_t count = 0;
int64_t* map_key = (int64_t*)(calloc(400, 8));
int32_t* map_c2 = (int32_t*)(calloc(400, 4));
int32_t* map_n = (int32_t*)(calloc(400, 4));
int32_t* L_b2 = (int32_t*)(calloc(200, 4));
int32_t* L_c1 = (int32_t*)(calloc(200, 4));
double* L_inv = (double*)(calloc(200, 8));
double* L_sb2 = (double*)(calloc(200, 8));
double* L_sc1 = (double*)(calloc(200, 8));
int32_t a2 = 1;
while (a2 < 179) {
double sin_a2 = sinv[a2];
int32_t b1 = 1;
while (b1 < (179 - a2)) {
double sin_b1 = sinv[b1];
int32_t max_b2 = ((179 - a2) - b1);
if (max_b2 <= 0) {
b1 = (b1 + 1);
continue;
}
int32_t max_c2 = ((a2 + b1) - 1);
if (max_c2 <= 0) {
b1 = (b1 + 1);
continue;
}
int32_t mc = 0;
int32_t c2 = 1;
while (c2 <= max_c2) {
int32_t d1 = ((a2 + b1) - c2);
int64_t key = ((int64_t)((((sinv[d1] / sinv[c2]) * SCALE) + 0.5)));
map_key[mc] = key;
map_c2[mc] = c2;
mc = (mc + 1);
c2 = (c2 + 1);
}
int32_t ii = 1;
while (ii < mc) {
int64_t ktmp = map_key[ii];
int32_t ctmp = map_c2[ii];
int32_t jj = ii;
while ((jj > 0 && map_key[(jj - 1)] > ktmp)) {
map_key[jj] = map_key[(jj - 1)];
map_c2[jj] = map_c2[(jj - 1)];
jj = (jj - 1);
}
map_key[jj] = ktmp;
map_c2[jj] = ctmp;
ii = (ii + 1);
}
int32_t lc = 0;
int32_t b2 = 1;
while (b2 <= max_b2) {
int32_t c1 = (((180 - a2) - b1) - b2);
L_b2[lc] = b2;
L_c1[lc] = c1;
L_inv[lc] = (sinv[b2] / sinv[c1]);
L_sb2[lc] = sinv[b2];
L_sc1[lc] = sinv[c1];
lc = (lc + 1);
b2 = (b2 + 1);
}
int32_t max_a1 = ((179 - a2) - b1);
int32_t a1 = 1;
while (a1 <= max_a1) {
double sin_a1 = sinv[a1];
int32_t d2 = (((180 - a1) - a2) - b1);
double sin_d2 = sinv[d2];
double R_scaled = (((sin_a2 * sin_d2) / (sin_a1 * sin_b1)) * SCALE);
int32_t li = 0;
while (li < lc) {
int64_t needed = ((int64_t)(((R_scaled * L_inv[li]) + 0.5)));
int32_t lo = 0;
int32_t hi = mc;
while (lo < hi) {
int32_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
if (map_key[mid] < needed) {
lo = (mid + 1);
} else {
hi = mid;
}
}
int32_t k = lo;
while ((k < mc && map_key[k] == needed)) {
c2 = map_c2[k];
if ((a1 + c2) < 180) {
int32_t d1 = ((a2 + b1) - c2);
int32_t b2v = L_b2[li];
int32_t c1v = L_c1[li];
double lhs = (((L_sc1[li] * sinv[d1]) * sin_a1) * sin_b1);
double rhs = (((sin_a2 * L_sb2[li]) * sinv[c2]) * sin_d2);
if (fabs((lhs - rhs)) <= tol) {
if (((((a1 + a2) < 180 && (b1 + b2v) < 180) && (c1v + c2) < 180) && (d1 + d2) < 180)) {
int64_t keyc = canon_i32_i32_i32_i32_i32_i32_i32_i32(a1, a2, b1, b2v, c1v, c2, d1, d2);
int64_t h = FLOW_CHECKED_MOD((keyc), (HS));
if (h < 0) {
h = (0 - h);
}
bool found = 0;
while (hused[h] == 1) {
if (hkey[h] == keyc) {
found = 1;
break;
}
h = (h + 1);
if (h >= HS) {
h = 0;
}
}
if ((!(found))) {
hused[h] = 1;
hkey[h] = keyc;
count = (count + 1);
}
}
}
}
k = (k + 1);
}
li = (li + 1);
}
a1 = (a1 + 1);
}
b1 = (b1 + 1);
}
a2 = (a2 + 1);
}
printf("%lld\n", count);
free(sinv);
free(hkey);
free(hused);
free(map_key);
free(map_c2);
free(map_n);
free(L_b2);
free(L_c1);
free(L_inv);
free(L_sb2);
free(L_sc1);
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 private @sin(f64) -> f64
func.func private @fabs(f64) -> f64
func.func @pack8(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32, %arg5: i32, %arg6: i32, %arg7: i32) -> i64 {
%0 = arith.extsi %arg0 : i32 to i64
%1 = llvm.mlir.constant(1 : i64) : i64
%2 = llvm.alloca %1 x i64 : (i64) -> !llvm.ptr
llvm.store %0, %2 : i64, !llvm.ptr
%3 = llvm.load %2 : !llvm.ptr -> i64
%4 = arith.constant 8 : i32
%6 = arith.extsi %4 : i32 to i64
%5 = arith.shli %3, %6 : i64
%7 = arith.extsi %arg1 : i32 to i64
%8 = arith.ori %5, %7 : i64
llvm.store %8, %2 : i64, !llvm.ptr
%9 = llvm.load %2 : !llvm.ptr -> i64
%10 = arith.constant 8 : i32
%12 = arith.extsi %10 : i32 to i64
%11 = arith.shli %9, %12 : i64
%13 = arith.extsi %arg2 : i32 to i64
%14 = arith.ori %11, %13 : i64
llvm.store %14, %2 : i64, !llvm.ptr
%15 = llvm.load %2 : !llvm.ptr -> i64
%16 = arith.constant 8 : i32
%18 = arith.extsi %16 : i32 to i64
%17 = arith.shli %15, %18 : i64
%19 = arith.extsi %arg3 : i32 to i64
%20 = arith.ori %17, %19 : i64
llvm.store %20, %2 : i64, !llvm.ptr
%21 = llvm.load %2 : !llvm.ptr -> i64
%22 = arith.constant 8 : i32
%24 = arith.extsi %22 : i32 to i64
%23 = arith.shli %21, %24 : i64
%25 = arith.extsi %arg4 : i32 to i64
%26 = arith.ori %23, %25 : i64
llvm.store %26, %2 : i64, !llvm.ptr
%27 = llvm.load %2 : !llvm.ptr -> i64
%28 = arith.constant 8 : i32
%30 = arith.extsi %28 : i32 to i64
%29 = arith.shli %27, %30 : i64
%31 = arith.extsi %arg5 : i32 to i64
%32 = arith.ori %29, %31 : i64
llvm.store %32, %2 : i64, !llvm.ptr
%33 = llvm.load %2 : !llvm.ptr -> i64
%34 = arith.constant 8 : i32
%36 = arith.extsi %34 : i32 to i64
%35 = arith.shli %33, %36 : i64
%37 = arith.extsi %arg6 : i32 to i64
%38 = arith.ori %35, %37 : i64
llvm.store %38, %2 : i64, !llvm.ptr
%39 = llvm.load %2 : !llvm.ptr -> i64
%40 = arith.constant 8 : i32
%42 = arith.extsi %40 : i32 to i64
%41 = arith.shli %39, %42 : i64
%43 = arith.extsi %arg7 : i32 to i64
%44 = arith.ori %41, %43 : i64
llvm.store %44, %2 : i64, !llvm.ptr
%45 = llvm.load %2 : !llvm.ptr -> i64
func.return %45 : i64
}
func.func @canon(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32, %arg5: i32, %arg6: i32, %arg7: i32) -> i64 {
%46 = func.call @pack8(%arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%47 = func.call @pack8(%arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg0, %arg1) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%48 = func.call @pack8(%arg4, %arg5, %arg6, %arg7, %arg0, %arg1, %arg2, %arg3) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%49 = func.call @pack8(%arg6, %arg7, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%50 = func.call @pack8(%arg1, %arg0, %arg7, %arg6, %arg5, %arg4, %arg3, %arg2) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%51 = func.call @pack8(%arg3, %arg2, %arg1, %arg0, %arg7, %arg6, %arg5, %arg4) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%52 = func.call @pack8(%arg5, %arg4, %arg3, %arg2, %arg1, %arg0, %arg7, %arg6) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%53 = func.call @pack8(%arg7, %arg6, %arg5, %arg4, %arg3, %arg2, %arg1, %arg0) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%54 = llvm.mlir.constant(1 : i64) : i64
%55 = llvm.alloca %54 x i64 : (i64) -> !llvm.ptr
llvm.store %46, %55 : i64, !llvm.ptr
%56 = llvm.load %55 : !llvm.ptr -> i64
%57 = arith.cmpi slt, %47, %56 : i64
cf.cond_br %57, ^bb0, ^bb1
^bb0:
llvm.store %47, %55 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
%58 = llvm.load %55 : !llvm.ptr -> i64
%59 = arith.cmpi slt, %48, %58 : i64
cf.cond_br %59, ^bb3, ^bb4
^bb3:
llvm.store %48, %55 : i64, !llvm.ptr
cf.br ^bb5
^bb4:
cf.br ^bb5
^bb5:
%60 = llvm.load %55 : !llvm.ptr -> i64
%61 = arith.cmpi slt, %49, %60 : i64
cf.cond_br %61, ^bb6, ^bb7
^bb6:
llvm.store %49, %55 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
cf.br ^bb8
^bb8:
%62 = llvm.load %55 : !llvm.ptr -> i64
%63 = arith.cmpi slt, %50, %62 : i64
cf.cond_br %63, ^bb9, ^bb10
^bb9:
llvm.store %50, %55 : i64, !llvm.ptr
cf.br ^bb11
^bb10:
cf.br ^bb11
^bb11:
%64 = llvm.load %55 : !llvm.ptr -> i64
%65 = arith.cmpi slt, %51, %64 : i64
cf.cond_br %65, ^bb12, ^bb13
^bb12:
llvm.store %51, %55 : i64, !llvm.ptr
cf.br ^bb14
^bb13:
cf.br ^bb14
^bb14:
%66 = llvm.load %55 : !llvm.ptr -> i64
%67 = arith.cmpi slt, %52, %66 : i64
cf.cond_br %67, ^bb15, ^bb16
^bb15:
llvm.store %52, %55 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%68 = llvm.load %55 : !llvm.ptr -> i64
%69 = arith.cmpi slt, %53, %68 : i64
cf.cond_br %69, ^bb18, ^bb19
^bb18:
llvm.store %53, %55 : i64, !llvm.ptr
cf.br ^bb20
^bb19:
cf.br ^bb20
^bb20:
%70 = llvm.load %55 : !llvm.ptr -> i64
func.return %70 : i64
}
func.func @main() -> i32 {
%71 = arith.constant 3.141592653589793 : f32
%72 = arith.extf %71 : f32 to f64
%74 = arith.constant 181 : i32
%75 = arith.constant 8 : i32
%76 = arith.extsi %74 : i32 to i64
%77 = arith.extsi %75 : i32 to i64
%73 = func.call @calloc(%76, %77) : (i64, i64) -> !llvm.ptr
%78 = llvm.mlir.zero : !llvm.ptr
%79 = llvm.icmp "eq" %73, %78 : !llvm.ptr
cf.cond_br %79, ^bb21, ^bb22
^bb21:
%80 = arith.constant 1 : i32
func.return %80 : i32
^bb22:
cf.br ^bb23
^bb23:
%81 = arith.constant 0 : i32
%82 = llvm.mlir.constant(1 : i64) : i64
%83 = llvm.alloca %82 x i32 : (i64) -> !llvm.ptr
llvm.store %81, %83 : i32, !llvm.ptr
cf.br ^bb24
^bb24:
%84 = llvm.load %83 : !llvm.ptr -> i32
%85 = arith.constant 180 : i32
%86 = arith.cmpi sle, %84, %85 : i32
cf.cond_br %86, ^bb25, ^bb26
^bb25:
%87 = llvm.load %83 : !llvm.ptr -> i32
%88 = arith.sitofp %87 : i32 to f64
%89 = arith.mulf %88, %72 : f64
%90 = arith.constant 180.0 : f32
%92 = arith.extf %90 : f32 to f64
%91 = arith.divf %89, %92 : f64
%93 = math.sin %91 : f64
%94 = llvm.load %83 : !llvm.ptr -> i32
%95 = arith.extsi %94 : i32 to i64
%96 = llvm.getelementptr %73[%95] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %93, %96 : f64, !llvm.ptr
%97 = llvm.load %83 : !llvm.ptr -> i32
%98 = arith.constant 1 : i32
%99 = arith.addi %97, %98 : i32
llvm.store %99, %83 : i32, !llvm.ptr
cf.br ^bb24
^bb26:
%100 = arith.constant 100000000000.0 : f32
%101 = arith.extf %100 : f32 to f64
%102 = arith.constant 0.000000000001 : f32
%103 = arith.extf %102 : f32 to f64
%104 = arith.constant 1 : i32
%105 = arith.constant 21 : i32
%106 = arith.shli %104, %105 : i32
%107 = arith.extsi %106 : i32 to i64
%109 = arith.constant 8 : i32
%110 = arith.extsi %109 : i32 to i64
%108 = func.call @calloc(%107, %110) : (i64, i64) -> !llvm.ptr
%112 = arith.constant 1 : i32
%113 = arith.extsi %112 : i32 to i64
%111 = func.call @calloc(%107, %113) : (i64, i64) -> !llvm.ptr
%114 = llvm.mlir.zero : !llvm.ptr
%115 = llvm.icmp "eq" %108, %114 : !llvm.ptr
%116 = scf.if %115 -> (i1) {
%117 = arith.constant true
scf.yield %117 : i1
} else {
%118 = llvm.mlir.zero : !llvm.ptr
%119 = llvm.icmp "eq" %111, %118 : !llvm.ptr
scf.yield %119 : i1
}
cf.cond_br %116, ^bb27, ^bb28
^bb27:
%120 = arith.constant 1 : i32
func.return %120 : i32
^bb28:
cf.br ^bb29
^bb29:
%121 = arith.constant 0 : i32
%122 = arith.extsi %121 : i32 to i64
%123 = llvm.mlir.constant(1 : i64) : i64
%124 = llvm.alloca %123 x i64 : (i64) -> !llvm.ptr
llvm.store %122, %124 : i64, !llvm.ptr
%126 = arith.constant 400 : i32
%127 = arith.constant 8 : i32
%128 = arith.extsi %126 : i32 to i64
%129 = arith.extsi %127 : i32 to i64
%125 = func.call @calloc(%128, %129) : (i64, i64) -> !llvm.ptr
%131 = arith.constant 400 : i32
%132 = arith.constant 4 : i32
%133 = arith.extsi %131 : i32 to i64
%134 = arith.extsi %132 : i32 to i64
%130 = func.call @calloc(%133, %134) : (i64, i64) -> !llvm.ptr
%136 = arith.constant 400 : i32
%137 = arith.constant 4 : i32
%138 = arith.extsi %136 : i32 to i64
%139 = arith.extsi %137 : i32 to i64
%135 = func.call @calloc(%138, %139) : (i64, i64) -> !llvm.ptr
%141 = arith.constant 200 : i32
%142 = arith.constant 4 : i32
%143 = arith.extsi %141 : i32 to i64
%144 = arith.extsi %142 : i32 to i64
%140 = func.call @calloc(%143, %144) : (i64, i64) -> !llvm.ptr
%146 = arith.constant 200 : i32
%147 = arith.constant 4 : i32
%148 = arith.extsi %146 : i32 to i64
%149 = arith.extsi %147 : i32 to i64
%145 = func.call @calloc(%148, %149) : (i64, i64) -> !llvm.ptr
%151 = arith.constant 200 : i32
%152 = arith.constant 8 : i32
%153 = arith.extsi %151 : i32 to i64
%154 = arith.extsi %152 : i32 to i64
%150 = func.call @calloc(%153, %154) : (i64, i64) -> !llvm.ptr
%156 = arith.constant 200 : i32
%157 = arith.constant 8 : i32
%158 = arith.extsi %156 : i32 to i64
%159 = arith.extsi %157 : i32 to i64
%155 = func.call @calloc(%158, %159) : (i64, i64) -> !llvm.ptr
%161 = arith.constant 200 : i32
%162 = arith.constant 8 : i32
%163 = arith.extsi %161 : i32 to i64
%164 = arith.extsi %162 : i32 to i64
%160 = func.call @calloc(%163, %164) : (i64, i64) -> !llvm.ptr
%165 = arith.constant 1 : i32
%166 = llvm.mlir.constant(1 : i64) : i64
%167 = llvm.alloca %166 x i32 : (i64) -> !llvm.ptr
llvm.store %165, %167 : i32, !llvm.ptr
cf.br ^bb30
^bb30:
%168 = llvm.load %167 : !llvm.ptr -> i32
%169 = arith.constant 179 : i32
%170 = arith.cmpi slt, %168, %169 : i32
cf.cond_br %170, ^bb31, ^bb32
^bb31:
%172 = llvm.load %167 : !llvm.ptr -> i32
%173 = arith.extsi %172 : i32 to i64
%174 = llvm.getelementptr %73[%173] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%171 = llvm.load %174 : !llvm.ptr -> f64
%175 = arith.constant 1 : i32
%176 = llvm.mlir.constant(1 : i64) : i64
%177 = llvm.alloca %176 x i32 : (i64) -> !llvm.ptr
llvm.store %175, %177 : i32, !llvm.ptr
cf.br ^bb33
^bb33:
%178 = llvm.load %177 : !llvm.ptr -> i32
%179 = arith.constant 179 : i32
%180 = llvm.load %167 : !llvm.ptr -> i32
%181 = arith.subi %179, %180 : i32
%182 = arith.cmpi slt, %178, %181 : i32
cf.cond_br %182, ^bb34, ^bb35
^bb34:
%184 = llvm.load %177 : !llvm.ptr -> i32
%185 = arith.extsi %184 : i32 to i64
%186 = llvm.getelementptr %73[%185] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%183 = llvm.load %186 : !llvm.ptr -> f64
%187 = arith.constant 179 : i32
%188 = llvm.load %167 : !llvm.ptr -> i32
%189 = arith.subi %187, %188 : i32
%190 = llvm.load %177 : !llvm.ptr -> i32
%191 = arith.subi %189, %190 : i32
%192 = arith.constant 0 : i32
%193 = arith.cmpi sle, %191, %192 : i32
cf.cond_br %193, ^bb36, ^bb37
^bb36:
%194 = llvm.load %177 : !llvm.ptr -> i32
%195 = arith.constant 1 : i32
%196 = arith.addi %194, %195 : i32
llvm.store %196, %177 : i32, !llvm.ptr
cf.br ^bb33
^bb37:
cf.br ^bb38
^bb38:
%197 = llvm.load %167 : !llvm.ptr -> i32
%198 = llvm.load %177 : !llvm.ptr -> i32
%199 = arith.addi %197, %198 : i32
%200 = arith.constant 1 : i32
%201 = arith.subi %199, %200 : i32
%202 = arith.constant 0 : i32
%203 = arith.cmpi sle, %201, %202 : i32
cf.cond_br %203, ^bb39, ^bb40
^bb39:
%204 = llvm.load %177 : !llvm.ptr -> i32
%205 = arith.constant 1 : i32
%206 = arith.addi %204, %205 : i32
llvm.store %206, %177 : i32, !llvm.ptr
cf.br ^bb33
^bb40:
cf.br ^bb41
^bb41:
%207 = arith.constant 0 : i32
%208 = llvm.mlir.constant(1 : i64) : i64
%209 = llvm.alloca %208 x i32 : (i64) -> !llvm.ptr
llvm.store %207, %209 : i32, !llvm.ptr
%210 = arith.constant 1 : i32
%211 = llvm.mlir.constant(1 : i64) : i64
%212 = llvm.alloca %211 x i32 : (i64) -> !llvm.ptr
llvm.store %210, %212 : i32, !llvm.ptr
cf.br ^bb42
^bb42:
%213 = llvm.load %212 : !llvm.ptr -> i32
%214 = arith.cmpi sle, %213, %201 : i32
cf.cond_br %214, ^bb43, ^bb44
^bb43:
%215 = llvm.load %167 : !llvm.ptr -> i32
%216 = llvm.load %177 : !llvm.ptr -> i32
%217 = arith.addi %215, %216 : i32
%218 = llvm.load %212 : !llvm.ptr -> i32
%219 = arith.subi %217, %218 : i32
%221 = arith.extsi %219 : i32 to i64
%222 = llvm.getelementptr %73[%221] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%220 = llvm.load %222 : !llvm.ptr -> f64
%224 = llvm.load %212 : !llvm.ptr -> i32
%225 = arith.extsi %224 : i32 to i64
%226 = llvm.getelementptr %73[%225] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%223 = llvm.load %226 : !llvm.ptr -> f64
%227 = arith.divf %220, %223 : f64
%228 = arith.mulf %227, %101 : f64
%229 = arith.constant 0.5 : f32
%231 = arith.extf %229 : f32 to f64
%230 = arith.addf %228, %231 : f64
%232 = arith.fptosi %230 : f64 to i64
%233 = llvm.load %209 : !llvm.ptr -> i32
%234 = arith.extsi %233 : i32 to i64
%235 = llvm.getelementptr %125[%234] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %232, %235 : i64, !llvm.ptr
%236 = llvm.load %212 : !llvm.ptr -> i32
%237 = llvm.load %209 : !llvm.ptr -> i32
%238 = arith.extsi %237 : i32 to i64
%239 = llvm.getelementptr %130[%238] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %236, %239 : i32, !llvm.ptr
%240 = llvm.load %209 : !llvm.ptr -> i32
%241 = arith.constant 1 : i32
%242 = arith.addi %240, %241 : i32
llvm.store %242, %209 : i32, !llvm.ptr
%243 = llvm.load %212 : !llvm.ptr -> i32
%244 = arith.constant 1 : i32
%245 = arith.addi %243, %244 : i32
llvm.store %245, %212 : i32, !llvm.ptr
cf.br ^bb42
^bb44:
%246 = arith.constant 1 : i32
%247 = llvm.mlir.constant(1 : i64) : i64
%248 = llvm.alloca %247 x i32 : (i64) -> !llvm.ptr
llvm.store %246, %248 : i32, !llvm.ptr
cf.br ^bb45
^bb45:
%249 = llvm.load %248 : !llvm.ptr -> i32
%250 = llvm.load %209 : !llvm.ptr -> i32
%251 = arith.cmpi slt, %249, %250 : i32
cf.cond_br %251, ^bb46, ^bb47
^bb46:
%253 = llvm.load %248 : !llvm.ptr -> i32
%254 = arith.extsi %253 : i32 to i64
%255 = llvm.getelementptr %125[%254] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%252 = llvm.load %255 : !llvm.ptr -> i64
%257 = llvm.load %248 : !llvm.ptr -> i32
%258 = arith.extsi %257 : i32 to i64
%259 = llvm.getelementptr %130[%258] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%256 = llvm.load %259 : !llvm.ptr -> i32
%260 = llvm.load %248 : !llvm.ptr -> i32
%261 = llvm.mlir.constant(1 : i64) : i64
%262 = llvm.alloca %261 x i32 : (i64) -> !llvm.ptr
llvm.store %260, %262 : i32, !llvm.ptr
cf.br ^bb48
^bb48:
%263 = llvm.load %262 : !llvm.ptr -> i32
%264 = arith.constant 0 : i32
%265 = arith.cmpi sgt, %263, %264 : i32
%266 = scf.if %265 -> (i1) {
%268 = llvm.load %262 : !llvm.ptr -> i32
%269 = arith.constant 1 : i32
%270 = arith.subi %268, %269 : i32
%271 = arith.extsi %270 : i32 to i64
%272 = llvm.getelementptr %125[%271] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%267 = llvm.load %272 : !llvm.ptr -> i64
%273 = arith.cmpi sgt, %267, %252 : i64
scf.yield %273 : i1
} else {
%274 = arith.constant false
scf.yield %274 : i1
}
cf.cond_br %266, ^bb49, ^bb50
^bb49:
%276 = llvm.load %262 : !llvm.ptr -> i32
%277 = arith.constant 1 : i32
%278 = arith.subi %276, %277 : i32
%279 = arith.extsi %278 : i32 to i64
%280 = llvm.getelementptr %125[%279] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%275 = llvm.load %280 : !llvm.ptr -> i64
%281 = llvm.load %262 : !llvm.ptr -> i32
%282 = arith.extsi %281 : i32 to i64
%283 = llvm.getelementptr %125[%282] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %275, %283 : i64, !llvm.ptr
%285 = llvm.load %262 : !llvm.ptr -> i32
%286 = arith.constant 1 : i32
%287 = arith.subi %285, %286 : i32
%288 = arith.extsi %287 : i32 to i64
%289 = llvm.getelementptr %130[%288] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%284 = llvm.load %289 : !llvm.ptr -> i32
%290 = llvm.load %262 : !llvm.ptr -> i32
%291 = arith.extsi %290 : i32 to i64
%292 = llvm.getelementptr %130[%291] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %284, %292 : i32, !llvm.ptr
%293 = llvm.load %262 : !llvm.ptr -> i32
%294 = arith.constant 1 : i32
%295 = arith.subi %293, %294 : i32
llvm.store %295, %262 : i32, !llvm.ptr
cf.br ^bb48
^bb50:
%296 = llvm.load %262 : !llvm.ptr -> i32
%297 = arith.extsi %296 : i32 to i64
%298 = llvm.getelementptr %125[%297] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %252, %298 : i64, !llvm.ptr
%299 = llvm.load %262 : !llvm.ptr -> i32
%300 = arith.extsi %299 : i32 to i64
%301 = llvm.getelementptr %130[%300] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %256, %301 : i32, !llvm.ptr
%302 = llvm.load %248 : !llvm.ptr -> i32
%303 = arith.constant 1 : i32
%304 = arith.addi %302, %303 : i32
llvm.store %304, %248 : i32, !llvm.ptr
cf.br ^bb45
^bb47:
%305 = arith.constant 0 : i32
%306 = llvm.mlir.constant(1 : i64) : i64
%307 = llvm.alloca %306 x i32 : (i64) -> !llvm.ptr
llvm.store %305, %307 : i32, !llvm.ptr
%308 = arith.constant 1 : i32
%309 = llvm.mlir.constant(1 : i64) : i64
%310 = llvm.alloca %309 x i32 : (i64) -> !llvm.ptr
llvm.store %308, %310 : i32, !llvm.ptr
cf.br ^bb51
^bb51:
%311 = llvm.load %310 : !llvm.ptr -> i32
%312 = arith.cmpi sle, %311, %191 : i32
cf.cond_br %312, ^bb52, ^bb53
^bb52:
%313 = arith.constant 180 : i32
%314 = llvm.load %167 : !llvm.ptr -> i32
%315 = arith.subi %313, %314 : i32
%316 = llvm.load %177 : !llvm.ptr -> i32
%317 = arith.subi %315, %316 : i32
%318 = llvm.load %310 : !llvm.ptr -> i32
%319 = arith.subi %317, %318 : i32
%320 = llvm.load %310 : !llvm.ptr -> i32
%321 = llvm.load %307 : !llvm.ptr -> i32
%322 = arith.extsi %321 : i32 to i64
%323 = llvm.getelementptr %140[%322] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %320, %323 : i32, !llvm.ptr
%324 = llvm.load %307 : !llvm.ptr -> i32
%325 = arith.extsi %324 : i32 to i64
%326 = llvm.getelementptr %145[%325] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %319, %326 : i32, !llvm.ptr
%328 = llvm.load %310 : !llvm.ptr -> i32
%329 = arith.extsi %328 : i32 to i64
%330 = llvm.getelementptr %73[%329] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%327 = llvm.load %330 : !llvm.ptr -> f64
%332 = arith.extsi %319 : i32 to i64
%333 = llvm.getelementptr %73[%332] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%331 = llvm.load %333 : !llvm.ptr -> f64
%334 = arith.divf %327, %331 : f64
%335 = llvm.load %307 : !llvm.ptr -> i32
%336 = arith.extsi %335 : i32 to i64
%337 = llvm.getelementptr %150[%336] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %334, %337 : f64, !llvm.ptr
%339 = llvm.load %310 : !llvm.ptr -> i32
%340 = arith.extsi %339 : i32 to i64
%341 = llvm.getelementptr %73[%340] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%338 = llvm.load %341 : !llvm.ptr -> f64
%342 = llvm.load %307 : !llvm.ptr -> i32
%343 = arith.extsi %342 : i32 to i64
%344 = llvm.getelementptr %155[%343] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %338, %344 : f64, !llvm.ptr
%346 = arith.extsi %319 : i32 to i64
%347 = llvm.getelementptr %73[%346] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%345 = llvm.load %347 : !llvm.ptr -> f64
%348 = llvm.load %307 : !llvm.ptr -> i32
%349 = arith.extsi %348 : i32 to i64
%350 = llvm.getelementptr %160[%349] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %345, %350 : f64, !llvm.ptr
%351 = llvm.load %307 : !llvm.ptr -> i32
%352 = arith.constant 1 : i32
%353 = arith.addi %351, %352 : i32
llvm.store %353, %307 : i32, !llvm.ptr
%354 = llvm.load %310 : !llvm.ptr -> i32
%355 = arith.constant 1 : i32
%356 = arith.addi %354, %355 : i32
llvm.store %356, %310 : i32, !llvm.ptr
cf.br ^bb51
^bb53:
%357 = arith.constant 179 : i32
%358 = llvm.load %167 : !llvm.ptr -> i32
%359 = arith.subi %357, %358 : i32
%360 = llvm.load %177 : !llvm.ptr -> i32
%361 = arith.subi %359, %360 : i32
%362 = arith.constant 1 : i32
%363 = llvm.mlir.constant(1 : i64) : i64
%364 = llvm.alloca %363 x i32 : (i64) -> !llvm.ptr
llvm.store %362, %364 : i32, !llvm.ptr
cf.br ^bb54
^bb54:
%365 = llvm.load %364 : !llvm.ptr -> i32
%366 = arith.cmpi sle, %365, %361 : i32
cf.cond_br %366, ^bb55, ^bb56
^bb55:
%368 = llvm.load %364 : !llvm.ptr -> i32
%369 = arith.extsi %368 : i32 to i64
%370 = llvm.getelementptr %73[%369] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%367 = llvm.load %370 : !llvm.ptr -> f64
%371 = arith.constant 180 : i32
%372 = llvm.load %364 : !llvm.ptr -> i32
%373 = arith.subi %371, %372 : i32
%374 = llvm.load %167 : !llvm.ptr -> i32
%375 = arith.subi %373, %374 : i32
%376 = llvm.load %177 : !llvm.ptr -> i32
%377 = arith.subi %375, %376 : i32
%379 = arith.extsi %377 : i32 to i64
%380 = llvm.getelementptr %73[%379] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%378 = llvm.load %380 : !llvm.ptr -> f64
%381 = arith.mulf %171, %378 : f64
%382 = arith.mulf %367, %183 : f64
%383 = arith.divf %381, %382 : f64
%384 = arith.mulf %383, %101 : f64
%385 = arith.constant 0 : i32
%386 = llvm.mlir.constant(1 : i64) : i64
%387 = llvm.alloca %386 x i32 : (i64) -> !llvm.ptr
llvm.store %385, %387 : i32, !llvm.ptr
cf.br ^bb57
^bb57:
%388 = llvm.load %387 : !llvm.ptr -> i32
%389 = llvm.load %307 : !llvm.ptr -> i32
%390 = arith.cmpi slt, %388, %389 : i32
cf.cond_br %390, ^bb58, ^bb59
^bb58:
%392 = llvm.load %387 : !llvm.ptr -> i32
%393 = arith.extsi %392 : i32 to i64
%394 = llvm.getelementptr %150[%393] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%391 = llvm.load %394 : !llvm.ptr -> f64
%395 = arith.mulf %384, %391 : f64
%396 = arith.constant 0.5 : f32
%398 = arith.extf %396 : f32 to f64
%397 = arith.addf %395, %398 : f64
%399 = arith.fptosi %397 : f64 to i64
%400 = arith.constant 0 : i32
%401 = llvm.mlir.constant(1 : i64) : i64
%402 = llvm.alloca %401 x i32 : (i64) -> !llvm.ptr
llvm.store %400, %402 : i32, !llvm.ptr
%403 = llvm.load %209 : !llvm.ptr -> i32
%404 = llvm.mlir.constant(1 : i64) : i64
%405 = llvm.alloca %404 x i32 : (i64) -> !llvm.ptr
llvm.store %403, %405 : i32, !llvm.ptr
cf.br ^bb60
^bb60:
%406 = llvm.load %402 : !llvm.ptr -> i32
%407 = llvm.load %405 : !llvm.ptr -> i32
%408 = arith.cmpi slt, %406, %407 : i32
cf.cond_br %408, ^bb61, ^bb62
^bb61:
%409 = llvm.load %402 : !llvm.ptr -> i32
%410 = llvm.load %405 : !llvm.ptr -> i32
%411 = arith.addi %409, %410 : i32
%412 = arith.constant 2 : i32
%413 = arith.divsi %411, %412 : i32
%415 = arith.extsi %413 : i32 to i64
%416 = llvm.getelementptr %125[%415] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%414 = llvm.load %416 : !llvm.ptr -> i64
%417 = arith.cmpi slt, %414, %399 : i64
cf.cond_br %417, ^bb63, ^bb64
^bb63:
%418 = arith.constant 1 : i32
%419 = arith.addi %413, %418 : i32
llvm.store %419, %402 : i32, !llvm.ptr
cf.br ^bb65
^bb64:
llvm.store %413, %405 : i32, !llvm.ptr
cf.br ^bb65
^bb65:
cf.br ^bb60
^bb62:
%420 = llvm.load %402 : !llvm.ptr -> i32
%421 = llvm.mlir.constant(1 : i64) : i64
%422 = llvm.alloca %421 x i32 : (i64) -> !llvm.ptr
llvm.store %420, %422 : i32, !llvm.ptr
cf.br ^bb66
^bb66:
%423 = llvm.load %422 : !llvm.ptr -> i32
%424 = llvm.load %209 : !llvm.ptr -> i32
%425 = arith.cmpi slt, %423, %424 : i32
%426 = scf.if %425 -> (i1) {
%428 = llvm.load %422 : !llvm.ptr -> i32
%429 = arith.extsi %428 : i32 to i64
%430 = llvm.getelementptr %125[%429] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%427 = llvm.load %430 : !llvm.ptr -> i64
%431 = arith.cmpi eq, %427, %399 : i64
scf.yield %431 : i1
} else {
%432 = arith.constant false
scf.yield %432 : i1
}
cf.cond_br %426, ^bb67, ^bb68
^bb67:
%434 = llvm.load %422 : !llvm.ptr -> i32
%435 = arith.extsi %434 : i32 to i64
%436 = llvm.getelementptr %130[%435] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%433 = llvm.load %436 : !llvm.ptr -> i32
llvm.store %433, %212 : i32, !llvm.ptr
%437 = llvm.load %364 : !llvm.ptr -> i32
%438 = llvm.load %212 : !llvm.ptr -> i32
%439 = arith.addi %437, %438 : i32
%440 = arith.constant 180 : i32
%441 = arith.cmpi slt, %439, %440 : i32
cf.cond_br %441, ^bb69, ^bb70
^bb69:
%442 = llvm.load %167 : !llvm.ptr -> i32
%443 = llvm.load %177 : !llvm.ptr -> i32
%444 = arith.addi %442, %443 : i32
%445 = llvm.load %212 : !llvm.ptr -> i32
%446 = arith.subi %444, %445 : i32
%448 = llvm.load %387 : !llvm.ptr -> i32
%449 = arith.extsi %448 : i32 to i64
%450 = llvm.getelementptr %140[%449] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%447 = llvm.load %450 : !llvm.ptr -> i32
%452 = llvm.load %387 : !llvm.ptr -> i32
%453 = arith.extsi %452 : i32 to i64
%454 = llvm.getelementptr %145[%453] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%451 = llvm.load %454 : !llvm.ptr -> i32
%456 = llvm.load %387 : !llvm.ptr -> i32
%457 = arith.extsi %456 : i32 to i64
%458 = llvm.getelementptr %160[%457] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%455 = llvm.load %458 : !llvm.ptr -> f64
%460 = arith.extsi %446 : i32 to i64
%461 = llvm.getelementptr %73[%460] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%459 = llvm.load %461 : !llvm.ptr -> f64
%462 = arith.mulf %455, %459 : f64
%463 = arith.mulf %462, %367 : f64
%464 = arith.mulf %463, %183 : f64
%466 = llvm.load %387 : !llvm.ptr -> i32
%467 = arith.extsi %466 : i32 to i64
%468 = llvm.getelementptr %155[%467] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%465 = llvm.load %468 : !llvm.ptr -> f64
%469 = arith.mulf %171, %465 : f64
%471 = llvm.load %212 : !llvm.ptr -> i32
%472 = arith.extsi %471 : i32 to i64
%473 = llvm.getelementptr %73[%472] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%470 = llvm.load %473 : !llvm.ptr -> f64
%474 = arith.mulf %469, %470 : f64
%475 = arith.mulf %474, %378 : f64
%476 = arith.subf %464, %475 : f64
%477 = math.absf %476 : f64
%478 = arith.cmpf ole, %477, %103 : f64
cf.cond_br %478, ^bb72, ^bb73
^bb72:
%479 = llvm.load %364 : !llvm.ptr -> i32
%480 = llvm.load %167 : !llvm.ptr -> i32
%481 = arith.addi %479, %480 : i32
%482 = arith.constant 180 : i32
%483 = arith.cmpi slt, %481, %482 : i32
%484 = scf.if %483 -> (i1) {
%485 = llvm.load %177 : !llvm.ptr -> i32
%486 = arith.addi %485, %447 : i32
%487 = arith.constant 180 : i32
%488 = arith.cmpi slt, %486, %487 : i32
scf.yield %488 : i1
} else {
%489 = arith.constant false
scf.yield %489 : i1
}
%490 = scf.if %484 -> (i1) {
%491 = llvm.load %212 : !llvm.ptr -> i32
%492 = arith.addi %451, %491 : i32
%493 = arith.constant 180 : i32
%494 = arith.cmpi slt, %492, %493 : i32
scf.yield %494 : i1
} else {
%495 = arith.constant false
scf.yield %495 : i1
}
%496 = scf.if %490 -> (i1) {
%497 = arith.addi %446, %377 : i32
%498 = arith.constant 180 : i32
%499 = arith.cmpi slt, %497, %498 : i32
scf.yield %499 : i1
} else {
%500 = arith.constant false
scf.yield %500 : i1
}
cf.cond_br %496, ^bb75, ^bb76
^bb75:
%502 = llvm.load %364 : !llvm.ptr -> i32
%503 = llvm.load %167 : !llvm.ptr -> i32
%504 = llvm.load %177 : !llvm.ptr -> i32
%505 = llvm.load %212 : !llvm.ptr -> i32
%501 = func.call @canon(%502, %503, %504, %447, %451, %505, %446, %377) : (i32, i32, i32, i32, i32, i32, i32, i32) -> i64
%506 = arith.remsi %501, %107 : i64
%507 = llvm.mlir.constant(1 : i64) : i64
%508 = llvm.alloca %507 x i64 : (i64) -> !llvm.ptr
llvm.store %506, %508 : i64, !llvm.ptr
%509 = llvm.load %508 : !llvm.ptr -> i64
%510 = arith.constant 0 : i32
%512 = arith.extsi %510 : i32 to i64
%511 = arith.cmpi slt, %509, %512 : i64
cf.cond_br %511, ^bb78, ^bb79
^bb78:
%513 = arith.constant 0 : i32
%514 = llvm.load %508 : !llvm.ptr -> i64
%516 = arith.extsi %513 : i32 to i64
%515 = arith.subi %516, %514 : i64
llvm.store %515, %508 : i64, !llvm.ptr
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
%517 = arith.constant 0 : i1
%518 = llvm.mlir.constant(1 : i64) : i64
%519 = llvm.alloca %518 x i1 : (i64) -> !llvm.ptr
llvm.store %517, %519 : i1, !llvm.ptr
cf.br ^bb81
^bb81:
%521 = llvm.load %508 : !llvm.ptr -> i64
%522 = llvm.getelementptr %111[%521] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%520 = llvm.load %522 : !llvm.ptr -> i8
%523 = arith.constant 1 : i32
%525 = arith.extsi %520 : i8 to i32
%524 = arith.cmpi eq, %525, %523 : i32
cf.cond_br %524, ^bb82, ^bb83
^bb82:
%527 = llvm.load %508 : !llvm.ptr -> i64
%528 = llvm.getelementptr %108[%527] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%526 = llvm.load %528 : !llvm.ptr -> i64
%529 = arith.cmpi eq, %526, %501 : i64
cf.cond_br %529, ^bb84, ^bb85
^bb84:
%530 = arith.constant 1 : i1
llvm.store %530, %519 : i1, !llvm.ptr
cf.br ^bb83
^bb85:
cf.br ^bb86
^bb86:
%531 = llvm.load %508 : !llvm.ptr -> i64
%532 = arith.constant 1 : i32
%534 = arith.extsi %532 : i32 to i64
%533 = arith.addi %531, %534 : i64
llvm.store %533, %508 : i64, !llvm.ptr
%535 = llvm.load %508 : !llvm.ptr -> i64
%536 = arith.cmpi sge, %535, %107 : i64
cf.cond_br %536, ^bb87, ^bb88
^bb87:
%537 = arith.constant 0 : i32
%538 = arith.extsi %537 : i32 to i64
llvm.store %538, %508 : i64, !llvm.ptr
cf.br ^bb89
^bb88:
cf.br ^bb89
^bb89:
cf.br ^bb81
^bb83:
%539 = llvm.load %519 : !llvm.ptr -> i1
%541 = arith.constant 1 : i1
%540 = arith.xori %539, %541 : i1
cf.cond_br %540, ^bb90, ^bb91
^bb90:
%543 = arith.constant 1 : i32
%544 = llvm.load %508 : !llvm.ptr -> i64
%545 = arith.trunci %543 : i32 to i8
%546 = llvm.getelementptr %111[%544] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %545, %546 : i8, !llvm.ptr
%547 = llvm.load %508 : !llvm.ptr -> i64
%548 = llvm.getelementptr %108[%547] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %501, %548 : i64, !llvm.ptr
%549 = llvm.load %124 : !llvm.ptr -> i64
%550 = arith.constant 1 : i32
%552 = arith.extsi %550 : i32 to i64
%551 = arith.addi %549, %552 : i64
llvm.store %551, %124 : i64, !llvm.ptr
cf.br ^bb92
^bb91:
cf.br ^bb92
^bb92:
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%553 = llvm.load %422 : !llvm.ptr -> i32
%554 = arith.constant 1 : i32
%555 = arith.addi %553, %554 : i32
llvm.store %555, %422 : i32, !llvm.ptr
cf.br ^bb66
^bb68:
%556 = llvm.load %387 : !llvm.ptr -> i32
%557 = arith.constant 1 : i32
%558 = arith.addi %556, %557 : i32
llvm.store %558, %387 : i32, !llvm.ptr
cf.br ^bb57
^bb59:
%559 = llvm.load %364 : !llvm.ptr -> i32
%560 = arith.constant 1 : i32
%561 = arith.addi %559, %560 : i32
llvm.store %561, %364 : i32, !llvm.ptr
cf.br ^bb54
^bb56:
%562 = llvm.load %177 : !llvm.ptr -> i32
%563 = arith.constant 1 : i32
%564 = arith.addi %562, %563 : i32
llvm.store %564, %177 : i32, !llvm.ptr
cf.br ^bb33
^bb35:
%565 = llvm.load %167 : !llvm.ptr -> i32
%566 = arith.constant 1 : i32
%567 = arith.addi %565, %566 : i32
llvm.store %567, %167 : i32, !llvm.ptr
cf.br ^bb30
^bb32:
%568 = llvm.mlir.addressof @str_0 : !llvm.ptr
%569 = llvm.load %124 : !llvm.ptr -> i64
%570 = llvm.call @printf(%568, %569) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%73) : (!llvm.ptr) -> ()
func.call @free(%108) : (!llvm.ptr) -> ()
func.call @free(%111) : (!llvm.ptr) -> ()
func.call @free(%125) : (!llvm.ptr) -> ()
func.call @free(%130) : (!llvm.ptr) -> ()
func.call @free(%135) : (!llvm.ptr) -> ()
func.call @free(%140) : (!llvm.ptr) -> ()
func.call @free(%145) : (!llvm.ptr) -> ()
func.call @free(%150) : (!llvm.ptr) -> ()
func.call @free(%155) : (!llvm.ptr) -> ()
func.call @free(%160) : (!llvm.ptr) -> ()
%582 = arith.constant 0 : i32
func.return %582 : i32
}
}