Problem 982
Dice game optimal strategy via linear programming. Direct port of the C reference solver (two-phase simplex) to pure Flow.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^4) | O(n * s) |
| Space complexity | O(n^2) | O(s) |
| Approach | Flow solution | Dice distribution DP |
| Verdict | Unknown |
Flow source
# Project Euler 982
# Dice game optimal strategy via linear programming.
# Direct port of the C reference solver (two-phase simplex) to pure Flow.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function malloc(n: i64) -> ptr<void>
function realloc(p: ptr<void>, n: i64) -> ptr<void>
function fabs(x: f64) -> f64
function memset(p: ptr<void>, c: i64, n: i64) -> ptr<void>
}
const EPS: f64 = 1e-9
# Global tableau state: flat array tab[M*N], basis[M]
let mut g_tab: ptr<f64> = null
let mut g_basis: ptr<i64> = null
let mut g_M: i64 = 0
let mut g_N: i64 = 0
let mut g_art_flags: ptr<i64> = null
let mut g_num_art: i64 = 0
let mut g_art_indices: ptr<i64> = null
function tidx(i: i64, j: i64) -> i64 {
return i * g_N + j
}
function pivot_op(row: i64, col: i64) -> void {
let pv: f64 = g_tab[tidx(row, col)]
let inv: f64 = 1.0 / pv
let mut j: i64 = 0
while j < g_N {
g_tab[tidx(row, j)] = g_tab[tidx(row, j)] * inv
j = j + 1
}
let mut i: i64 = 0
while i < g_M {
if i == row { i = i + 1 } else {
let f: f64 = g_tab[tidx(i, col)]
if fabs(f) > EPS {
j = 0
while j < g_N {
g_tab[tidx(i, j)] = g_tab[tidx(i, j)] - f * g_tab[tidx(row, j)]
j = j + 1
}
}
i = i + 1
}
}
g_basis[row] = col
}
function simplex_max() -> i64 {
let m: i64 = g_M - 1
let n: i64 = g_N - 1
let mut iter: i64 = 0
while iter < 2000000 {
let mut entering: i64 = -1
let mut j: i64 = 0
while j < n {
if g_tab[tidx(m, j)] < -EPS { entering = j; j = n }
j = j + 1
}
if entering == -1 { return 1 }
let mut min_ratio: f64 = 1e18
let mut leaving: i64 = -1
let mut i: i64 = 0
while i < m {
let a: f64 = g_tab[tidx(i, entering)]
if a > EPS {
let ratio: f64 = g_tab[tidx(i, n)] / a
if ratio < min_ratio - EPS { min_ratio = ratio; leaving = i }
}
i = i + 1
}
if leaving == -1 { return 0 }
pivot_op(leaving, entering)
iter = iter + 1
}
return -1
}
function set_objective(c: ptr<f64>) -> void {
let m: i64 = g_M - 1
let n: i64 = g_N - 1
let mut j: i64 = 0
while j < g_N {
g_tab[tidx(m, j)] = 0.0
j = j + 1
}
j = 0
while j < n {
g_tab[tidx(m, j)] = -c[j]
j = j + 1
}
let mut i: i64 = 0
while i < m {
let cb: f64 = c[g_basis[i]]
if fabs(cb) > EPS {
j = 0
while j < g_N {
g_tab[tidx(m, j)] = g_tab[tidx(m, j)] + cb * g_tab[tidx(i, j)]
j = j + 1
}
}
i = i + 1
}
}
# Constraint: coeffs[n_vars], sense (60='<', 62='>', 61='='), rhs
# We pass constraint data via flat arrays:
# cons_coeffs: nc * n_vars flat array
# cons_sense: nc array
# cons_rhs: nc array
function build_tableau(n_vars: i64, cons_coeffs: ptr<f64>, cons_sense: ptr<i64>, cons_rhs: ptr<f64>, nc: i64) -> void {
let mut n_total: i64 = n_vars
let mut ci: i64 = 0
while ci < nc {
let s: i64 = cons_sense[ci]
if s == 60 { n_total = n_total + 1 }
else {
if s == 62 { n_total = n_total + 2 }
else { n_total = n_total + 1 }
}
ci = ci + 1
}
g_M = nc
g_N = n_total + 1
g_tab = calloc(g_M * g_N, 8) as ptr<f64>
g_basis = calloc(g_M, 8) as ptr<i64>
g_art_flags = calloc(n_total, 8) as ptr<i64>
g_art_indices = calloc(n_total, 8) as ptr<i64>
g_num_art = 0
let mut cur: i64 = n_vars
ci = 0
while ci < nc {
let mut b: f64 = cons_rhs[ci]
let mut sense: i64 = cons_sense[ci]
if b < 0.0 {
let mut j: i64 = 0
while j < n_vars {
g_tab[tidx(ci, j)] = -cons_coeffs[ci * n_vars + j]
j = j + 1
}
b = -b
if sense == 60 { sense = 62 }
else {
if sense == 62 { sense = 60 }
}
} else {
let mut j: i64 = 0
while j < n_vars {
g_tab[tidx(ci, j)] = cons_coeffs[ci * n_vars + j]
j = j + 1
}
}
if sense == 60 {
g_tab[tidx(ci, cur)] = 1.0
g_basis[ci] = cur
cur = cur + 1
} else {
if sense == 62 {
g_tab[tidx(ci, cur)] = -1.0
cur = cur + 1
g_tab[tidx(ci, cur)] = 1.0
g_basis[ci] = cur
g_art_flags[cur] = 1
g_art_indices[g_num_art] = cur
g_num_art = g_num_art + 1
cur = cur + 1
} else {
g_tab[tidx(ci, cur)] = 1.0
g_basis[ci] = cur
g_art_flags[cur] = 1
g_art_indices[g_num_art] = cur
g_num_art = g_num_art + 1
cur = cur + 1
}
}
g_tab[tidx(ci, g_N - 1)] = b
ci = ci + 1
}
}
function remove_artificial() -> void {
let mut m: i64 = g_M
let n: i64 = g_N - 1
let mut i: i64 = 0
while i < m {
if g_art_flags[g_basis[i]] != 0 {
let mut pc: i64 = -1
let mut j: i64 = 0
while j < n {
if g_art_flags[j] != 0 { j = j + 1 } else {
if fabs(g_tab[tidx(i, j)]) > EPS { pc = j; j = n }
j = j + 1
}
}
if pc != -1 {
pivot_op(i, pc)
i = i + 1
} else {
# Redundant row: remove it by shifting down
let mut r: i64 = i
while r < m - 1 {
let mut j2: i64 = 0
while j2 < g_N {
g_tab[tidx(r, j2)] = g_tab[tidx(r + 1, j2)]
j2 = j2 + 1
}
g_basis[r] = g_basis[r + 1]
r = r + 1
}
m = m - 1
}
} else {
i = i + 1
}
}
# Remove artificial columns
let mut n_keep: i64 = 0
let keep: ptr<i64> = calloc(n, 8)
let mut j: i64 = 0
while j < n {
if g_art_flags[j] == 0 { keep[n_keep] = j; n_keep = n_keep + 1 }
j = j + 1
}
let mapping: ptr<i64> = calloc(n, 8)
let mut new_idx: i64 = 0
j = 0
while j < n {
if g_art_flags[j] == 0 { mapping[j] = new_idx; new_idx = new_idx + 1 }
else { mapping[j] = -1 }
j = j + 1
}
let new_N: i64 = n_keep + 1
let new_tab: ptr<f64> = calloc(m * new_N, 8) as ptr<f64>
let mut r: i64 = 0
while r < m {
let mut j2: i64 = 0
while j2 < n_keep {
new_tab[r * new_N + j2] = g_tab[tidx(r, keep[j2])]
j2 = j2 + 1
}
new_tab[r * new_N + n_keep] = g_tab[tidx(r, n)]
g_basis[r] = mapping[g_basis[r]]
r = r + 1
}
free(g_tab as ptr<void>)
g_tab = new_tab
g_N = new_N
g_M = m
free(keep as ptr<void>)
free(mapping as ptr<void>)
}
# Returns result. obj is n_vars-length.
function solve_lp(n_vars: i64, cons_coeffs: ptr<f64>, cons_sense: ptr<i64>, cons_rhs: ptr<f64>, nc: i64, obj: ptr<f64>) -> f64 {
build_tableau(n_vars, cons_coeffs, cons_sense, cons_rhs, nc)
if g_num_art > 0 {
# Phase I: maximize -sum(artificial)
let nt: i64 = g_N - 1
let c1: ptr<f64> = calloc(nt, 8) as ptr<f64>
let mut j: i64 = 0
while j < nt {
if g_art_flags[j] != 0 { c1[j] = -1.0 }
j = j + 1
}
# Add objective row
let obj_row: i64 = g_M
g_M = g_M + 1
# realloc tab to M*N
let new_tab: ptr<f64> = calloc(g_M * g_N, 8) as ptr<f64>
let mut i: i64 = 0
while i < obj_row {
let mut j2: i64 = 0
while j2 < g_N {
new_tab[i * g_N + j2] = g_tab[tidx(i, j2)]
j2 = j2 + 1
}
i = i + 1
}
free(g_tab as ptr<void>)
g_tab = new_tab
# basis also needs to grow
let new_basis: ptr<i64> = calloc(g_M, 8) as ptr<i64>
i = 0
while i < obj_row {
new_basis[i] = g_basis[i]
i = i + 1
}
free(g_basis as ptr<void>)
g_basis = new_basis
set_objective(c1)
simplex_max()
if g_tab[tidx(obj_row, g_N - 1)] < -1e-7 {
free(g_tab as ptr<void>)
free(g_basis as ptr<void>)
free(g_art_flags as ptr<void>)
free(g_art_indices as ptr<void>)
free(c1 as ptr<void>)
return -1e18
}
# Remove objective row
g_M = g_M - 1
# (we just stop using the last row; no need to actually free it)
remove_artificial()
free(c1 as ptr<void>)
}
# Phase II: minimize sum(obj[j]*x[j]) = maximize -sum(obj[j]*x[j])
let nt2: i64 = g_N - 1
let c2: ptr<f64> = calloc(nt2, 8) as ptr<f64>
let mut j: i64 = 0
while j < n_vars {
c2[j] = -obj[j]
j = j + 1
}
# Add objective row
let obj_row: i64 = g_M
g_M = g_M + 1
let new_tab2: ptr<f64> = calloc(g_M * g_N, 8) as ptr<f64>
let mut i: i64 = 0
while i < obj_row {
let mut j2: i64 = 0
while j2 < g_N {
new_tab2[i * g_N + j2] = g_tab[tidx(i, j2)]
j2 = j2 + 1
}
i = i + 1
}
free(g_tab as ptr<void>)
g_tab = new_tab2
let new_basis2: ptr<i64> = calloc(g_M, 8) as ptr<i64>
i = 0
while i < obj_row {
new_basis2[i] = g_basis[i]
i = i + 1
}
free(g_basis as ptr<void>)
g_basis = new_basis2
set_objective(c2)
simplex_max()
let result: f64 = -g_tab[tidx(obj_row, g_N - 1)]
free(g_tab as ptr<void>)
free(g_basis as ptr<void>)
free(g_art_flags as ptr<void>)
free(g_art_indices as ptr<void>)
free(c2 as ptr<void>)
return result
}
function build_and_solve(num_dice: i64) -> f64 {
let num_states: i64 = 1
let mut i: i64 = 0
while i < num_dice {
num_states = num_states * 6
i = i + 1
}
# states: num_states * 3 flat array
let states: ptr<i64> = calloc(num_states * 3, 8) as ptr<i64>
let mut s_idx: i64 = 0
let mut a: i64 = 0
while a < 6 {
let mut b: i64 = 0
while b < 6 {
let mut c: i64 = 0
while c < 6 {
states[s_idx * 3 + 0] = a + 1
states[s_idx * 3 + 1] = b + 1
states[s_idx * 3 + 2] = c + 1
s_idx = s_idx + 1
c = c + 1
}
b = b + 1
}
a = a + 1
}
# signals: 21 pairs (a,b) with a<=b
let num_signals: i64 = 21
let sig_arr: ptr<i64> = calloc(num_signals * 2, 8) as ptr<i64>
let mut nsig: i64 = 0
a = 0
while a < 6 {
let mut b: i64 = a
while b < 6 {
sig_arr[nsig * 2 + 0] = a + 1
sig_arr[nsig * 2 + 1] = b + 1
nsig = nsig + 1
b = b + 1
}
a = a + 1
}
let num_x: i64 = num_states * num_dice
let num_z: i64 = num_signals
let n_vars: i64 = num_x + num_z
let n_constraints: i64 = num_states + 2 * num_signals
let cons_coeffs: ptr<f64> = calloc(n_constraints * n_vars, 8) as ptr<f64>
let cons_sense: ptr<i64> = calloc(n_constraints, 8) as ptr<i64>
let cons_rhs: ptr<f64> = calloc(n_constraints, 8) as ptr<f64>
let mut nc: i64 = 0
let p_state: f64 = 1.0 / (num_states as f64)
# State constraints: sum_h x[si,h] = p_state
let mut si: i64 = 0
while si < num_states {
let mut h: i64 = 0
while h < num_dice {
cons_coeffs[nc * n_vars + si * num_dice + h] = 1.0
h = h + 1
}
cons_sense[nc] = 61
cons_rhs[nc] = p_state
nc = nc + 1
si = si + 1
}
# Signal constraints
let mut sig_i: i64 = 0
while sig_i < num_signals {
let b_val: i64 = sig_arr[sig_i * 2 + 1]
let z_idx: i64 = num_x + sig_i
cons_coeffs[nc * n_vars + z_idx] = -1.0
cons_coeffs[(nc + 1) * n_vars + z_idx] = -1.0
si = 0
while si < num_states {
let mut h: i64 = 0
while h < num_dice {
# revealed = the two dice values that are not h
let mut revealed0: i64 = 0
let mut revealed1: i64 = 0
let mut ri: i64 = 0
let mut ii: i64 = 0
while ii < num_dice {
if ii != h {
if ri == 0 { revealed0 = states[si * 3 + ii] }
else { revealed1 = states[si * 3 + ii] }
ri = ri + 1
}
ii = ii + 1
}
if revealed0 > revealed1 {
let tmp: i64 = revealed0
revealed0 = revealed1
revealed1 = tmp
}
if revealed0 == sig_arr[sig_i * 2 + 0] && revealed1 == sig_arr[sig_i * 2 + 1] {
let x_idx: i64 = si * num_dice + h
cons_coeffs[nc * n_vars + x_idx] = cons_coeffs[nc * n_vars + x_idx] + (b_val as f64)
cons_coeffs[(nc + 1) * n_vars + x_idx] = cons_coeffs[(nc + 1) * n_vars + x_idx] + (states[si * 3 + h] as f64)
}
h = h + 1
}
si = si + 1
}
cons_sense[nc] = 60
cons_rhs[nc] = 0.0
cons_sense[nc + 1] = 60
cons_rhs[nc + 1] = 0.0
nc = nc + 2
sig_i = sig_i + 1
}
let objective: ptr<f64> = calloc(n_vars, 8) as ptr<f64>
let mut j: i64 = 0
while j < num_z {
objective[num_x + j] = 1.0
j = j + 1
}
let result: f64 = solve_lp(n_vars, cons_coeffs, cons_sense, cons_rhs, n_constraints, objective)
free(cons_coeffs as ptr<void>)
free(cons_sense as ptr<void>)
free(cons_rhs as ptr<void>)
free(objective as ptr<void>)
free(states as ptr<void>)
free(sig_arr as ptr<void>)
return result
}
function main() -> i32 {
printf("%.6f\n", build_and_solve(3))
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 tidx_i64_i64(int64_t i, int64_t j);
void pivot_op_i64_i64(int64_t row, int64_t col);
int64_t simplex_max(void);
void set_objective_ptr_f64(double* c);
void build_tableau_i64_ptr_f64_ptr_i64_ptr_f64_i64(int64_t n_vars, double* cons_coeffs, int64_t* cons_sense, double* cons_rhs, int64_t nc);
void remove_artificial(void);
double solve_lp_i64_ptr_f64_ptr_i64_ptr_f64_i64_ptr_f64(int64_t n_vars, double* cons_coeffs, int64_t* cons_sense, double* cons_rhs, int64_t nc, double* obj);
double build_and_solve_i64(int64_t num_dice);
int32_t main(void);
static const double EPS = 1e-9;
/* Module statics */
static double* g_tab = NULL;
static int64_t* g_basis = NULL;
static int64_t g_M = 0;
static int64_t g_N = 0;
static int64_t* g_art_flags = NULL;
static int64_t g_num_art = 0;
static int64_t* g_art_indices = NULL;
int64_t tidx_i64_i64(int64_t i, int64_t j) {
return ((i * g_N) + j);
}
void pivot_op_i64_i64(int64_t row, int64_t col) {
double pv = g_tab[tidx_i64_i64(row, col)];
double inv = (1.0 / pv);
int64_t j = 0;
while (j < g_N) {
g_tab[tidx_i64_i64(row, j)] = (g_tab[tidx_i64_i64(row, j)] * inv);
j = (j + 1);
}
int64_t i = 0;
while (i < g_M) {
if (i == row) {
i = (i + 1);
} else {
double f = g_tab[tidx_i64_i64(i, col)];
if (fabs(f) > EPS) {
j = 0;
while (j < g_N) {
g_tab[tidx_i64_i64(i, j)] = (g_tab[tidx_i64_i64(i, j)] - (f * g_tab[tidx_i64_i64(row, j)]));
j = (j + 1);
}
}
i = (i + 1);
}
}
g_basis[row] = col;
}
int64_t simplex_max(void) {
int64_t m = (g_M - 1);
int64_t n = (g_N - 1);
int64_t iter = 0;
while (iter < 2000000) {
int64_t entering = (-1);
int64_t j = 0;
while (j < n) {
if (g_tab[tidx_i64_i64(m, j)] < (-EPS)) {
entering = j;
j = n;
}
j = (j + 1);
}
if (entering == (-1)) {
return 1;
}
double min_ratio = 1e18;
int64_t leaving = (-1);
int64_t i = 0;
while (i < m) {
double a = g_tab[tidx_i64_i64(i, entering)];
if (a > EPS) {
double ratio = (g_tab[tidx_i64_i64(i, n)] / a);
if (ratio < (min_ratio - EPS)) {
min_ratio = ratio;
leaving = i;
}
}
i = (i + 1);
}
if (leaving == (-1)) {
return 0;
}
pivot_op_i64_i64(leaving, entering);
iter = (iter + 1);
}
return (-1);
}
void set_objective_ptr_f64(double* c) {
int64_t m = (g_M - 1);
int64_t n = (g_N - 1);
int64_t j = 0;
while (j < g_N) {
g_tab[tidx_i64_i64(m, j)] = 0.0;
j = (j + 1);
}
j = 0;
while (j < n) {
g_tab[tidx_i64_i64(m, j)] = (-c[j]);
j = (j + 1);
}
int64_t i = 0;
while (i < m) {
double cb = c[g_basis[i]];
if (fabs(cb) > EPS) {
j = 0;
while (j < g_N) {
g_tab[tidx_i64_i64(m, j)] = (g_tab[tidx_i64_i64(m, j)] + (cb * g_tab[tidx_i64_i64(i, j)]));
j = (j + 1);
}
}
i = (i + 1);
}
}
void build_tableau_i64_ptr_f64_ptr_i64_ptr_f64_i64(int64_t n_vars, double* cons_coeffs, int64_t* cons_sense, double* cons_rhs, int64_t nc) {
int64_t n_total = n_vars;
int64_t ci = 0;
while (ci < nc) {
int64_t s = cons_sense[ci];
if (s == 60) {
n_total = (n_total + 1);
} else {
if (s == 62) {
n_total = (n_total + 2);
} else {
n_total = (n_total + 1);
}
}
ci = (ci + 1);
}
g_M = nc;
g_N = (n_total + 1);
g_tab = ((double*)(calloc((g_M * g_N), 8)));
g_basis = ((int64_t*)(calloc(g_M, 8)));
g_art_flags = ((int64_t*)(calloc(n_total, 8)));
g_art_indices = ((int64_t*)(calloc(n_total, 8)));
g_num_art = 0;
int64_t cur = n_vars;
ci = 0;
while (ci < nc) {
double b = cons_rhs[ci];
int64_t sense = cons_sense[ci];
if (b < 0.0) {
int64_t j = 0;
while (j < n_vars) {
g_tab[tidx_i64_i64(ci, j)] = (-cons_coeffs[((ci * n_vars) + j)]);
j = (j + 1);
}
b = (-b);
if (sense == 60) {
sense = 62;
} else {
if (sense == 62) {
sense = 60;
}
}
} else {
int64_t j = 0;
while (j < n_vars) {
g_tab[tidx_i64_i64(ci, j)] = cons_coeffs[((ci * n_vars) + j)];
j = (j + 1);
}
}
if (sense == 60) {
g_tab[tidx_i64_i64(ci, cur)] = 1.0;
g_basis[ci] = cur;
cur = (cur + 1);
} else {
if (sense == 62) {
g_tab[tidx_i64_i64(ci, cur)] = (-1.0);
cur = (cur + 1);
g_tab[tidx_i64_i64(ci, cur)] = 1.0;
g_basis[ci] = cur;
g_art_flags[cur] = 1;
g_art_indices[g_num_art] = cur;
g_num_art = (g_num_art + 1);
cur = (cur + 1);
} else {
g_tab[tidx_i64_i64(ci, cur)] = 1.0;
g_basis[ci] = cur;
g_art_flags[cur] = 1;
g_art_indices[g_num_art] = cur;
g_num_art = (g_num_art + 1);
cur = (cur + 1);
}
}
g_tab[tidx_i64_i64(ci, (g_N - 1))] = b;
ci = (ci + 1);
}
}
void remove_artificial(void) {
int64_t m = g_M;
int64_t n = (g_N - 1);
int64_t i = 0;
while (i < m) {
if (g_art_flags[g_basis[i]] != 0) {
int64_t pc = (-1);
int64_t j = 0;
while (j < n) {
if (g_art_flags[j] != 0) {
j = (j + 1);
} else {
if (fabs(g_tab[tidx_i64_i64(i, j)]) > EPS) {
pc = j;
j = n;
}
j = (j + 1);
}
}
if (pc != (-1)) {
pivot_op_i64_i64(i, pc);
i = (i + 1);
} else {
int64_t r = i;
while (r < (m - 1)) {
int64_t j2 = 0;
while (j2 < g_N) {
g_tab[tidx_i64_i64(r, j2)] = g_tab[tidx_i64_i64((r + 1), j2)];
j2 = (j2 + 1);
}
g_basis[r] = g_basis[(r + 1)];
r = (r + 1);
}
m = (m - 1);
}
} else {
i = (i + 1);
}
}
int64_t n_keep = 0;
int64_t* keep = (int64_t*)(calloc(n, 8));
int64_t j = 0;
while (j < n) {
if (g_art_flags[j] == 0) {
keep[n_keep] = j;
n_keep = (n_keep + 1);
}
j = (j + 1);
}
int64_t* mapping = (int64_t*)(calloc(n, 8));
int64_t new_idx = 0;
j = 0;
while (j < n) {
if (g_art_flags[j] == 0) {
mapping[j] = new_idx;
new_idx = (new_idx + 1);
} else {
mapping[j] = (-1);
}
j = (j + 1);
}
int64_t new_N = (n_keep + 1);
double* new_tab = (double*)(((double*)(calloc((m * new_N), 8))));
int64_t r = 0;
while (r < m) {
int64_t j2 = 0;
while (j2 < n_keep) {
new_tab[((r * new_N) + j2)] = g_tab[tidx_i64_i64(r, keep[j2])];
j2 = (j2 + 1);
}
new_tab[((r * new_N) + n_keep)] = g_tab[tidx_i64_i64(r, n)];
g_basis[r] = mapping[g_basis[r]];
r = (r + 1);
}
free(((void*)(g_tab)));
g_tab = new_tab;
g_N = new_N;
g_M = m;
free(((void*)(keep)));
free(((void*)(mapping)));
}
double solve_lp_i64_ptr_f64_ptr_i64_ptr_f64_i64_ptr_f64(int64_t n_vars, double* cons_coeffs, int64_t* cons_sense, double* cons_rhs, int64_t nc, double* obj) {
build_tableau_i64_ptr_f64_ptr_i64_ptr_f64_i64(n_vars, cons_coeffs, cons_sense, cons_rhs, nc);
if (g_num_art > 0) {
int64_t nt = (g_N - 1);
double* c1 = (double*)(((double*)(calloc(nt, 8))));
int64_t j = 0;
while (j < nt) {
if (g_art_flags[j] != 0) {
c1[j] = (-1.0);
}
j = (j + 1);
}
int64_t obj_row = g_M;
g_M = (g_M + 1);
double* new_tab = (double*)(((double*)(calloc((g_M * g_N), 8))));
int64_t i = 0;
while (i < obj_row) {
int64_t j2 = 0;
while (j2 < g_N) {
new_tab[((i * g_N) + j2)] = g_tab[tidx_i64_i64(i, j2)];
j2 = (j2 + 1);
}
i = (i + 1);
}
free(((void*)(g_tab)));
g_tab = new_tab;
int64_t* new_basis = (int64_t*)(((int64_t*)(calloc(g_M, 8))));
i = 0;
while (i < obj_row) {
new_basis[i] = g_basis[i];
i = (i + 1);
}
free(((void*)(g_basis)));
g_basis = new_basis;
set_objective_ptr_f64(c1);
simplex_max();
if (g_tab[tidx_i64_i64(obj_row, (g_N - 1))] < (-1e-7)) {
free(((void*)(g_tab)));
free(((void*)(g_basis)));
free(((void*)(g_art_flags)));
free(((void*)(g_art_indices)));
free(((void*)(c1)));
return (-1e18);
}
g_M = (g_M - 1);
remove_artificial();
free(((void*)(c1)));
}
int64_t nt2 = (g_N - 1);
double* c2 = (double*)(((double*)(calloc(nt2, 8))));
int64_t j = 0;
while (j < n_vars) {
c2[j] = (-obj[j]);
j = (j + 1);
}
int64_t obj_row = g_M;
g_M = (g_M + 1);
double* new_tab2 = (double*)(((double*)(calloc((g_M * g_N), 8))));
int64_t i = 0;
while (i < obj_row) {
int64_t j2 = 0;
while (j2 < g_N) {
new_tab2[((i * g_N) + j2)] = g_tab[tidx_i64_i64(i, j2)];
j2 = (j2 + 1);
}
i = (i + 1);
}
free(((void*)(g_tab)));
g_tab = new_tab2;
int64_t* new_basis2 = (int64_t*)(((int64_t*)(calloc(g_M, 8))));
i = 0;
while (i < obj_row) {
new_basis2[i] = g_basis[i];
i = (i + 1);
}
free(((void*)(g_basis)));
g_basis = new_basis2;
set_objective_ptr_f64(c2);
simplex_max();
double result = (-g_tab[tidx_i64_i64(obj_row, (g_N - 1))]);
free(((void*)(g_tab)));
free(((void*)(g_basis)));
free(((void*)(g_art_flags)));
free(((void*)(g_art_indices)));
free(((void*)(c2)));
return result;
}
double build_and_solve_i64(int64_t num_dice) {
int64_t num_states = 1;
int64_t i = 0;
while (i < num_dice) {
num_states = (num_states * 6);
i = (i + 1);
}
int64_t* states = (int64_t*)(((int64_t*)(calloc((num_states * 3), 8))));
int64_t s_idx = 0;
int64_t a = 0;
while (a < 6) {
int64_t b = 0;
while (b < 6) {
int64_t c = 0;
while (c < 6) {
states[((s_idx * 3) + 0)] = (a + 1);
states[((s_idx * 3) + 1)] = (b + 1);
states[((s_idx * 3) + 2)] = (c + 1);
s_idx = (s_idx + 1);
c = (c + 1);
}
b = (b + 1);
}
a = (a + 1);
}
int64_t num_signals = 21;
int64_t* sig_arr = (int64_t*)(((int64_t*)(calloc((num_signals * 2), 8))));
int64_t nsig = 0;
a = 0;
while (a < 6) {
int64_t b = a;
while (b < 6) {
sig_arr[((nsig * 2) + 0)] = (a + 1);
sig_arr[((nsig * 2) + 1)] = (b + 1);
nsig = (nsig + 1);
b = (b + 1);
}
a = (a + 1);
}
int64_t num_x = (num_states * num_dice);
int64_t num_z = num_signals;
int64_t n_vars = (num_x + num_z);
int64_t n_constraints = (num_states + (2 * num_signals));
double* cons_coeffs = (double*)(((double*)(calloc((n_constraints * n_vars), 8))));
int64_t* cons_sense = (int64_t*)(((int64_t*)(calloc(n_constraints, 8))));
double* cons_rhs = (double*)(((double*)(calloc(n_constraints, 8))));
int64_t nc = 0;
double p_state = (1.0 / ((double)(num_states)));
int64_t si = 0;
while (si < num_states) {
int64_t h = 0;
while (h < num_dice) {
cons_coeffs[(((nc * n_vars) + (si * num_dice)) + h)] = 1.0;
h = (h + 1);
}
cons_sense[nc] = 61;
cons_rhs[nc] = p_state;
nc = (nc + 1);
si = (si + 1);
}
int64_t sig_i = 0;
while (sig_i < num_signals) {
int64_t b_val = sig_arr[((sig_i * 2) + 1)];
int64_t z_idx = (num_x + sig_i);
cons_coeffs[((nc * n_vars) + z_idx)] = (-1.0);
cons_coeffs[(((nc + 1) * n_vars) + z_idx)] = (-1.0);
si = 0;
while (si < num_states) {
int64_t h = 0;
while (h < num_dice) {
int64_t revealed0 = 0;
int64_t revealed1 = 0;
int64_t ri = 0;
int64_t ii = 0;
while (ii < num_dice) {
if (ii != h) {
if (ri == 0) {
revealed0 = states[((si * 3) + ii)];
} else {
revealed1 = states[((si * 3) + ii)];
}
ri = (ri + 1);
}
ii = (ii + 1);
}
if (revealed0 > revealed1) {
int64_t tmp = revealed0;
revealed0 = revealed1;
revealed1 = tmp;
}
if ((revealed0 == sig_arr[((sig_i * 2) + 0)] && revealed1 == sig_arr[((sig_i * 2) + 1)])) {
int64_t x_idx = ((si * num_dice) + h);
cons_coeffs[((nc * n_vars) + x_idx)] = (cons_coeffs[((nc * n_vars) + x_idx)] + ((double)(b_val)));
cons_coeffs[(((nc + 1) * n_vars) + x_idx)] = (cons_coeffs[(((nc + 1) * n_vars) + x_idx)] + ((double)(states[((si * 3) + h)])));
}
h = (h + 1);
}
si = (si + 1);
}
cons_sense[nc] = 60;
cons_rhs[nc] = 0.0;
cons_sense[(nc + 1)] = 60;
cons_rhs[(nc + 1)] = 0.0;
nc = (nc + 2);
sig_i = (sig_i + 1);
}
double* objective = (double*)(((double*)(calloc(n_vars, 8))));
int64_t j = 0;
while (j < num_z) {
objective[(num_x + j)] = 1.0;
j = (j + 1);
}
double result = solve_lp_i64_ptr_f64_ptr_i64_ptr_f64_i64_ptr_f64(n_vars, cons_coeffs, cons_sense, cons_rhs, n_constraints, objective);
free(((void*)(cons_coeffs)));
free(((void*)(cons_sense)));
free(((void*)(cons_rhs)));
free(((void*)(objective)));
free(((void*)(states)));
free(((void*)(sig_arr)));
return result;
}
int32_t main(void) {
printf("%.6f\n", build_and_solve_i64(3));
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%.6f\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 @malloc(i64) -> !llvm.ptr
func.func private @realloc(!llvm.ptr, i64) -> !llvm.ptr
func.func private @fabs(f64) -> f64
func.func private @memset(!llvm.ptr, i64, i64) -> !llvm.ptr
// Constant: EPS
llvm.mlir.global internal constant @EPS(0.000000001 : f64) : f64
// Module static: g_tab
llvm.mlir.global internal @g_tab() {addr_space = 0 : i32} : !llvm.ptr {
%0 = llvm.mlir.zero : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
// Module static: g_basis
llvm.mlir.global internal @g_basis() {addr_space = 0 : i32} : !llvm.ptr {
%1 = llvm.mlir.zero : !llvm.ptr
llvm.return %1 : !llvm.ptr
}
// Module static: g_M
llvm.mlir.global internal @g_M(0 : i64) : i64
// Module static: g_N
llvm.mlir.global internal @g_N(0 : i64) : i64
// Module static: g_art_flags
llvm.mlir.global internal @g_art_flags() {addr_space = 0 : i32} : !llvm.ptr {
%2 = llvm.mlir.zero : !llvm.ptr
llvm.return %2 : !llvm.ptr
}
// Module static: g_num_art
llvm.mlir.global internal @g_num_art(0 : i64) : i64
// Module static: g_art_indices
llvm.mlir.global internal @g_art_indices() {addr_space = 0 : i32} : !llvm.ptr {
%3 = llvm.mlir.zero : !llvm.ptr
llvm.return %3 : !llvm.ptr
}
func.func @tidx(%arg0: i64, %arg1: i64) -> i64 {
%4 = llvm.mlir.addressof @g_N : !llvm.ptr
%5 = llvm.load %4 : !llvm.ptr -> i64
%6 = arith.muli %arg0, %5 : i64
%7 = arith.addi %6, %arg1 : i64
func.return %7 : i64
}
func.func @pivot_op(%arg0: i64, %arg1: i64) -> () {
%9 = llvm.mlir.addressof @g_tab : !llvm.ptr
%10 = llvm.load %9 : !llvm.ptr -> !llvm.ptr
%11 = func.call @tidx(%arg0, %arg1) : (i64, i64) -> i64
%12 = llvm.getelementptr %10[%11] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%8 = llvm.load %12 : !llvm.ptr -> f64
%13 = arith.constant 1.0 : f32
%15 = arith.extf %13 : f32 to f64
%14 = arith.divf %15, %8 : f64
%16 = arith.constant 0 : i32
%17 = arith.extsi %16 : i32 to i64
%18 = llvm.mlir.constant(1 : i64) : i64
%19 = llvm.alloca %18 x i64 : (i64) -> !llvm.ptr
llvm.store %17, %19 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%20 = llvm.load %19 : !llvm.ptr -> i64
%21 = llvm.mlir.addressof @g_N : !llvm.ptr
%22 = llvm.load %21 : !llvm.ptr -> i64
%23 = arith.cmpi slt, %20, %22 : i64
cf.cond_br %23, ^bb1, ^bb2
^bb1:
%25 = llvm.mlir.addressof @g_tab : !llvm.ptr
%26 = llvm.load %25 : !llvm.ptr -> !llvm.ptr
%28 = llvm.load %19 : !llvm.ptr -> i64
%27 = func.call @tidx(%arg0, %28) : (i64, i64) -> i64
%29 = llvm.getelementptr %26[%27] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%24 = llvm.load %29 : !llvm.ptr -> f64
%30 = arith.mulf %24, %14 : f64
%31 = llvm.mlir.addressof @g_tab : !llvm.ptr
%32 = llvm.load %31 : !llvm.ptr -> !llvm.ptr
%34 = llvm.load %19 : !llvm.ptr -> i64
%33 = func.call @tidx(%arg0, %34) : (i64, i64) -> i64
%35 = llvm.getelementptr %32[%33] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %30, %35 : f64, !llvm.ptr
%36 = llvm.load %19 : !llvm.ptr -> i64
%37 = arith.constant 1 : i32
%39 = arith.extsi %37 : i32 to i64
%38 = arith.addi %36, %39 : i64
llvm.store %38, %19 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%40 = arith.constant 0 : i32
%41 = arith.extsi %40 : i32 to i64
%42 = llvm.mlir.constant(1 : i64) : i64
%43 = llvm.alloca %42 x i64 : (i64) -> !llvm.ptr
llvm.store %41, %43 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%44 = llvm.load %43 : !llvm.ptr -> i64
%45 = llvm.mlir.addressof @g_M : !llvm.ptr
%46 = llvm.load %45 : !llvm.ptr -> i64
%47 = arith.cmpi slt, %44, %46 : i64
cf.cond_br %47, ^bb4, ^bb5
^bb4:
%48 = llvm.load %43 : !llvm.ptr -> i64
%49 = arith.cmpi eq, %48, %arg0 : i64
cf.cond_br %49, ^bb6, ^bb7
^bb6:
%50 = llvm.load %43 : !llvm.ptr -> i64
%51 = arith.constant 1 : i32
%53 = arith.extsi %51 : i32 to i64
%52 = arith.addi %50, %53 : i64
llvm.store %52, %43 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
%55 = llvm.mlir.addressof @g_tab : !llvm.ptr
%56 = llvm.load %55 : !llvm.ptr -> !llvm.ptr
%58 = llvm.load %43 : !llvm.ptr -> i64
%57 = func.call @tidx(%58, %arg1) : (i64, i64) -> i64
%59 = llvm.getelementptr %56[%57] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%54 = llvm.load %59 : !llvm.ptr -> f64
%60 = math.absf %54 : f64
%61 = llvm.mlir.addressof @EPS : !llvm.ptr
%62 = llvm.load %61 : !llvm.ptr -> f64
%63 = arith.cmpf ogt, %60, %62 : f64
cf.cond_br %63, ^bb9, ^bb10
^bb9:
%64 = arith.constant 0 : i32
%65 = arith.extsi %64 : i32 to i64
llvm.store %65, %19 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%66 = llvm.load %19 : !llvm.ptr -> i64
%67 = llvm.mlir.addressof @g_N : !llvm.ptr
%68 = llvm.load %67 : !llvm.ptr -> i64
%69 = arith.cmpi slt, %66, %68 : i64
cf.cond_br %69, ^bb13, ^bb14
^bb13:
%71 = llvm.mlir.addressof @g_tab : !llvm.ptr
%72 = llvm.load %71 : !llvm.ptr -> !llvm.ptr
%74 = llvm.load %43 : !llvm.ptr -> i64
%75 = llvm.load %19 : !llvm.ptr -> i64
%73 = func.call @tidx(%74, %75) : (i64, i64) -> i64
%76 = llvm.getelementptr %72[%73] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%70 = llvm.load %76 : !llvm.ptr -> f64
%78 = llvm.mlir.addressof @g_tab : !llvm.ptr
%79 = llvm.load %78 : !llvm.ptr -> !llvm.ptr
%81 = llvm.load %19 : !llvm.ptr -> i64
%80 = func.call @tidx(%arg0, %81) : (i64, i64) -> i64
%82 = llvm.getelementptr %79[%80] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%77 = llvm.load %82 : !llvm.ptr -> f64
%83 = arith.mulf %54, %77 : f64
%84 = arith.subf %70, %83 : f64
%85 = llvm.mlir.addressof @g_tab : !llvm.ptr
%86 = llvm.load %85 : !llvm.ptr -> !llvm.ptr
%88 = llvm.load %43 : !llvm.ptr -> i64
%89 = llvm.load %19 : !llvm.ptr -> i64
%87 = func.call @tidx(%88, %89) : (i64, i64) -> i64
%90 = llvm.getelementptr %86[%87] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %84, %90 : f64, !llvm.ptr
%91 = llvm.load %19 : !llvm.ptr -> i64
%92 = arith.constant 1 : i32
%94 = arith.extsi %92 : i32 to i64
%93 = arith.addi %91, %94 : i64
llvm.store %93, %19 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
cf.br ^bb11
^bb10:
cf.br ^bb11
^bb11:
%95 = llvm.load %43 : !llvm.ptr -> i64
%96 = arith.constant 1 : i32
%98 = arith.extsi %96 : i32 to i64
%97 = arith.addi %95, %98 : i64
llvm.store %97, %43 : i64, !llvm.ptr
cf.br ^bb8
^bb8:
cf.br ^bb3
^bb5:
%99 = llvm.mlir.addressof @g_basis : !llvm.ptr
%100 = llvm.load %99 : !llvm.ptr -> !llvm.ptr
%101 = llvm.getelementptr %100[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg1, %101 : i64, !llvm.ptr
func.return
}
func.func @simplex_max() -> i64 {
%102 = llvm.mlir.addressof @g_M : !llvm.ptr
%103 = llvm.load %102 : !llvm.ptr -> i64
%104 = arith.constant 1 : i32
%106 = arith.extsi %104 : i32 to i64
%105 = arith.subi %103, %106 : i64
%107 = llvm.mlir.addressof @g_N : !llvm.ptr
%108 = llvm.load %107 : !llvm.ptr -> i64
%109 = arith.constant 1 : i32
%111 = arith.extsi %109 : i32 to i64
%110 = arith.subi %108, %111 : i64
%112 = arith.constant 0 : i32
%113 = arith.extsi %112 : i32 to i64
%114 = llvm.mlir.constant(1 : i64) : i64
%115 = llvm.alloca %114 x i64 : (i64) -> !llvm.ptr
llvm.store %113, %115 : i64, !llvm.ptr
cf.br ^bb15
^bb15:
%116 = llvm.load %115 : !llvm.ptr -> i64
%117 = arith.constant 2000000 : i32
%119 = arith.extsi %117 : i32 to i64
%118 = arith.cmpi slt, %116, %119 : i64
cf.cond_br %118, ^bb16, ^bb17
^bb16:
%120 = arith.constant 1 : i32
%122 = arith.constant 0 : i32
%121 = arith.subi %122, %120 : i32
%123 = arith.extsi %121 : i32 to i64
%124 = llvm.mlir.constant(1 : i64) : i64
%125 = llvm.alloca %124 x i64 : (i64) -> !llvm.ptr
llvm.store %123, %125 : i64, !llvm.ptr
%126 = arith.constant 0 : i32
%127 = arith.extsi %126 : i32 to i64
%128 = llvm.mlir.constant(1 : i64) : i64
%129 = llvm.alloca %128 x i64 : (i64) -> !llvm.ptr
llvm.store %127, %129 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%130 = llvm.load %129 : !llvm.ptr -> i64
%131 = arith.cmpi slt, %130, %110 : i64
cf.cond_br %131, ^bb19, ^bb20
^bb19:
%133 = llvm.mlir.addressof @g_tab : !llvm.ptr
%134 = llvm.load %133 : !llvm.ptr -> !llvm.ptr
%136 = llvm.load %129 : !llvm.ptr -> i64
%135 = func.call @tidx(%105, %136) : (i64, i64) -> i64
%137 = llvm.getelementptr %134[%135] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%132 = llvm.load %137 : !llvm.ptr -> f64
%138 = llvm.mlir.addressof @EPS : !llvm.ptr
%139 = llvm.load %138 : !llvm.ptr -> f64
%140 = arith.negf %139 : f64
%141 = arith.cmpf olt, %132, %140 : f64
cf.cond_br %141, ^bb21, ^bb22
^bb21:
%142 = llvm.load %129 : !llvm.ptr -> i64
llvm.store %142, %125 : i64, !llvm.ptr
llvm.store %110, %129 : i64, !llvm.ptr
cf.br ^bb23
^bb22:
cf.br ^bb23
^bb23:
%143 = llvm.load %129 : !llvm.ptr -> i64
%144 = arith.constant 1 : i32
%146 = arith.extsi %144 : i32 to i64
%145 = arith.addi %143, %146 : i64
llvm.store %145, %129 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%147 = llvm.load %125 : !llvm.ptr -> i64
%148 = arith.constant 1 : i32
%150 = arith.constant 0 : i32
%149 = arith.subi %150, %148 : i32
%152 = arith.extsi %149 : i32 to i64
%151 = arith.cmpi eq, %147, %152 : i64
cf.cond_br %151, ^bb24, ^bb25
^bb24:
%153 = arith.constant 1 : i32
%154 = arith.extsi %153 : i32 to i64
func.return %154 : i64
^bb25:
cf.br ^bb26
^bb26:
%155 = arith.constant 1000000000000000000 : f32
%156 = arith.extf %155 : f32 to f64
%157 = llvm.mlir.constant(1 : i64) : i64
%158 = llvm.alloca %157 x f64 : (i64) -> !llvm.ptr
llvm.store %156, %158 : f64, !llvm.ptr
%159 = arith.constant 1 : i32
%161 = arith.constant 0 : i32
%160 = arith.subi %161, %159 : i32
%162 = arith.extsi %160 : i32 to i64
%163 = llvm.mlir.constant(1 : i64) : i64
%164 = llvm.alloca %163 x i64 : (i64) -> !llvm.ptr
llvm.store %162, %164 : i64, !llvm.ptr
%165 = arith.constant 0 : i32
%166 = arith.extsi %165 : i32 to i64
%167 = llvm.mlir.constant(1 : i64) : i64
%168 = llvm.alloca %167 x i64 : (i64) -> !llvm.ptr
llvm.store %166, %168 : i64, !llvm.ptr
cf.br ^bb27
^bb27:
%169 = llvm.load %168 : !llvm.ptr -> i64
%170 = arith.cmpi slt, %169, %105 : i64
cf.cond_br %170, ^bb28, ^bb29
^bb28:
%172 = llvm.mlir.addressof @g_tab : !llvm.ptr
%173 = llvm.load %172 : !llvm.ptr -> !llvm.ptr
%175 = llvm.load %168 : !llvm.ptr -> i64
%176 = llvm.load %125 : !llvm.ptr -> i64
%174 = func.call @tidx(%175, %176) : (i64, i64) -> i64
%177 = llvm.getelementptr %173[%174] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%171 = llvm.load %177 : !llvm.ptr -> f64
%178 = llvm.mlir.addressof @EPS : !llvm.ptr
%179 = llvm.load %178 : !llvm.ptr -> f64
%180 = arith.cmpf ogt, %171, %179 : f64
cf.cond_br %180, ^bb30, ^bb31
^bb30:
%182 = llvm.mlir.addressof @g_tab : !llvm.ptr
%183 = llvm.load %182 : !llvm.ptr -> !llvm.ptr
%185 = llvm.load %168 : !llvm.ptr -> i64
%184 = func.call @tidx(%185, %110) : (i64, i64) -> i64
%186 = llvm.getelementptr %183[%184] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%181 = llvm.load %186 : !llvm.ptr -> f64
%187 = arith.divf %181, %171 : f64
%188 = llvm.load %158 : !llvm.ptr -> f64
%189 = llvm.mlir.addressof @EPS : !llvm.ptr
%190 = llvm.load %189 : !llvm.ptr -> f64
%191 = arith.subf %188, %190 : f64
%192 = arith.cmpf olt, %187, %191 : f64
cf.cond_br %192, ^bb33, ^bb34
^bb33:
llvm.store %187, %158 : f64, !llvm.ptr
%193 = llvm.load %168 : !llvm.ptr -> i64
llvm.store %193, %164 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%194 = llvm.load %168 : !llvm.ptr -> i64
%195 = arith.constant 1 : i32
%197 = arith.extsi %195 : i32 to i64
%196 = arith.addi %194, %197 : i64
llvm.store %196, %168 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
%198 = llvm.load %164 : !llvm.ptr -> i64
%199 = arith.constant 1 : i32
%201 = arith.constant 0 : i32
%200 = arith.subi %201, %199 : i32
%203 = arith.extsi %200 : i32 to i64
%202 = arith.cmpi eq, %198, %203 : i64
cf.cond_br %202, ^bb36, ^bb37
^bb36:
%204 = arith.constant 0 : i32
%205 = arith.extsi %204 : i32 to i64
func.return %205 : i64
^bb37:
cf.br ^bb38
^bb38:
%207 = llvm.load %164 : !llvm.ptr -> i64
%208 = llvm.load %125 : !llvm.ptr -> i64
func.call @pivot_op(%207, %208) : (i64, i64) -> ()
%209 = llvm.load %115 : !llvm.ptr -> i64
%210 = arith.constant 1 : i32
%212 = arith.extsi %210 : i32 to i64
%211 = arith.addi %209, %212 : i64
llvm.store %211, %115 : i64, !llvm.ptr
cf.br ^bb15
^bb17:
%213 = arith.constant 1 : i32
%215 = arith.constant 0 : i32
%214 = arith.subi %215, %213 : i32
%216 = arith.extsi %214 : i32 to i64
func.return %216 : i64
}
func.func @set_objective(%arg0: !llvm.ptr) -> () {
%217 = llvm.mlir.addressof @g_M : !llvm.ptr
%218 = llvm.load %217 : !llvm.ptr -> i64
%219 = arith.constant 1 : i32
%221 = arith.extsi %219 : i32 to i64
%220 = arith.subi %218, %221 : i64
%222 = llvm.mlir.addressof @g_N : !llvm.ptr
%223 = llvm.load %222 : !llvm.ptr -> i64
%224 = arith.constant 1 : i32
%226 = arith.extsi %224 : i32 to i64
%225 = arith.subi %223, %226 : i64
%227 = arith.constant 0 : i32
%228 = arith.extsi %227 : i32 to i64
%229 = llvm.mlir.constant(1 : i64) : i64
%230 = llvm.alloca %229 x i64 : (i64) -> !llvm.ptr
llvm.store %228, %230 : i64, !llvm.ptr
cf.br ^bb39
^bb39:
%231 = llvm.load %230 : !llvm.ptr -> i64
%232 = llvm.mlir.addressof @g_N : !llvm.ptr
%233 = llvm.load %232 : !llvm.ptr -> i64
%234 = arith.cmpi slt, %231, %233 : i64
cf.cond_br %234, ^bb40, ^bb41
^bb40:
%235 = arith.constant 0.0 : f32
%236 = llvm.mlir.addressof @g_tab : !llvm.ptr
%237 = llvm.load %236 : !llvm.ptr -> !llvm.ptr
%239 = llvm.load %230 : !llvm.ptr -> i64
%238 = func.call @tidx(%220, %239) : (i64, i64) -> i64
%240 = arith.extf %235 : f32 to f64
%241 = llvm.getelementptr %237[%238] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %240, %241 : f64, !llvm.ptr
%242 = llvm.load %230 : !llvm.ptr -> i64
%243 = arith.constant 1 : i32
%245 = arith.extsi %243 : i32 to i64
%244 = arith.addi %242, %245 : i64
llvm.store %244, %230 : i64, !llvm.ptr
cf.br ^bb39
^bb41:
%246 = arith.constant 0 : i32
%247 = arith.extsi %246 : i32 to i64
llvm.store %247, %230 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%248 = llvm.load %230 : !llvm.ptr -> i64
%249 = arith.cmpi slt, %248, %225 : i64
cf.cond_br %249, ^bb43, ^bb44
^bb43:
%251 = llvm.load %230 : !llvm.ptr -> i64
%252 = llvm.getelementptr %arg0[%251] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%250 = llvm.load %252 : !llvm.ptr -> f64
%253 = arith.negf %250 : f64
%254 = llvm.mlir.addressof @g_tab : !llvm.ptr
%255 = llvm.load %254 : !llvm.ptr -> !llvm.ptr
%257 = llvm.load %230 : !llvm.ptr -> i64
%256 = func.call @tidx(%220, %257) : (i64, i64) -> i64
%258 = llvm.getelementptr %255[%256] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %253, %258 : f64, !llvm.ptr
%259 = llvm.load %230 : !llvm.ptr -> i64
%260 = arith.constant 1 : i32
%262 = arith.extsi %260 : i32 to i64
%261 = arith.addi %259, %262 : i64
llvm.store %261, %230 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%263 = arith.constant 0 : i32
%264 = arith.extsi %263 : i32 to i64
%265 = llvm.mlir.constant(1 : i64) : i64
%266 = llvm.alloca %265 x i64 : (i64) -> !llvm.ptr
llvm.store %264, %266 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%267 = llvm.load %266 : !llvm.ptr -> i64
%268 = arith.cmpi slt, %267, %220 : i64
cf.cond_br %268, ^bb46, ^bb47
^bb46:
%271 = llvm.mlir.addressof @g_basis : !llvm.ptr
%272 = llvm.load %271 : !llvm.ptr -> !llvm.ptr
%273 = llvm.load %266 : !llvm.ptr -> i64
%274 = llvm.getelementptr %272[%273] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%270 = llvm.load %274 : !llvm.ptr -> i64
%275 = llvm.getelementptr %arg0[%270] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%269 = llvm.load %275 : !llvm.ptr -> f64
%276 = math.absf %269 : f64
%277 = llvm.mlir.addressof @EPS : !llvm.ptr
%278 = llvm.load %277 : !llvm.ptr -> f64
%279 = arith.cmpf ogt, %276, %278 : f64
cf.cond_br %279, ^bb48, ^bb49
^bb48:
%280 = arith.constant 0 : i32
%281 = arith.extsi %280 : i32 to i64
llvm.store %281, %230 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%282 = llvm.load %230 : !llvm.ptr -> i64
%283 = llvm.mlir.addressof @g_N : !llvm.ptr
%284 = llvm.load %283 : !llvm.ptr -> i64
%285 = arith.cmpi slt, %282, %284 : i64
cf.cond_br %285, ^bb52, ^bb53
^bb52:
%287 = llvm.mlir.addressof @g_tab : !llvm.ptr
%288 = llvm.load %287 : !llvm.ptr -> !llvm.ptr
%290 = llvm.load %230 : !llvm.ptr -> i64
%289 = func.call @tidx(%220, %290) : (i64, i64) -> i64
%291 = llvm.getelementptr %288[%289] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%286 = llvm.load %291 : !llvm.ptr -> f64
%293 = llvm.mlir.addressof @g_tab : !llvm.ptr
%294 = llvm.load %293 : !llvm.ptr -> !llvm.ptr
%296 = llvm.load %266 : !llvm.ptr -> i64
%297 = llvm.load %230 : !llvm.ptr -> i64
%295 = func.call @tidx(%296, %297) : (i64, i64) -> i64
%298 = llvm.getelementptr %294[%295] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%292 = llvm.load %298 : !llvm.ptr -> f64
%299 = arith.mulf %269, %292 : f64
%300 = arith.addf %286, %299 : f64
%301 = llvm.mlir.addressof @g_tab : !llvm.ptr
%302 = llvm.load %301 : !llvm.ptr -> !llvm.ptr
%304 = llvm.load %230 : !llvm.ptr -> i64
%303 = func.call @tidx(%220, %304) : (i64, i64) -> i64
%305 = llvm.getelementptr %302[%303] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %300, %305 : f64, !llvm.ptr
%306 = llvm.load %230 : !llvm.ptr -> i64
%307 = arith.constant 1 : i32
%309 = arith.extsi %307 : i32 to i64
%308 = arith.addi %306, %309 : i64
llvm.store %308, %230 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
%310 = llvm.load %266 : !llvm.ptr -> i64
%311 = arith.constant 1 : i32
%313 = arith.extsi %311 : i32 to i64
%312 = arith.addi %310, %313 : i64
llvm.store %312, %266 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
func.return
}
func.func @build_tableau(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i64) -> () {
%314 = llvm.mlir.constant(1 : i64) : i64
%315 = llvm.alloca %314 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %315 : i64, !llvm.ptr
%316 = arith.constant 0 : i32
%317 = arith.extsi %316 : i32 to i64
%318 = llvm.mlir.constant(1 : i64) : i64
%319 = llvm.alloca %318 x i64 : (i64) -> !llvm.ptr
llvm.store %317, %319 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%320 = llvm.load %319 : !llvm.ptr -> i64
%321 = arith.cmpi slt, %320, %arg4 : i64
cf.cond_br %321, ^bb55, ^bb56
^bb55:
%323 = llvm.load %319 : !llvm.ptr -> i64
%324 = llvm.getelementptr %arg2[%323] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%322 = llvm.load %324 : !llvm.ptr -> i64
%325 = arith.constant 60 : i32
%327 = arith.extsi %325 : i32 to i64
%326 = arith.cmpi eq, %322, %327 : i64
cf.cond_br %326, ^bb57, ^bb58
^bb57:
%328 = llvm.load %315 : !llvm.ptr -> i64
%329 = arith.constant 1 : i32
%331 = arith.extsi %329 : i32 to i64
%330 = arith.addi %328, %331 : i64
llvm.store %330, %315 : i64, !llvm.ptr
cf.br ^bb59
^bb58:
%332 = arith.constant 62 : i32
%334 = arith.extsi %332 : i32 to i64
%333 = arith.cmpi eq, %322, %334 : i64
cf.cond_br %333, ^bb60, ^bb61
^bb60:
%335 = llvm.load %315 : !llvm.ptr -> i64
%336 = arith.constant 2 : i32
%338 = arith.extsi %336 : i32 to i64
%337 = arith.addi %335, %338 : i64
llvm.store %337, %315 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
%339 = llvm.load %315 : !llvm.ptr -> i64
%340 = arith.constant 1 : i32
%342 = arith.extsi %340 : i32 to i64
%341 = arith.addi %339, %342 : i64
llvm.store %341, %315 : i64, !llvm.ptr
cf.br ^bb62
^bb62:
cf.br ^bb59
^bb59:
%343 = llvm.load %319 : !llvm.ptr -> i64
%344 = arith.constant 1 : i32
%346 = arith.extsi %344 : i32 to i64
%345 = arith.addi %343, %346 : i64
llvm.store %345, %319 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%347 = llvm.mlir.addressof @g_M : !llvm.ptr
llvm.store %arg4, %347 : i64, !llvm.ptr
%348 = llvm.load %315 : !llvm.ptr -> i64
%349 = arith.constant 1 : i32
%351 = arith.extsi %349 : i32 to i64
%350 = arith.addi %348, %351 : i64
%352 = llvm.mlir.addressof @g_N : !llvm.ptr
llvm.store %350, %352 : i64, !llvm.ptr
%354 = llvm.mlir.addressof @g_M : !llvm.ptr
%355 = llvm.load %354 : !llvm.ptr -> i64
%356 = llvm.mlir.addressof @g_N : !llvm.ptr
%357 = llvm.load %356 : !llvm.ptr -> i64
%358 = arith.muli %355, %357 : i64
%359 = arith.constant 8 : i32
%360 = arith.extsi %359 : i32 to i64
%353 = func.call @calloc(%358, %360) : (i64, i64) -> !llvm.ptr
%361 = llvm.mlir.addressof @g_tab : !llvm.ptr
llvm.store %353, %361 : !llvm.ptr, !llvm.ptr
%363 = llvm.mlir.addressof @g_M : !llvm.ptr
%364 = llvm.load %363 : !llvm.ptr -> i64
%365 = arith.constant 8 : i32
%366 = arith.extsi %365 : i32 to i64
%362 = func.call @calloc(%364, %366) : (i64, i64) -> !llvm.ptr
%367 = llvm.mlir.addressof @g_basis : !llvm.ptr
llvm.store %362, %367 : !llvm.ptr, !llvm.ptr
%369 = llvm.load %315 : !llvm.ptr -> i64
%370 = arith.constant 8 : i32
%371 = arith.extsi %370 : i32 to i64
%368 = func.call @calloc(%369, %371) : (i64, i64) -> !llvm.ptr
%372 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
llvm.store %368, %372 : !llvm.ptr, !llvm.ptr
%374 = llvm.load %315 : !llvm.ptr -> i64
%375 = arith.constant 8 : i32
%376 = arith.extsi %375 : i32 to i64
%373 = func.call @calloc(%374, %376) : (i64, i64) -> !llvm.ptr
%377 = llvm.mlir.addressof @g_art_indices : !llvm.ptr
llvm.store %373, %377 : !llvm.ptr, !llvm.ptr
%378 = arith.constant 0 : i32
%379 = arith.extsi %378 : i32 to i64
%380 = llvm.mlir.addressof @g_num_art : !llvm.ptr
llvm.store %379, %380 : i64, !llvm.ptr
%381 = llvm.mlir.constant(1 : i64) : i64
%382 = llvm.alloca %381 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %382 : i64, !llvm.ptr
%383 = arith.constant 0 : i32
%384 = arith.extsi %383 : i32 to i64
llvm.store %384, %319 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%385 = llvm.load %319 : !llvm.ptr -> i64
%386 = arith.cmpi slt, %385, %arg4 : i64
cf.cond_br %386, ^bb64, ^bb65
^bb64:
%388 = llvm.load %319 : !llvm.ptr -> i64
%389 = llvm.getelementptr %arg3[%388] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%387 = llvm.load %389 : !llvm.ptr -> f64
%390 = llvm.mlir.constant(1 : i64) : i64
%391 = llvm.alloca %390 x f64 : (i64) -> !llvm.ptr
llvm.store %387, %391 : f64, !llvm.ptr
%393 = llvm.load %319 : !llvm.ptr -> i64
%394 = llvm.getelementptr %arg2[%393] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%392 = llvm.load %394 : !llvm.ptr -> i64
%395 = llvm.mlir.constant(1 : i64) : i64
%396 = llvm.alloca %395 x i64 : (i64) -> !llvm.ptr
llvm.store %392, %396 : i64, !llvm.ptr
%397 = llvm.load %391 : !llvm.ptr -> f64
%398 = arith.constant 0.0 : f32
%400 = arith.extf %398 : f32 to f64
%399 = arith.cmpf olt, %397, %400 : f64
cf.cond_br %399, ^bb66, ^bb67
^bb66:
%401 = arith.constant 0 : i32
%402 = arith.extsi %401 : i32 to i64
%403 = llvm.mlir.constant(1 : i64) : i64
%404 = llvm.alloca %403 x i64 : (i64) -> !llvm.ptr
llvm.store %402, %404 : i64, !llvm.ptr
cf.br ^bb69
^bb69:
%405 = llvm.load %404 : !llvm.ptr -> i64
%406 = arith.cmpi slt, %405, %arg0 : i64
cf.cond_br %406, ^bb70, ^bb71
^bb70:
%408 = llvm.load %319 : !llvm.ptr -> i64
%409 = arith.muli %408, %arg0 : i64
%410 = llvm.load %404 : !llvm.ptr -> i64
%411 = arith.addi %409, %410 : i64
%412 = llvm.getelementptr %arg1[%411] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%407 = llvm.load %412 : !llvm.ptr -> f64
%413 = arith.negf %407 : f64
%414 = llvm.mlir.addressof @g_tab : !llvm.ptr
%415 = llvm.load %414 : !llvm.ptr -> !llvm.ptr
%417 = llvm.load %319 : !llvm.ptr -> i64
%418 = llvm.load %404 : !llvm.ptr -> i64
%416 = func.call @tidx(%417, %418) : (i64, i64) -> i64
%419 = llvm.getelementptr %415[%416] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %413, %419 : f64, !llvm.ptr
%420 = llvm.load %404 : !llvm.ptr -> i64
%421 = arith.constant 1 : i32
%423 = arith.extsi %421 : i32 to i64
%422 = arith.addi %420, %423 : i64
llvm.store %422, %404 : i64, !llvm.ptr
cf.br ^bb69
^bb71:
%424 = llvm.load %391 : !llvm.ptr -> f64
%425 = arith.negf %424 : f64
llvm.store %425, %391 : f64, !llvm.ptr
%426 = llvm.load %396 : !llvm.ptr -> i64
%427 = arith.constant 60 : i32
%429 = arith.extsi %427 : i32 to i64
%428 = arith.cmpi eq, %426, %429 : i64
cf.cond_br %428, ^bb72, ^bb73
^bb72:
%430 = arith.constant 62 : i32
%431 = arith.extsi %430 : i32 to i64
llvm.store %431, %396 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
%432 = llvm.load %396 : !llvm.ptr -> i64
%433 = arith.constant 62 : i32
%435 = arith.extsi %433 : i32 to i64
%434 = arith.cmpi eq, %432, %435 : i64
cf.cond_br %434, ^bb75, ^bb76
^bb75:
%436 = arith.constant 60 : i32
%437 = arith.extsi %436 : i32 to i64
llvm.store %437, %396 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
cf.br ^bb74
^bb74:
cf.br ^bb68
^bb67:
%438 = arith.constant 0 : i32
%439 = arith.extsi %438 : i32 to i64
%440 = llvm.mlir.constant(1 : i64) : i64
%441 = llvm.alloca %440 x i64 : (i64) -> !llvm.ptr
llvm.store %439, %441 : i64, !llvm.ptr
cf.br ^bb78
^bb78:
%442 = llvm.load %441 : !llvm.ptr -> i64
%443 = arith.cmpi slt, %442, %arg0 : i64
cf.cond_br %443, ^bb79, ^bb80
^bb79:
%445 = llvm.load %319 : !llvm.ptr -> i64
%446 = arith.muli %445, %arg0 : i64
%447 = llvm.load %441 : !llvm.ptr -> i64
%448 = arith.addi %446, %447 : i64
%449 = llvm.getelementptr %arg1[%448] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%444 = llvm.load %449 : !llvm.ptr -> f64
%450 = llvm.mlir.addressof @g_tab : !llvm.ptr
%451 = llvm.load %450 : !llvm.ptr -> !llvm.ptr
%453 = llvm.load %319 : !llvm.ptr -> i64
%454 = llvm.load %441 : !llvm.ptr -> i64
%452 = func.call @tidx(%453, %454) : (i64, i64) -> i64
%455 = llvm.getelementptr %451[%452] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %444, %455 : f64, !llvm.ptr
%456 = llvm.load %441 : !llvm.ptr -> i64
%457 = arith.constant 1 : i32
%459 = arith.extsi %457 : i32 to i64
%458 = arith.addi %456, %459 : i64
llvm.store %458, %441 : i64, !llvm.ptr
cf.br ^bb78
^bb80:
cf.br ^bb68
^bb68:
%460 = llvm.load %396 : !llvm.ptr -> i64
%461 = arith.constant 60 : i32
%463 = arith.extsi %461 : i32 to i64
%462 = arith.cmpi eq, %460, %463 : i64
cf.cond_br %462, ^bb81, ^bb82
^bb81:
%464 = arith.constant 1.0 : f32
%465 = llvm.mlir.addressof @g_tab : !llvm.ptr
%466 = llvm.load %465 : !llvm.ptr -> !llvm.ptr
%468 = llvm.load %319 : !llvm.ptr -> i64
%469 = llvm.load %382 : !llvm.ptr -> i64
%467 = func.call @tidx(%468, %469) : (i64, i64) -> i64
%470 = arith.extf %464 : f32 to f64
%471 = llvm.getelementptr %466[%467] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %470, %471 : f64, !llvm.ptr
%472 = llvm.load %382 : !llvm.ptr -> i64
%473 = llvm.mlir.addressof @g_basis : !llvm.ptr
%474 = llvm.load %473 : !llvm.ptr -> !llvm.ptr
%475 = llvm.load %319 : !llvm.ptr -> i64
%476 = llvm.getelementptr %474[%475] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %472, %476 : i64, !llvm.ptr
%477 = llvm.load %382 : !llvm.ptr -> i64
%478 = arith.constant 1 : i32
%480 = arith.extsi %478 : i32 to i64
%479 = arith.addi %477, %480 : i64
llvm.store %479, %382 : i64, !llvm.ptr
cf.br ^bb83
^bb82:
%481 = llvm.load %396 : !llvm.ptr -> i64
%482 = arith.constant 62 : i32
%484 = arith.extsi %482 : i32 to i64
%483 = arith.cmpi eq, %481, %484 : i64
cf.cond_br %483, ^bb84, ^bb85
^bb84:
%485 = arith.constant 1.0 : f32
%486 = arith.negf %485 : f32
%487 = llvm.mlir.addressof @g_tab : !llvm.ptr
%488 = llvm.load %487 : !llvm.ptr -> !llvm.ptr
%490 = llvm.load %319 : !llvm.ptr -> i64
%491 = llvm.load %382 : !llvm.ptr -> i64
%489 = func.call @tidx(%490, %491) : (i64, i64) -> i64
%492 = arith.extf %486 : f32 to f64
%493 = llvm.getelementptr %488[%489] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %492, %493 : f64, !llvm.ptr
%494 = llvm.load %382 : !llvm.ptr -> i64
%495 = arith.constant 1 : i32
%497 = arith.extsi %495 : i32 to i64
%496 = arith.addi %494, %497 : i64
llvm.store %496, %382 : i64, !llvm.ptr
%498 = arith.constant 1.0 : f32
%499 = llvm.mlir.addressof @g_tab : !llvm.ptr
%500 = llvm.load %499 : !llvm.ptr -> !llvm.ptr
%502 = llvm.load %319 : !llvm.ptr -> i64
%503 = llvm.load %382 : !llvm.ptr -> i64
%501 = func.call @tidx(%502, %503) : (i64, i64) -> i64
%504 = arith.extf %498 : f32 to f64
%505 = llvm.getelementptr %500[%501] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %504, %505 : f64, !llvm.ptr
%506 = llvm.load %382 : !llvm.ptr -> i64
%507 = llvm.mlir.addressof @g_basis : !llvm.ptr
%508 = llvm.load %507 : !llvm.ptr -> !llvm.ptr
%509 = llvm.load %319 : !llvm.ptr -> i64
%510 = llvm.getelementptr %508[%509] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %506, %510 : i64, !llvm.ptr
%511 = arith.constant 1 : i32
%512 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%513 = llvm.load %512 : !llvm.ptr -> !llvm.ptr
%514 = llvm.load %382 : !llvm.ptr -> i64
%515 = arith.extsi %511 : i32 to i64
%516 = llvm.getelementptr %513[%514] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %515, %516 : i64, !llvm.ptr
%517 = llvm.load %382 : !llvm.ptr -> i64
%518 = llvm.mlir.addressof @g_art_indices : !llvm.ptr
%519 = llvm.load %518 : !llvm.ptr -> !llvm.ptr
%520 = llvm.mlir.addressof @g_num_art : !llvm.ptr
%521 = llvm.load %520 : !llvm.ptr -> i64
%522 = llvm.getelementptr %519[%521] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %517, %522 : i64, !llvm.ptr
%523 = llvm.mlir.addressof @g_num_art : !llvm.ptr
%524 = llvm.load %523 : !llvm.ptr -> i64
%525 = arith.constant 1 : i32
%527 = arith.extsi %525 : i32 to i64
%526 = arith.addi %524, %527 : i64
%528 = llvm.mlir.addressof @g_num_art : !llvm.ptr
llvm.store %526, %528 : i64, !llvm.ptr
%529 = llvm.load %382 : !llvm.ptr -> i64
%530 = arith.constant 1 : i32
%532 = arith.extsi %530 : i32 to i64
%531 = arith.addi %529, %532 : i64
llvm.store %531, %382 : i64, !llvm.ptr
cf.br ^bb86
^bb85:
%533 = arith.constant 1.0 : f32
%534 = llvm.mlir.addressof @g_tab : !llvm.ptr
%535 = llvm.load %534 : !llvm.ptr -> !llvm.ptr
%537 = llvm.load %319 : !llvm.ptr -> i64
%538 = llvm.load %382 : !llvm.ptr -> i64
%536 = func.call @tidx(%537, %538) : (i64, i64) -> i64
%539 = arith.extf %533 : f32 to f64
%540 = llvm.getelementptr %535[%536] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %539, %540 : f64, !llvm.ptr
%541 = llvm.load %382 : !llvm.ptr -> i64
%542 = llvm.mlir.addressof @g_basis : !llvm.ptr
%543 = llvm.load %542 : !llvm.ptr -> !llvm.ptr
%544 = llvm.load %319 : !llvm.ptr -> i64
%545 = llvm.getelementptr %543[%544] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %541, %545 : i64, !llvm.ptr
%546 = arith.constant 1 : i32
%547 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%548 = llvm.load %547 : !llvm.ptr -> !llvm.ptr
%549 = llvm.load %382 : !llvm.ptr -> i64
%550 = arith.extsi %546 : i32 to i64
%551 = llvm.getelementptr %548[%549] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %550, %551 : i64, !llvm.ptr
%552 = llvm.load %382 : !llvm.ptr -> i64
%553 = llvm.mlir.addressof @g_art_indices : !llvm.ptr
%554 = llvm.load %553 : !llvm.ptr -> !llvm.ptr
%555 = llvm.mlir.addressof @g_num_art : !llvm.ptr
%556 = llvm.load %555 : !llvm.ptr -> i64
%557 = llvm.getelementptr %554[%556] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %552, %557 : i64, !llvm.ptr
%558 = llvm.mlir.addressof @g_num_art : !llvm.ptr
%559 = llvm.load %558 : !llvm.ptr -> i64
%560 = arith.constant 1 : i32
%562 = arith.extsi %560 : i32 to i64
%561 = arith.addi %559, %562 : i64
%563 = llvm.mlir.addressof @g_num_art : !llvm.ptr
llvm.store %561, %563 : i64, !llvm.ptr
%564 = llvm.load %382 : !llvm.ptr -> i64
%565 = arith.constant 1 : i32
%567 = arith.extsi %565 : i32 to i64
%566 = arith.addi %564, %567 : i64
llvm.store %566, %382 : i64, !llvm.ptr
cf.br ^bb86
^bb86:
cf.br ^bb83
^bb83:
%568 = llvm.load %391 : !llvm.ptr -> f64
%569 = llvm.mlir.addressof @g_tab : !llvm.ptr
%570 = llvm.load %569 : !llvm.ptr -> !llvm.ptr
%572 = llvm.load %319 : !llvm.ptr -> i64
%573 = llvm.mlir.addressof @g_N : !llvm.ptr
%574 = llvm.load %573 : !llvm.ptr -> i64
%575 = arith.constant 1 : i32
%577 = arith.extsi %575 : i32 to i64
%576 = arith.subi %574, %577 : i64
%571 = func.call @tidx(%572, %576) : (i64, i64) -> i64
%578 = llvm.getelementptr %570[%571] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %568, %578 : f64, !llvm.ptr
%579 = llvm.load %319 : !llvm.ptr -> i64
%580 = arith.constant 1 : i32
%582 = arith.extsi %580 : i32 to i64
%581 = arith.addi %579, %582 : i64
llvm.store %581, %319 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
func.return
}
func.func @remove_artificial() -> () {
%583 = llvm.mlir.addressof @g_M : !llvm.ptr
%584 = llvm.load %583 : !llvm.ptr -> i64
%585 = llvm.mlir.constant(1 : i64) : i64
%586 = llvm.alloca %585 x i64 : (i64) -> !llvm.ptr
llvm.store %584, %586 : i64, !llvm.ptr
%587 = llvm.mlir.addressof @g_N : !llvm.ptr
%588 = llvm.load %587 : !llvm.ptr -> i64
%589 = arith.constant 1 : i32
%591 = arith.extsi %589 : i32 to i64
%590 = arith.subi %588, %591 : i64
%592 = arith.constant 0 : i32
%593 = arith.extsi %592 : i32 to i64
%594 = llvm.mlir.constant(1 : i64) : i64
%595 = llvm.alloca %594 x i64 : (i64) -> !llvm.ptr
llvm.store %593, %595 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%596 = llvm.load %595 : !llvm.ptr -> i64
%597 = llvm.load %586 : !llvm.ptr -> i64
%598 = arith.cmpi slt, %596, %597 : i64
cf.cond_br %598, ^bb88, ^bb89
^bb88:
%600 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%601 = llvm.load %600 : !llvm.ptr -> !llvm.ptr
%603 = llvm.mlir.addressof @g_basis : !llvm.ptr
%604 = llvm.load %603 : !llvm.ptr -> !llvm.ptr
%605 = llvm.load %595 : !llvm.ptr -> i64
%606 = llvm.getelementptr %604[%605] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%602 = llvm.load %606 : !llvm.ptr -> i64
%607 = llvm.getelementptr %601[%602] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%599 = llvm.load %607 : !llvm.ptr -> i64
%608 = arith.constant 0 : i32
%610 = arith.extsi %608 : i32 to i64
%609 = arith.cmpi ne, %599, %610 : i64
cf.cond_br %609, ^bb90, ^bb91
^bb90:
%611 = arith.constant 1 : i32
%613 = arith.constant 0 : i32
%612 = arith.subi %613, %611 : i32
%614 = arith.extsi %612 : i32 to i64
%615 = llvm.mlir.constant(1 : i64) : i64
%616 = llvm.alloca %615 x i64 : (i64) -> !llvm.ptr
llvm.store %614, %616 : i64, !llvm.ptr
%617 = arith.constant 0 : i32
%618 = arith.extsi %617 : i32 to i64
%619 = llvm.mlir.constant(1 : i64) : i64
%620 = llvm.alloca %619 x i64 : (i64) -> !llvm.ptr
llvm.store %618, %620 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%621 = llvm.load %620 : !llvm.ptr -> i64
%622 = arith.cmpi slt, %621, %590 : i64
cf.cond_br %622, ^bb94, ^bb95
^bb94:
%624 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%625 = llvm.load %624 : !llvm.ptr -> !llvm.ptr
%626 = llvm.load %620 : !llvm.ptr -> i64
%627 = llvm.getelementptr %625[%626] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%623 = llvm.load %627 : !llvm.ptr -> i64
%628 = arith.constant 0 : i32
%630 = arith.extsi %628 : i32 to i64
%629 = arith.cmpi ne, %623, %630 : i64
cf.cond_br %629, ^bb96, ^bb97
^bb96:
%631 = llvm.load %620 : !llvm.ptr -> i64
%632 = arith.constant 1 : i32
%634 = arith.extsi %632 : i32 to i64
%633 = arith.addi %631, %634 : i64
llvm.store %633, %620 : i64, !llvm.ptr
cf.br ^bb98
^bb97:
%636 = llvm.mlir.addressof @g_tab : !llvm.ptr
%637 = llvm.load %636 : !llvm.ptr -> !llvm.ptr
%639 = llvm.load %595 : !llvm.ptr -> i64
%640 = llvm.load %620 : !llvm.ptr -> i64
%638 = func.call @tidx(%639, %640) : (i64, i64) -> i64
%641 = llvm.getelementptr %637[%638] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%635 = llvm.load %641 : !llvm.ptr -> f64
%642 = math.absf %635 : f64
%643 = llvm.mlir.addressof @EPS : !llvm.ptr
%644 = llvm.load %643 : !llvm.ptr -> f64
%645 = arith.cmpf ogt, %642, %644 : f64
cf.cond_br %645, ^bb99, ^bb100
^bb99:
%646 = llvm.load %620 : !llvm.ptr -> i64
llvm.store %646, %616 : i64, !llvm.ptr
llvm.store %590, %620 : i64, !llvm.ptr
cf.br ^bb101
^bb100:
cf.br ^bb101
^bb101:
%647 = llvm.load %620 : !llvm.ptr -> i64
%648 = arith.constant 1 : i32
%650 = arith.extsi %648 : i32 to i64
%649 = arith.addi %647, %650 : i64
llvm.store %649, %620 : i64, !llvm.ptr
cf.br ^bb98
^bb98:
cf.br ^bb93
^bb95:
%651 = llvm.load %616 : !llvm.ptr -> i64
%652 = arith.constant 1 : i32
%654 = arith.constant 0 : i32
%653 = arith.subi %654, %652 : i32
%656 = arith.extsi %653 : i32 to i64
%655 = arith.cmpi ne, %651, %656 : i64
cf.cond_br %655, ^bb102, ^bb103
^bb102:
%658 = llvm.load %595 : !llvm.ptr -> i64
%659 = llvm.load %616 : !llvm.ptr -> i64
func.call @pivot_op(%658, %659) : (i64, i64) -> ()
%660 = llvm.load %595 : !llvm.ptr -> i64
%661 = arith.constant 1 : i32
%663 = arith.extsi %661 : i32 to i64
%662 = arith.addi %660, %663 : i64
llvm.store %662, %595 : i64, !llvm.ptr
cf.br ^bb104
^bb103:
%664 = llvm.load %595 : !llvm.ptr -> i64
%665 = llvm.mlir.constant(1 : i64) : i64
%666 = llvm.alloca %665 x i64 : (i64) -> !llvm.ptr
llvm.store %664, %666 : i64, !llvm.ptr
cf.br ^bb105
^bb105:
%667 = llvm.load %666 : !llvm.ptr -> i64
%668 = llvm.load %586 : !llvm.ptr -> i64
%669 = arith.constant 1 : i32
%671 = arith.extsi %669 : i32 to i64
%670 = arith.subi %668, %671 : i64
%672 = arith.cmpi slt, %667, %670 : i64
cf.cond_br %672, ^bb106, ^bb107
^bb106:
%673 = arith.constant 0 : i32
%674 = arith.extsi %673 : i32 to i64
%675 = llvm.mlir.constant(1 : i64) : i64
%676 = llvm.alloca %675 x i64 : (i64) -> !llvm.ptr
llvm.store %674, %676 : i64, !llvm.ptr
cf.br ^bb108
^bb108:
%677 = llvm.load %676 : !llvm.ptr -> i64
%678 = llvm.mlir.addressof @g_N : !llvm.ptr
%679 = llvm.load %678 : !llvm.ptr -> i64
%680 = arith.cmpi slt, %677, %679 : i64
cf.cond_br %680, ^bb109, ^bb110
^bb109:
%682 = llvm.mlir.addressof @g_tab : !llvm.ptr
%683 = llvm.load %682 : !llvm.ptr -> !llvm.ptr
%685 = llvm.load %666 : !llvm.ptr -> i64
%686 = arith.constant 1 : i32
%688 = arith.extsi %686 : i32 to i64
%687 = arith.addi %685, %688 : i64
%689 = llvm.load %676 : !llvm.ptr -> i64
%684 = func.call @tidx(%687, %689) : (i64, i64) -> i64
%690 = llvm.getelementptr %683[%684] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%681 = llvm.load %690 : !llvm.ptr -> f64
%691 = llvm.mlir.addressof @g_tab : !llvm.ptr
%692 = llvm.load %691 : !llvm.ptr -> !llvm.ptr
%694 = llvm.load %666 : !llvm.ptr -> i64
%695 = llvm.load %676 : !llvm.ptr -> i64
%693 = func.call @tidx(%694, %695) : (i64, i64) -> i64
%696 = llvm.getelementptr %692[%693] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %681, %696 : f64, !llvm.ptr
%697 = llvm.load %676 : !llvm.ptr -> i64
%698 = arith.constant 1 : i32
%700 = arith.extsi %698 : i32 to i64
%699 = arith.addi %697, %700 : i64
llvm.store %699, %676 : i64, !llvm.ptr
cf.br ^bb108
^bb110:
%702 = llvm.mlir.addressof @g_basis : !llvm.ptr
%703 = llvm.load %702 : !llvm.ptr -> !llvm.ptr
%704 = llvm.load %666 : !llvm.ptr -> i64
%705 = arith.constant 1 : i32
%707 = arith.extsi %705 : i32 to i64
%706 = arith.addi %704, %707 : i64
%708 = llvm.getelementptr %703[%706] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%701 = llvm.load %708 : !llvm.ptr -> i64
%709 = llvm.mlir.addressof @g_basis : !llvm.ptr
%710 = llvm.load %709 : !llvm.ptr -> !llvm.ptr
%711 = llvm.load %666 : !llvm.ptr -> i64
%712 = llvm.getelementptr %710[%711] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %701, %712 : i64, !llvm.ptr
%713 = llvm.load %666 : !llvm.ptr -> i64
%714 = arith.constant 1 : i32
%716 = arith.extsi %714 : i32 to i64
%715 = arith.addi %713, %716 : i64
llvm.store %715, %666 : i64, !llvm.ptr
cf.br ^bb105
^bb107:
%717 = llvm.load %586 : !llvm.ptr -> i64
%718 = arith.constant 1 : i32
%720 = arith.extsi %718 : i32 to i64
%719 = arith.subi %717, %720 : i64
llvm.store %719, %586 : i64, !llvm.ptr
cf.br ^bb104
^bb104:
cf.br ^bb92
^bb91:
%721 = llvm.load %595 : !llvm.ptr -> i64
%722 = arith.constant 1 : i32
%724 = arith.extsi %722 : i32 to i64
%723 = arith.addi %721, %724 : i64
llvm.store %723, %595 : i64, !llvm.ptr
cf.br ^bb92
^bb92:
cf.br ^bb87
^bb89:
%725 = arith.constant 0 : i32
%726 = arith.extsi %725 : i32 to i64
%727 = llvm.mlir.constant(1 : i64) : i64
%728 = llvm.alloca %727 x i64 : (i64) -> !llvm.ptr
llvm.store %726, %728 : i64, !llvm.ptr
%730 = arith.constant 8 : i32
%731 = arith.extsi %730 : i32 to i64
%729 = func.call @calloc(%590, %731) : (i64, i64) -> !llvm.ptr
%732 = arith.constant 0 : i32
%733 = arith.extsi %732 : i32 to i64
%734 = llvm.mlir.constant(1 : i64) : i64
%735 = llvm.alloca %734 x i64 : (i64) -> !llvm.ptr
llvm.store %733, %735 : i64, !llvm.ptr
cf.br ^bb111
^bb111:
%736 = llvm.load %735 : !llvm.ptr -> i64
%737 = arith.cmpi slt, %736, %590 : i64
cf.cond_br %737, ^bb112, ^bb113
^bb112:
%739 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%740 = llvm.load %739 : !llvm.ptr -> !llvm.ptr
%741 = llvm.load %735 : !llvm.ptr -> i64
%742 = llvm.getelementptr %740[%741] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%738 = llvm.load %742 : !llvm.ptr -> i64
%743 = arith.constant 0 : i32
%745 = arith.extsi %743 : i32 to i64
%744 = arith.cmpi eq, %738, %745 : i64
cf.cond_br %744, ^bb114, ^bb115
^bb114:
%746 = llvm.load %735 : !llvm.ptr -> i64
%747 = llvm.load %728 : !llvm.ptr -> i64
%748 = llvm.getelementptr %729[%747] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %746, %748 : i64, !llvm.ptr
%749 = llvm.load %728 : !llvm.ptr -> i64
%750 = arith.constant 1 : i32
%752 = arith.extsi %750 : i32 to i64
%751 = arith.addi %749, %752 : i64
llvm.store %751, %728 : i64, !llvm.ptr
cf.br ^bb116
^bb115:
cf.br ^bb116
^bb116:
%753 = llvm.load %735 : !llvm.ptr -> i64
%754 = arith.constant 1 : i32
%756 = arith.extsi %754 : i32 to i64
%755 = arith.addi %753, %756 : i64
llvm.store %755, %735 : i64, !llvm.ptr
cf.br ^bb111
^bb113:
%758 = arith.constant 8 : i32
%759 = arith.extsi %758 : i32 to i64
%757 = func.call @calloc(%590, %759) : (i64, i64) -> !llvm.ptr
%760 = arith.constant 0 : i32
%761 = arith.extsi %760 : i32 to i64
%762 = llvm.mlir.constant(1 : i64) : i64
%763 = llvm.alloca %762 x i64 : (i64) -> !llvm.ptr
llvm.store %761, %763 : i64, !llvm.ptr
%764 = arith.constant 0 : i32
%765 = arith.extsi %764 : i32 to i64
llvm.store %765, %735 : i64, !llvm.ptr
cf.br ^bb117
^bb117:
%766 = llvm.load %735 : !llvm.ptr -> i64
%767 = arith.cmpi slt, %766, %590 : i64
cf.cond_br %767, ^bb118, ^bb119
^bb118:
%769 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%770 = llvm.load %769 : !llvm.ptr -> !llvm.ptr
%771 = llvm.load %735 : !llvm.ptr -> i64
%772 = llvm.getelementptr %770[%771] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%768 = llvm.load %772 : !llvm.ptr -> i64
%773 = arith.constant 0 : i32
%775 = arith.extsi %773 : i32 to i64
%774 = arith.cmpi eq, %768, %775 : i64
cf.cond_br %774, ^bb120, ^bb121
^bb120:
%776 = llvm.load %763 : !llvm.ptr -> i64
%777 = llvm.load %735 : !llvm.ptr -> i64
%778 = llvm.getelementptr %757[%777] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %776, %778 : i64, !llvm.ptr
%779 = llvm.load %763 : !llvm.ptr -> i64
%780 = arith.constant 1 : i32
%782 = arith.extsi %780 : i32 to i64
%781 = arith.addi %779, %782 : i64
llvm.store %781, %763 : i64, !llvm.ptr
cf.br ^bb122
^bb121:
%783 = arith.constant 1 : i32
%785 = arith.constant 0 : i32
%784 = arith.subi %785, %783 : i32
%786 = llvm.load %735 : !llvm.ptr -> i64
%787 = arith.extsi %784 : i32 to i64
%788 = llvm.getelementptr %757[%786] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %787, %788 : i64, !llvm.ptr
cf.br ^bb122
^bb122:
%789 = llvm.load %735 : !llvm.ptr -> i64
%790 = arith.constant 1 : i32
%792 = arith.extsi %790 : i32 to i64
%791 = arith.addi %789, %792 : i64
llvm.store %791, %735 : i64, !llvm.ptr
cf.br ^bb117
^bb119:
%793 = llvm.load %728 : !llvm.ptr -> i64
%794 = arith.constant 1 : i32
%796 = arith.extsi %794 : i32 to i64
%795 = arith.addi %793, %796 : i64
%798 = llvm.load %586 : !llvm.ptr -> i64
%799 = arith.muli %798, %795 : i64
%800 = arith.constant 8 : i32
%801 = arith.extsi %800 : i32 to i64
%797 = func.call @calloc(%799, %801) : (i64, i64) -> !llvm.ptr
%802 = arith.constant 0 : i32
%803 = arith.extsi %802 : i32 to i64
%804 = llvm.mlir.constant(1 : i64) : i64
%805 = llvm.alloca %804 x i64 : (i64) -> !llvm.ptr
llvm.store %803, %805 : i64, !llvm.ptr
cf.br ^bb123
^bb123:
%806 = llvm.load %805 : !llvm.ptr -> i64
%807 = llvm.load %586 : !llvm.ptr -> i64
%808 = arith.cmpi slt, %806, %807 : i64
cf.cond_br %808, ^bb124, ^bb125
^bb124:
%809 = arith.constant 0 : i32
%810 = arith.extsi %809 : i32 to i64
%811 = llvm.mlir.constant(1 : i64) : i64
%812 = llvm.alloca %811 x i64 : (i64) -> !llvm.ptr
llvm.store %810, %812 : i64, !llvm.ptr
cf.br ^bb126
^bb126:
%813 = llvm.load %812 : !llvm.ptr -> i64
%814 = llvm.load %728 : !llvm.ptr -> i64
%815 = arith.cmpi slt, %813, %814 : i64
cf.cond_br %815, ^bb127, ^bb128
^bb127:
%817 = llvm.mlir.addressof @g_tab : !llvm.ptr
%818 = llvm.load %817 : !llvm.ptr -> !llvm.ptr
%820 = llvm.load %805 : !llvm.ptr -> i64
%822 = llvm.load %812 : !llvm.ptr -> i64
%823 = llvm.getelementptr %729[%822] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%821 = llvm.load %823 : !llvm.ptr -> i64
%819 = func.call @tidx(%820, %821) : (i64, i64) -> i64
%824 = llvm.getelementptr %818[%819] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%816 = llvm.load %824 : !llvm.ptr -> f64
%825 = llvm.load %805 : !llvm.ptr -> i64
%826 = arith.muli %825, %795 : i64
%827 = llvm.load %812 : !llvm.ptr -> i64
%828 = arith.addi %826, %827 : i64
%829 = llvm.getelementptr %797[%828] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %816, %829 : f64, !llvm.ptr
%830 = llvm.load %812 : !llvm.ptr -> i64
%831 = arith.constant 1 : i32
%833 = arith.extsi %831 : i32 to i64
%832 = arith.addi %830, %833 : i64
llvm.store %832, %812 : i64, !llvm.ptr
cf.br ^bb126
^bb128:
%835 = llvm.mlir.addressof @g_tab : !llvm.ptr
%836 = llvm.load %835 : !llvm.ptr -> !llvm.ptr
%838 = llvm.load %805 : !llvm.ptr -> i64
%837 = func.call @tidx(%838, %590) : (i64, i64) -> i64
%839 = llvm.getelementptr %836[%837] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%834 = llvm.load %839 : !llvm.ptr -> f64
%840 = llvm.load %805 : !llvm.ptr -> i64
%841 = arith.muli %840, %795 : i64
%842 = llvm.load %728 : !llvm.ptr -> i64
%843 = arith.addi %841, %842 : i64
%844 = llvm.getelementptr %797[%843] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %834, %844 : f64, !llvm.ptr
%847 = llvm.mlir.addressof @g_basis : !llvm.ptr
%848 = llvm.load %847 : !llvm.ptr -> !llvm.ptr
%849 = llvm.load %805 : !llvm.ptr -> i64
%850 = llvm.getelementptr %848[%849] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%846 = llvm.load %850 : !llvm.ptr -> i64
%851 = llvm.getelementptr %757[%846] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%845 = llvm.load %851 : !llvm.ptr -> i64
%852 = llvm.mlir.addressof @g_basis : !llvm.ptr
%853 = llvm.load %852 : !llvm.ptr -> !llvm.ptr
%854 = llvm.load %805 : !llvm.ptr -> i64
%855 = llvm.getelementptr %853[%854] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %845, %855 : i64, !llvm.ptr
%856 = llvm.load %805 : !llvm.ptr -> i64
%857 = arith.constant 1 : i32
%859 = arith.extsi %857 : i32 to i64
%858 = arith.addi %856, %859 : i64
llvm.store %858, %805 : i64, !llvm.ptr
cf.br ^bb123
^bb125:
%861 = llvm.mlir.addressof @g_tab : !llvm.ptr
%862 = llvm.load %861 : !llvm.ptr -> !llvm.ptr
func.call @free(%862) : (!llvm.ptr) -> ()
%863 = llvm.mlir.addressof @g_tab : !llvm.ptr
llvm.store %797, %863 : !llvm.ptr, !llvm.ptr
%864 = llvm.mlir.addressof @g_N : !llvm.ptr
llvm.store %795, %864 : i64, !llvm.ptr
%865 = llvm.load %586 : !llvm.ptr -> i64
%866 = llvm.mlir.addressof @g_M : !llvm.ptr
llvm.store %865, %866 : i64, !llvm.ptr
func.call @free(%729) : (!llvm.ptr) -> ()
func.call @free(%757) : (!llvm.ptr) -> ()
func.return
}
func.func @solve_lp(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i64, %arg5: !llvm.ptr) -> f64 {
func.call @build_tableau(%arg0, %arg1, %arg2, %arg3, %arg4) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%870 = llvm.mlir.addressof @g_num_art : !llvm.ptr
%871 = llvm.load %870 : !llvm.ptr -> i64
%872 = arith.constant 0 : i32
%874 = arith.extsi %872 : i32 to i64
%873 = arith.cmpi sgt, %871, %874 : i64
cf.cond_br %873, ^bb129, ^bb130
^bb129:
%875 = llvm.mlir.addressof @g_N : !llvm.ptr
%876 = llvm.load %875 : !llvm.ptr -> i64
%877 = arith.constant 1 : i32
%879 = arith.extsi %877 : i32 to i64
%878 = arith.subi %876, %879 : i64
%881 = arith.constant 8 : i32
%882 = arith.extsi %881 : i32 to i64
%880 = func.call @calloc(%878, %882) : (i64, i64) -> !llvm.ptr
%883 = arith.constant 0 : i32
%884 = arith.extsi %883 : i32 to i64
%885 = llvm.mlir.constant(1 : i64) : i64
%886 = llvm.alloca %885 x i64 : (i64) -> !llvm.ptr
llvm.store %884, %886 : i64, !llvm.ptr
cf.br ^bb132
^bb132:
%887 = llvm.load %886 : !llvm.ptr -> i64
%888 = arith.cmpi slt, %887, %878 : i64
cf.cond_br %888, ^bb133, ^bb134
^bb133:
%890 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%891 = llvm.load %890 : !llvm.ptr -> !llvm.ptr
%892 = llvm.load %886 : !llvm.ptr -> i64
%893 = llvm.getelementptr %891[%892] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%889 = llvm.load %893 : !llvm.ptr -> i64
%894 = arith.constant 0 : i32
%896 = arith.extsi %894 : i32 to i64
%895 = arith.cmpi ne, %889, %896 : i64
cf.cond_br %895, ^bb135, ^bb136
^bb135:
%897 = arith.constant 1.0 : f32
%898 = arith.negf %897 : f32
%899 = llvm.load %886 : !llvm.ptr -> i64
%900 = arith.extf %898 : f32 to f64
%901 = llvm.getelementptr %880[%899] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %900, %901 : f64, !llvm.ptr
cf.br ^bb137
^bb136:
cf.br ^bb137
^bb137:
%902 = llvm.load %886 : !llvm.ptr -> i64
%903 = arith.constant 1 : i32
%905 = arith.extsi %903 : i32 to i64
%904 = arith.addi %902, %905 : i64
llvm.store %904, %886 : i64, !llvm.ptr
cf.br ^bb132
^bb134:
%906 = llvm.mlir.addressof @g_M : !llvm.ptr
%907 = llvm.load %906 : !llvm.ptr -> i64
%908 = llvm.mlir.addressof @g_M : !llvm.ptr
%909 = llvm.load %908 : !llvm.ptr -> i64
%910 = arith.constant 1 : i32
%912 = arith.extsi %910 : i32 to i64
%911 = arith.addi %909, %912 : i64
%913 = llvm.mlir.addressof @g_M : !llvm.ptr
llvm.store %911, %913 : i64, !llvm.ptr
%915 = llvm.mlir.addressof @g_M : !llvm.ptr
%916 = llvm.load %915 : !llvm.ptr -> i64
%917 = llvm.mlir.addressof @g_N : !llvm.ptr
%918 = llvm.load %917 : !llvm.ptr -> i64
%919 = arith.muli %916, %918 : i64
%920 = arith.constant 8 : i32
%921 = arith.extsi %920 : i32 to i64
%914 = func.call @calloc(%919, %921) : (i64, i64) -> !llvm.ptr
%922 = arith.constant 0 : i32
%923 = arith.extsi %922 : i32 to i64
%924 = llvm.mlir.constant(1 : i64) : i64
%925 = llvm.alloca %924 x i64 : (i64) -> !llvm.ptr
llvm.store %923, %925 : i64, !llvm.ptr
cf.br ^bb138
^bb138:
%926 = llvm.load %925 : !llvm.ptr -> i64
%927 = arith.cmpi slt, %926, %907 : i64
cf.cond_br %927, ^bb139, ^bb140
^bb139:
%928 = arith.constant 0 : i32
%929 = arith.extsi %928 : i32 to i64
%930 = llvm.mlir.constant(1 : i64) : i64
%931 = llvm.alloca %930 x i64 : (i64) -> !llvm.ptr
llvm.store %929, %931 : i64, !llvm.ptr
cf.br ^bb141
^bb141:
%932 = llvm.load %931 : !llvm.ptr -> i64
%933 = llvm.mlir.addressof @g_N : !llvm.ptr
%934 = llvm.load %933 : !llvm.ptr -> i64
%935 = arith.cmpi slt, %932, %934 : i64
cf.cond_br %935, ^bb142, ^bb143
^bb142:
%937 = llvm.mlir.addressof @g_tab : !llvm.ptr
%938 = llvm.load %937 : !llvm.ptr -> !llvm.ptr
%940 = llvm.load %925 : !llvm.ptr -> i64
%941 = llvm.load %931 : !llvm.ptr -> i64
%939 = func.call @tidx(%940, %941) : (i64, i64) -> i64
%942 = llvm.getelementptr %938[%939] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%936 = llvm.load %942 : !llvm.ptr -> f64
%943 = llvm.load %925 : !llvm.ptr -> i64
%944 = llvm.mlir.addressof @g_N : !llvm.ptr
%945 = llvm.load %944 : !llvm.ptr -> i64
%946 = arith.muli %943, %945 : i64
%947 = llvm.load %931 : !llvm.ptr -> i64
%948 = arith.addi %946, %947 : i64
%949 = llvm.getelementptr %914[%948] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %936, %949 : f64, !llvm.ptr
%950 = llvm.load %931 : !llvm.ptr -> i64
%951 = arith.constant 1 : i32
%953 = arith.extsi %951 : i32 to i64
%952 = arith.addi %950, %953 : i64
llvm.store %952, %931 : i64, !llvm.ptr
cf.br ^bb141
^bb143:
%954 = llvm.load %925 : !llvm.ptr -> i64
%955 = arith.constant 1 : i32
%957 = arith.extsi %955 : i32 to i64
%956 = arith.addi %954, %957 : i64
llvm.store %956, %925 : i64, !llvm.ptr
cf.br ^bb138
^bb140:
%959 = llvm.mlir.addressof @g_tab : !llvm.ptr
%960 = llvm.load %959 : !llvm.ptr -> !llvm.ptr
func.call @free(%960) : (!llvm.ptr) -> ()
%961 = llvm.mlir.addressof @g_tab : !llvm.ptr
llvm.store %914, %961 : !llvm.ptr, !llvm.ptr
%963 = llvm.mlir.addressof @g_M : !llvm.ptr
%964 = llvm.load %963 : !llvm.ptr -> i64
%965 = arith.constant 8 : i32
%966 = arith.extsi %965 : i32 to i64
%962 = func.call @calloc(%964, %966) : (i64, i64) -> !llvm.ptr
%967 = arith.constant 0 : i32
%968 = arith.extsi %967 : i32 to i64
llvm.store %968, %925 : i64, !llvm.ptr
cf.br ^bb144
^bb144:
%969 = llvm.load %925 : !llvm.ptr -> i64
%970 = arith.cmpi slt, %969, %907 : i64
cf.cond_br %970, ^bb145, ^bb146
^bb145:
%972 = llvm.mlir.addressof @g_basis : !llvm.ptr
%973 = llvm.load %972 : !llvm.ptr -> !llvm.ptr
%974 = llvm.load %925 : !llvm.ptr -> i64
%975 = llvm.getelementptr %973[%974] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%971 = llvm.load %975 : !llvm.ptr -> i64
%976 = llvm.load %925 : !llvm.ptr -> i64
%977 = llvm.getelementptr %962[%976] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %971, %977 : i64, !llvm.ptr
%978 = llvm.load %925 : !llvm.ptr -> i64
%979 = arith.constant 1 : i32
%981 = arith.extsi %979 : i32 to i64
%980 = arith.addi %978, %981 : i64
llvm.store %980, %925 : i64, !llvm.ptr
cf.br ^bb144
^bb146:
%983 = llvm.mlir.addressof @g_basis : !llvm.ptr
%984 = llvm.load %983 : !llvm.ptr -> !llvm.ptr
func.call @free(%984) : (!llvm.ptr) -> ()
%985 = llvm.mlir.addressof @g_basis : !llvm.ptr
llvm.store %962, %985 : !llvm.ptr, !llvm.ptr
func.call @set_objective(%880) : (!llvm.ptr) -> ()
%987 = func.call @simplex_max() : () -> i64
%989 = llvm.mlir.addressof @g_tab : !llvm.ptr
%990 = llvm.load %989 : !llvm.ptr -> !llvm.ptr
%992 = llvm.mlir.addressof @g_N : !llvm.ptr
%993 = llvm.load %992 : !llvm.ptr -> i64
%994 = arith.constant 1 : i32
%996 = arith.extsi %994 : i32 to i64
%995 = arith.subi %993, %996 : i64
%991 = func.call @tidx(%907, %995) : (i64, i64) -> i64
%997 = llvm.getelementptr %990[%991] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%988 = llvm.load %997 : !llvm.ptr -> f64
%998 = arith.constant 0.0000001 : f32
%999 = arith.negf %998 : f32
%1001 = arith.extf %999 : f32 to f64
%1000 = arith.cmpf olt, %988, %1001 : f64
cf.cond_br %1000, ^bb147, ^bb148
^bb147:
%1003 = llvm.mlir.addressof @g_tab : !llvm.ptr
%1004 = llvm.load %1003 : !llvm.ptr -> !llvm.ptr
func.call @free(%1004) : (!llvm.ptr) -> ()
%1006 = llvm.mlir.addressof @g_basis : !llvm.ptr
%1007 = llvm.load %1006 : !llvm.ptr -> !llvm.ptr
func.call @free(%1007) : (!llvm.ptr) -> ()
%1009 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%1010 = llvm.load %1009 : !llvm.ptr -> !llvm.ptr
func.call @free(%1010) : (!llvm.ptr) -> ()
%1012 = llvm.mlir.addressof @g_art_indices : !llvm.ptr
%1013 = llvm.load %1012 : !llvm.ptr -> !llvm.ptr
func.call @free(%1013) : (!llvm.ptr) -> ()
func.call @free(%880) : (!llvm.ptr) -> ()
%1015 = arith.constant 1000000000000000000 : f32
%1016 = arith.negf %1015 : f32
%1017 = arith.extf %1016 : f32 to f64
func.return %1017 : f64
^bb148:
cf.br ^bb149
^bb149:
%1018 = llvm.mlir.addressof @g_M : !llvm.ptr
%1019 = llvm.load %1018 : !llvm.ptr -> i64
%1020 = arith.constant 1 : i32
%1022 = arith.extsi %1020 : i32 to i64
%1021 = arith.subi %1019, %1022 : i64
%1023 = llvm.mlir.addressof @g_M : !llvm.ptr
llvm.store %1021, %1023 : i64, !llvm.ptr
func.call @remove_artificial() : () -> ()
func.call @free(%880) : (!llvm.ptr) -> ()
cf.br ^bb131
^bb130:
cf.br ^bb131
^bb131:
%1026 = llvm.mlir.addressof @g_N : !llvm.ptr
%1027 = llvm.load %1026 : !llvm.ptr -> i64
%1028 = arith.constant 1 : i32
%1030 = arith.extsi %1028 : i32 to i64
%1029 = arith.subi %1027, %1030 : i64
%1032 = arith.constant 8 : i32
%1033 = arith.extsi %1032 : i32 to i64
%1031 = func.call @calloc(%1029, %1033) : (i64, i64) -> !llvm.ptr
%1034 = arith.constant 0 : i32
%1035 = arith.extsi %1034 : i32 to i64
%1036 = llvm.mlir.constant(1 : i64) : i64
%1037 = llvm.alloca %1036 x i64 : (i64) -> !llvm.ptr
llvm.store %1035, %1037 : i64, !llvm.ptr
cf.br ^bb150
^bb150:
%1038 = llvm.load %1037 : !llvm.ptr -> i64
%1039 = arith.cmpi slt, %1038, %arg0 : i64
cf.cond_br %1039, ^bb151, ^bb152
^bb151:
%1041 = llvm.load %1037 : !llvm.ptr -> i64
%1042 = llvm.getelementptr %arg5[%1041] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%1040 = llvm.load %1042 : !llvm.ptr -> f64
%1043 = arith.negf %1040 : f64
%1044 = llvm.load %1037 : !llvm.ptr -> i64
%1045 = llvm.getelementptr %1031[%1044] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1043, %1045 : f64, !llvm.ptr
%1046 = llvm.load %1037 : !llvm.ptr -> i64
%1047 = arith.constant 1 : i32
%1049 = arith.extsi %1047 : i32 to i64
%1048 = arith.addi %1046, %1049 : i64
llvm.store %1048, %1037 : i64, !llvm.ptr
cf.br ^bb150
^bb152:
%1050 = llvm.mlir.addressof @g_M : !llvm.ptr
%1051 = llvm.load %1050 : !llvm.ptr -> i64
%1052 = llvm.mlir.addressof @g_M : !llvm.ptr
%1053 = llvm.load %1052 : !llvm.ptr -> i64
%1054 = arith.constant 1 : i32
%1056 = arith.extsi %1054 : i32 to i64
%1055 = arith.addi %1053, %1056 : i64
%1057 = llvm.mlir.addressof @g_M : !llvm.ptr
llvm.store %1055, %1057 : i64, !llvm.ptr
%1059 = llvm.mlir.addressof @g_M : !llvm.ptr
%1060 = llvm.load %1059 : !llvm.ptr -> i64
%1061 = llvm.mlir.addressof @g_N : !llvm.ptr
%1062 = llvm.load %1061 : !llvm.ptr -> i64
%1063 = arith.muli %1060, %1062 : i64
%1064 = arith.constant 8 : i32
%1065 = arith.extsi %1064 : i32 to i64
%1058 = func.call @calloc(%1063, %1065) : (i64, i64) -> !llvm.ptr
%1066 = arith.constant 0 : i32
%1067 = arith.extsi %1066 : i32 to i64
%1068 = llvm.mlir.constant(1 : i64) : i64
%1069 = llvm.alloca %1068 x i64 : (i64) -> !llvm.ptr
llvm.store %1067, %1069 : i64, !llvm.ptr
cf.br ^bb153
^bb153:
%1070 = llvm.load %1069 : !llvm.ptr -> i64
%1071 = arith.cmpi slt, %1070, %1051 : i64
cf.cond_br %1071, ^bb154, ^bb155
^bb154:
%1072 = arith.constant 0 : i32
%1073 = arith.extsi %1072 : i32 to i64
%1074 = llvm.mlir.constant(1 : i64) : i64
%1075 = llvm.alloca %1074 x i64 : (i64) -> !llvm.ptr
llvm.store %1073, %1075 : i64, !llvm.ptr
cf.br ^bb156
^bb156:
%1076 = llvm.load %1075 : !llvm.ptr -> i64
%1077 = llvm.mlir.addressof @g_N : !llvm.ptr
%1078 = llvm.load %1077 : !llvm.ptr -> i64
%1079 = arith.cmpi slt, %1076, %1078 : i64
cf.cond_br %1079, ^bb157, ^bb158
^bb157:
%1081 = llvm.mlir.addressof @g_tab : !llvm.ptr
%1082 = llvm.load %1081 : !llvm.ptr -> !llvm.ptr
%1084 = llvm.load %1069 : !llvm.ptr -> i64
%1085 = llvm.load %1075 : !llvm.ptr -> i64
%1083 = func.call @tidx(%1084, %1085) : (i64, i64) -> i64
%1086 = llvm.getelementptr %1082[%1083] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%1080 = llvm.load %1086 : !llvm.ptr -> f64
%1087 = llvm.load %1069 : !llvm.ptr -> i64
%1088 = llvm.mlir.addressof @g_N : !llvm.ptr
%1089 = llvm.load %1088 : !llvm.ptr -> i64
%1090 = arith.muli %1087, %1089 : i64
%1091 = llvm.load %1075 : !llvm.ptr -> i64
%1092 = arith.addi %1090, %1091 : i64
%1093 = llvm.getelementptr %1058[%1092] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1080, %1093 : f64, !llvm.ptr
%1094 = llvm.load %1075 : !llvm.ptr -> i64
%1095 = arith.constant 1 : i32
%1097 = arith.extsi %1095 : i32 to i64
%1096 = arith.addi %1094, %1097 : i64
llvm.store %1096, %1075 : i64, !llvm.ptr
cf.br ^bb156
^bb158:
%1098 = llvm.load %1069 : !llvm.ptr -> i64
%1099 = arith.constant 1 : i32
%1101 = arith.extsi %1099 : i32 to i64
%1100 = arith.addi %1098, %1101 : i64
llvm.store %1100, %1069 : i64, !llvm.ptr
cf.br ^bb153
^bb155:
%1103 = llvm.mlir.addressof @g_tab : !llvm.ptr
%1104 = llvm.load %1103 : !llvm.ptr -> !llvm.ptr
func.call @free(%1104) : (!llvm.ptr) -> ()
%1105 = llvm.mlir.addressof @g_tab : !llvm.ptr
llvm.store %1058, %1105 : !llvm.ptr, !llvm.ptr
%1107 = llvm.mlir.addressof @g_M : !llvm.ptr
%1108 = llvm.load %1107 : !llvm.ptr -> i64
%1109 = arith.constant 8 : i32
%1110 = arith.extsi %1109 : i32 to i64
%1106 = func.call @calloc(%1108, %1110) : (i64, i64) -> !llvm.ptr
%1111 = arith.constant 0 : i32
%1112 = arith.extsi %1111 : i32 to i64
llvm.store %1112, %1069 : i64, !llvm.ptr
cf.br ^bb159
^bb159:
%1113 = llvm.load %1069 : !llvm.ptr -> i64
%1114 = arith.cmpi slt, %1113, %1051 : i64
cf.cond_br %1114, ^bb160, ^bb161
^bb160:
%1116 = llvm.mlir.addressof @g_basis : !llvm.ptr
%1117 = llvm.load %1116 : !llvm.ptr -> !llvm.ptr
%1118 = llvm.load %1069 : !llvm.ptr -> i64
%1119 = llvm.getelementptr %1117[%1118] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1115 = llvm.load %1119 : !llvm.ptr -> i64
%1120 = llvm.load %1069 : !llvm.ptr -> i64
%1121 = llvm.getelementptr %1106[%1120] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1115, %1121 : i64, !llvm.ptr
%1122 = llvm.load %1069 : !llvm.ptr -> i64
%1123 = arith.constant 1 : i32
%1125 = arith.extsi %1123 : i32 to i64
%1124 = arith.addi %1122, %1125 : i64
llvm.store %1124, %1069 : i64, !llvm.ptr
cf.br ^bb159
^bb161:
%1127 = llvm.mlir.addressof @g_basis : !llvm.ptr
%1128 = llvm.load %1127 : !llvm.ptr -> !llvm.ptr
func.call @free(%1128) : (!llvm.ptr) -> ()
%1129 = llvm.mlir.addressof @g_basis : !llvm.ptr
llvm.store %1106, %1129 : !llvm.ptr, !llvm.ptr
func.call @set_objective(%1031) : (!llvm.ptr) -> ()
%1131 = func.call @simplex_max() : () -> i64
%1133 = llvm.mlir.addressof @g_tab : !llvm.ptr
%1134 = llvm.load %1133 : !llvm.ptr -> !llvm.ptr
%1136 = llvm.mlir.addressof @g_N : !llvm.ptr
%1137 = llvm.load %1136 : !llvm.ptr -> i64
%1138 = arith.constant 1 : i32
%1140 = arith.extsi %1138 : i32 to i64
%1139 = arith.subi %1137, %1140 : i64
%1135 = func.call @tidx(%1051, %1139) : (i64, i64) -> i64
%1141 = llvm.getelementptr %1134[%1135] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%1132 = llvm.load %1141 : !llvm.ptr -> f64
%1142 = arith.negf %1132 : f64
%1144 = llvm.mlir.addressof @g_tab : !llvm.ptr
%1145 = llvm.load %1144 : !llvm.ptr -> !llvm.ptr
func.call @free(%1145) : (!llvm.ptr) -> ()
%1147 = llvm.mlir.addressof @g_basis : !llvm.ptr
%1148 = llvm.load %1147 : !llvm.ptr -> !llvm.ptr
func.call @free(%1148) : (!llvm.ptr) -> ()
%1150 = llvm.mlir.addressof @g_art_flags : !llvm.ptr
%1151 = llvm.load %1150 : !llvm.ptr -> !llvm.ptr
func.call @free(%1151) : (!llvm.ptr) -> ()
%1153 = llvm.mlir.addressof @g_art_indices : !llvm.ptr
%1154 = llvm.load %1153 : !llvm.ptr -> !llvm.ptr
func.call @free(%1154) : (!llvm.ptr) -> ()
func.call @free(%1031) : (!llvm.ptr) -> ()
func.return %1142 : f64
}
func.func @build_and_solve(%arg0: i64) -> f64 {
%1156 = arith.constant 1 : i32
%1157 = arith.extsi %1156 : i32 to i64
%1158 = arith.constant 0 : i32
%1159 = arith.extsi %1158 : i32 to i64
%1160 = llvm.mlir.constant(1 : i64) : i64
%1161 = llvm.alloca %1160 x i64 : (i64) -> !llvm.ptr
llvm.store %1159, %1161 : i64, !llvm.ptr
cf.br ^bb162(%1157 : i64)
^bb162(%1162: i64):
%1163 = llvm.load %1161 : !llvm.ptr -> i64
%1164 = arith.cmpi slt, %1163, %arg0 : i64
cf.cond_br %1164, ^bb163(%1162 : i64), ^bb164(%1162 : i64)
^bb163(%1165: i64):
%1166 = arith.constant 6 : i32
%1168 = arith.extsi %1166 : i32 to i64
%1167 = arith.muli %1165, %1168 : i64
%1169 = llvm.load %1161 : !llvm.ptr -> i64
%1170 = arith.constant 1 : i32
%1172 = arith.extsi %1170 : i32 to i64
%1171 = arith.addi %1169, %1172 : i64
llvm.store %1171, %1161 : i64, !llvm.ptr
cf.br ^bb162(%1167 : i64)
^bb164(%1173: i64):
%1175 = arith.constant 3 : i32
%1177 = arith.extsi %1175 : i32 to i64
%1176 = arith.muli %1173, %1177 : i64
%1178 = arith.constant 8 : i32
%1179 = arith.extsi %1178 : i32 to i64
%1174 = func.call @calloc(%1176, %1179) : (i64, i64) -> !llvm.ptr
%1180 = arith.constant 0 : i32
%1181 = arith.extsi %1180 : i32 to i64
%1182 = llvm.mlir.constant(1 : i64) : i64
%1183 = llvm.alloca %1182 x i64 : (i64) -> !llvm.ptr
llvm.store %1181, %1183 : i64, !llvm.ptr
%1184 = arith.constant 0 : i32
%1185 = arith.extsi %1184 : i32 to i64
%1186 = llvm.mlir.constant(1 : i64) : i64
%1187 = llvm.alloca %1186 x i64 : (i64) -> !llvm.ptr
llvm.store %1185, %1187 : i64, !llvm.ptr
cf.br ^bb165
^bb165:
%1188 = llvm.load %1187 : !llvm.ptr -> i64
%1189 = arith.constant 6 : i32
%1191 = arith.extsi %1189 : i32 to i64
%1190 = arith.cmpi slt, %1188, %1191 : i64
cf.cond_br %1190, ^bb166, ^bb167
^bb166:
%1192 = arith.constant 0 : i32
%1193 = arith.extsi %1192 : i32 to i64
%1194 = llvm.mlir.constant(1 : i64) : i64
%1195 = llvm.alloca %1194 x i64 : (i64) -> !llvm.ptr
llvm.store %1193, %1195 : i64, !llvm.ptr
cf.br ^bb168
^bb168:
%1196 = llvm.load %1195 : !llvm.ptr -> i64
%1197 = arith.constant 6 : i32
%1199 = arith.extsi %1197 : i32 to i64
%1198 = arith.cmpi slt, %1196, %1199 : i64
cf.cond_br %1198, ^bb169, ^bb170
^bb169:
%1200 = arith.constant 0 : i32
%1201 = arith.extsi %1200 : i32 to i64
%1202 = llvm.mlir.constant(1 : i64) : i64
%1203 = llvm.alloca %1202 x i64 : (i64) -> !llvm.ptr
llvm.store %1201, %1203 : i64, !llvm.ptr
cf.br ^bb171
^bb171:
%1204 = llvm.load %1203 : !llvm.ptr -> i64
%1205 = arith.constant 6 : i32
%1207 = arith.extsi %1205 : i32 to i64
%1206 = arith.cmpi slt, %1204, %1207 : i64
cf.cond_br %1206, ^bb172, ^bb173
^bb172:
%1208 = llvm.load %1187 : !llvm.ptr -> i64
%1209 = arith.constant 1 : i32
%1211 = arith.extsi %1209 : i32 to i64
%1210 = arith.addi %1208, %1211 : i64
%1212 = llvm.load %1183 : !llvm.ptr -> i64
%1213 = arith.constant 3 : i32
%1215 = arith.extsi %1213 : i32 to i64
%1214 = arith.muli %1212, %1215 : i64
%1216 = arith.constant 0 : i32
%1218 = arith.extsi %1216 : i32 to i64
%1217 = arith.addi %1214, %1218 : i64
%1219 = llvm.getelementptr %1174[%1217] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1210, %1219 : i64, !llvm.ptr
%1220 = llvm.load %1195 : !llvm.ptr -> i64
%1221 = arith.constant 1 : i32
%1223 = arith.extsi %1221 : i32 to i64
%1222 = arith.addi %1220, %1223 : i64
%1224 = llvm.load %1183 : !llvm.ptr -> i64
%1225 = arith.constant 3 : i32
%1227 = arith.extsi %1225 : i32 to i64
%1226 = arith.muli %1224, %1227 : i64
%1228 = arith.constant 1 : i32
%1230 = arith.extsi %1228 : i32 to i64
%1229 = arith.addi %1226, %1230 : i64
%1231 = llvm.getelementptr %1174[%1229] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1222, %1231 : i64, !llvm.ptr
%1232 = llvm.load %1203 : !llvm.ptr -> i64
%1233 = arith.constant 1 : i32
%1235 = arith.extsi %1233 : i32 to i64
%1234 = arith.addi %1232, %1235 : i64
%1236 = llvm.load %1183 : !llvm.ptr -> i64
%1237 = arith.constant 3 : i32
%1239 = arith.extsi %1237 : i32 to i64
%1238 = arith.muli %1236, %1239 : i64
%1240 = arith.constant 2 : i32
%1242 = arith.extsi %1240 : i32 to i64
%1241 = arith.addi %1238, %1242 : i64
%1243 = llvm.getelementptr %1174[%1241] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1234, %1243 : i64, !llvm.ptr
%1244 = llvm.load %1183 : !llvm.ptr -> i64
%1245 = arith.constant 1 : i32
%1247 = arith.extsi %1245 : i32 to i64
%1246 = arith.addi %1244, %1247 : i64
llvm.store %1246, %1183 : i64, !llvm.ptr
%1248 = llvm.load %1203 : !llvm.ptr -> i64
%1249 = arith.constant 1 : i32
%1251 = arith.extsi %1249 : i32 to i64
%1250 = arith.addi %1248, %1251 : i64
llvm.store %1250, %1203 : i64, !llvm.ptr
cf.br ^bb171
^bb173:
%1252 = llvm.load %1195 : !llvm.ptr -> i64
%1253 = arith.constant 1 : i32
%1255 = arith.extsi %1253 : i32 to i64
%1254 = arith.addi %1252, %1255 : i64
llvm.store %1254, %1195 : i64, !llvm.ptr
cf.br ^bb168
^bb170:
%1256 = llvm.load %1187 : !llvm.ptr -> i64
%1257 = arith.constant 1 : i32
%1259 = arith.extsi %1257 : i32 to i64
%1258 = arith.addi %1256, %1259 : i64
llvm.store %1258, %1187 : i64, !llvm.ptr
cf.br ^bb165
^bb167:
%1260 = arith.constant 21 : i32
%1261 = arith.extsi %1260 : i32 to i64
%1263 = arith.constant 2 : i32
%1265 = arith.extsi %1263 : i32 to i64
%1264 = arith.muli %1261, %1265 : i64
%1266 = arith.constant 8 : i32
%1267 = arith.extsi %1266 : i32 to i64
%1262 = func.call @calloc(%1264, %1267) : (i64, i64) -> !llvm.ptr
%1268 = arith.constant 0 : i32
%1269 = arith.extsi %1268 : i32 to i64
%1270 = llvm.mlir.constant(1 : i64) : i64
%1271 = llvm.alloca %1270 x i64 : (i64) -> !llvm.ptr
llvm.store %1269, %1271 : i64, !llvm.ptr
%1272 = arith.constant 0 : i32
%1273 = arith.extsi %1272 : i32 to i64
llvm.store %1273, %1187 : i64, !llvm.ptr
cf.br ^bb174
^bb174:
%1274 = llvm.load %1187 : !llvm.ptr -> i64
%1275 = arith.constant 6 : i32
%1277 = arith.extsi %1275 : i32 to i64
%1276 = arith.cmpi slt, %1274, %1277 : i64
cf.cond_br %1276, ^bb175, ^bb176
^bb175:
%1278 = llvm.load %1187 : !llvm.ptr -> i64
%1279 = llvm.mlir.constant(1 : i64) : i64
%1280 = llvm.alloca %1279 x i64 : (i64) -> !llvm.ptr
llvm.store %1278, %1280 : i64, !llvm.ptr
cf.br ^bb177
^bb177:
%1281 = llvm.load %1280 : !llvm.ptr -> i64
%1282 = arith.constant 6 : i32
%1284 = arith.extsi %1282 : i32 to i64
%1283 = arith.cmpi slt, %1281, %1284 : i64
cf.cond_br %1283, ^bb178, ^bb179
^bb178:
%1285 = llvm.load %1187 : !llvm.ptr -> i64
%1286 = arith.constant 1 : i32
%1288 = arith.extsi %1286 : i32 to i64
%1287 = arith.addi %1285, %1288 : i64
%1289 = llvm.load %1271 : !llvm.ptr -> i64
%1290 = arith.constant 2 : i32
%1292 = arith.extsi %1290 : i32 to i64
%1291 = arith.muli %1289, %1292 : i64
%1293 = arith.constant 0 : i32
%1295 = arith.extsi %1293 : i32 to i64
%1294 = arith.addi %1291, %1295 : i64
%1296 = llvm.getelementptr %1262[%1294] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1287, %1296 : i64, !llvm.ptr
%1297 = llvm.load %1280 : !llvm.ptr -> i64
%1298 = arith.constant 1 : i32
%1300 = arith.extsi %1298 : i32 to i64
%1299 = arith.addi %1297, %1300 : i64
%1301 = llvm.load %1271 : !llvm.ptr -> i64
%1302 = arith.constant 2 : i32
%1304 = arith.extsi %1302 : i32 to i64
%1303 = arith.muli %1301, %1304 : i64
%1305 = arith.constant 1 : i32
%1307 = arith.extsi %1305 : i32 to i64
%1306 = arith.addi %1303, %1307 : i64
%1308 = llvm.getelementptr %1262[%1306] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1299, %1308 : i64, !llvm.ptr
%1309 = llvm.load %1271 : !llvm.ptr -> i64
%1310 = arith.constant 1 : i32
%1312 = arith.extsi %1310 : i32 to i64
%1311 = arith.addi %1309, %1312 : i64
llvm.store %1311, %1271 : i64, !llvm.ptr
%1313 = llvm.load %1280 : !llvm.ptr -> i64
%1314 = arith.constant 1 : i32
%1316 = arith.extsi %1314 : i32 to i64
%1315 = arith.addi %1313, %1316 : i64
llvm.store %1315, %1280 : i64, !llvm.ptr
cf.br ^bb177
^bb179:
%1317 = llvm.load %1187 : !llvm.ptr -> i64
%1318 = arith.constant 1 : i32
%1320 = arith.extsi %1318 : i32 to i64
%1319 = arith.addi %1317, %1320 : i64
llvm.store %1319, %1187 : i64, !llvm.ptr
cf.br ^bb174
^bb176:
%1321 = arith.muli %1173, %arg0 : i64
%1322 = arith.addi %1321, %1261 : i64
%1323 = arith.constant 2 : i32
%1325 = arith.extsi %1323 : i32 to i64
%1324 = arith.muli %1325, %1261 : i64
%1326 = arith.addi %1173, %1324 : i64
%1328 = arith.muli %1326, %1322 : i64
%1329 = arith.constant 8 : i32
%1330 = arith.extsi %1329 : i32 to i64
%1327 = func.call @calloc(%1328, %1330) : (i64, i64) -> !llvm.ptr
%1332 = arith.constant 8 : i32
%1333 = arith.extsi %1332 : i32 to i64
%1331 = func.call @calloc(%1326, %1333) : (i64, i64) -> !llvm.ptr
%1335 = arith.constant 8 : i32
%1336 = arith.extsi %1335 : i32 to i64
%1334 = func.call @calloc(%1326, %1336) : (i64, i64) -> !llvm.ptr
%1337 = arith.constant 0 : i32
%1338 = arith.extsi %1337 : i32 to i64
%1339 = llvm.mlir.constant(1 : i64) : i64
%1340 = llvm.alloca %1339 x i64 : (i64) -> !llvm.ptr
llvm.store %1338, %1340 : i64, !llvm.ptr
%1341 = arith.constant 1.0 : f32
%1342 = arith.sitofp %1173 : i64 to f64
%1344 = arith.extf %1341 : f32 to f64
%1343 = arith.divf %1344, %1342 : f64
%1345 = arith.constant 0 : i32
%1346 = arith.extsi %1345 : i32 to i64
%1347 = llvm.mlir.constant(1 : i64) : i64
%1348 = llvm.alloca %1347 x i64 : (i64) -> !llvm.ptr
llvm.store %1346, %1348 : i64, !llvm.ptr
cf.br ^bb180
^bb180:
%1349 = llvm.load %1348 : !llvm.ptr -> i64
%1350 = arith.cmpi slt, %1349, %1173 : i64
cf.cond_br %1350, ^bb181, ^bb182
^bb181:
%1351 = arith.constant 0 : i32
%1352 = arith.extsi %1351 : i32 to i64
%1353 = llvm.mlir.constant(1 : i64) : i64
%1354 = llvm.alloca %1353 x i64 : (i64) -> !llvm.ptr
llvm.store %1352, %1354 : i64, !llvm.ptr
cf.br ^bb183
^bb183:
%1355 = llvm.load %1354 : !llvm.ptr -> i64
%1356 = arith.cmpi slt, %1355, %arg0 : i64
cf.cond_br %1356, ^bb184, ^bb185
^bb184:
%1357 = arith.constant 1.0 : f32
%1358 = llvm.load %1340 : !llvm.ptr -> i64
%1359 = arith.muli %1358, %1322 : i64
%1360 = llvm.load %1348 : !llvm.ptr -> i64
%1361 = arith.muli %1360, %arg0 : i64
%1362 = arith.addi %1359, %1361 : i64
%1363 = llvm.load %1354 : !llvm.ptr -> i64
%1364 = arith.addi %1362, %1363 : i64
%1365 = arith.extf %1357 : f32 to f64
%1366 = llvm.getelementptr %1327[%1364] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1365, %1366 : f64, !llvm.ptr
%1367 = llvm.load %1354 : !llvm.ptr -> i64
%1368 = arith.constant 1 : i32
%1370 = arith.extsi %1368 : i32 to i64
%1369 = arith.addi %1367, %1370 : i64
llvm.store %1369, %1354 : i64, !llvm.ptr
cf.br ^bb183
^bb185:
%1371 = arith.constant 61 : i32
%1372 = llvm.load %1340 : !llvm.ptr -> i64
%1373 = arith.extsi %1371 : i32 to i64
%1374 = llvm.getelementptr %1331[%1372] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1373, %1374 : i64, !llvm.ptr
%1375 = llvm.load %1340 : !llvm.ptr -> i64
%1376 = llvm.getelementptr %1334[%1375] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1343, %1376 : f64, !llvm.ptr
%1377 = llvm.load %1340 : !llvm.ptr -> i64
%1378 = arith.constant 1 : i32
%1380 = arith.extsi %1378 : i32 to i64
%1379 = arith.addi %1377, %1380 : i64
llvm.store %1379, %1340 : i64, !llvm.ptr
%1381 = llvm.load %1348 : !llvm.ptr -> i64
%1382 = arith.constant 1 : i32
%1384 = arith.extsi %1382 : i32 to i64
%1383 = arith.addi %1381, %1384 : i64
llvm.store %1383, %1348 : i64, !llvm.ptr
cf.br ^bb180
^bb182:
%1385 = arith.constant 0 : i32
%1386 = arith.extsi %1385 : i32 to i64
%1387 = llvm.mlir.constant(1 : i64) : i64
%1388 = llvm.alloca %1387 x i64 : (i64) -> !llvm.ptr
llvm.store %1386, %1388 : i64, !llvm.ptr
cf.br ^bb186
^bb186:
%1389 = llvm.load %1388 : !llvm.ptr -> i64
%1390 = arith.cmpi slt, %1389, %1261 : i64
cf.cond_br %1390, ^bb187, ^bb188
^bb187:
%1392 = llvm.load %1388 : !llvm.ptr -> i64
%1393 = arith.constant 2 : i32
%1395 = arith.extsi %1393 : i32 to i64
%1394 = arith.muli %1392, %1395 : i64
%1396 = arith.constant 1 : i32
%1398 = arith.extsi %1396 : i32 to i64
%1397 = arith.addi %1394, %1398 : i64
%1399 = llvm.getelementptr %1262[%1397] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1391 = llvm.load %1399 : !llvm.ptr -> i64
%1400 = llvm.load %1388 : !llvm.ptr -> i64
%1401 = arith.addi %1321, %1400 : i64
%1402 = arith.constant 1.0 : f32
%1403 = arith.negf %1402 : f32
%1404 = llvm.load %1340 : !llvm.ptr -> i64
%1405 = arith.muli %1404, %1322 : i64
%1406 = arith.addi %1405, %1401 : i64
%1407 = arith.extf %1403 : f32 to f64
%1408 = llvm.getelementptr %1327[%1406] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1407, %1408 : f64, !llvm.ptr
%1409 = arith.constant 1.0 : f32
%1410 = arith.negf %1409 : f32
%1411 = llvm.load %1340 : !llvm.ptr -> i64
%1412 = arith.constant 1 : i32
%1414 = arith.extsi %1412 : i32 to i64
%1413 = arith.addi %1411, %1414 : i64
%1415 = arith.muli %1413, %1322 : i64
%1416 = arith.addi %1415, %1401 : i64
%1417 = arith.extf %1410 : f32 to f64
%1418 = llvm.getelementptr %1327[%1416] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1417, %1418 : f64, !llvm.ptr
%1419 = arith.constant 0 : i32
%1420 = arith.extsi %1419 : i32 to i64
llvm.store %1420, %1348 : i64, !llvm.ptr
cf.br ^bb189
^bb189:
%1421 = llvm.load %1348 : !llvm.ptr -> i64
%1422 = arith.cmpi slt, %1421, %1173 : i64
cf.cond_br %1422, ^bb190, ^bb191
^bb190:
%1423 = arith.constant 0 : i32
%1424 = arith.extsi %1423 : i32 to i64
%1425 = llvm.mlir.constant(1 : i64) : i64
%1426 = llvm.alloca %1425 x i64 : (i64) -> !llvm.ptr
llvm.store %1424, %1426 : i64, !llvm.ptr
cf.br ^bb192
^bb192:
%1427 = llvm.load %1426 : !llvm.ptr -> i64
%1428 = arith.cmpi slt, %1427, %arg0 : i64
cf.cond_br %1428, ^bb193, ^bb194
^bb193:
%1429 = arith.constant 0 : i32
%1430 = arith.extsi %1429 : i32 to i64
%1431 = llvm.mlir.constant(1 : i64) : i64
%1432 = llvm.alloca %1431 x i64 : (i64) -> !llvm.ptr
llvm.store %1430, %1432 : i64, !llvm.ptr
%1433 = arith.constant 0 : i32
%1434 = arith.extsi %1433 : i32 to i64
%1435 = llvm.mlir.constant(1 : i64) : i64
%1436 = llvm.alloca %1435 x i64 : (i64) -> !llvm.ptr
llvm.store %1434, %1436 : i64, !llvm.ptr
%1437 = arith.constant 0 : i32
%1438 = arith.extsi %1437 : i32 to i64
%1439 = llvm.mlir.constant(1 : i64) : i64
%1440 = llvm.alloca %1439 x i64 : (i64) -> !llvm.ptr
llvm.store %1438, %1440 : i64, !llvm.ptr
%1441 = arith.constant 0 : i32
%1442 = arith.extsi %1441 : i32 to i64
%1443 = llvm.mlir.constant(1 : i64) : i64
%1444 = llvm.alloca %1443 x i64 : (i64) -> !llvm.ptr
llvm.store %1442, %1444 : i64, !llvm.ptr
cf.br ^bb195
^bb195:
%1445 = llvm.load %1444 : !llvm.ptr -> i64
%1446 = arith.cmpi slt, %1445, %arg0 : i64
cf.cond_br %1446, ^bb196, ^bb197
^bb196:
%1447 = llvm.load %1444 : !llvm.ptr -> i64
%1448 = llvm.load %1426 : !llvm.ptr -> i64
%1449 = arith.cmpi ne, %1447, %1448 : i64
cf.cond_br %1449, ^bb198, ^bb199
^bb198:
%1450 = llvm.load %1440 : !llvm.ptr -> i64
%1451 = arith.constant 0 : i32
%1453 = arith.extsi %1451 : i32 to i64
%1452 = arith.cmpi eq, %1450, %1453 : i64
cf.cond_br %1452, ^bb201, ^bb202
^bb201:
%1455 = llvm.load %1348 : !llvm.ptr -> i64
%1456 = arith.constant 3 : i32
%1458 = arith.extsi %1456 : i32 to i64
%1457 = arith.muli %1455, %1458 : i64
%1459 = llvm.load %1444 : !llvm.ptr -> i64
%1460 = arith.addi %1457, %1459 : i64
%1461 = llvm.getelementptr %1174[%1460] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1454 = llvm.load %1461 : !llvm.ptr -> i64
llvm.store %1454, %1432 : i64, !llvm.ptr
cf.br ^bb203
^bb202:
%1463 = llvm.load %1348 : !llvm.ptr -> i64
%1464 = arith.constant 3 : i32
%1466 = arith.extsi %1464 : i32 to i64
%1465 = arith.muli %1463, %1466 : i64
%1467 = llvm.load %1444 : !llvm.ptr -> i64
%1468 = arith.addi %1465, %1467 : i64
%1469 = llvm.getelementptr %1174[%1468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1462 = llvm.load %1469 : !llvm.ptr -> i64
llvm.store %1462, %1436 : i64, !llvm.ptr
cf.br ^bb203
^bb203:
%1470 = llvm.load %1440 : !llvm.ptr -> i64
%1471 = arith.constant 1 : i32
%1473 = arith.extsi %1471 : i32 to i64
%1472 = arith.addi %1470, %1473 : i64
llvm.store %1472, %1440 : i64, !llvm.ptr
cf.br ^bb200
^bb199:
cf.br ^bb200
^bb200:
%1474 = llvm.load %1444 : !llvm.ptr -> i64
%1475 = arith.constant 1 : i32
%1477 = arith.extsi %1475 : i32 to i64
%1476 = arith.addi %1474, %1477 : i64
llvm.store %1476, %1444 : i64, !llvm.ptr
cf.br ^bb195
^bb197:
%1478 = llvm.load %1432 : !llvm.ptr -> i64
%1479 = llvm.load %1436 : !llvm.ptr -> i64
%1480 = arith.cmpi sgt, %1478, %1479 : i64
cf.cond_br %1480, ^bb204, ^bb205
^bb204:
%1481 = llvm.load %1432 : !llvm.ptr -> i64
%1482 = llvm.load %1436 : !llvm.ptr -> i64
llvm.store %1482, %1432 : i64, !llvm.ptr
llvm.store %1481, %1436 : i64, !llvm.ptr
cf.br ^bb206
^bb205:
cf.br ^bb206
^bb206:
%1483 = llvm.load %1432 : !llvm.ptr -> i64
%1485 = llvm.load %1388 : !llvm.ptr -> i64
%1486 = arith.constant 2 : i32
%1488 = arith.extsi %1486 : i32 to i64
%1487 = arith.muli %1485, %1488 : i64
%1489 = arith.constant 0 : i32
%1491 = arith.extsi %1489 : i32 to i64
%1490 = arith.addi %1487, %1491 : i64
%1492 = llvm.getelementptr %1262[%1490] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1484 = llvm.load %1492 : !llvm.ptr -> i64
%1493 = arith.cmpi eq, %1483, %1484 : i64
%1494 = scf.if %1493 -> (i1) {
%1495 = llvm.load %1436 : !llvm.ptr -> i64
%1497 = llvm.load %1388 : !llvm.ptr -> i64
%1498 = arith.constant 2 : i32
%1500 = arith.extsi %1498 : i32 to i64
%1499 = arith.muli %1497, %1500 : i64
%1501 = arith.constant 1 : i32
%1503 = arith.extsi %1501 : i32 to i64
%1502 = arith.addi %1499, %1503 : i64
%1504 = llvm.getelementptr %1262[%1502] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1496 = llvm.load %1504 : !llvm.ptr -> i64
%1505 = arith.cmpi eq, %1495, %1496 : i64
scf.yield %1505 : i1
} else {
%1506 = arith.constant false
scf.yield %1506 : i1
}
cf.cond_br %1494, ^bb207, ^bb208
^bb207:
%1507 = llvm.load %1348 : !llvm.ptr -> i64
%1508 = arith.muli %1507, %arg0 : i64
%1509 = llvm.load %1426 : !llvm.ptr -> i64
%1510 = arith.addi %1508, %1509 : i64
%1512 = llvm.load %1340 : !llvm.ptr -> i64
%1513 = arith.muli %1512, %1322 : i64
%1514 = arith.addi %1513, %1510 : i64
%1515 = llvm.getelementptr %1327[%1514] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%1511 = llvm.load %1515 : !llvm.ptr -> f64
%1516 = arith.sitofp %1391 : i64 to f64
%1517 = arith.addf %1511, %1516 : f64
%1518 = llvm.load %1340 : !llvm.ptr -> i64
%1519 = arith.muli %1518, %1322 : i64
%1520 = arith.addi %1519, %1510 : i64
%1521 = llvm.getelementptr %1327[%1520] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1517, %1521 : f64, !llvm.ptr
%1523 = llvm.load %1340 : !llvm.ptr -> i64
%1524 = arith.constant 1 : i32
%1526 = arith.extsi %1524 : i32 to i64
%1525 = arith.addi %1523, %1526 : i64
%1527 = arith.muli %1525, %1322 : i64
%1528 = arith.addi %1527, %1510 : i64
%1529 = llvm.getelementptr %1327[%1528] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%1522 = llvm.load %1529 : !llvm.ptr -> f64
%1531 = llvm.load %1348 : !llvm.ptr -> i64
%1532 = arith.constant 3 : i32
%1534 = arith.extsi %1532 : i32 to i64
%1533 = arith.muli %1531, %1534 : i64
%1535 = llvm.load %1426 : !llvm.ptr -> i64
%1536 = arith.addi %1533, %1535 : i64
%1537 = llvm.getelementptr %1174[%1536] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1530 = llvm.load %1537 : !llvm.ptr -> i64
%1538 = arith.sitofp %1530 : i64 to f64
%1539 = arith.addf %1522, %1538 : f64
%1540 = llvm.load %1340 : !llvm.ptr -> i64
%1541 = arith.constant 1 : i32
%1543 = arith.extsi %1541 : i32 to i64
%1542 = arith.addi %1540, %1543 : i64
%1544 = arith.muli %1542, %1322 : i64
%1545 = arith.addi %1544, %1510 : i64
%1546 = llvm.getelementptr %1327[%1545] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1539, %1546 : f64, !llvm.ptr
cf.br ^bb209
^bb208:
cf.br ^bb209
^bb209:
%1547 = llvm.load %1426 : !llvm.ptr -> i64
%1548 = arith.constant 1 : i32
%1550 = arith.extsi %1548 : i32 to i64
%1549 = arith.addi %1547, %1550 : i64
llvm.store %1549, %1426 : i64, !llvm.ptr
cf.br ^bb192
^bb194:
%1551 = llvm.load %1348 : !llvm.ptr -> i64
%1552 = arith.constant 1 : i32
%1554 = arith.extsi %1552 : i32 to i64
%1553 = arith.addi %1551, %1554 : i64
llvm.store %1553, %1348 : i64, !llvm.ptr
cf.br ^bb189
^bb191:
%1555 = arith.constant 60 : i32
%1556 = llvm.load %1340 : !llvm.ptr -> i64
%1557 = arith.extsi %1555 : i32 to i64
%1558 = llvm.getelementptr %1331[%1556] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1557, %1558 : i64, !llvm.ptr
%1559 = arith.constant 0.0 : f32
%1560 = llvm.load %1340 : !llvm.ptr -> i64
%1561 = arith.extf %1559 : f32 to f64
%1562 = llvm.getelementptr %1334[%1560] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1561, %1562 : f64, !llvm.ptr
%1563 = arith.constant 60 : i32
%1564 = llvm.load %1340 : !llvm.ptr -> i64
%1565 = arith.constant 1 : i32
%1567 = arith.extsi %1565 : i32 to i64
%1566 = arith.addi %1564, %1567 : i64
%1568 = arith.extsi %1563 : i32 to i64
%1569 = llvm.getelementptr %1331[%1566] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1568, %1569 : i64, !llvm.ptr
%1570 = arith.constant 0.0 : f32
%1571 = llvm.load %1340 : !llvm.ptr -> i64
%1572 = arith.constant 1 : i32
%1574 = arith.extsi %1572 : i32 to i64
%1573 = arith.addi %1571, %1574 : i64
%1575 = arith.extf %1570 : f32 to f64
%1576 = llvm.getelementptr %1334[%1573] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1575, %1576 : f64, !llvm.ptr
%1577 = llvm.load %1340 : !llvm.ptr -> i64
%1578 = arith.constant 2 : i32
%1580 = arith.extsi %1578 : i32 to i64
%1579 = arith.addi %1577, %1580 : i64
llvm.store %1579, %1340 : i64, !llvm.ptr
%1581 = llvm.load %1388 : !llvm.ptr -> i64
%1582 = arith.constant 1 : i32
%1584 = arith.extsi %1582 : i32 to i64
%1583 = arith.addi %1581, %1584 : i64
llvm.store %1583, %1388 : i64, !llvm.ptr
cf.br ^bb186
^bb188:
%1586 = arith.constant 8 : i32
%1587 = arith.extsi %1586 : i32 to i64
%1585 = func.call @calloc(%1322, %1587) : (i64, i64) -> !llvm.ptr
%1588 = arith.constant 0 : i32
%1589 = arith.extsi %1588 : i32 to i64
%1590 = llvm.mlir.constant(1 : i64) : i64
%1591 = llvm.alloca %1590 x i64 : (i64) -> !llvm.ptr
llvm.store %1589, %1591 : i64, !llvm.ptr
cf.br ^bb210
^bb210:
%1592 = llvm.load %1591 : !llvm.ptr -> i64
%1593 = arith.cmpi slt, %1592, %1261 : i64
cf.cond_br %1593, ^bb211, ^bb212
^bb211:
%1594 = arith.constant 1.0 : f32
%1595 = llvm.load %1591 : !llvm.ptr -> i64
%1596 = arith.addi %1321, %1595 : i64
%1597 = arith.extf %1594 : f32 to f64
%1598 = llvm.getelementptr %1585[%1596] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %1597, %1598 : f64, !llvm.ptr
%1599 = llvm.load %1591 : !llvm.ptr -> i64
%1600 = arith.constant 1 : i32
%1602 = arith.extsi %1600 : i32 to i64
%1601 = arith.addi %1599, %1602 : i64
llvm.store %1601, %1591 : i64, !llvm.ptr
cf.br ^bb210
^bb212:
%1603 = func.call @solve_lp(%1322, %1327, %1331, %1334, %1326, %1585) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr) -> f64
func.call @free(%1327) : (!llvm.ptr) -> ()
func.call @free(%1331) : (!llvm.ptr) -> ()
func.call @free(%1334) : (!llvm.ptr) -> ()
func.call @free(%1585) : (!llvm.ptr) -> ()
func.call @free(%1174) : (!llvm.ptr) -> ()
func.call @free(%1262) : (!llvm.ptr) -> ()
func.return %1603 : f64
}
func.func @main() -> i32 {
%1610 = llvm.mlir.addressof @str_0 : !llvm.ptr
%1612 = arith.constant 3 : i32
%1613 = arith.extsi %1612 : i32 to i64
%1611 = func.call @build_and_solve(%1613) : (i64) -> f64
%1614 = llvm.call @printf(%1610, %1611) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
%1615 = arith.constant 0 : i32
func.return %1615 : i32
}
}