Problem 361
Sum of A(10^k) for k=1..18, mod 10^9 (Thue-Morse factors).
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(2^n) | O(n log n) |
| Space complexity | O(n^2) | O(n) |
| Approach | Flow solution | Modular DP or matrix exponentiation |
| Verdict | Suboptimal |
Flow source
# Project Euler 361
# Sum of A(10^k) for k=1..18, mod 10^9 (Thue-Morse factors).
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function modpow(base: i64, exp: i64, mod: i64) -> i64 {
let mut r: i64 = 1
let mut b: i64 = base % mod
let mut e: i64 = exp
while e > 0 {
if (e & 1) == 1 { r = (r * b) % mod }
b = (b * b) % mod
e = e / 2
}
return r
}
function hget(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64) -> i64 {
let mut slot: i64 = key
if slot < 0 { slot = 0 - slot }
slot = slot & (cap - 1)
while used[slot] != 0 {
if keys[slot] == key { return vals[slot] }
slot = (slot + 1) & (cap - 1)
}
return 0 - 1
}
function hput(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64, val: i64) -> void {
let mut slot: i64 = key
if slot < 0 { slot = 0 - slot }
slot = slot & (cap - 1)
while used[slot] != 0 && keys[slot] != key {
slot = (slot + 1) & (cap - 1)
}
used[slot] = 1
keys[slot] = key
vals[slot] = val
}
function count_start1(length: i64, keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64) -> i64 {
if length == 1 { return 1 }
if length == 2 { return 2 }
if length == 3 { return 3 }
let hit: i64 = hget(keys, vals, used, cap, length)
if hit >= 0 { return hit }
let mut res: i64 = 0
if (length % 2) == 0 {
let half: i64 = length / 2
res = count_start1(half, keys, vals, used, cap) + count_start1(half + 1, keys, vals, used, cap)
} else {
let half: i64 = length / 2
res = 2 * count_start1(half + 1, keys, vals, used, cap)
}
hput(keys, vals, used, cap, length, res)
return res
}
function count_prefix(length: i64, ck: ptr<i64>, cv: ptr<i64>, cu: ptr<i8>, cc: i64,
pk: ptr<i64>, pv: ptr<i64>, pu: ptr<i8>, pc: i64) -> i64 {
if length == 0 { return 0 }
if length == 1 { return 1 }
if length == 2 { return 3 }
if length == 3 { return 6 }
let hit: i64 = hget(pk, pv, pu, pc, length)
if hit >= 0 { return hit }
let mut res: i64 = 0
if (length % 2) == 0 {
let half: i64 = length / 2
res = 3 * count_prefix(half, ck, cv, cu, cc, pk, pv, pu, pc) + count_prefix(half + 1, ck, cv, cu, cc, pk, pv, pu, pc) - 4
} else {
let half: i64 = length / 2
res = count_prefix(2 * half, ck, cv, cu, cc, pk, pv, pu, pc) + 2 * count_start1(half + 1, ck, cv, cu, cc)
}
hput(pk, pv, pu, pc, length, res)
return res
}
function find_length(index: i64, ck: ptr<i64>, cv: ptr<i64>, cu: ptr<i8>, cc: i64,
pk: ptr<i64>, pv: ptr<i64>, pu: ptr<i8>, pc: i64) -> i64 {
let mut lo: i64 = 1
let mut hi: i64 = 1
while count_prefix(hi, ck, cv, cu, cc, pk, pv, pu, pc) < index {
hi = hi * 2
}
while lo < hi {
let mid: i64 = (lo + hi) / 2
if count_prefix(mid, ck, cv, cu, cc, pk, pv, pu, pc) >= index {
hi = mid
} else {
lo = mid + 1
}
}
return lo
}
function geom_sum(base: i64, count: i64, mod: i64, gk: ptr<i64>, gv: ptr<i64>, gu: ptr<i8>, gc: i64) -> i64 {
if count == 0 { return 0 }
if count == 1 { return 1 }
let key: i64 = base * 1000000007 + count
let hit: i64 = hget(gk, gv, gu, gc, key)
if hit >= 0 { return hit }
let mut res: i64 = 0
if (count % 2) == 0 {
let half: i64 = geom_sum(base, count / 2, mod, gk, gv, gu, gc)
res = (half + modpow(base, count / 2, mod) * half) % mod
} else {
res = (geom_sum(base, count - 1, mod, gk, gv, gu, gc) + modpow(base, count - 1, mod)) % mod
}
hput(gk, gv, gu, gc, key, res)
return res
}
function pow_x(k: i64, exp: i64, mod: i64, xpow: ptr<i64>, pk: ptr<i64>, pv: ptr<i64>, pu: ptr<i8>, pc: i64) -> i64 {
let key: i64 = k * 1000000007 + exp
let hit: i64 = hget(pk, pv, pu, pc, key)
if hit >= 0 { return hit }
let val: i64 = modpow(xpow[k], exp, mod)
hput(pk, pv, pu, pc, key, val)
return val
}
# Arena node helpers. kind: 0=empty/lit-empty, 1=lit, 2=comp, 3=even, 4=odd
# ncount stored at nc[0]
function new_lit(val: i64, len: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>) -> i64 {
let id: i64 = nc[0]
nc[0] = id + 1
kind[id] = 1
child[id] = 0
length[id] = len as i32
litval[id] = val as i8
return id
}
function new_comp(ch: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>) -> i64 {
if length[ch] == 0 { return ch }
let id: i64 = nc[0]
nc[0] = id + 1
kind[id] = 2
child[id] = ch as i32
length[id] = length[ch]
litval[id] = 0
return id
}
function new_even(ch: i64, len: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>) -> i64 {
let id: i64 = nc[0]
nc[0] = id + 1
kind[id] = 3
child[id] = ch as i32
length[id] = len as i32
litval[id] = 0
return id
}
function new_odd(ch: i64, len: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>) -> i64 {
let id: i64 = nc[0]
nc[0] = id + 1
kind[id] = 4
child[id] = ch as i32
length[id] = len as i32
litval[id] = 0
return id
}
function first_bit(id: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>,
fc: ptr<i8>, fv: ptr<i8>) -> i64 {
if fc[id] != 0 { return fv[id] as i64 }
let mut val: i64 = 0
let k: i64 = kind[id] as i64
if k == 1 {
let len: i64 = length[id] as i64
val = ((litval[id] as i64) >> (len - 1)) & 1
} elif k == 2 {
val = 1 - first_bit(child[id] as i64, kind, child, length, litval, fc, fv)
} elif k == 3 {
val = first_bit(child[id] as i64, kind, child, length, litval, fc, fv)
} else {
val = 1 - first_bit(child[id] as i64, kind, child, length, litval, fc, fv)
}
fc[id] = 1
fv[id] = val as i8
return val
}
function last_bit(id: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>,
lc: ptr<i8>, lv: ptr<i8>, fc: ptr<i8>, fv: ptr<i8>) -> i64 {
if lc[id] != 0 { return lv[id] as i64 }
let mut val: i64 = 0
let k: i64 = kind[id] as i64
let len: i64 = length[id] as i64
if k == 1 {
val = (litval[id] as i64) & 1
} elif k == 2 {
val = 1 - last_bit(child[id] as i64, kind, child, length, litval, lc, lv, fc, fv)
} elif k == 3 {
let ch: i64 = child[id] as i64
if (len % 2) == 0 {
val = 1 - last_bit(ch, kind, child, length, litval, lc, lv, fc, fv)
} else {
val = last_bit(ch, kind, child, length, litval, lc, lv, fc, fv)
}
} else {
let ch: i64 = child[id] as i64
if (len % 2) == 0 {
val = last_bit(ch, kind, child, length, litval, lc, lv, fc, fv)
} else {
val = 1 - last_bit(ch, kind, child, length, litval, lc, lv, fc, fv)
}
}
lc[id] = 1
lv[id] = val as i8
return val
}
function drop_first(id: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>,
df: ptr<i32>, fc: ptr<i8>, fv: ptr<i8>, lc: ptr<i8>, lv: ptr<i8>) -> i64 {
let len: i64 = length[id] as i64
if len == 0 { return id }
if len == 1 { return 0 }
if df[id] >= 0 { return df[id] as i64 }
let mut res: i64 = 0
let k: i64 = kind[id] as i64
if k == 1 {
let v: i64 = litval[id] as i64
# drop high bit
let mask: i64 = (1 << (len - 1)) - 1
res = new_lit(v & mask, len - 1, kind, child, length, litval, nc)
} elif k == 2 {
res = new_comp(drop_first(child[id] as i64, kind, child, length, litval, nc, df, fc, fv, lc, lv), kind, child, length, litval, nc)
} elif k == 3 {
res = new_odd(child[id] as i64, len - 1, kind, child, length, litval, nc)
} else {
res = new_even(drop_first(child[id] as i64, kind, child, length, litval, nc, df, fc, fv, lc, lv), len - 1, kind, child, length, litval, nc)
}
df[id] = res as i32
return res
}
function drop_last(id: i64, kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>,
dl: ptr<i32>, df: ptr<i32>, fc: ptr<i8>, fv: ptr<i8>, lc: ptr<i8>, lv: ptr<i8>) -> i64 {
let len: i64 = length[id] as i64
if len == 0 { return id }
if len == 1 { return 0 }
if dl[id] >= 0 { return dl[id] as i64 }
let mut res: i64 = 0
let k: i64 = kind[id] as i64
if k == 1 {
let v: i64 = litval[id] as i64
res = new_lit(v >> 1, len - 1, kind, child, length, litval, nc)
} elif k == 2 {
res = new_comp(drop_last(child[id] as i64, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv), kind, child, length, litval, nc)
} elif k == 3 {
let ch: i64 = child[id] as i64
if (len % 2) == 0 {
res = new_even(ch, len - 1, kind, child, length, litval, nc)
} else {
res = new_even(drop_last(ch, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv), len - 1, kind, child, length, litval, nc)
}
} else {
let ch: i64 = child[id] as i64
if (len % 2) == 0 {
res = new_odd(drop_last(ch, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv), len - 1, kind, child, length, litval, nc)
} else {
res = new_odd(ch, len - 1, kind, child, length, litval, nc)
}
}
dl[id] = res as i32
return res
}
function evals_node(id: i64, KLEN: i64, MOD: i64, xpow: ptr<i64>,
kind: ptr<i8>, child: ptr<i32>, length: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>,
df: ptr<i32>, dl: ptr<i32>, fc: ptr<i8>, fv: ptr<i8>, lc: ptr<i8>, lv: ptr<i8>,
ev: ptr<i32>, eok: ptr<i8>, mu: ptr<i32>, mok: ptr<i8>,
gk: ptr<i64>, gv: ptr<i64>, gu: ptr<i8>, gc: i64,
pk: ptr<i64>, pv: ptr<i64>, pu: ptr<i8>, pc: i64) -> void {
if eok[id] != 0 { return }
let len: i64 = length[id] as i64
let knd: i64 = kind[id] as i64
if len == 0 {
let mut t: i64 = 0
while t < KLEN {
ev[id * KLEN + t] = 0
t = t + 1
}
eok[id] = 1
return
}
if knd == 1 {
let mut t: i64 = 0
while t < KLEN {
let mut val: i64 = 0
let mut b: i64 = len - 1
while b >= 0 {
let bit: i64 = ((litval[id] as i64) >> b) & 1
val = (val * xpow[t] + bit) % MOD
b = b - 1
}
ev[id * KLEN + t] = val as i32
t = t + 1
}
} elif knd == 2 {
let ch: i64 = child[id] as i64
evals_node(ch, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc)
let mut t: i64 = 0
while t < KLEN {
let total: i64 = geom_sum(xpow[t], len, MOD, gk, gv, gu, gc)
let cv: i64 = ev[ch * KLEN + t] as i64
ev[id * KLEN + t] = ((((total - cv) % MOD + MOD) % MOD) as i32)
t = t + 1
}
} elif knd == 3 {
let ch: i64 = child[id] as i64
if (len % 2) == 0 {
let len_u: i64 = len / 2
evals_node(ch, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc)
let mut t: i64 = 0
while t < KLEN {
let mut val: i64 = 0
if t + 1 < KLEN {
let cv: i64 = ev[ch * KLEN + (t + 1)] as i64
val = ((xpow[t] - 1) * cv + geom_sum((xpow[t] * xpow[t]) % MOD, len_u, MOD, gk, gv, gu, gc)) % MOD
if val < 0 { val = val + MOD }
}
ev[id * KLEN + t] = val as i32
t = t + 1
}
} else {
let up: i64 = drop_last(ch, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv)
let u_last: i64 = last_bit(ch, kind, child, length, litval, lc, lv, fc, fv)
# mu_evals(up)
evals_node(up, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc)
if mok[up] == 0 {
let mut t: i64 = 0
while t < KLEN {
let mut val: i64 = 0
if t + 1 < KLEN {
let base: i64 = ev[up * KLEN + (t + 1)] as i64
val = ((xpow[t] - 1) * base + geom_sum((xpow[t] * xpow[t]) % MOD, length[up] as i64, MOD, gk, gv, gu, gc)) % MOD
if val < 0 { val = val + MOD }
}
mu[up * KLEN + t] = val as i32
t = t + 1
}
mok[up] = 1
}
let mut t: i64 = 0
while t < KLEN {
let mv: i64 = mu[up * KLEN + t] as i64
ev[id * KLEN + t] = ((mv * xpow[t] + u_last) % MOD) as i32
t = t + 1
}
}
} else {
# odd
let ch: i64 = child[id] as i64
let half: i64 = len / 2
let u_first: i64 = first_bit(ch, kind, child, length, litval, fc, fv)
let u_last: i64 = last_bit(ch, kind, child, length, litval, lc, lv, fc, fv)
if (len % 2) == 1 {
let u_tail: i64 = drop_first(ch, kind, child, length, litval, nc, df, fc, fv, lc, lv)
evals_node(u_tail, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc)
if mok[u_tail] == 0 {
let mut t: i64 = 0
while t < KLEN {
let mut val: i64 = 0
if t + 1 < KLEN {
let base: i64 = ev[u_tail * KLEN + (t + 1)] as i64
val = ((xpow[t] - 1) * base + geom_sum((xpow[t] * xpow[t]) % MOD, length[u_tail] as i64, MOD, gk, gv, gu, gc)) % MOD
if val < 0 { val = val + MOD }
}
mu[u_tail * KLEN + t] = val as i32
t = t + 1
}
mok[u_tail] = 1
}
let mut t: i64 = 0
while t < KLEN {
let mv: i64 = mu[u_tail * KLEN + t] as i64
ev[id * KLEN + t] = (((1 - u_first) * pow_x(t, 2 * half, MOD, xpow, pk, pv, pu, pc) + mv) % MOD) as i32
t = t + 1
}
} else {
let mid: i64 = drop_last(drop_first(ch, kind, child, length, litval, nc, df, fc, fv, lc, lv), kind, child, length, litval, nc, dl, df, fc, fv, lc, lv)
evals_node(mid, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc)
if mok[mid] == 0 {
let mut t: i64 = 0
while t < KLEN {
let mut val: i64 = 0
if t + 1 < KLEN {
let base: i64 = ev[mid * KLEN + (t + 1)] as i64
val = ((xpow[t] - 1) * base + geom_sum((xpow[t] * xpow[t]) % MOD, length[mid] as i64, MOD, gk, gv, gu, gc)) % MOD
if val < 0 { val = val + MOD }
}
mu[mid * KLEN + t] = val as i32
t = t + 1
}
mok[mid] = 1
}
let mut t: i64 = 0
while t < KLEN {
let mv: i64 = mu[mid * KLEN + t] as i64
ev[id * KLEN + t] = (((1 - u_first) * pow_x(t, 2 * half - 1, MOD, xpow, pk, pv, pu, pc) + mv * xpow[t] + u_last) % MOD) as i32
t = t + 1
}
}
}
eok[id] = 1
}
function kth_word(length: i64, rank: i64, start_bit: i64,
ck: ptr<i64>, cv: ptr<i64>, cu: ptr<i8>, cc: i64,
kind: ptr<i8>, child: ptr<i32>, lengtha: ptr<i32>, litval: ptr<i8>, nc: ptr<i64>) -> i64 {
if start_bit == 0 {
let total: i64 = count_start1(length, ck, cv, cu, cc)
return new_comp(kth_word(length, total - 1 - rank, 1, ck, cv, cu, cc, kind, child, lengtha, litval, nc), kind, child, lengtha, litval, nc)
}
if length <= 3 {
# PRE_WORDS
if length == 1 { return new_lit(1, 1, kind, child, lengtha, litval, nc) }
if length == 2 {
if rank == 0 { return new_lit(2, 2, kind, child, lengtha, litval, nc) } # 10
return new_lit(3, 2, kind, child, lengtha, litval, nc) # 11
}
# length 3: 100,101,110
if rank == 0 { return new_lit(4, 3, kind, child, lengtha, litval, nc) }
if rank == 1 { return new_lit(5, 3, kind, child, lengtha, litval, nc) }
return new_lit(6, 3, kind, child, lengtha, litval, nc)
}
let half_even: i64 = (length + 1) / 2
let count_even: i64 = count_start1(half_even, ck, cv, cu, cc)
if rank < count_even {
let ch: i64 = kth_word(half_even, rank, 1, ck, cv, cu, cc, kind, child, lengtha, litval, nc)
return new_even(ch, length, kind, child, lengtha, litval, nc)
}
let half_odd: i64 = length / 2 + 1
let ch: i64 = kth_word(half_odd, rank - count_even, 0, ck, cv, cu, cc, kind, child, lengtha, litval, nc)
return new_odd(ch, length, kind, child, lengtha, litval, nc)
}
function main() -> i32 {
let MOD: i64 = 1000000000
let CAP: i64 = 1 << 20
let ck: ptr<i64> = calloc(CAP, 8)
let cv: ptr<i64> = calloc(CAP, 8)
let cu: ptr<i8> = calloc(CAP, 1)
let pk: ptr<i64> = calloc(CAP, 8)
let pv: ptr<i64> = calloc(CAP, 8)
let pu: ptr<i8> = calloc(CAP, 1)
let mut max_len: i64 = 0
let mut ten: i64 = 10
let mut k: i64 = 1
while k <= 18 {
let L: i64 = find_length(ten, ck, cv, cu, CAP, pk, pv, pu, CAP)
if L > max_len { max_len = L }
if k < 18 { ten = ten * 10 }
k = k + 1
}
let mut depth: i64 = 0
let mut ll: i64 = max_len
while ll > 3 {
ll = ll / 2 + 1
depth = depth + 1
}
let KMAX: i64 = depth + 2
let KLEN: i64 = KMAX + 2
let xpow: ptr<i64> = calloc(KLEN, 8)
let mut t: i64 = 0
while t < KLEN {
let mut e: i64 = 1
let mut i: i64 = 0
while i < t {
e = e * 2
i = i + 1
}
xpow[t] = modpow(2, e, MOD)
t = t + 1
}
let AMAX: i64 = 50000
let kind: ptr<i8> = calloc(AMAX, 1)
let child: ptr<i32> = calloc(AMAX, 4)
let lengtha: ptr<i32> = calloc(AMAX, 4)
let litval: ptr<i8> = calloc(AMAX, 1)
let nc: ptr<i64> = calloc(1, 8)
nc[0] = 1
lengtha[0] = 0
kind[0] = 1
litval[0] = 0
let df: ptr<i32> = calloc(AMAX, 4)
let dl: ptr<i32> = calloc(AMAX, 4)
let fc: ptr<i8> = calloc(AMAX, 1)
let fv: ptr<i8> = calloc(AMAX, 1)
let lc: ptr<i8> = calloc(AMAX, 1)
let lv: ptr<i8> = calloc(AMAX, 1)
let mut i: i64 = 0
while i < AMAX {
df[i] = -1
dl[i] = -1
i = i + 1
}
let ev: ptr<i32> = calloc(AMAX * KLEN, 4)
let eok: ptr<i8> = calloc(AMAX, 1)
let mu: ptr<i32> = calloc(AMAX * KLEN, 4)
let mok: ptr<i8> = calloc(AMAX, 1)
let GCAP: i64 = 1 << 18
let gk: ptr<i64> = calloc(GCAP, 8)
let gv: ptr<i64> = calloc(GCAP, 8)
let gu: ptr<i8> = calloc(GCAP, 1)
let p2k: ptr<i64> = calloc(GCAP, 8)
let p2v: ptr<i64> = calloc(GCAP, 8)
let p2u: ptr<i8> = calloc(GCAP, 1)
let mut total: i64 = 0
ten = 10
k = 1
while k <= 18 {
let index: i64 = ten
let length: i64 = find_length(index, ck, cv, cu, CAP, pk, pv, pu, CAP)
let rank: i64 = index - 1 - count_prefix(length - 1, ck, cv, cu, CAP, pk, pv, pu, CAP)
let node: i64 = kth_word(length, rank, 1, ck, cv, cu, CAP, kind, child, lengtha, litval, nc)
evals_node(node, KLEN, MOD, xpow, kind, child, lengtha, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, GCAP, p2k, p2v, p2u, GCAP)
let aval: i64 = ev[node * KLEN + 0] as i64
total = (total + aval) % MOD
if k < 18 { ten = ten * 10 }
k = k + 1
}
printf("%lld\n", total)
return 0
}
Generated C
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
while (flow_temp_head) {
flow_temp_node* n = flow_temp_head;
flow_temp_head = n->next;
free(n);
}
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
if (!node) return NULL;
node->next = flow_temp_head;
flow_temp_head = node;
if (!flow_temp_atexit_set) {
flow_temp_atexit_set = 1;
atexit(flow_temp_free_all);
}
return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
char* r = (char*)flow_temp_alloc(la + lb + 1);
if (!r) return NULL;
if (la) memcpy(r, a, la);
if (lb) memcpy(r + la, b, lb);
r[la + lb] = '\0';
return r;
}
#define __flow_in_arr(arr, val) __extension__ ({ \
int _found = 0; \
size_t _n = sizeof(arr)/sizeof((arr)[0]); \
for (size_t _i = 0; _i < _n; _i++) { \
if ((arr)[_i] == (val)) { _found = 1; break; } \
} _found; })
/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
abort();
#if defined(__GNUC__) || defined(__clang__)
__builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")
#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#include <math.h>
void* _ui_state = NULL;
static inline float i32_to_f32(int32_t v) { return (float)v; }
/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }
int64_t modpow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key);
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val);
int64_t count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t length, int64_t* keys, int64_t* vals, int8_t* used, int64_t cap);
int64_t count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t length, int64_t* ck, int64_t* cv, int8_t* cu, int64_t cc, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc);
int64_t find_length_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t index, int64_t* ck, int64_t* cv, int8_t* cu, int64_t cc, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc);
int64_t geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t base, int64_t count, int64_t mod, int64_t* gk, int64_t* gv, int8_t* gu, int64_t gc);
int64_t pow_x_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t k, int64_t exp, int64_t mod, int64_t* xpow, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc);
int64_t new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t val, int64_t len, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc);
int64_t new_comp_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t ch, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc);
int64_t new_even_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t ch, int64_t len, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc);
int64_t new_odd_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t ch, int64_t len, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc);
int64_t first_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int8_t* fc, int8_t* fv);
int64_t last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int8_t* lc, int8_t* lv, int8_t* fc, int8_t* fv);
int64_t drop_first_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc, int32_t* df, int8_t* fc, int8_t* fv, int8_t* lc, int8_t* lv);
int64_t drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc, int32_t* dl, int32_t* df, int8_t* fc, int8_t* fv, int8_t* lc, int8_t* lv);
void evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t id, int64_t KLEN, int64_t MOD, int64_t* xpow, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc, int32_t* df, int32_t* dl, int8_t* fc, int8_t* fv, int8_t* lc, int8_t* lv, int32_t* ev, int8_t* eok, int32_t* mu, int8_t* mok, int64_t* gk, int64_t* gv, int8_t* gu, int64_t gc, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc);
int64_t kth_word_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t length, int64_t rank, int64_t start_bit, int64_t* ck, int64_t* cv, int8_t* cu, int64_t cc, int8_t* kind, int32_t* child, int32_t* lengtha, int8_t* litval, int64_t* nc);
int32_t main(void);
int64_t modpow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
int64_t r = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
int64_t e = exp;
while (e > 0) {
if ((e & 1) == 1) {
r = FLOW_CHECKED_MOD(((r * b)), (mod));
}
b = FLOW_CHECKED_MOD(((b * b)), (mod));
e = FLOW_CHECKED_DIV((e), (2));
}
return r;
}
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key) {
int64_t slot = key;
if (slot < 0) {
slot = (0 - slot);
}
slot = (slot & (cap - 1));
while (used[slot] != 0) {
if (keys[slot] == key) {
return vals[slot];
}
slot = ((slot + 1) & (cap - 1));
}
return (0 - 1);
}
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val) {
int64_t slot = key;
if (slot < 0) {
slot = (0 - slot);
}
slot = (slot & (cap - 1));
while ((used[slot] != 0 && keys[slot] != key)) {
slot = ((slot + 1) & (cap - 1));
}
used[slot] = 1;
keys[slot] = key;
vals[slot] = val;
}
int64_t count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t length, int64_t* keys, int64_t* vals, int8_t* used, int64_t cap) {
if (length == 1) {
return 1;
}
if (length == 2) {
return 2;
}
if (length == 3) {
return 3;
}
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(keys, vals, used, cap, length);
if (hit >= 0) {
return hit;
}
int64_t res = 0;
if (FLOW_CHECKED_MOD((length), (2)) == 0) {
int64_t half = FLOW_CHECKED_DIV((length), (2));
res = (count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64(half, keys, vals, used, cap) + count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64((half + 1), keys, vals, used, cap));
} else {
int64_t half = FLOW_CHECKED_DIV((length), (2));
res = (2 * count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64((half + 1), keys, vals, used, cap));
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(keys, vals, used, cap, length, res);
return res;
}
int64_t count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t length, int64_t* ck, int64_t* cv, int8_t* cu, int64_t cc, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc) {
if (length == 0) {
return 0;
}
if (length == 1) {
return 1;
}
if (length == 2) {
return 3;
}
if (length == 3) {
return 6;
}
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(pk, pv, pu, pc, length);
if (hit >= 0) {
return hit;
}
int64_t res = 0;
if (FLOW_CHECKED_MOD((length), (2)) == 0) {
int64_t half = FLOW_CHECKED_DIV((length), (2));
res = (((3 * count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(half, ck, cv, cu, cc, pk, pv, pu, pc)) + count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64((half + 1), ck, cv, cu, cc, pk, pv, pu, pc)) - 4);
} else {
int64_t half = FLOW_CHECKED_DIV((length), (2));
res = (count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64((2 * half), ck, cv, cu, cc, pk, pv, pu, pc) + (2 * count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64((half + 1), ck, cv, cu, cc)));
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(pk, pv, pu, pc, length, res);
return res;
}
int64_t find_length_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t index, int64_t* ck, int64_t* cv, int8_t* cu, int64_t cc, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc) {
int64_t lo = 1;
int64_t hi = 1;
while (count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(hi, ck, cv, cu, cc, pk, pv, pu, pc) < index) {
hi = (hi * 2);
}
while (lo < hi) {
int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
if (count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(mid, ck, cv, cu, cc, pk, pv, pu, pc) >= index) {
hi = mid;
} else {
lo = (mid + 1);
}
}
return lo;
}
int64_t geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t base, int64_t count, int64_t mod, int64_t* gk, int64_t* gv, int8_t* gu, int64_t gc) {
if (count == 0) {
return 0;
}
if (count == 1) {
return 1;
}
int64_t key = ((base * 1000000007) + count);
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(gk, gv, gu, gc, key);
if (hit >= 0) {
return hit;
}
int64_t res = 0;
if (FLOW_CHECKED_MOD((count), (2)) == 0) {
int64_t half = geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(base, FLOW_CHECKED_DIV((count), (2)), mod, gk, gv, gu, gc);
res = FLOW_CHECKED_MOD(((half + (modpow_i64_i64_i64(base, FLOW_CHECKED_DIV((count), (2)), mod) * half))), (mod));
} else {
res = FLOW_CHECKED_MOD(((geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(base, (count - 1), mod, gk, gv, gu, gc) + modpow_i64_i64_i64(base, (count - 1), mod))), (mod));
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(gk, gv, gu, gc, key, res);
return res;
}
int64_t pow_x_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t k, int64_t exp, int64_t mod, int64_t* xpow, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc) {
int64_t key = ((k * 1000000007) + exp);
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(pk, pv, pu, pc, key);
if (hit >= 0) {
return hit;
}
int64_t val = modpow_i64_i64_i64(xpow[k], exp, mod);
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(pk, pv, pu, pc, key, val);
return val;
}
int64_t new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t val, int64_t len, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc) {
int64_t id = nc[0];
nc[0] = (id + 1);
kind[id] = 1;
child[id] = 0;
length[id] = ((int32_t)(len));
litval[id] = ((int8_t)(val));
return id;
}
int64_t new_comp_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t ch, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc) {
if (length[ch] == 0) {
return ch;
}
int64_t id = nc[0];
nc[0] = (id + 1);
kind[id] = 2;
child[id] = ((int32_t)(ch));
length[id] = length[ch];
litval[id] = 0;
return id;
}
int64_t new_even_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t ch, int64_t len, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc) {
int64_t id = nc[0];
nc[0] = (id + 1);
kind[id] = 3;
child[id] = ((int32_t)(ch));
length[id] = ((int32_t)(len));
litval[id] = 0;
return id;
}
int64_t new_odd_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t ch, int64_t len, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc) {
int64_t id = nc[0];
nc[0] = (id + 1);
kind[id] = 4;
child[id] = ((int32_t)(ch));
length[id] = ((int32_t)(len));
litval[id] = 0;
return id;
}
int64_t first_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int8_t* fc, int8_t* fv) {
if (fc[id] != 0) {
return ((int64_t)(fv[id]));
}
int64_t val = 0;
int64_t k = ((int64_t)(kind[id]));
if (k == 1) {
int64_t len = ((int64_t)(length[id]));
val = (FLOW_CHECKED_SHR((((int64_t)(litval[id]))), ((len - 1))) & 1);
} else if (k == 2) {
val = (1 - first_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, fc, fv));
} else if (k == 3) {
val = first_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, fc, fv);
} else {
val = (1 - first_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, fc, fv));
}
fc[id] = 1;
fv[id] = ((int8_t)(val));
return val;
}
int64_t last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int8_t* lc, int8_t* lv, int8_t* fc, int8_t* fv) {
if (lc[id] != 0) {
return ((int64_t)(lv[id]));
}
int64_t val = 0;
int64_t k = ((int64_t)(kind[id]));
int64_t len = ((int64_t)(length[id]));
if (k == 1) {
val = (((int64_t)(litval[id])) & 1);
} else if (k == 2) {
val = (1 - last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, lc, lv, fc, fv));
} else if (k == 3) {
int64_t ch = ((int64_t)(child[id]));
if (FLOW_CHECKED_MOD((len), (2)) == 0) {
val = (1 - last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, lc, lv, fc, fv));
} else {
val = last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, lc, lv, fc, fv);
}
} else {
int64_t ch = ((int64_t)(child[id]));
if (FLOW_CHECKED_MOD((len), (2)) == 0) {
val = last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, lc, lv, fc, fv);
} else {
val = (1 - last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, lc, lv, fc, fv));
}
}
lc[id] = 1;
lv[id] = ((int8_t)(val));
return val;
}
int64_t drop_first_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc, int32_t* df, int8_t* fc, int8_t* fv, int8_t* lc, int8_t* lv) {
int64_t len = ((int64_t)(length[id]));
if (len == 0) {
return id;
}
if (len == 1) {
return 0;
}
if (df[id] >= 0) {
return ((int64_t)(df[id]));
}
int64_t res = 0;
int64_t k = ((int64_t)(kind[id]));
if (k == 1) {
int64_t v = ((int64_t)(litval[id]));
int64_t mask = (FLOW_CHECKED_SHL((1), ((len - 1))) - 1);
res = new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64((v & mask), (len - 1), kind, child, length, litval, nc);
} else if (k == 2) {
res = new_comp_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(drop_first_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, nc, df, fc, fv, lc, lv), kind, child, length, litval, nc);
} else if (k == 3) {
res = new_odd_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(((int64_t)(child[id])), (len - 1), kind, child, length, litval, nc);
} else {
res = new_even_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(drop_first_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, nc, df, fc, fv, lc, lv), (len - 1), kind, child, length, litval, nc);
}
df[id] = ((int32_t)(res));
return res;
}
int64_t drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(int64_t id, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc, int32_t* dl, int32_t* df, int8_t* fc, int8_t* fv, int8_t* lc, int8_t* lv) {
int64_t len = ((int64_t)(length[id]));
if (len == 0) {
return id;
}
if (len == 1) {
return 0;
}
if (dl[id] >= 0) {
return ((int64_t)(dl[id]));
}
int64_t res = 0;
int64_t k = ((int64_t)(kind[id]));
if (k == 1) {
int64_t v = ((int64_t)(litval[id]));
res = new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(FLOW_CHECKED_SHR((v), (1)), (len - 1), kind, child, length, litval, nc);
} else if (k == 2) {
res = new_comp_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(((int64_t)(child[id])), kind, child, length, litval, nc, dl, df, fc, fv, lc, lv), kind, child, length, litval, nc);
} else if (k == 3) {
int64_t ch = ((int64_t)(child[id]));
if (FLOW_CHECKED_MOD((len), (2)) == 0) {
res = new_even_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(ch, (len - 1), kind, child, length, litval, nc);
} else {
res = new_even_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv), (len - 1), kind, child, length, litval, nc);
}
} else {
int64_t ch = ((int64_t)(child[id]));
if (FLOW_CHECKED_MOD((len), (2)) == 0) {
res = new_odd_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv), (len - 1), kind, child, length, litval, nc);
} else {
res = new_odd_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(ch, (len - 1), kind, child, length, litval, nc);
}
}
dl[id] = ((int32_t)(res));
return res;
}
void evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t id, int64_t KLEN, int64_t MOD, int64_t* xpow, int8_t* kind, int32_t* child, int32_t* length, int8_t* litval, int64_t* nc, int32_t* df, int32_t* dl, int8_t* fc, int8_t* fv, int8_t* lc, int8_t* lv, int32_t* ev, int8_t* eok, int32_t* mu, int8_t* mok, int64_t* gk, int64_t* gv, int8_t* gu, int64_t gc, int64_t* pk, int64_t* pv, int8_t* pu, int64_t pc) {
if (eok[id] != 0) {
return;
}
int64_t len = ((int64_t)(length[id]));
int64_t knd = ((int64_t)(kind[id]));
if (len == 0) {
int64_t t = 0;
while (t < KLEN) {
ev[((id * KLEN) + t)] = 0;
t = (t + 1);
}
eok[id] = 1;
return;
}
if (knd == 1) {
int64_t t = 0;
while (t < KLEN) {
int64_t val = 0;
int64_t b = (len - 1);
while (b >= 0) {
int64_t bit = (FLOW_CHECKED_SHR((((int64_t)(litval[id]))), (b)) & 1);
val = FLOW_CHECKED_MOD((((val * xpow[t]) + bit)), (MOD));
b = (b - 1);
}
ev[((id * KLEN) + t)] = ((int32_t)(val));
t = (t + 1);
}
} else if (knd == 2) {
int64_t ch = ((int64_t)(child[id]));
evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(ch, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc);
int64_t t = 0;
while (t < KLEN) {
int64_t total = geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(xpow[t], len, MOD, gk, gv, gu, gc);
int64_t cv = ((int64_t)(ev[((ch * KLEN) + t)]));
ev[((id * KLEN) + t)] = ((int32_t)(FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((total - cv)), (MOD)) + MOD)), (MOD))));
t = (t + 1);
}
} else if (knd == 3) {
int64_t ch = ((int64_t)(child[id]));
if (FLOW_CHECKED_MOD((len), (2)) == 0) {
int64_t len_u = FLOW_CHECKED_DIV((len), (2));
evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(ch, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc);
int64_t t = 0;
while (t < KLEN) {
int64_t val = 0;
if ((t + 1) < KLEN) {
int64_t cv = ((int64_t)(ev[((ch * KLEN) + (t + 1))]));
val = FLOW_CHECKED_MOD(((((xpow[t] - 1) * cv) + geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_MOD(((xpow[t] * xpow[t])), (MOD)), len_u, MOD, gk, gv, gu, gc))), (MOD));
if (val < 0) {
val = (val + MOD);
}
}
ev[((id * KLEN) + t)] = ((int32_t)(val));
t = (t + 1);
}
} else {
int64_t up = drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, nc, dl, df, fc, fv, lc, lv);
int64_t u_last = last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, lc, lv, fc, fv);
evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(up, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc);
if (mok[up] == 0) {
int64_t t = 0;
while (t < KLEN) {
int64_t val = 0;
if ((t + 1) < KLEN) {
int64_t base = ((int64_t)(ev[((up * KLEN) + (t + 1))]));
val = FLOW_CHECKED_MOD(((((xpow[t] - 1) * base) + geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_MOD(((xpow[t] * xpow[t])), (MOD)), ((int64_t)(length[up])), MOD, gk, gv, gu, gc))), (MOD));
if (val < 0) {
val = (val + MOD);
}
}
mu[((up * KLEN) + t)] = ((int32_t)(val));
t = (t + 1);
}
mok[up] = 1;
}
int64_t t = 0;
while (t < KLEN) {
int64_t mv = ((int64_t)(mu[((up * KLEN) + t)]));
ev[((id * KLEN) + t)] = ((int32_t)(FLOW_CHECKED_MOD((((mv * xpow[t]) + u_last)), (MOD))));
t = (t + 1);
}
}
} else {
int64_t ch = ((int64_t)(child[id]));
int64_t half = FLOW_CHECKED_DIV((len), (2));
int64_t u_first = first_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, fc, fv);
int64_t u_last = last_bit_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, lc, lv, fc, fv);
if (FLOW_CHECKED_MOD((len), (2)) == 1) {
int64_t u_tail = drop_first_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, nc, df, fc, fv, lc, lv);
evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(u_tail, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc);
if (mok[u_tail] == 0) {
int64_t t = 0;
while (t < KLEN) {
int64_t val = 0;
if ((t + 1) < KLEN) {
int64_t base = ((int64_t)(ev[((u_tail * KLEN) + (t + 1))]));
val = FLOW_CHECKED_MOD(((((xpow[t] - 1) * base) + geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_MOD(((xpow[t] * xpow[t])), (MOD)), ((int64_t)(length[u_tail])), MOD, gk, gv, gu, gc))), (MOD));
if (val < 0) {
val = (val + MOD);
}
}
mu[((u_tail * KLEN) + t)] = ((int32_t)(val));
t = (t + 1);
}
mok[u_tail] = 1;
}
int64_t t = 0;
while (t < KLEN) {
int64_t mv = ((int64_t)(mu[((u_tail * KLEN) + t)]));
ev[((id * KLEN) + t)] = ((int32_t)(FLOW_CHECKED_MOD(((((1 - u_first) * pow_x_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(t, (2 * half), MOD, xpow, pk, pv, pu, pc)) + mv)), (MOD))));
t = (t + 1);
}
} else {
int64_t mid = drop_last_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(drop_first_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8(ch, kind, child, length, litval, nc, df, fc, fv, lc, lv), kind, child, length, litval, nc, dl, df, fc, fv, lc, lv);
evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(mid, KLEN, MOD, xpow, kind, child, length, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, gc, pk, pv, pu, pc);
if (mok[mid] == 0) {
int64_t t = 0;
while (t < KLEN) {
int64_t val = 0;
if ((t + 1) < KLEN) {
int64_t base = ((int64_t)(ev[((mid * KLEN) + (t + 1))]));
val = FLOW_CHECKED_MOD(((((xpow[t] - 1) * base) + geom_sum_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_MOD(((xpow[t] * xpow[t])), (MOD)), ((int64_t)(length[mid])), MOD, gk, gv, gu, gc))), (MOD));
if (val < 0) {
val = (val + MOD);
}
}
mu[((mid * KLEN) + t)] = ((int32_t)(val));
t = (t + 1);
}
mok[mid] = 1;
}
int64_t t = 0;
while (t < KLEN) {
int64_t mv = ((int64_t)(mu[((mid * KLEN) + t)]));
ev[((id * KLEN) + t)] = ((int32_t)(FLOW_CHECKED_MOD((((((1 - u_first) * pow_x_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(t, ((2 * half) - 1), MOD, xpow, pk, pv, pu, pc)) + (mv * xpow[t])) + u_last)), (MOD))));
t = (t + 1);
}
}
}
eok[id] = 1;
}
int64_t kth_word_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(int64_t length, int64_t rank, int64_t start_bit, int64_t* ck, int64_t* cv, int8_t* cu, int64_t cc, int8_t* kind, int32_t* child, int32_t* lengtha, int8_t* litval, int64_t* nc) {
if (start_bit == 0) {
int64_t total = count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64(length, ck, cv, cu, cc);
return new_comp_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(kth_word_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(length, ((total - 1) - rank), 1, ck, cv, cu, cc, kind, child, lengtha, litval, nc), kind, child, lengtha, litval, nc);
}
if (length <= 3) {
if (length == 1) {
return new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(1, 1, kind, child, lengtha, litval, nc);
}
if (length == 2) {
if (rank == 0) {
return new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(2, 2, kind, child, lengtha, litval, nc);
}
return new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(3, 2, kind, child, lengtha, litval, nc);
}
if (rank == 0) {
return new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(4, 3, kind, child, lengtha, litval, nc);
}
if (rank == 1) {
return new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(5, 3, kind, child, lengtha, litval, nc);
}
return new_lit_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(6, 3, kind, child, lengtha, litval, nc);
}
int64_t half_even = FLOW_CHECKED_DIV(((length + 1)), (2));
int64_t count_even = count_start1_i64_ptr_i64_ptr_i64_ptr_i8_i64(half_even, ck, cv, cu, cc);
if (rank < count_even) {
int64_t ch = kth_word_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(half_even, rank, 1, ck, cv, cu, cc, kind, child, lengtha, litval, nc);
return new_even_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(ch, length, kind, child, lengtha, litval, nc);
}
int64_t half_odd = (FLOW_CHECKED_DIV((length), (2)) + 1);
int64_t ch = kth_word_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(half_odd, (rank - count_even), 0, ck, cv, cu, cc, kind, child, lengtha, litval, nc);
return new_odd_i64_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(ch, length, kind, child, lengtha, litval, nc);
}
int32_t main(void) {
int64_t MOD = 1000000000;
int64_t CAP = FLOW_CHECKED_SHL((1), (20));
int64_t* ck = (int64_t*)(calloc(CAP, 8));
int64_t* cv = (int64_t*)(calloc(CAP, 8));
int8_t* cu = (int8_t*)(calloc(CAP, 1));
int64_t* pk = (int64_t*)(calloc(CAP, 8));
int64_t* pv = (int64_t*)(calloc(CAP, 8));
int8_t* pu = (int8_t*)(calloc(CAP, 1));
int64_t max_len = 0;
int64_t ten = 10;
int64_t k = 1;
while (k <= 18) {
int64_t L = find_length_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(ten, ck, cv, cu, CAP, pk, pv, pu, CAP);
if (L > max_len) {
max_len = L;
}
if (k < 18) {
ten = (ten * 10);
}
k = (k + 1);
}
int64_t depth = 0;
int64_t ll = max_len;
while (ll > 3) {
ll = (FLOW_CHECKED_DIV((ll), (2)) + 1);
depth = (depth + 1);
}
int64_t KMAX = (depth + 2);
int64_t KLEN = (KMAX + 2);
int64_t* xpow = (int64_t*)(calloc(KLEN, 8));
int64_t t = 0;
while (t < KLEN) {
int64_t e = 1;
int64_t i = 0;
while (i < t) {
e = (e * 2);
i = (i + 1);
}
xpow[t] = modpow_i64_i64_i64(2, e, MOD);
t = (t + 1);
}
int64_t AMAX = 50000;
int8_t* kind = (int8_t*)(calloc(AMAX, 1));
int32_t* child = (int32_t*)(calloc(AMAX, 4));
int32_t* lengtha = (int32_t*)(calloc(AMAX, 4));
int8_t* litval = (int8_t*)(calloc(AMAX, 1));
int64_t* nc = (int64_t*)(calloc(1, 8));
nc[0] = 1;
lengtha[0] = 0;
kind[0] = 1;
litval[0] = 0;
int32_t* df = (int32_t*)(calloc(AMAX, 4));
int32_t* dl = (int32_t*)(calloc(AMAX, 4));
int8_t* fc = (int8_t*)(calloc(AMAX, 1));
int8_t* fv = (int8_t*)(calloc(AMAX, 1));
int8_t* lc = (int8_t*)(calloc(AMAX, 1));
int8_t* lv = (int8_t*)(calloc(AMAX, 1));
int64_t i = 0;
while (i < AMAX) {
df[i] = (-1);
dl[i] = (-1);
i = (i + 1);
}
int32_t* ev = (int32_t*)(calloc((AMAX * KLEN), 4));
int8_t* eok = (int8_t*)(calloc(AMAX, 1));
int32_t* mu = (int32_t*)(calloc((AMAX * KLEN), 4));
int8_t* mok = (int8_t*)(calloc(AMAX, 1));
int64_t GCAP = FLOW_CHECKED_SHL((1), (18));
int64_t* gk = (int64_t*)(calloc(GCAP, 8));
int64_t* gv = (int64_t*)(calloc(GCAP, 8));
int8_t* gu = (int8_t*)(calloc(GCAP, 1));
int64_t* p2k = (int64_t*)(calloc(GCAP, 8));
int64_t* p2v = (int64_t*)(calloc(GCAP, 8));
int8_t* p2u = (int8_t*)(calloc(GCAP, 1));
int64_t total = 0;
ten = 10;
k = 1;
while (k <= 18) {
int64_t index = ten;
int64_t length = find_length_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(index, ck, cv, cu, CAP, pk, pv, pu, CAP);
int64_t rank = ((index - 1) - count_prefix_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64((length - 1), ck, cv, cu, CAP, pk, pv, pu, CAP));
int64_t node = kth_word_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64(length, rank, 1, ck, cv, cu, CAP, kind, child, lengtha, litval, nc);
evals_node_i64_i64_i64_ptr_i64_ptr_i8_ptr_i32_ptr_i32_ptr_i8_ptr_i64_ptr_i32_ptr_i32_ptr_i8_ptr_i8_ptr_i8_ptr_i8_ptr_i32_ptr_i8_ptr_i32_ptr_i8_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(node, KLEN, MOD, xpow, kind, child, lengtha, litval, nc, df, dl, fc, fv, lc, lv, ev, eok, mu, mok, gk, gv, gu, GCAP, p2k, p2v, p2u, GCAP);
int64_t aval = ((int64_t)(ev[((node * KLEN) + 0)]));
total = FLOW_CHECKED_MOD(((total + aval)), (MOD));
if (k < 18) {
ten = (ten * 10);
}
k = (k + 1);
}
printf("%lld\n", total);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @modpow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%0 = arith.constant 1 : i32
%1 = arith.extsi %0 : i32 to i64
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %1, %3 : i64, !llvm.ptr
%4 = arith.remsi %arg0, %arg2 : i64
%5 = llvm.mlir.constant(1 : i64) : i64
%6 = llvm.alloca %5 x i64 : (i64) -> !llvm.ptr
llvm.store %4, %6 : i64, !llvm.ptr
%7 = llvm.mlir.constant(1 : i64) : i64
%8 = llvm.alloca %7 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %8 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%9 = llvm.load %8 : !llvm.ptr -> i64
%10 = arith.constant 0 : i32
%12 = arith.extsi %10 : i32 to i64
%11 = arith.cmpi sgt, %9, %12 : i64
cf.cond_br %11, ^bb1, ^bb2
^bb1:
%13 = llvm.load %8 : !llvm.ptr -> i64
%14 = arith.constant 1 : i32
%16 = arith.extsi %14 : i32 to i64
%15 = arith.andi %13, %16 : i64
%17 = arith.constant 1 : i32
%19 = arith.extsi %17 : i32 to i64
%18 = arith.cmpi eq, %15, %19 : i64
cf.cond_br %18, ^bb3, ^bb4
^bb3:
%20 = llvm.load %3 : !llvm.ptr -> i64
%21 = llvm.load %6 : !llvm.ptr -> i64
%22 = arith.muli %20, %21 : i64
%23 = arith.remsi %22, %arg2 : i64
llvm.store %23, %3 : i64, !llvm.ptr
cf.br ^bb5
^bb4:
cf.br ^bb5
^bb5:
%24 = llvm.load %6 : !llvm.ptr -> i64
%25 = llvm.load %6 : !llvm.ptr -> i64
%26 = arith.muli %24, %25 : i64
%27 = arith.remsi %26, %arg2 : i64
llvm.store %27, %6 : i64, !llvm.ptr
%28 = llvm.load %8 : !llvm.ptr -> i64
%29 = arith.constant 2 : i32
%31 = arith.extsi %29 : i32 to i64
%30 = arith.divsi %28, %31 : i64
llvm.store %30, %8 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%32 = llvm.load %3 : !llvm.ptr -> i64
func.return %32 : i64
}
func.func @hget(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64) -> i64 {
%33 = llvm.mlir.constant(1 : i64) : i64
%34 = llvm.alloca %33 x i64 : (i64) -> !llvm.ptr
llvm.store %arg4, %34 : i64, !llvm.ptr
%35 = llvm.load %34 : !llvm.ptr -> i64
%36 = arith.constant 0 : i32
%38 = arith.extsi %36 : i32 to i64
%37 = arith.cmpi slt, %35, %38 : i64
cf.cond_br %37, ^bb6, ^bb7
^bb6:
%39 = arith.constant 0 : i32
%40 = llvm.load %34 : !llvm.ptr -> i64
%42 = arith.extsi %39 : i32 to i64
%41 = arith.subi %42, %40 : i64
llvm.store %41, %34 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
cf.br ^bb8
^bb8:
%43 = llvm.load %34 : !llvm.ptr -> i64
%44 = arith.constant 1 : i32
%46 = arith.extsi %44 : i32 to i64
%45 = arith.subi %arg3, %46 : i64
%47 = arith.andi %43, %45 : i64
llvm.store %47, %34 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%49 = llvm.load %34 : !llvm.ptr -> i64
%50 = llvm.getelementptr %arg2[%49] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%48 = llvm.load %50 : !llvm.ptr -> i8
%51 = arith.constant 0 : i32
%53 = arith.extsi %48 : i8 to i32
%52 = arith.cmpi ne, %53, %51 : i32
cf.cond_br %52, ^bb10, ^bb11
^bb10:
%55 = llvm.load %34 : !llvm.ptr -> i64
%56 = llvm.getelementptr %arg0[%55] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%54 = llvm.load %56 : !llvm.ptr -> i64
%57 = arith.cmpi eq, %54, %arg4 : i64
cf.cond_br %57, ^bb12, ^bb13
^bb12:
%59 = llvm.load %34 : !llvm.ptr -> i64
%60 = llvm.getelementptr %arg1[%59] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%58 = llvm.load %60 : !llvm.ptr -> i64
func.return %58 : i64
^bb13:
cf.br ^bb14
^bb14:
%61 = llvm.load %34 : !llvm.ptr -> i64
%62 = arith.constant 1 : i32
%64 = arith.extsi %62 : i32 to i64
%63 = arith.addi %61, %64 : i64
%65 = arith.constant 1 : i32
%67 = arith.extsi %65 : i32 to i64
%66 = arith.subi %arg3, %67 : i64
%68 = arith.andi %63, %66 : i64
llvm.store %68, %34 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%69 = arith.constant 0 : i32
%70 = arith.constant 1 : i32
%71 = arith.subi %69, %70 : i32
%72 = arith.extsi %71 : i32 to i64
func.return %72 : i64
}
func.func @hput(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64, %arg5: i64) -> () {
%73 = llvm.mlir.constant(1 : i64) : i64
%74 = llvm.alloca %73 x i64 : (i64) -> !llvm.ptr
llvm.store %arg4, %74 : i64, !llvm.ptr
%75 = llvm.load %74 : !llvm.ptr -> i64
%76 = arith.constant 0 : i32
%78 = arith.extsi %76 : i32 to i64
%77 = arith.cmpi slt, %75, %78 : i64
cf.cond_br %77, ^bb15, ^bb16
^bb15:
%79 = arith.constant 0 : i32
%80 = llvm.load %74 : !llvm.ptr -> i64
%82 = arith.extsi %79 : i32 to i64
%81 = arith.subi %82, %80 : i64
llvm.store %81, %74 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%83 = llvm.load %74 : !llvm.ptr -> i64
%84 = arith.constant 1 : i32
%86 = arith.extsi %84 : i32 to i64
%85 = arith.subi %arg3, %86 : i64
%87 = arith.andi %83, %85 : i64
llvm.store %87, %74 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%89 = llvm.load %74 : !llvm.ptr -> i64
%90 = llvm.getelementptr %arg2[%89] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%88 = llvm.load %90 : !llvm.ptr -> i8
%91 = arith.constant 0 : i32
%93 = arith.extsi %88 : i8 to i32
%92 = arith.cmpi ne, %93, %91 : i32
%94 = scf.if %92 -> (i1) {
%96 = llvm.load %74 : !llvm.ptr -> i64
%97 = llvm.getelementptr %arg0[%96] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%95 = llvm.load %97 : !llvm.ptr -> i64
%98 = arith.cmpi ne, %95, %arg4 : i64
scf.yield %98 : i1
} else {
%99 = arith.constant false
scf.yield %99 : i1
}
cf.cond_br %94, ^bb19, ^bb20
^bb19:
%100 = llvm.load %74 : !llvm.ptr -> i64
%101 = arith.constant 1 : i32
%103 = arith.extsi %101 : i32 to i64
%102 = arith.addi %100, %103 : i64
%104 = arith.constant 1 : i32
%106 = arith.extsi %104 : i32 to i64
%105 = arith.subi %arg3, %106 : i64
%107 = arith.andi %102, %105 : i64
llvm.store %107, %74 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%108 = arith.constant 1 : i32
%109 = llvm.load %74 : !llvm.ptr -> i64
%110 = arith.trunci %108 : i32 to i8
%111 = llvm.getelementptr %arg2[%109] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %110, %111 : i8, !llvm.ptr
%112 = llvm.load %74 : !llvm.ptr -> i64
%113 = llvm.getelementptr %arg0[%112] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg4, %113 : i64, !llvm.ptr
%114 = llvm.load %74 : !llvm.ptr -> i64
%115 = llvm.getelementptr %arg1[%114] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg5, %115 : i64, !llvm.ptr
func.return
}
func.func @count_start1(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i64) -> i64 {
%116 = arith.constant 1 : i32
%118 = arith.extsi %116 : i32 to i64
%117 = arith.cmpi eq, %arg0, %118 : i64
cf.cond_br %117, ^bb21, ^bb22
^bb21:
%119 = arith.constant 1 : i32
%120 = arith.extsi %119 : i32 to i64
func.return %120 : i64
^bb22:
cf.br ^bb23
^bb23:
%121 = arith.constant 2 : i32
%123 = arith.extsi %121 : i32 to i64
%122 = arith.cmpi eq, %arg0, %123 : i64
cf.cond_br %122, ^bb24, ^bb25
^bb24:
%124 = arith.constant 2 : i32
%125 = arith.extsi %124 : i32 to i64
func.return %125 : i64
^bb25:
cf.br ^bb26
^bb26:
%126 = arith.constant 3 : i32
%128 = arith.extsi %126 : i32 to i64
%127 = arith.cmpi eq, %arg0, %128 : i64
cf.cond_br %127, ^bb27, ^bb28
^bb27:
%129 = arith.constant 3 : i32
%130 = arith.extsi %129 : i32 to i64
func.return %130 : i64
^bb28:
cf.br ^bb29
^bb29:
%131 = func.call @hget(%arg1, %arg2, %arg3, %arg4, %arg0) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%132 = arith.constant 0 : i32
%134 = arith.extsi %132 : i32 to i64
%133 = arith.cmpi sge, %131, %134 : i64
cf.cond_br %133, ^bb30, ^bb31
^bb30:
func.return %131 : i64
^bb31:
cf.br ^bb32
^bb32:
%135 = arith.constant 0 : i32
%136 = arith.extsi %135 : i32 to i64
%137 = llvm.mlir.constant(1 : i64) : i64
%138 = llvm.alloca %137 x i64 : (i64) -> !llvm.ptr
llvm.store %136, %138 : i64, !llvm.ptr
%139 = arith.constant 2 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.remsi %arg0, %141 : i64
%142 = arith.constant 0 : i32
%144 = arith.extsi %142 : i32 to i64
%143 = arith.cmpi eq, %140, %144 : i64
cf.cond_br %143, ^bb33, ^bb34
^bb33:
%145 = arith.constant 2 : i32
%147 = arith.extsi %145 : i32 to i64
%146 = arith.divsi %arg0, %147 : i64
%148 = func.call @count_start1(%146, %arg1, %arg2, %arg3, %arg4) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%150 = arith.constant 1 : i32
%152 = arith.extsi %150 : i32 to i64
%151 = arith.addi %146, %152 : i64
%149 = func.call @count_start1(%151, %arg1, %arg2, %arg3, %arg4) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%153 = arith.addi %148, %149 : i64
llvm.store %153, %138 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
%154 = arith.constant 2 : i32
%156 = arith.extsi %154 : i32 to i64
%155 = arith.divsi %arg0, %156 : i64
%157 = arith.constant 2 : i32
%159 = arith.constant 1 : i32
%161 = arith.extsi %159 : i32 to i64
%160 = arith.addi %155, %161 : i64
%158 = func.call @count_start1(%160, %arg1, %arg2, %arg3, %arg4) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%163 = arith.extsi %157 : i32 to i64
%162 = arith.muli %163, %158 : i64
llvm.store %162, %138 : i64, !llvm.ptr
cf.br ^bb35
^bb35:
%165 = llvm.load %138 : !llvm.ptr -> i64
func.call @hput(%arg1, %arg2, %arg3, %arg4, %arg0, %165) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%166 = llvm.load %138 : !llvm.ptr -> i64
func.return %166 : i64
}
func.func @count_prefix(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i64, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: i64) -> i64 {
%167 = arith.constant 0 : i32
%169 = arith.extsi %167 : i32 to i64
%168 = arith.cmpi eq, %arg0, %169 : i64
cf.cond_br %168, ^bb36, ^bb37
^bb36:
%170 = arith.constant 0 : i32
%171 = arith.extsi %170 : i32 to i64
func.return %171 : i64
^bb37:
cf.br ^bb38
^bb38:
%172 = arith.constant 1 : i32
%174 = arith.extsi %172 : i32 to i64
%173 = arith.cmpi eq, %arg0, %174 : i64
cf.cond_br %173, ^bb39, ^bb40
^bb39:
%175 = arith.constant 1 : i32
%176 = arith.extsi %175 : i32 to i64
func.return %176 : i64
^bb40:
cf.br ^bb41
^bb41:
%177 = arith.constant 2 : i32
%179 = arith.extsi %177 : i32 to i64
%178 = arith.cmpi eq, %arg0, %179 : i64
cf.cond_br %178, ^bb42, ^bb43
^bb42:
%180 = arith.constant 3 : i32
%181 = arith.extsi %180 : i32 to i64
func.return %181 : i64
^bb43:
cf.br ^bb44
^bb44:
%182 = arith.constant 3 : i32
%184 = arith.extsi %182 : i32 to i64
%183 = arith.cmpi eq, %arg0, %184 : i64
cf.cond_br %183, ^bb45, ^bb46
^bb45:
%185 = arith.constant 6 : i32
%186 = arith.extsi %185 : i32 to i64
func.return %186 : i64
^bb46:
cf.br ^bb47
^bb47:
%187 = func.call @hget(%arg5, %arg6, %arg7, %arg8, %arg0) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%188 = arith.constant 0 : i32
%190 = arith.extsi %188 : i32 to i64
%189 = arith.cmpi sge, %187, %190 : i64
cf.cond_br %189, ^bb48, ^bb49
^bb48:
func.return %187 : i64
^bb49:
cf.br ^bb50
^bb50:
%191 = arith.constant 0 : i32
%192 = arith.extsi %191 : i32 to i64
%193 = llvm.mlir.constant(1 : i64) : i64
%194 = llvm.alloca %193 x i64 : (i64) -> !llvm.ptr
llvm.store %192, %194 : i64, !llvm.ptr
%195 = arith.constant 2 : i32
%197 = arith.extsi %195 : i32 to i64
%196 = arith.remsi %arg0, %197 : i64
%198 = arith.constant 0 : i32
%200 = arith.extsi %198 : i32 to i64
%199 = arith.cmpi eq, %196, %200 : i64
cf.cond_br %199, ^bb51, ^bb52
^bb51:
%201 = arith.constant 2 : i32
%203 = arith.extsi %201 : i32 to i64
%202 = arith.divsi %arg0, %203 : i64
%204 = arith.constant 3 : i32
%205 = func.call @count_prefix(%202, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%207 = arith.extsi %204 : i32 to i64
%206 = arith.muli %207, %205 : i64
%209 = arith.constant 1 : i32
%211 = arith.extsi %209 : i32 to i64
%210 = arith.addi %202, %211 : i64
%208 = func.call @count_prefix(%210, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%212 = arith.addi %206, %208 : i64
%213 = arith.constant 4 : i32
%215 = arith.extsi %213 : i32 to i64
%214 = arith.subi %212, %215 : i64
llvm.store %214, %194 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
%216 = arith.constant 2 : i32
%218 = arith.extsi %216 : i32 to i64
%217 = arith.divsi %arg0, %218 : i64
%220 = arith.constant 2 : i32
%222 = arith.extsi %220 : i32 to i64
%221 = arith.muli %222, %217 : i64
%219 = func.call @count_prefix(%221, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%223 = arith.constant 2 : i32
%225 = arith.constant 1 : i32
%227 = arith.extsi %225 : i32 to i64
%226 = arith.addi %217, %227 : i64
%224 = func.call @count_start1(%226, %arg1, %arg2, %arg3, %arg4) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%229 = arith.extsi %223 : i32 to i64
%228 = arith.muli %229, %224 : i64
%230 = arith.addi %219, %228 : i64
llvm.store %230, %194 : i64, !llvm.ptr
cf.br ^bb53
^bb53:
%232 = llvm.load %194 : !llvm.ptr -> i64
func.call @hput(%arg5, %arg6, %arg7, %arg8, %arg0, %232) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%233 = llvm.load %194 : !llvm.ptr -> i64
func.return %233 : i64
}
func.func @find_length(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i64, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: i64) -> i64 {
%234 = arith.constant 1 : i32
%235 = arith.extsi %234 : i32 to i64
%236 = llvm.mlir.constant(1 : i64) : i64
%237 = llvm.alloca %236 x i64 : (i64) -> !llvm.ptr
llvm.store %235, %237 : i64, !llvm.ptr
%238 = arith.constant 1 : i32
%239 = arith.extsi %238 : i32 to i64
%240 = llvm.mlir.constant(1 : i64) : i64
%241 = llvm.alloca %240 x i64 : (i64) -> !llvm.ptr
llvm.store %239, %241 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%243 = llvm.load %241 : !llvm.ptr -> i64
%242 = func.call @count_prefix(%243, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%244 = arith.cmpi slt, %242, %arg0 : i64
cf.cond_br %244, ^bb55, ^bb56
^bb55:
%245 = llvm.load %241 : !llvm.ptr -> i64
%246 = arith.constant 2 : i32
%248 = arith.extsi %246 : i32 to i64
%247 = arith.muli %245, %248 : i64
llvm.store %247, %241 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
cf.br ^bb57
^bb57:
%249 = llvm.load %237 : !llvm.ptr -> i64
%250 = llvm.load %241 : !llvm.ptr -> i64
%251 = arith.cmpi slt, %249, %250 : i64
cf.cond_br %251, ^bb58, ^bb59
^bb58:
%252 = llvm.load %237 : !llvm.ptr -> i64
%253 = llvm.load %241 : !llvm.ptr -> i64
%254 = arith.addi %252, %253 : i64
%255 = arith.constant 2 : i32
%257 = arith.extsi %255 : i32 to i64
%256 = arith.divsi %254, %257 : i64
%258 = func.call @count_prefix(%256, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%259 = arith.cmpi sge, %258, %arg0 : i64
cf.cond_br %259, ^bb60, ^bb61
^bb60:
llvm.store %256, %241 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
%260 = arith.constant 1 : i32
%262 = arith.extsi %260 : i32 to i64
%261 = arith.addi %256, %262 : i64
llvm.store %261, %237 : i64, !llvm.ptr
cf.br ^bb62
^bb62:
cf.br ^bb57
^bb59:
%263 = llvm.load %237 : !llvm.ptr -> i64
func.return %263 : i64
}
func.func @geom_sum(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i64) -> i64 {
%264 = arith.constant 0 : i32
%266 = arith.extsi %264 : i32 to i64
%265 = arith.cmpi eq, %arg1, %266 : i64
cf.cond_br %265, ^bb63, ^bb64
^bb63:
%267 = arith.constant 0 : i32
%268 = arith.extsi %267 : i32 to i64
func.return %268 : i64
^bb64:
cf.br ^bb65
^bb65:
%269 = arith.constant 1 : i32
%271 = arith.extsi %269 : i32 to i64
%270 = arith.cmpi eq, %arg1, %271 : i64
cf.cond_br %270, ^bb66, ^bb67
^bb66:
%272 = arith.constant 1 : i32
%273 = arith.extsi %272 : i32 to i64
func.return %273 : i64
^bb67:
cf.br ^bb68
^bb68:
%274 = arith.constant 1000000007 : i32
%276 = arith.extsi %274 : i32 to i64
%275 = arith.muli %arg0, %276 : i64
%277 = arith.addi %275, %arg1 : i64
%278 = func.call @hget(%arg3, %arg4, %arg5, %arg6, %277) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%279 = arith.constant 0 : i32
%281 = arith.extsi %279 : i32 to i64
%280 = arith.cmpi sge, %278, %281 : i64
cf.cond_br %280, ^bb69, ^bb70
^bb69:
func.return %278 : i64
^bb70:
cf.br ^bb71
^bb71:
%282 = arith.constant 0 : i32
%283 = arith.extsi %282 : i32 to i64
%284 = llvm.mlir.constant(1 : i64) : i64
%285 = llvm.alloca %284 x i64 : (i64) -> !llvm.ptr
llvm.store %283, %285 : i64, !llvm.ptr
%286 = arith.constant 2 : i32
%288 = arith.extsi %286 : i32 to i64
%287 = arith.remsi %arg1, %288 : i64
%289 = arith.constant 0 : i32
%291 = arith.extsi %289 : i32 to i64
%290 = arith.cmpi eq, %287, %291 : i64
cf.cond_br %290, ^bb72, ^bb73
^bb72:
%293 = arith.constant 2 : i32
%295 = arith.extsi %293 : i32 to i64
%294 = arith.divsi %arg1, %295 : i64
%292 = func.call @geom_sum(%arg0, %294, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%297 = arith.constant 2 : i32
%299 = arith.extsi %297 : i32 to i64
%298 = arith.divsi %arg1, %299 : i64
%296 = func.call @modpow(%arg0, %298, %arg2) : (i64, i64, i64) -> i64
%300 = arith.muli %296, %292 : i64
%301 = arith.addi %292, %300 : i64
%302 = arith.remsi %301, %arg2 : i64
llvm.store %302, %285 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
%304 = arith.constant 1 : i32
%306 = arith.extsi %304 : i32 to i64
%305 = arith.subi %arg1, %306 : i64
%303 = func.call @geom_sum(%arg0, %305, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%308 = arith.constant 1 : i32
%310 = arith.extsi %308 : i32 to i64
%309 = arith.subi %arg1, %310 : i64
%307 = func.call @modpow(%arg0, %309, %arg2) : (i64, i64, i64) -> i64
%311 = arith.addi %303, %307 : i64
%312 = arith.remsi %311, %arg2 : i64
llvm.store %312, %285 : i64, !llvm.ptr
cf.br ^bb74
^bb74:
%314 = llvm.load %285 : !llvm.ptr -> i64
func.call @hput(%arg3, %arg4, %arg5, %arg6, %277, %314) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%315 = llvm.load %285 : !llvm.ptr -> i64
func.return %315 : i64
}
func.func @pow_x(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: i64) -> i64 {
%316 = arith.constant 1000000007 : i32
%318 = arith.extsi %316 : i32 to i64
%317 = arith.muli %arg0, %318 : i64
%319 = arith.addi %317, %arg1 : i64
%320 = func.call @hget(%arg4, %arg5, %arg6, %arg7, %319) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%321 = arith.constant 0 : i32
%323 = arith.extsi %321 : i32 to i64
%322 = arith.cmpi sge, %320, %323 : i64
cf.cond_br %322, ^bb75, ^bb76
^bb75:
func.return %320 : i64
^bb76:
cf.br ^bb77
^bb77:
%326 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%325 = llvm.load %326 : !llvm.ptr -> i64
%324 = func.call @modpow(%325, %arg1, %arg2) : (i64, i64, i64) -> i64
func.call @hput(%arg4, %arg5, %arg6, %arg7, %319, %324) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
func.return %324 : i64
}
func.func @new_lit(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr) -> i64 {
%329 = arith.constant 0 : i32
%330 = arith.extsi %329 : i32 to i64
%331 = llvm.getelementptr %arg6[%330] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%328 = llvm.load %331 : !llvm.ptr -> i64
%332 = arith.constant 1 : i32
%334 = arith.extsi %332 : i32 to i64
%333 = arith.addi %328, %334 : i64
%335 = arith.constant 0 : i32
%336 = arith.extsi %335 : i32 to i64
%337 = llvm.getelementptr %arg6[%336] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %333, %337 : i64, !llvm.ptr
%338 = arith.constant 1 : i32
%339 = arith.trunci %338 : i32 to i8
%340 = llvm.getelementptr %arg2[%328] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %339, %340 : i8, !llvm.ptr
%341 = arith.constant 0 : i32
%342 = llvm.getelementptr %arg3[%328] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %341, %342 : i32, !llvm.ptr
%343 = arith.trunci %arg1 : i64 to i32
%344 = llvm.getelementptr %arg4[%328] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %343, %344 : i32, !llvm.ptr
%345 = arith.trunci %arg0 : i64 to i8
%346 = llvm.getelementptr %arg5[%328] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %345, %346 : i8, !llvm.ptr
func.return %328 : i64
}
func.func @new_comp(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr) -> i64 {
%348 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%347 = llvm.load %348 : !llvm.ptr -> i32
%349 = arith.constant 0 : i32
%350 = arith.cmpi eq, %347, %349 : i32
cf.cond_br %350, ^bb78, ^bb79
^bb78:
func.return %arg0 : i64
^bb79:
cf.br ^bb80
^bb80:
%352 = arith.constant 0 : i32
%353 = arith.extsi %352 : i32 to i64
%354 = llvm.getelementptr %arg5[%353] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%351 = llvm.load %354 : !llvm.ptr -> i64
%355 = arith.constant 1 : i32
%357 = arith.extsi %355 : i32 to i64
%356 = arith.addi %351, %357 : i64
%358 = arith.constant 0 : i32
%359 = arith.extsi %358 : i32 to i64
%360 = llvm.getelementptr %arg5[%359] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %356, %360 : i64, !llvm.ptr
%361 = arith.constant 2 : i32
%362 = arith.trunci %361 : i32 to i8
%363 = llvm.getelementptr %arg1[%351] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %362, %363 : i8, !llvm.ptr
%364 = arith.trunci %arg0 : i64 to i32
%365 = llvm.getelementptr %arg2[%351] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %364, %365 : i32, !llvm.ptr
%367 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%366 = llvm.load %367 : !llvm.ptr -> i32
%368 = llvm.getelementptr %arg3[%351] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %366, %368 : i32, !llvm.ptr
%369 = arith.constant 0 : i32
%370 = arith.trunci %369 : i32 to i8
%371 = llvm.getelementptr %arg4[%351] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %370, %371 : i8, !llvm.ptr
func.return %351 : i64
}
func.func @new_even(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr) -> i64 {
%373 = arith.constant 0 : i32
%374 = arith.extsi %373 : i32 to i64
%375 = llvm.getelementptr %arg6[%374] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%372 = llvm.load %375 : !llvm.ptr -> i64
%376 = arith.constant 1 : i32
%378 = arith.extsi %376 : i32 to i64
%377 = arith.addi %372, %378 : i64
%379 = arith.constant 0 : i32
%380 = arith.extsi %379 : i32 to i64
%381 = llvm.getelementptr %arg6[%380] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %377, %381 : i64, !llvm.ptr
%382 = arith.constant 3 : i32
%383 = arith.trunci %382 : i32 to i8
%384 = llvm.getelementptr %arg2[%372] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %383, %384 : i8, !llvm.ptr
%385 = arith.trunci %arg0 : i64 to i32
%386 = llvm.getelementptr %arg3[%372] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %385, %386 : i32, !llvm.ptr
%387 = arith.trunci %arg1 : i64 to i32
%388 = llvm.getelementptr %arg4[%372] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %387, %388 : i32, !llvm.ptr
%389 = arith.constant 0 : i32
%390 = arith.trunci %389 : i32 to i8
%391 = llvm.getelementptr %arg5[%372] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %390, %391 : i8, !llvm.ptr
func.return %372 : i64
}
func.func @new_odd(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr) -> i64 {
%393 = arith.constant 0 : i32
%394 = arith.extsi %393 : i32 to i64
%395 = llvm.getelementptr %arg6[%394] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%392 = llvm.load %395 : !llvm.ptr -> i64
%396 = arith.constant 1 : i32
%398 = arith.extsi %396 : i32 to i64
%397 = arith.addi %392, %398 : i64
%399 = arith.constant 0 : i32
%400 = arith.extsi %399 : i32 to i64
%401 = llvm.getelementptr %arg6[%400] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %397, %401 : i64, !llvm.ptr
%402 = arith.constant 4 : i32
%403 = arith.trunci %402 : i32 to i8
%404 = llvm.getelementptr %arg2[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %403, %404 : i8, !llvm.ptr
%405 = arith.trunci %arg0 : i64 to i32
%406 = llvm.getelementptr %arg3[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %405, %406 : i32, !llvm.ptr
%407 = arith.trunci %arg1 : i64 to i32
%408 = llvm.getelementptr %arg4[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %407, %408 : i32, !llvm.ptr
%409 = arith.constant 0 : i32
%410 = arith.trunci %409 : i32 to i8
%411 = llvm.getelementptr %arg5[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %410, %411 : i8, !llvm.ptr
func.return %392 : i64
}
func.func @first_bit(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr) -> i64 {
%413 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%412 = llvm.load %413 : !llvm.ptr -> i8
%414 = arith.constant 0 : i32
%416 = arith.extsi %412 : i8 to i32
%415 = arith.cmpi ne, %416, %414 : i32
cf.cond_br %415, ^bb81, ^bb82
^bb81:
%418 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%417 = llvm.load %418 : !llvm.ptr -> i8
%419 = arith.extsi %417 : i8 to i64
func.return %419 : i64
^bb82:
cf.br ^bb83
^bb83:
%420 = arith.constant 0 : i32
%421 = arith.extsi %420 : i32 to i64
%422 = llvm.mlir.constant(1 : i64) : i64
%423 = llvm.alloca %422 x i64 : (i64) -> !llvm.ptr
llvm.store %421, %423 : i64, !llvm.ptr
%425 = llvm.getelementptr %arg1[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%424 = llvm.load %425 : !llvm.ptr -> i8
%426 = arith.extsi %424 : i8 to i64
%427 = arith.constant 1 : i32
%429 = arith.extsi %427 : i32 to i64
%428 = arith.cmpi eq, %426, %429 : i64
cf.cond_br %428, ^bb84, ^bb85
^bb84:
%431 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%430 = llvm.load %431 : !llvm.ptr -> i32
%432 = arith.extsi %430 : i32 to i64
%434 = llvm.getelementptr %arg4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%433 = llvm.load %434 : !llvm.ptr -> i8
%435 = arith.extsi %433 : i8 to i64
%436 = arith.constant 1 : i32
%438 = arith.extsi %436 : i32 to i64
%437 = arith.subi %432, %438 : i64
%439 = arith.shrsi %435, %437 : i64
%440 = arith.constant 1 : i32
%442 = arith.extsi %440 : i32 to i64
%441 = arith.andi %439, %442 : i64
llvm.store %441, %423 : i64, !llvm.ptr
cf.br ^bb86
^bb85:
%443 = arith.constant 2 : i32
%445 = arith.extsi %443 : i32 to i64
%444 = arith.cmpi eq, %426, %445 : i64
cf.cond_br %444, ^bb88, ^bb87
^bb88:
%446 = arith.constant 1 : i32
%449 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%448 = llvm.load %449 : !llvm.ptr -> i32
%450 = arith.extsi %448 : i32 to i64
%447 = func.call @first_bit(%450, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%452 = arith.extsi %446 : i32 to i64
%451 = arith.subi %452, %447 : i64
llvm.store %451, %423 : i64, !llvm.ptr
cf.br ^bb86
^bb87:
%453 = arith.constant 3 : i32
%455 = arith.extsi %453 : i32 to i64
%454 = arith.cmpi eq, %426, %455 : i64
cf.cond_br %454, ^bb90, ^bb89
^bb90:
%458 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%457 = llvm.load %458 : !llvm.ptr -> i32
%459 = arith.extsi %457 : i32 to i64
%456 = func.call @first_bit(%459, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %456, %423 : i64, !llvm.ptr
cf.br ^bb86
^bb89:
%460 = arith.constant 1 : i32
%463 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%462 = llvm.load %463 : !llvm.ptr -> i32
%464 = arith.extsi %462 : i32 to i64
%461 = func.call @first_bit(%464, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%466 = arith.extsi %460 : i32 to i64
%465 = arith.subi %466, %461 : i64
llvm.store %465, %423 : i64, !llvm.ptr
cf.br ^bb86
^bb86:
%467 = arith.constant 1 : i32
%468 = arith.trunci %467 : i32 to i8
%469 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %468, %469 : i8, !llvm.ptr
%470 = llvm.load %423 : !llvm.ptr -> i64
%471 = arith.trunci %470 : i64 to i8
%472 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %471, %472 : i8, !llvm.ptr
%473 = llvm.load %423 : !llvm.ptr -> i64
func.return %473 : i64
}
func.func @last_bit(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr) -> i64 {
%475 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%474 = llvm.load %475 : !llvm.ptr -> i8
%476 = arith.constant 0 : i32
%478 = arith.extsi %474 : i8 to i32
%477 = arith.cmpi ne, %478, %476 : i32
cf.cond_br %477, ^bb91, ^bb92
^bb91:
%480 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%479 = llvm.load %480 : !llvm.ptr -> i8
%481 = arith.extsi %479 : i8 to i64
func.return %481 : i64
^bb92:
cf.br ^bb93
^bb93:
%482 = arith.constant 0 : i32
%483 = arith.extsi %482 : i32 to i64
%484 = llvm.mlir.constant(1 : i64) : i64
%485 = llvm.alloca %484 x i64 : (i64) -> !llvm.ptr
llvm.store %483, %485 : i64, !llvm.ptr
%487 = llvm.getelementptr %arg1[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%486 = llvm.load %487 : !llvm.ptr -> i8
%488 = arith.extsi %486 : i8 to i64
%490 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%489 = llvm.load %490 : !llvm.ptr -> i32
%491 = arith.extsi %489 : i32 to i64
%492 = arith.constant 1 : i32
%494 = arith.extsi %492 : i32 to i64
%493 = arith.cmpi eq, %488, %494 : i64
cf.cond_br %493, ^bb94, ^bb95
^bb94:
%496 = llvm.getelementptr %arg4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%495 = llvm.load %496 : !llvm.ptr -> i8
%497 = arith.extsi %495 : i8 to i64
%498 = arith.constant 1 : i32
%500 = arith.extsi %498 : i32 to i64
%499 = arith.andi %497, %500 : i64
llvm.store %499, %485 : i64, !llvm.ptr
cf.br ^bb96
^bb95:
%501 = arith.constant 2 : i32
%503 = arith.extsi %501 : i32 to i64
%502 = arith.cmpi eq, %488, %503 : i64
cf.cond_br %502, ^bb98, ^bb97
^bb98:
%504 = arith.constant 1 : i32
%507 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%506 = llvm.load %507 : !llvm.ptr -> i32
%508 = arith.extsi %506 : i32 to i64
%505 = func.call @last_bit(%508, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%510 = arith.extsi %504 : i32 to i64
%509 = arith.subi %510, %505 : i64
llvm.store %509, %485 : i64, !llvm.ptr
cf.br ^bb96
^bb97:
%511 = arith.constant 3 : i32
%513 = arith.extsi %511 : i32 to i64
%512 = arith.cmpi eq, %488, %513 : i64
cf.cond_br %512, ^bb100, ^bb99
^bb100:
%515 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%514 = llvm.load %515 : !llvm.ptr -> i32
%516 = arith.extsi %514 : i32 to i64
%517 = arith.constant 2 : i32
%519 = arith.extsi %517 : i32 to i64
%518 = arith.remsi %491, %519 : i64
%520 = arith.constant 0 : i32
%522 = arith.extsi %520 : i32 to i64
%521 = arith.cmpi eq, %518, %522 : i64
cf.cond_br %521, ^bb101, ^bb102
^bb101:
%523 = arith.constant 1 : i32
%524 = func.call @last_bit(%516, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%526 = arith.extsi %523 : i32 to i64
%525 = arith.subi %526, %524 : i64
llvm.store %525, %485 : i64, !llvm.ptr
cf.br ^bb103
^bb102:
%527 = func.call @last_bit(%516, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %527, %485 : i64, !llvm.ptr
cf.br ^bb103
^bb103:
cf.br ^bb96
^bb99:
%529 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%528 = llvm.load %529 : !llvm.ptr -> i32
%530 = arith.extsi %528 : i32 to i64
%531 = arith.constant 2 : i32
%533 = arith.extsi %531 : i32 to i64
%532 = arith.remsi %491, %533 : i64
%534 = arith.constant 0 : i32
%536 = arith.extsi %534 : i32 to i64
%535 = arith.cmpi eq, %532, %536 : i64
cf.cond_br %535, ^bb104, ^bb105
^bb104:
%537 = func.call @last_bit(%530, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %537, %485 : i64, !llvm.ptr
cf.br ^bb106
^bb105:
%538 = arith.constant 1 : i32
%539 = func.call @last_bit(%530, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%541 = arith.extsi %538 : i32 to i64
%540 = arith.subi %541, %539 : i64
llvm.store %540, %485 : i64, !llvm.ptr
cf.br ^bb106
^bb106:
cf.br ^bb96
^bb96:
%542 = arith.constant 1 : i32
%543 = arith.trunci %542 : i32 to i8
%544 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %543, %544 : i8, !llvm.ptr
%545 = llvm.load %485 : !llvm.ptr -> i64
%546 = arith.trunci %545 : i64 to i8
%547 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %546, %547 : i8, !llvm.ptr
%548 = llvm.load %485 : !llvm.ptr -> i64
func.return %548 : i64
}
func.func @drop_first(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr) -> i64 {
%550 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%549 = llvm.load %550 : !llvm.ptr -> i32
%551 = arith.extsi %549 : i32 to i64
%552 = arith.constant 0 : i32
%554 = arith.extsi %552 : i32 to i64
%553 = arith.cmpi eq, %551, %554 : i64
cf.cond_br %553, ^bb107, ^bb108
^bb107:
func.return %arg0 : i64
^bb108:
cf.br ^bb109
^bb109:
%555 = arith.constant 1 : i32
%557 = arith.extsi %555 : i32 to i64
%556 = arith.cmpi eq, %551, %557 : i64
cf.cond_br %556, ^bb110, ^bb111
^bb110:
%558 = arith.constant 0 : i32
%559 = arith.extsi %558 : i32 to i64
func.return %559 : i64
^bb111:
cf.br ^bb112
^bb112:
%561 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%560 = llvm.load %561 : !llvm.ptr -> i32
%562 = arith.constant 0 : i32
%563 = arith.cmpi sge, %560, %562 : i32
cf.cond_br %563, ^bb113, ^bb114
^bb113:
%565 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%564 = llvm.load %565 : !llvm.ptr -> i32
%566 = arith.extsi %564 : i32 to i64
func.return %566 : i64
^bb114:
cf.br ^bb115
^bb115:
%567 = arith.constant 0 : i32
%568 = arith.extsi %567 : i32 to i64
%569 = llvm.mlir.constant(1 : i64) : i64
%570 = llvm.alloca %569 x i64 : (i64) -> !llvm.ptr
llvm.store %568, %570 : i64, !llvm.ptr
%572 = llvm.getelementptr %arg1[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%571 = llvm.load %572 : !llvm.ptr -> i8
%573 = arith.extsi %571 : i8 to i64
%574 = arith.constant 1 : i32
%576 = arith.extsi %574 : i32 to i64
%575 = arith.cmpi eq, %573, %576 : i64
cf.cond_br %575, ^bb116, ^bb117
^bb116:
%578 = llvm.getelementptr %arg4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%577 = llvm.load %578 : !llvm.ptr -> i8
%579 = arith.extsi %577 : i8 to i64
%580 = arith.constant 1 : i32
%581 = arith.constant 1 : i32
%583 = arith.extsi %581 : i32 to i64
%582 = arith.subi %551, %583 : i64
%585 = arith.extsi %580 : i32 to i64
%584 = arith.shli %585, %582 : i64
%586 = arith.constant 1 : i32
%588 = arith.extsi %586 : i32 to i64
%587 = arith.subi %584, %588 : i64
%590 = arith.andi %579, %587 : i64
%591 = arith.constant 1 : i32
%593 = arith.extsi %591 : i32 to i64
%592 = arith.subi %551, %593 : i64
%589 = func.call @new_lit(%590, %592, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %589, %570 : i64, !llvm.ptr
cf.br ^bb118
^bb117:
%594 = arith.constant 2 : i32
%596 = arith.extsi %594 : i32 to i64
%595 = arith.cmpi eq, %573, %596 : i64
cf.cond_br %595, ^bb120, ^bb119
^bb120:
%600 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%599 = llvm.load %600 : !llvm.ptr -> i32
%601 = arith.extsi %599 : i32 to i64
%598 = func.call @drop_first(%601, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%597 = func.call @new_comp(%598, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %597, %570 : i64, !llvm.ptr
cf.br ^bb118
^bb119:
%602 = arith.constant 3 : i32
%604 = arith.extsi %602 : i32 to i64
%603 = arith.cmpi eq, %573, %604 : i64
cf.cond_br %603, ^bb122, ^bb121
^bb122:
%607 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%606 = llvm.load %607 : !llvm.ptr -> i32
%608 = arith.extsi %606 : i32 to i64
%609 = arith.constant 1 : i32
%611 = arith.extsi %609 : i32 to i64
%610 = arith.subi %551, %611 : i64
%605 = func.call @new_odd(%608, %610, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %605, %570 : i64, !llvm.ptr
cf.br ^bb118
^bb121:
%615 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%614 = llvm.load %615 : !llvm.ptr -> i32
%616 = arith.extsi %614 : i32 to i64
%613 = func.call @drop_first(%616, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%617 = arith.constant 1 : i32
%619 = arith.extsi %617 : i32 to i64
%618 = arith.subi %551, %619 : i64
%612 = func.call @new_even(%613, %618, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %612, %570 : i64, !llvm.ptr
cf.br ^bb118
^bb118:
%620 = llvm.load %570 : !llvm.ptr -> i64
%621 = arith.trunci %620 : i64 to i32
%622 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %621, %622 : i32, !llvm.ptr
%623 = llvm.load %570 : !llvm.ptr -> i64
func.return %623 : i64
}
func.func @drop_last(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr) -> i64 {
%625 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%624 = llvm.load %625 : !llvm.ptr -> i32
%626 = arith.extsi %624 : i32 to i64
%627 = arith.constant 0 : i32
%629 = arith.extsi %627 : i32 to i64
%628 = arith.cmpi eq, %626, %629 : i64
cf.cond_br %628, ^bb123, ^bb124
^bb123:
func.return %arg0 : i64
^bb124:
cf.br ^bb125
^bb125:
%630 = arith.constant 1 : i32
%632 = arith.extsi %630 : i32 to i64
%631 = arith.cmpi eq, %626, %632 : i64
cf.cond_br %631, ^bb126, ^bb127
^bb126:
%633 = arith.constant 0 : i32
%634 = arith.extsi %633 : i32 to i64
func.return %634 : i64
^bb127:
cf.br ^bb128
^bb128:
%636 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%635 = llvm.load %636 : !llvm.ptr -> i32
%637 = arith.constant 0 : i32
%638 = arith.cmpi sge, %635, %637 : i32
cf.cond_br %638, ^bb129, ^bb130
^bb129:
%640 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%639 = llvm.load %640 : !llvm.ptr -> i32
%641 = arith.extsi %639 : i32 to i64
func.return %641 : i64
^bb130:
cf.br ^bb131
^bb131:
%642 = arith.constant 0 : i32
%643 = arith.extsi %642 : i32 to i64
%644 = llvm.mlir.constant(1 : i64) : i64
%645 = llvm.alloca %644 x i64 : (i64) -> !llvm.ptr
llvm.store %643, %645 : i64, !llvm.ptr
%647 = llvm.getelementptr %arg1[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%646 = llvm.load %647 : !llvm.ptr -> i8
%648 = arith.extsi %646 : i8 to i64
%649 = arith.constant 1 : i32
%651 = arith.extsi %649 : i32 to i64
%650 = arith.cmpi eq, %648, %651 : i64
cf.cond_br %650, ^bb132, ^bb133
^bb132:
%653 = llvm.getelementptr %arg4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%652 = llvm.load %653 : !llvm.ptr -> i8
%654 = arith.extsi %652 : i8 to i64
%656 = arith.constant 1 : i32
%658 = arith.extsi %656 : i32 to i64
%657 = arith.shrsi %654, %658 : i64
%659 = arith.constant 1 : i32
%661 = arith.extsi %659 : i32 to i64
%660 = arith.subi %626, %661 : i64
%655 = func.call @new_lit(%657, %660, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %655, %645 : i64, !llvm.ptr
cf.br ^bb134
^bb133:
%662 = arith.constant 2 : i32
%664 = arith.extsi %662 : i32 to i64
%663 = arith.cmpi eq, %648, %664 : i64
cf.cond_br %663, ^bb136, ^bb135
^bb136:
%668 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%667 = llvm.load %668 : !llvm.ptr -> i32
%669 = arith.extsi %667 : i32 to i64
%666 = func.call @drop_last(%669, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%665 = func.call @new_comp(%666, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %665, %645 : i64, !llvm.ptr
cf.br ^bb134
^bb135:
%670 = arith.constant 3 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.cmpi eq, %648, %672 : i64
cf.cond_br %671, ^bb138, ^bb137
^bb138:
%674 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%673 = llvm.load %674 : !llvm.ptr -> i32
%675 = arith.extsi %673 : i32 to i64
%676 = arith.constant 2 : i32
%678 = arith.extsi %676 : i32 to i64
%677 = arith.remsi %626, %678 : i64
%679 = arith.constant 0 : i32
%681 = arith.extsi %679 : i32 to i64
%680 = arith.cmpi eq, %677, %681 : i64
cf.cond_br %680, ^bb139, ^bb140
^bb139:
%683 = arith.constant 1 : i32
%685 = arith.extsi %683 : i32 to i64
%684 = arith.subi %626, %685 : i64
%682 = func.call @new_even(%675, %684, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %682, %645 : i64, !llvm.ptr
cf.br ^bb141
^bb140:
%687 = func.call @drop_last(%675, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%688 = arith.constant 1 : i32
%690 = arith.extsi %688 : i32 to i64
%689 = arith.subi %626, %690 : i64
%686 = func.call @new_even(%687, %689, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %686, %645 : i64, !llvm.ptr
cf.br ^bb141
^bb141:
cf.br ^bb134
^bb137:
%692 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%691 = llvm.load %692 : !llvm.ptr -> i32
%693 = arith.extsi %691 : i32 to i64
%694 = arith.constant 2 : i32
%696 = arith.extsi %694 : i32 to i64
%695 = arith.remsi %626, %696 : i64
%697 = arith.constant 0 : i32
%699 = arith.extsi %697 : i32 to i64
%698 = arith.cmpi eq, %695, %699 : i64
cf.cond_br %698, ^bb142, ^bb143
^bb142:
%701 = func.call @drop_last(%693, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%702 = arith.constant 1 : i32
%704 = arith.extsi %702 : i32 to i64
%703 = arith.subi %626, %704 : i64
%700 = func.call @new_odd(%701, %703, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %700, %645 : i64, !llvm.ptr
cf.br ^bb144
^bb143:
%706 = arith.constant 1 : i32
%708 = arith.extsi %706 : i32 to i64
%707 = arith.subi %626, %708 : i64
%705 = func.call @new_odd(%693, %707, %arg1, %arg2, %arg3, %arg4, %arg5) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
llvm.store %705, %645 : i64, !llvm.ptr
cf.br ^bb144
^bb144:
cf.br ^bb134
^bb134:
%709 = llvm.load %645 : !llvm.ptr -> i64
%710 = arith.trunci %709 : i64 to i32
%711 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %710, %711 : i32, !llvm.ptr
%712 = llvm.load %645 : !llvm.ptr -> i64
func.return %712 : i64
}
func.func @evals_node(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr, %arg12: !llvm.ptr, %arg13: !llvm.ptr, %arg14: !llvm.ptr, %arg15: !llvm.ptr, %arg16: !llvm.ptr, %arg17: !llvm.ptr, %arg18: !llvm.ptr, %arg19: !llvm.ptr, %arg20: !llvm.ptr, %arg21: !llvm.ptr, %arg22: i64, %arg23: !llvm.ptr, %arg24: !llvm.ptr, %arg25: !llvm.ptr, %arg26: i64) -> () {
%714 = llvm.getelementptr %arg16[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%713 = llvm.load %714 : !llvm.ptr -> i8
%715 = arith.constant 0 : i32
%717 = arith.extsi %713 : i8 to i32
%716 = arith.cmpi ne, %717, %715 : i32
cf.cond_br %716, ^bb145, ^bb146
^bb145:
func.return
^bb146:
cf.br ^bb147
^bb147:
%719 = llvm.getelementptr %arg6[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%718 = llvm.load %719 : !llvm.ptr -> i32
%720 = arith.extsi %718 : i32 to i64
%722 = llvm.getelementptr %arg4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%721 = llvm.load %722 : !llvm.ptr -> i8
%723 = arith.extsi %721 : i8 to i64
%724 = arith.constant 0 : i32
%726 = arith.extsi %724 : i32 to i64
%725 = arith.cmpi eq, %720, %726 : i64
cf.cond_br %725, ^bb148, ^bb149
^bb148:
%727 = arith.constant 0 : i32
%728 = arith.extsi %727 : i32 to i64
%729 = llvm.mlir.constant(1 : i64) : i64
%730 = llvm.alloca %729 x i64 : (i64) -> !llvm.ptr
llvm.store %728, %730 : i64, !llvm.ptr
cf.br ^bb151
^bb151:
%731 = llvm.load %730 : !llvm.ptr -> i64
%732 = arith.cmpi slt, %731, %arg1 : i64
cf.cond_br %732, ^bb152, ^bb153
^bb152:
%733 = arith.constant 0 : i32
%734 = arith.muli %arg0, %arg1 : i64
%735 = llvm.load %730 : !llvm.ptr -> i64
%736 = arith.addi %734, %735 : i64
%737 = llvm.getelementptr %arg15[%736] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %733, %737 : i32, !llvm.ptr
%738 = llvm.load %730 : !llvm.ptr -> i64
%739 = arith.constant 1 : i32
%741 = arith.extsi %739 : i32 to i64
%740 = arith.addi %738, %741 : i64
llvm.store %740, %730 : i64, !llvm.ptr
cf.br ^bb151
^bb153:
%742 = arith.constant 1 : i32
%743 = arith.trunci %742 : i32 to i8
%744 = llvm.getelementptr %arg16[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %743, %744 : i8, !llvm.ptr
func.return
^bb149:
cf.br ^bb150
^bb150:
%745 = arith.constant 1 : i32
%747 = arith.extsi %745 : i32 to i64
%746 = arith.cmpi eq, %723, %747 : i64
cf.cond_br %746, ^bb154, ^bb155
^bb154:
%748 = arith.constant 0 : i32
%749 = arith.extsi %748 : i32 to i64
%750 = llvm.mlir.constant(1 : i64) : i64
%751 = llvm.alloca %750 x i64 : (i64) -> !llvm.ptr
llvm.store %749, %751 : i64, !llvm.ptr
cf.br ^bb157
^bb157:
%752 = llvm.load %751 : !llvm.ptr -> i64
%753 = arith.cmpi slt, %752, %arg1 : i64
cf.cond_br %753, ^bb158, ^bb159
^bb158:
%754 = arith.constant 0 : i32
%755 = arith.extsi %754 : i32 to i64
%756 = llvm.mlir.constant(1 : i64) : i64
%757 = llvm.alloca %756 x i64 : (i64) -> !llvm.ptr
llvm.store %755, %757 : i64, !llvm.ptr
%758 = arith.constant 1 : i32
%760 = arith.extsi %758 : i32 to i64
%759 = arith.subi %720, %760 : i64
%761 = llvm.mlir.constant(1 : i64) : i64
%762 = llvm.alloca %761 x i64 : (i64) -> !llvm.ptr
llvm.store %759, %762 : i64, !llvm.ptr
cf.br ^bb160
^bb160:
%763 = llvm.load %762 : !llvm.ptr -> i64
%764 = arith.constant 0 : i32
%766 = arith.extsi %764 : i32 to i64
%765 = arith.cmpi sge, %763, %766 : i64
cf.cond_br %765, ^bb161, ^bb162
^bb161:
%768 = llvm.getelementptr %arg7[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%767 = llvm.load %768 : !llvm.ptr -> i8
%769 = arith.extsi %767 : i8 to i64
%770 = llvm.load %762 : !llvm.ptr -> i64
%771 = arith.shrsi %769, %770 : i64
%772 = arith.constant 1 : i32
%774 = arith.extsi %772 : i32 to i64
%773 = arith.andi %771, %774 : i64
%775 = llvm.load %757 : !llvm.ptr -> i64
%777 = llvm.load %751 : !llvm.ptr -> i64
%778 = llvm.getelementptr %arg3[%777] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%776 = llvm.load %778 : !llvm.ptr -> i64
%779 = arith.muli %775, %776 : i64
%780 = arith.addi %779, %773 : i64
%781 = arith.remsi %780, %arg2 : i64
llvm.store %781, %757 : i64, !llvm.ptr
%782 = llvm.load %762 : !llvm.ptr -> i64
%783 = arith.constant 1 : i32
%785 = arith.extsi %783 : i32 to i64
%784 = arith.subi %782, %785 : i64
llvm.store %784, %762 : i64, !llvm.ptr
cf.br ^bb160
^bb162:
%786 = llvm.load %757 : !llvm.ptr -> i64
%787 = arith.trunci %786 : i64 to i32
%788 = arith.muli %arg0, %arg1 : i64
%789 = llvm.load %751 : !llvm.ptr -> i64
%790 = arith.addi %788, %789 : i64
%791 = llvm.getelementptr %arg15[%790] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %787, %791 : i32, !llvm.ptr
%792 = llvm.load %751 : !llvm.ptr -> i64
%793 = arith.constant 1 : i32
%795 = arith.extsi %793 : i32 to i64
%794 = arith.addi %792, %795 : i64
llvm.store %794, %751 : i64, !llvm.ptr
cf.br ^bb157
^bb159:
cf.br ^bb156
^bb155:
%796 = arith.constant 2 : i32
%798 = arith.extsi %796 : i32 to i64
%797 = arith.cmpi eq, %723, %798 : i64
cf.cond_br %797, ^bb164, ^bb163
^bb164:
%800 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%799 = llvm.load %800 : !llvm.ptr -> i32
%801 = arith.extsi %799 : i32 to i64
func.call @evals_node(%801, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%803 = arith.constant 0 : i32
%804 = arith.extsi %803 : i32 to i64
%805 = llvm.mlir.constant(1 : i64) : i64
%806 = llvm.alloca %805 x i64 : (i64) -> !llvm.ptr
llvm.store %804, %806 : i64, !llvm.ptr
cf.br ^bb165
^bb165:
%807 = llvm.load %806 : !llvm.ptr -> i64
%808 = arith.cmpi slt, %807, %arg1 : i64
cf.cond_br %808, ^bb166, ^bb167
^bb166:
%811 = llvm.load %806 : !llvm.ptr -> i64
%812 = llvm.getelementptr %arg3[%811] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%810 = llvm.load %812 : !llvm.ptr -> i64
%809 = func.call @geom_sum(%810, %720, %arg2, %arg19, %arg20, %arg21, %arg22) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%814 = arith.muli %801, %arg1 : i64
%815 = llvm.load %806 : !llvm.ptr -> i64
%816 = arith.addi %814, %815 : i64
%817 = llvm.getelementptr %arg15[%816] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%813 = llvm.load %817 : !llvm.ptr -> i32
%818 = arith.extsi %813 : i32 to i64
%819 = arith.subi %809, %818 : i64
%820 = arith.remsi %819, %arg2 : i64
%821 = arith.addi %820, %arg2 : i64
%822 = arith.remsi %821, %arg2 : i64
%823 = arith.trunci %822 : i64 to i32
%824 = arith.muli %arg0, %arg1 : i64
%825 = llvm.load %806 : !llvm.ptr -> i64
%826 = arith.addi %824, %825 : i64
%827 = llvm.getelementptr %arg15[%826] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %823, %827 : i32, !llvm.ptr
%828 = llvm.load %806 : !llvm.ptr -> i64
%829 = arith.constant 1 : i32
%831 = arith.extsi %829 : i32 to i64
%830 = arith.addi %828, %831 : i64
llvm.store %830, %806 : i64, !llvm.ptr
cf.br ^bb165
^bb167:
cf.br ^bb156
^bb163:
%832 = arith.constant 3 : i32
%834 = arith.extsi %832 : i32 to i64
%833 = arith.cmpi eq, %723, %834 : i64
cf.cond_br %833, ^bb169, ^bb168
^bb169:
%836 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%835 = llvm.load %836 : !llvm.ptr -> i32
%837 = arith.extsi %835 : i32 to i64
%838 = arith.constant 2 : i32
%840 = arith.extsi %838 : i32 to i64
%839 = arith.remsi %720, %840 : i64
%841 = arith.constant 0 : i32
%843 = arith.extsi %841 : i32 to i64
%842 = arith.cmpi eq, %839, %843 : i64
cf.cond_br %842, ^bb170, ^bb171
^bb170:
%844 = arith.constant 2 : i32
%846 = arith.extsi %844 : i32 to i64
%845 = arith.divsi %720, %846 : i64
func.call @evals_node(%837, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%848 = arith.constant 0 : i32
%849 = arith.extsi %848 : i32 to i64
%850 = llvm.mlir.constant(1 : i64) : i64
%851 = llvm.alloca %850 x i64 : (i64) -> !llvm.ptr
llvm.store %849, %851 : i64, !llvm.ptr
cf.br ^bb173
^bb173:
%852 = llvm.load %851 : !llvm.ptr -> i64
%853 = arith.cmpi slt, %852, %arg1 : i64
cf.cond_br %853, ^bb174, ^bb175
^bb174:
%854 = arith.constant 0 : i32
%855 = arith.extsi %854 : i32 to i64
%856 = llvm.mlir.constant(1 : i64) : i64
%857 = llvm.alloca %856 x i64 : (i64) -> !llvm.ptr
llvm.store %855, %857 : i64, !llvm.ptr
%858 = llvm.load %851 : !llvm.ptr -> i64
%859 = arith.constant 1 : i32
%861 = arith.extsi %859 : i32 to i64
%860 = arith.addi %858, %861 : i64
%862 = arith.cmpi slt, %860, %arg1 : i64
cf.cond_br %862, ^bb176, ^bb177
^bb176:
%864 = arith.muli %837, %arg1 : i64
%865 = llvm.load %851 : !llvm.ptr -> i64
%866 = arith.constant 1 : i32
%868 = arith.extsi %866 : i32 to i64
%867 = arith.addi %865, %868 : i64
%869 = arith.addi %864, %867 : i64
%870 = llvm.getelementptr %arg15[%869] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%863 = llvm.load %870 : !llvm.ptr -> i32
%871 = arith.extsi %863 : i32 to i64
%873 = llvm.load %851 : !llvm.ptr -> i64
%874 = llvm.getelementptr %arg3[%873] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%872 = llvm.load %874 : !llvm.ptr -> i64
%875 = arith.constant 1 : i32
%877 = arith.extsi %875 : i32 to i64
%876 = arith.subi %872, %877 : i64
%878 = arith.muli %876, %871 : i64
%881 = llvm.load %851 : !llvm.ptr -> i64
%882 = llvm.getelementptr %arg3[%881] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%880 = llvm.load %882 : !llvm.ptr -> i64
%884 = llvm.load %851 : !llvm.ptr -> i64
%885 = llvm.getelementptr %arg3[%884] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%883 = llvm.load %885 : !llvm.ptr -> i64
%886 = arith.muli %880, %883 : i64
%887 = arith.remsi %886, %arg2 : i64
%879 = func.call @geom_sum(%887, %845, %arg2, %arg19, %arg20, %arg21, %arg22) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%888 = arith.addi %878, %879 : i64
%889 = arith.remsi %888, %arg2 : i64
llvm.store %889, %857 : i64, !llvm.ptr
%890 = llvm.load %857 : !llvm.ptr -> i64
%891 = arith.constant 0 : i32
%893 = arith.extsi %891 : i32 to i64
%892 = arith.cmpi slt, %890, %893 : i64
cf.cond_br %892, ^bb179, ^bb180
^bb179:
%894 = llvm.load %857 : !llvm.ptr -> i64
%895 = arith.addi %894, %arg2 : i64
llvm.store %895, %857 : i64, !llvm.ptr
cf.br ^bb181
^bb180:
cf.br ^bb181
^bb181:
cf.br ^bb178
^bb177:
cf.br ^bb178
^bb178:
%896 = llvm.load %857 : !llvm.ptr -> i64
%897 = arith.trunci %896 : i64 to i32
%898 = arith.muli %arg0, %arg1 : i64
%899 = llvm.load %851 : !llvm.ptr -> i64
%900 = arith.addi %898, %899 : i64
%901 = llvm.getelementptr %arg15[%900] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %897, %901 : i32, !llvm.ptr
%902 = llvm.load %851 : !llvm.ptr -> i64
%903 = arith.constant 1 : i32
%905 = arith.extsi %903 : i32 to i64
%904 = arith.addi %902, %905 : i64
llvm.store %904, %851 : i64, !llvm.ptr
cf.br ^bb173
^bb175:
cf.br ^bb172
^bb171:
%906 = func.call @drop_last(%837, %arg4, %arg5, %arg6, %arg7, %arg8, %arg10, %arg9, %arg11, %arg12, %arg13, %arg14) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%907 = func.call @last_bit(%837, %arg4, %arg5, %arg6, %arg7, %arg13, %arg14, %arg11, %arg12) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.call @evals_node(%906, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%910 = llvm.getelementptr %arg18[%906] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%909 = llvm.load %910 : !llvm.ptr -> i8
%911 = arith.constant 0 : i32
%913 = arith.extsi %909 : i8 to i32
%912 = arith.cmpi eq, %913, %911 : i32
cf.cond_br %912, ^bb182, ^bb183
^bb182:
%914 = arith.constant 0 : i32
%915 = arith.extsi %914 : i32 to i64
%916 = llvm.mlir.constant(1 : i64) : i64
%917 = llvm.alloca %916 x i64 : (i64) -> !llvm.ptr
llvm.store %915, %917 : i64, !llvm.ptr
cf.br ^bb185
^bb185:
%918 = llvm.load %917 : !llvm.ptr -> i64
%919 = arith.cmpi slt, %918, %arg1 : i64
cf.cond_br %919, ^bb186, ^bb187
^bb186:
%920 = arith.constant 0 : i32
%921 = arith.extsi %920 : i32 to i64
%922 = llvm.mlir.constant(1 : i64) : i64
%923 = llvm.alloca %922 x i64 : (i64) -> !llvm.ptr
llvm.store %921, %923 : i64, !llvm.ptr
%924 = llvm.load %917 : !llvm.ptr -> i64
%925 = arith.constant 1 : i32
%927 = arith.extsi %925 : i32 to i64
%926 = arith.addi %924, %927 : i64
%928 = arith.cmpi slt, %926, %arg1 : i64
cf.cond_br %928, ^bb188, ^bb189
^bb188:
%930 = arith.muli %906, %arg1 : i64
%931 = llvm.load %917 : !llvm.ptr -> i64
%932 = arith.constant 1 : i32
%934 = arith.extsi %932 : i32 to i64
%933 = arith.addi %931, %934 : i64
%935 = arith.addi %930, %933 : i64
%936 = llvm.getelementptr %arg15[%935] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%929 = llvm.load %936 : !llvm.ptr -> i32
%937 = arith.extsi %929 : i32 to i64
%939 = llvm.load %917 : !llvm.ptr -> i64
%940 = llvm.getelementptr %arg3[%939] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%938 = llvm.load %940 : !llvm.ptr -> i64
%941 = arith.constant 1 : i32
%943 = arith.extsi %941 : i32 to i64
%942 = arith.subi %938, %943 : i64
%944 = arith.muli %942, %937 : i64
%947 = llvm.load %917 : !llvm.ptr -> i64
%948 = llvm.getelementptr %arg3[%947] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%946 = llvm.load %948 : !llvm.ptr -> i64
%950 = llvm.load %917 : !llvm.ptr -> i64
%951 = llvm.getelementptr %arg3[%950] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%949 = llvm.load %951 : !llvm.ptr -> i64
%952 = arith.muli %946, %949 : i64
%953 = arith.remsi %952, %arg2 : i64
%955 = llvm.getelementptr %arg6[%906] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%954 = llvm.load %955 : !llvm.ptr -> i32
%956 = arith.extsi %954 : i32 to i64
%945 = func.call @geom_sum(%953, %956, %arg2, %arg19, %arg20, %arg21, %arg22) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%957 = arith.addi %944, %945 : i64
%958 = arith.remsi %957, %arg2 : i64
llvm.store %958, %923 : i64, !llvm.ptr
%959 = llvm.load %923 : !llvm.ptr -> i64
%960 = arith.constant 0 : i32
%962 = arith.extsi %960 : i32 to i64
%961 = arith.cmpi slt, %959, %962 : i64
cf.cond_br %961, ^bb191, ^bb192
^bb191:
%963 = llvm.load %923 : !llvm.ptr -> i64
%964 = arith.addi %963, %arg2 : i64
llvm.store %964, %923 : i64, !llvm.ptr
cf.br ^bb193
^bb192:
cf.br ^bb193
^bb193:
cf.br ^bb190
^bb189:
cf.br ^bb190
^bb190:
%965 = llvm.load %923 : !llvm.ptr -> i64
%966 = arith.trunci %965 : i64 to i32
%967 = arith.muli %906, %arg1 : i64
%968 = llvm.load %917 : !llvm.ptr -> i64
%969 = arith.addi %967, %968 : i64
%970 = llvm.getelementptr %arg17[%969] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %966, %970 : i32, !llvm.ptr
%971 = llvm.load %917 : !llvm.ptr -> i64
%972 = arith.constant 1 : i32
%974 = arith.extsi %972 : i32 to i64
%973 = arith.addi %971, %974 : i64
llvm.store %973, %917 : i64, !llvm.ptr
cf.br ^bb185
^bb187:
%975 = arith.constant 1 : i32
%976 = arith.trunci %975 : i32 to i8
%977 = llvm.getelementptr %arg18[%906] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %976, %977 : i8, !llvm.ptr
cf.br ^bb184
^bb183:
cf.br ^bb184
^bb184:
%978 = arith.constant 0 : i32
%979 = arith.extsi %978 : i32 to i64
%980 = llvm.mlir.constant(1 : i64) : i64
%981 = llvm.alloca %980 x i64 : (i64) -> !llvm.ptr
llvm.store %979, %981 : i64, !llvm.ptr
cf.br ^bb194
^bb194:
%982 = llvm.load %981 : !llvm.ptr -> i64
%983 = arith.cmpi slt, %982, %arg1 : i64
cf.cond_br %983, ^bb195, ^bb196
^bb195:
%985 = arith.muli %906, %arg1 : i64
%986 = llvm.load %981 : !llvm.ptr -> i64
%987 = arith.addi %985, %986 : i64
%988 = llvm.getelementptr %arg17[%987] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%984 = llvm.load %988 : !llvm.ptr -> i32
%989 = arith.extsi %984 : i32 to i64
%991 = llvm.load %981 : !llvm.ptr -> i64
%992 = llvm.getelementptr %arg3[%991] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%990 = llvm.load %992 : !llvm.ptr -> i64
%993 = arith.muli %989, %990 : i64
%994 = arith.addi %993, %907 : i64
%995 = arith.remsi %994, %arg2 : i64
%996 = arith.trunci %995 : i64 to i32
%997 = arith.muli %arg0, %arg1 : i64
%998 = llvm.load %981 : !llvm.ptr -> i64
%999 = arith.addi %997, %998 : i64
%1000 = llvm.getelementptr %arg15[%999] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %996, %1000 : i32, !llvm.ptr
%1001 = llvm.load %981 : !llvm.ptr -> i64
%1002 = arith.constant 1 : i32
%1004 = arith.extsi %1002 : i32 to i64
%1003 = arith.addi %1001, %1004 : i64
llvm.store %1003, %981 : i64, !llvm.ptr
cf.br ^bb194
^bb196:
cf.br ^bb172
^bb172:
cf.br ^bb156
^bb168:
%1006 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1005 = llvm.load %1006 : !llvm.ptr -> i32
%1007 = arith.extsi %1005 : i32 to i64
%1008 = arith.constant 2 : i32
%1010 = arith.extsi %1008 : i32 to i64
%1009 = arith.divsi %720, %1010 : i64
%1011 = func.call @first_bit(%1007, %arg4, %arg5, %arg6, %arg7, %arg11, %arg12) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%1012 = func.call @last_bit(%1007, %arg4, %arg5, %arg6, %arg7, %arg13, %arg14, %arg11, %arg12) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%1013 = arith.constant 2 : i32
%1015 = arith.extsi %1013 : i32 to i64
%1014 = arith.remsi %720, %1015 : i64
%1016 = arith.constant 1 : i32
%1018 = arith.extsi %1016 : i32 to i64
%1017 = arith.cmpi eq, %1014, %1018 : i64
cf.cond_br %1017, ^bb197, ^bb198
^bb197:
%1019 = func.call @drop_first(%1007, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg11, %arg12, %arg13, %arg14) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.call @evals_node(%1019, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%1022 = llvm.getelementptr %arg18[%1019] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%1021 = llvm.load %1022 : !llvm.ptr -> i8
%1023 = arith.constant 0 : i32
%1025 = arith.extsi %1021 : i8 to i32
%1024 = arith.cmpi eq, %1025, %1023 : i32
cf.cond_br %1024, ^bb200, ^bb201
^bb200:
%1026 = arith.constant 0 : i32
%1027 = arith.extsi %1026 : i32 to i64
%1028 = llvm.mlir.constant(1 : i64) : i64
%1029 = llvm.alloca %1028 x i64 : (i64) -> !llvm.ptr
llvm.store %1027, %1029 : i64, !llvm.ptr
cf.br ^bb203
^bb203:
%1030 = llvm.load %1029 : !llvm.ptr -> i64
%1031 = arith.cmpi slt, %1030, %arg1 : i64
cf.cond_br %1031, ^bb204, ^bb205
^bb204:
%1032 = arith.constant 0 : i32
%1033 = arith.extsi %1032 : i32 to i64
%1034 = llvm.mlir.constant(1 : i64) : i64
%1035 = llvm.alloca %1034 x i64 : (i64) -> !llvm.ptr
llvm.store %1033, %1035 : i64, !llvm.ptr
%1036 = llvm.load %1029 : !llvm.ptr -> i64
%1037 = arith.constant 1 : i32
%1039 = arith.extsi %1037 : i32 to i64
%1038 = arith.addi %1036, %1039 : i64
%1040 = arith.cmpi slt, %1038, %arg1 : i64
cf.cond_br %1040, ^bb206, ^bb207
^bb206:
%1042 = arith.muli %1019, %arg1 : i64
%1043 = llvm.load %1029 : !llvm.ptr -> i64
%1044 = arith.constant 1 : i32
%1046 = arith.extsi %1044 : i32 to i64
%1045 = arith.addi %1043, %1046 : i64
%1047 = arith.addi %1042, %1045 : i64
%1048 = llvm.getelementptr %arg15[%1047] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1041 = llvm.load %1048 : !llvm.ptr -> i32
%1049 = arith.extsi %1041 : i32 to i64
%1051 = llvm.load %1029 : !llvm.ptr -> i64
%1052 = llvm.getelementptr %arg3[%1051] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1050 = llvm.load %1052 : !llvm.ptr -> i64
%1053 = arith.constant 1 : i32
%1055 = arith.extsi %1053 : i32 to i64
%1054 = arith.subi %1050, %1055 : i64
%1056 = arith.muli %1054, %1049 : i64
%1059 = llvm.load %1029 : !llvm.ptr -> i64
%1060 = llvm.getelementptr %arg3[%1059] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1058 = llvm.load %1060 : !llvm.ptr -> i64
%1062 = llvm.load %1029 : !llvm.ptr -> i64
%1063 = llvm.getelementptr %arg3[%1062] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1061 = llvm.load %1063 : !llvm.ptr -> i64
%1064 = arith.muli %1058, %1061 : i64
%1065 = arith.remsi %1064, %arg2 : i64
%1067 = llvm.getelementptr %arg6[%1019] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1066 = llvm.load %1067 : !llvm.ptr -> i32
%1068 = arith.extsi %1066 : i32 to i64
%1057 = func.call @geom_sum(%1065, %1068, %arg2, %arg19, %arg20, %arg21, %arg22) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1069 = arith.addi %1056, %1057 : i64
%1070 = arith.remsi %1069, %arg2 : i64
llvm.store %1070, %1035 : i64, !llvm.ptr
%1071 = llvm.load %1035 : !llvm.ptr -> i64
%1072 = arith.constant 0 : i32
%1074 = arith.extsi %1072 : i32 to i64
%1073 = arith.cmpi slt, %1071, %1074 : i64
cf.cond_br %1073, ^bb209, ^bb210
^bb209:
%1075 = llvm.load %1035 : !llvm.ptr -> i64
%1076 = arith.addi %1075, %arg2 : i64
llvm.store %1076, %1035 : i64, !llvm.ptr
cf.br ^bb211
^bb210:
cf.br ^bb211
^bb211:
cf.br ^bb208
^bb207:
cf.br ^bb208
^bb208:
%1077 = llvm.load %1035 : !llvm.ptr -> i64
%1078 = arith.trunci %1077 : i64 to i32
%1079 = arith.muli %1019, %arg1 : i64
%1080 = llvm.load %1029 : !llvm.ptr -> i64
%1081 = arith.addi %1079, %1080 : i64
%1082 = llvm.getelementptr %arg17[%1081] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1078, %1082 : i32, !llvm.ptr
%1083 = llvm.load %1029 : !llvm.ptr -> i64
%1084 = arith.constant 1 : i32
%1086 = arith.extsi %1084 : i32 to i64
%1085 = arith.addi %1083, %1086 : i64
llvm.store %1085, %1029 : i64, !llvm.ptr
cf.br ^bb203
^bb205:
%1087 = arith.constant 1 : i32
%1088 = arith.trunci %1087 : i32 to i8
%1089 = llvm.getelementptr %arg18[%1019] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1088, %1089 : i8, !llvm.ptr
cf.br ^bb202
^bb201:
cf.br ^bb202
^bb202:
%1090 = arith.constant 0 : i32
%1091 = arith.extsi %1090 : i32 to i64
%1092 = llvm.mlir.constant(1 : i64) : i64
%1093 = llvm.alloca %1092 x i64 : (i64) -> !llvm.ptr
llvm.store %1091, %1093 : i64, !llvm.ptr
cf.br ^bb212
^bb212:
%1094 = llvm.load %1093 : !llvm.ptr -> i64
%1095 = arith.cmpi slt, %1094, %arg1 : i64
cf.cond_br %1095, ^bb213, ^bb214
^bb213:
%1097 = arith.muli %1019, %arg1 : i64
%1098 = llvm.load %1093 : !llvm.ptr -> i64
%1099 = arith.addi %1097, %1098 : i64
%1100 = llvm.getelementptr %arg17[%1099] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1096 = llvm.load %1100 : !llvm.ptr -> i32
%1101 = arith.extsi %1096 : i32 to i64
%1102 = arith.constant 1 : i32
%1104 = arith.extsi %1102 : i32 to i64
%1103 = arith.subi %1104, %1011 : i64
%1106 = llvm.load %1093 : !llvm.ptr -> i64
%1107 = arith.constant 2 : i32
%1109 = arith.extsi %1107 : i32 to i64
%1108 = arith.muli %1109, %1009 : i64
%1105 = func.call @pow_x(%1106, %1108, %arg2, %arg3, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1110 = arith.muli %1103, %1105 : i64
%1111 = arith.addi %1110, %1101 : i64
%1112 = arith.remsi %1111, %arg2 : i64
%1113 = arith.trunci %1112 : i64 to i32
%1114 = arith.muli %arg0, %arg1 : i64
%1115 = llvm.load %1093 : !llvm.ptr -> i64
%1116 = arith.addi %1114, %1115 : i64
%1117 = llvm.getelementptr %arg15[%1116] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1113, %1117 : i32, !llvm.ptr
%1118 = llvm.load %1093 : !llvm.ptr -> i64
%1119 = arith.constant 1 : i32
%1121 = arith.extsi %1119 : i32 to i64
%1120 = arith.addi %1118, %1121 : i64
llvm.store %1120, %1093 : i64, !llvm.ptr
cf.br ^bb212
^bb214:
cf.br ^bb199
^bb198:
%1123 = func.call @drop_first(%1007, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg11, %arg12, %arg13, %arg14) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%1122 = func.call @drop_last(%1123, %arg4, %arg5, %arg6, %arg7, %arg8, %arg10, %arg9, %arg11, %arg12, %arg13, %arg14) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.call @evals_node(%1122, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%1126 = llvm.getelementptr %arg18[%1122] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%1125 = llvm.load %1126 : !llvm.ptr -> i8
%1127 = arith.constant 0 : i32
%1129 = arith.extsi %1125 : i8 to i32
%1128 = arith.cmpi eq, %1129, %1127 : i32
cf.cond_br %1128, ^bb215, ^bb216
^bb215:
%1130 = arith.constant 0 : i32
%1131 = arith.extsi %1130 : i32 to i64
%1132 = llvm.mlir.constant(1 : i64) : i64
%1133 = llvm.alloca %1132 x i64 : (i64) -> !llvm.ptr
llvm.store %1131, %1133 : i64, !llvm.ptr
cf.br ^bb218
^bb218:
%1134 = llvm.load %1133 : !llvm.ptr -> i64
%1135 = arith.cmpi slt, %1134, %arg1 : i64
cf.cond_br %1135, ^bb219, ^bb220
^bb219:
%1136 = arith.constant 0 : i32
%1137 = arith.extsi %1136 : i32 to i64
%1138 = llvm.mlir.constant(1 : i64) : i64
%1139 = llvm.alloca %1138 x i64 : (i64) -> !llvm.ptr
llvm.store %1137, %1139 : i64, !llvm.ptr
%1140 = llvm.load %1133 : !llvm.ptr -> i64
%1141 = arith.constant 1 : i32
%1143 = arith.extsi %1141 : i32 to i64
%1142 = arith.addi %1140, %1143 : i64
%1144 = arith.cmpi slt, %1142, %arg1 : i64
cf.cond_br %1144, ^bb221, ^bb222
^bb221:
%1146 = arith.muli %1122, %arg1 : i64
%1147 = llvm.load %1133 : !llvm.ptr -> i64
%1148 = arith.constant 1 : i32
%1150 = arith.extsi %1148 : i32 to i64
%1149 = arith.addi %1147, %1150 : i64
%1151 = arith.addi %1146, %1149 : i64
%1152 = llvm.getelementptr %arg15[%1151] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1145 = llvm.load %1152 : !llvm.ptr -> i32
%1153 = arith.extsi %1145 : i32 to i64
%1155 = llvm.load %1133 : !llvm.ptr -> i64
%1156 = llvm.getelementptr %arg3[%1155] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1154 = llvm.load %1156 : !llvm.ptr -> i64
%1157 = arith.constant 1 : i32
%1159 = arith.extsi %1157 : i32 to i64
%1158 = arith.subi %1154, %1159 : i64
%1160 = arith.muli %1158, %1153 : i64
%1163 = llvm.load %1133 : !llvm.ptr -> i64
%1164 = llvm.getelementptr %arg3[%1163] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1162 = llvm.load %1164 : !llvm.ptr -> i64
%1166 = llvm.load %1133 : !llvm.ptr -> i64
%1167 = llvm.getelementptr %arg3[%1166] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1165 = llvm.load %1167 : !llvm.ptr -> i64
%1168 = arith.muli %1162, %1165 : i64
%1169 = arith.remsi %1168, %arg2 : i64
%1171 = llvm.getelementptr %arg6[%1122] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1170 = llvm.load %1171 : !llvm.ptr -> i32
%1172 = arith.extsi %1170 : i32 to i64
%1161 = func.call @geom_sum(%1169, %1172, %arg2, %arg19, %arg20, %arg21, %arg22) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1173 = arith.addi %1160, %1161 : i64
%1174 = arith.remsi %1173, %arg2 : i64
llvm.store %1174, %1139 : i64, !llvm.ptr
%1175 = llvm.load %1139 : !llvm.ptr -> i64
%1176 = arith.constant 0 : i32
%1178 = arith.extsi %1176 : i32 to i64
%1177 = arith.cmpi slt, %1175, %1178 : i64
cf.cond_br %1177, ^bb224, ^bb225
^bb224:
%1179 = llvm.load %1139 : !llvm.ptr -> i64
%1180 = arith.addi %1179, %arg2 : i64
llvm.store %1180, %1139 : i64, !llvm.ptr
cf.br ^bb226
^bb225:
cf.br ^bb226
^bb226:
cf.br ^bb223
^bb222:
cf.br ^bb223
^bb223:
%1181 = llvm.load %1139 : !llvm.ptr -> i64
%1182 = arith.trunci %1181 : i64 to i32
%1183 = arith.muli %1122, %arg1 : i64
%1184 = llvm.load %1133 : !llvm.ptr -> i64
%1185 = arith.addi %1183, %1184 : i64
%1186 = llvm.getelementptr %arg17[%1185] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1182, %1186 : i32, !llvm.ptr
%1187 = llvm.load %1133 : !llvm.ptr -> i64
%1188 = arith.constant 1 : i32
%1190 = arith.extsi %1188 : i32 to i64
%1189 = arith.addi %1187, %1190 : i64
llvm.store %1189, %1133 : i64, !llvm.ptr
cf.br ^bb218
^bb220:
%1191 = arith.constant 1 : i32
%1192 = arith.trunci %1191 : i32 to i8
%1193 = llvm.getelementptr %arg18[%1122] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1192, %1193 : i8, !llvm.ptr
cf.br ^bb217
^bb216:
cf.br ^bb217
^bb217:
%1194 = arith.constant 0 : i32
%1195 = arith.extsi %1194 : i32 to i64
%1196 = llvm.mlir.constant(1 : i64) : i64
%1197 = llvm.alloca %1196 x i64 : (i64) -> !llvm.ptr
llvm.store %1195, %1197 : i64, !llvm.ptr
cf.br ^bb227
^bb227:
%1198 = llvm.load %1197 : !llvm.ptr -> i64
%1199 = arith.cmpi slt, %1198, %arg1 : i64
cf.cond_br %1199, ^bb228, ^bb229
^bb228:
%1201 = arith.muli %1122, %arg1 : i64
%1202 = llvm.load %1197 : !llvm.ptr -> i64
%1203 = arith.addi %1201, %1202 : i64
%1204 = llvm.getelementptr %arg17[%1203] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1200 = llvm.load %1204 : !llvm.ptr -> i32
%1205 = arith.extsi %1200 : i32 to i64
%1206 = arith.constant 1 : i32
%1208 = arith.extsi %1206 : i32 to i64
%1207 = arith.subi %1208, %1011 : i64
%1210 = llvm.load %1197 : !llvm.ptr -> i64
%1211 = arith.constant 2 : i32
%1213 = arith.extsi %1211 : i32 to i64
%1212 = arith.muli %1213, %1009 : i64
%1214 = arith.constant 1 : i32
%1216 = arith.extsi %1214 : i32 to i64
%1215 = arith.subi %1212, %1216 : i64
%1209 = func.call @pow_x(%1210, %1215, %arg2, %arg3, %arg23, %arg24, %arg25, %arg26) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1217 = arith.muli %1207, %1209 : i64
%1219 = llvm.load %1197 : !llvm.ptr -> i64
%1220 = llvm.getelementptr %arg3[%1219] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1218 = llvm.load %1220 : !llvm.ptr -> i64
%1221 = arith.muli %1205, %1218 : i64
%1222 = arith.addi %1217, %1221 : i64
%1223 = arith.addi %1222, %1012 : i64
%1224 = arith.remsi %1223, %arg2 : i64
%1225 = arith.trunci %1224 : i64 to i32
%1226 = arith.muli %arg0, %arg1 : i64
%1227 = llvm.load %1197 : !llvm.ptr -> i64
%1228 = arith.addi %1226, %1227 : i64
%1229 = llvm.getelementptr %arg15[%1228] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1225, %1229 : i32, !llvm.ptr
%1230 = llvm.load %1197 : !llvm.ptr -> i64
%1231 = arith.constant 1 : i32
%1233 = arith.extsi %1231 : i32 to i64
%1232 = arith.addi %1230, %1233 : i64
llvm.store %1232, %1197 : i64, !llvm.ptr
cf.br ^bb227
^bb229:
cf.br ^bb199
^bb199:
cf.br ^bb156
^bb156:
%1234 = arith.constant 1 : i32
%1235 = arith.trunci %1234 : i32 to i8
%1236 = llvm.getelementptr %arg16[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1235, %1236 : i8, !llvm.ptr
func.return
}
func.func @kth_word(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i64, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr) -> i64 {
%1237 = arith.constant 0 : i32
%1239 = arith.extsi %1237 : i32 to i64
%1238 = arith.cmpi eq, %arg2, %1239 : i64
cf.cond_br %1238, ^bb230, ^bb231
^bb230:
%1240 = func.call @count_start1(%arg0, %arg3, %arg4, %arg5, %arg6) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1243 = arith.constant 1 : i32
%1245 = arith.extsi %1243 : i32 to i64
%1244 = arith.subi %1240, %1245 : i64
%1246 = arith.subi %1244, %arg1 : i64
%1247 = arith.constant 1 : i32
%1248 = arith.extsi %1247 : i32 to i64
%1242 = func.call @kth_word(%arg0, %1246, %1248, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%1241 = func.call @new_comp(%1242, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1241 : i64
^bb231:
cf.br ^bb232
^bb232:
%1249 = arith.constant 3 : i32
%1251 = arith.extsi %1249 : i32 to i64
%1250 = arith.cmpi sle, %arg0, %1251 : i64
cf.cond_br %1250, ^bb233, ^bb234
^bb233:
%1252 = arith.constant 1 : i32
%1254 = arith.extsi %1252 : i32 to i64
%1253 = arith.cmpi eq, %arg0, %1254 : i64
cf.cond_br %1253, ^bb236, ^bb237
^bb236:
%1256 = arith.constant 1 : i32
%1257 = arith.constant 1 : i32
%1258 = arith.extsi %1256 : i32 to i64
%1259 = arith.extsi %1257 : i32 to i64
%1255 = func.call @new_lit(%1258, %1259, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1255 : i64
^bb237:
cf.br ^bb238
^bb238:
%1260 = arith.constant 2 : i32
%1262 = arith.extsi %1260 : i32 to i64
%1261 = arith.cmpi eq, %arg0, %1262 : i64
cf.cond_br %1261, ^bb239, ^bb240
^bb239:
%1263 = arith.constant 0 : i32
%1265 = arith.extsi %1263 : i32 to i64
%1264 = arith.cmpi eq, %arg1, %1265 : i64
cf.cond_br %1264, ^bb242, ^bb243
^bb242:
%1267 = arith.constant 2 : i32
%1268 = arith.constant 2 : i32
%1269 = arith.extsi %1267 : i32 to i64
%1270 = arith.extsi %1268 : i32 to i64
%1266 = func.call @new_lit(%1269, %1270, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1266 : i64
^bb243:
cf.br ^bb244
^bb244:
%1272 = arith.constant 3 : i32
%1273 = arith.constant 2 : i32
%1274 = arith.extsi %1272 : i32 to i64
%1275 = arith.extsi %1273 : i32 to i64
%1271 = func.call @new_lit(%1274, %1275, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1271 : i64
^bb240:
cf.br ^bb241
^bb241:
%1276 = arith.constant 0 : i32
%1278 = arith.extsi %1276 : i32 to i64
%1277 = arith.cmpi eq, %arg1, %1278 : i64
cf.cond_br %1277, ^bb245, ^bb246
^bb245:
%1280 = arith.constant 4 : i32
%1281 = arith.constant 3 : i32
%1282 = arith.extsi %1280 : i32 to i64
%1283 = arith.extsi %1281 : i32 to i64
%1279 = func.call @new_lit(%1282, %1283, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1279 : i64
^bb246:
cf.br ^bb247
^bb247:
%1284 = arith.constant 1 : i32
%1286 = arith.extsi %1284 : i32 to i64
%1285 = arith.cmpi eq, %arg1, %1286 : i64
cf.cond_br %1285, ^bb248, ^bb249
^bb248:
%1288 = arith.constant 5 : i32
%1289 = arith.constant 3 : i32
%1290 = arith.extsi %1288 : i32 to i64
%1291 = arith.extsi %1289 : i32 to i64
%1287 = func.call @new_lit(%1290, %1291, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1287 : i64
^bb249:
cf.br ^bb250
^bb250:
%1293 = arith.constant 6 : i32
%1294 = arith.constant 3 : i32
%1295 = arith.extsi %1293 : i32 to i64
%1296 = arith.extsi %1294 : i32 to i64
%1292 = func.call @new_lit(%1295, %1296, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1292 : i64
^bb234:
cf.br ^bb235
^bb235:
%1297 = arith.constant 1 : i32
%1299 = arith.extsi %1297 : i32 to i64
%1298 = arith.addi %arg0, %1299 : i64
%1300 = arith.constant 2 : i32
%1302 = arith.extsi %1300 : i32 to i64
%1301 = arith.divsi %1298, %1302 : i64
%1303 = func.call @count_start1(%1301, %arg3, %arg4, %arg5, %arg6) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1304 = arith.cmpi slt, %arg1, %1303 : i64
cf.cond_br %1304, ^bb251, ^bb252
^bb251:
%1306 = arith.constant 1 : i32
%1307 = arith.extsi %1306 : i32 to i64
%1305 = func.call @kth_word(%1301, %arg1, %1307, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%1308 = func.call @new_even(%1305, %arg0, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1308 : i64
^bb252:
cf.br ^bb253
^bb253:
%1309 = arith.constant 2 : i32
%1311 = arith.extsi %1309 : i32 to i64
%1310 = arith.divsi %arg0, %1311 : i64
%1312 = arith.constant 1 : i32
%1314 = arith.extsi %1312 : i32 to i64
%1313 = arith.addi %1310, %1314 : i64
%1316 = arith.subi %arg1, %1303 : i64
%1317 = arith.constant 0 : i32
%1318 = arith.extsi %1317 : i32 to i64
%1315 = func.call @kth_word(%1313, %1316, %1318, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
%1319 = func.call @new_odd(%1315, %arg0, %arg7, %arg8, %arg9, %arg10, %arg11) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.return %1319 : i64
}
func.func @main() -> i32 {
%1320 = arith.constant 1000000000 : i32
%1321 = arith.extsi %1320 : i32 to i64
%1322 = arith.constant 1 : i32
%1323 = arith.constant 20 : i32
%1324 = arith.shli %1322, %1323 : i32
%1325 = arith.extsi %1324 : i32 to i64
%1327 = arith.constant 8 : i32
%1328 = arith.extsi %1327 : i32 to i64
%1326 = func.call @calloc(%1325, %1328) : (i64, i64) -> !llvm.ptr
%1330 = arith.constant 8 : i32
%1331 = arith.extsi %1330 : i32 to i64
%1329 = func.call @calloc(%1325, %1331) : (i64, i64) -> !llvm.ptr
%1333 = arith.constant 1 : i32
%1334 = arith.extsi %1333 : i32 to i64
%1332 = func.call @calloc(%1325, %1334) : (i64, i64) -> !llvm.ptr
%1336 = arith.constant 8 : i32
%1337 = arith.extsi %1336 : i32 to i64
%1335 = func.call @calloc(%1325, %1337) : (i64, i64) -> !llvm.ptr
%1339 = arith.constant 8 : i32
%1340 = arith.extsi %1339 : i32 to i64
%1338 = func.call @calloc(%1325, %1340) : (i64, i64) -> !llvm.ptr
%1342 = arith.constant 1 : i32
%1343 = arith.extsi %1342 : i32 to i64
%1341 = func.call @calloc(%1325, %1343) : (i64, i64) -> !llvm.ptr
%1344 = arith.constant 0 : i32
%1345 = arith.extsi %1344 : i32 to i64
%1346 = llvm.mlir.constant(1 : i64) : i64
%1347 = llvm.alloca %1346 x i64 : (i64) -> !llvm.ptr
llvm.store %1345, %1347 : i64, !llvm.ptr
%1348 = arith.constant 10 : i32
%1349 = arith.extsi %1348 : i32 to i64
%1350 = llvm.mlir.constant(1 : i64) : i64
%1351 = llvm.alloca %1350 x i64 : (i64) -> !llvm.ptr
llvm.store %1349, %1351 : i64, !llvm.ptr
%1352 = arith.constant 1 : i32
%1353 = arith.extsi %1352 : i32 to i64
%1354 = llvm.mlir.constant(1 : i64) : i64
%1355 = llvm.alloca %1354 x i64 : (i64) -> !llvm.ptr
llvm.store %1353, %1355 : i64, !llvm.ptr
cf.br ^bb254
^bb254:
%1356 = llvm.load %1355 : !llvm.ptr -> i64
%1357 = arith.constant 18 : i32
%1359 = arith.extsi %1357 : i32 to i64
%1358 = arith.cmpi sle, %1356, %1359 : i64
cf.cond_br %1358, ^bb255, ^bb256
^bb255:
%1361 = llvm.load %1351 : !llvm.ptr -> i64
%1360 = func.call @find_length(%1361, %1326, %1329, %1332, %1325, %1335, %1338, %1341, %1325) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1362 = llvm.load %1347 : !llvm.ptr -> i64
%1363 = arith.cmpi sgt, %1360, %1362 : i64
cf.cond_br %1363, ^bb257, ^bb258
^bb257:
llvm.store %1360, %1347 : i64, !llvm.ptr
cf.br ^bb259
^bb258:
cf.br ^bb259
^bb259:
%1364 = llvm.load %1355 : !llvm.ptr -> i64
%1365 = arith.constant 18 : i32
%1367 = arith.extsi %1365 : i32 to i64
%1366 = arith.cmpi slt, %1364, %1367 : i64
cf.cond_br %1366, ^bb260, ^bb261
^bb260:
%1368 = llvm.load %1351 : !llvm.ptr -> i64
%1369 = arith.constant 10 : i32
%1371 = arith.extsi %1369 : i32 to i64
%1370 = arith.muli %1368, %1371 : i64
llvm.store %1370, %1351 : i64, !llvm.ptr
cf.br ^bb262
^bb261:
cf.br ^bb262
^bb262:
%1372 = llvm.load %1355 : !llvm.ptr -> i64
%1373 = arith.constant 1 : i32
%1375 = arith.extsi %1373 : i32 to i64
%1374 = arith.addi %1372, %1375 : i64
llvm.store %1374, %1355 : i64, !llvm.ptr
cf.br ^bb254
^bb256:
%1376 = arith.constant 0 : i32
%1377 = arith.extsi %1376 : i32 to i64
%1378 = llvm.mlir.constant(1 : i64) : i64
%1379 = llvm.alloca %1378 x i64 : (i64) -> !llvm.ptr
llvm.store %1377, %1379 : i64, !llvm.ptr
%1380 = llvm.load %1347 : !llvm.ptr -> i64
%1381 = llvm.mlir.constant(1 : i64) : i64
%1382 = llvm.alloca %1381 x i64 : (i64) -> !llvm.ptr
llvm.store %1380, %1382 : i64, !llvm.ptr
cf.br ^bb263
^bb263:
%1383 = llvm.load %1382 : !llvm.ptr -> i64
%1384 = arith.constant 3 : i32
%1386 = arith.extsi %1384 : i32 to i64
%1385 = arith.cmpi sgt, %1383, %1386 : i64
cf.cond_br %1385, ^bb264, ^bb265
^bb264:
%1387 = llvm.load %1382 : !llvm.ptr -> i64
%1388 = arith.constant 2 : i32
%1390 = arith.extsi %1388 : i32 to i64
%1389 = arith.divsi %1387, %1390 : i64
%1391 = arith.constant 1 : i32
%1393 = arith.extsi %1391 : i32 to i64
%1392 = arith.addi %1389, %1393 : i64
llvm.store %1392, %1382 : i64, !llvm.ptr
%1394 = llvm.load %1379 : !llvm.ptr -> i64
%1395 = arith.constant 1 : i32
%1397 = arith.extsi %1395 : i32 to i64
%1396 = arith.addi %1394, %1397 : i64
llvm.store %1396, %1379 : i64, !llvm.ptr
cf.br ^bb263
^bb265:
%1398 = llvm.load %1379 : !llvm.ptr -> i64
%1399 = arith.constant 2 : i32
%1401 = arith.extsi %1399 : i32 to i64
%1400 = arith.addi %1398, %1401 : i64
%1402 = arith.constant 2 : i32
%1404 = arith.extsi %1402 : i32 to i64
%1403 = arith.addi %1400, %1404 : i64
%1406 = arith.constant 8 : i32
%1407 = arith.extsi %1406 : i32 to i64
%1405 = func.call @calloc(%1403, %1407) : (i64, i64) -> !llvm.ptr
%1408 = arith.constant 0 : i32
%1409 = arith.extsi %1408 : i32 to i64
%1410 = llvm.mlir.constant(1 : i64) : i64
%1411 = llvm.alloca %1410 x i64 : (i64) -> !llvm.ptr
llvm.store %1409, %1411 : i64, !llvm.ptr
cf.br ^bb266
^bb266:
%1412 = llvm.load %1411 : !llvm.ptr -> i64
%1413 = arith.cmpi slt, %1412, %1403 : i64
cf.cond_br %1413, ^bb267, ^bb268
^bb267:
%1414 = arith.constant 1 : i32
%1415 = arith.extsi %1414 : i32 to i64
%1416 = llvm.mlir.constant(1 : i64) : i64
%1417 = llvm.alloca %1416 x i64 : (i64) -> !llvm.ptr
llvm.store %1415, %1417 : i64, !llvm.ptr
%1418 = arith.constant 0 : i32
%1419 = arith.extsi %1418 : i32 to i64
%1420 = llvm.mlir.constant(1 : i64) : i64
%1421 = llvm.alloca %1420 x i64 : (i64) -> !llvm.ptr
llvm.store %1419, %1421 : i64, !llvm.ptr
cf.br ^bb269
^bb269:
%1422 = llvm.load %1421 : !llvm.ptr -> i64
%1423 = llvm.load %1411 : !llvm.ptr -> i64
%1424 = arith.cmpi slt, %1422, %1423 : i64
cf.cond_br %1424, ^bb270, ^bb271
^bb270:
%1425 = llvm.load %1417 : !llvm.ptr -> i64
%1426 = arith.constant 2 : i32
%1428 = arith.extsi %1426 : i32 to i64
%1427 = arith.muli %1425, %1428 : i64
llvm.store %1427, %1417 : i64, !llvm.ptr
%1429 = llvm.load %1421 : !llvm.ptr -> i64
%1430 = arith.constant 1 : i32
%1432 = arith.extsi %1430 : i32 to i64
%1431 = arith.addi %1429, %1432 : i64
llvm.store %1431, %1421 : i64, !llvm.ptr
cf.br ^bb269
^bb271:
%1434 = arith.constant 2 : i32
%1435 = llvm.load %1417 : !llvm.ptr -> i64
%1436 = arith.extsi %1434 : i32 to i64
%1433 = func.call @modpow(%1436, %1435, %1321) : (i64, i64, i64) -> i64
%1437 = llvm.load %1411 : !llvm.ptr -> i64
%1438 = llvm.getelementptr %1405[%1437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1433, %1438 : i64, !llvm.ptr
%1439 = llvm.load %1411 : !llvm.ptr -> i64
%1440 = arith.constant 1 : i32
%1442 = arith.extsi %1440 : i32 to i64
%1441 = arith.addi %1439, %1442 : i64
llvm.store %1441, %1411 : i64, !llvm.ptr
cf.br ^bb266
^bb268:
%1443 = arith.constant 50000 : i32
%1444 = arith.extsi %1443 : i32 to i64
%1446 = arith.constant 1 : i32
%1447 = arith.extsi %1446 : i32 to i64
%1445 = func.call @calloc(%1444, %1447) : (i64, i64) -> !llvm.ptr
%1449 = arith.constant 4 : i32
%1450 = arith.extsi %1449 : i32 to i64
%1448 = func.call @calloc(%1444, %1450) : (i64, i64) -> !llvm.ptr
%1452 = arith.constant 4 : i32
%1453 = arith.extsi %1452 : i32 to i64
%1451 = func.call @calloc(%1444, %1453) : (i64, i64) -> !llvm.ptr
%1455 = arith.constant 1 : i32
%1456 = arith.extsi %1455 : i32 to i64
%1454 = func.call @calloc(%1444, %1456) : (i64, i64) -> !llvm.ptr
%1458 = arith.constant 1 : i32
%1459 = arith.constant 8 : i32
%1460 = arith.extsi %1458 : i32 to i64
%1461 = arith.extsi %1459 : i32 to i64
%1457 = func.call @calloc(%1460, %1461) : (i64, i64) -> !llvm.ptr
%1462 = arith.constant 1 : i32
%1463 = arith.constant 0 : i32
%1464 = arith.extsi %1462 : i32 to i64
%1465 = arith.extsi %1463 : i32 to i64
%1466 = llvm.getelementptr %1457[%1465] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1464, %1466 : i64, !llvm.ptr
%1467 = arith.constant 0 : i32
%1468 = arith.constant 0 : i32
%1469 = arith.extsi %1468 : i32 to i64
%1470 = llvm.getelementptr %1451[%1469] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1467, %1470 : i32, !llvm.ptr
%1471 = arith.constant 1 : i32
%1472 = arith.constant 0 : i32
%1473 = arith.trunci %1471 : i32 to i8
%1474 = arith.extsi %1472 : i32 to i64
%1475 = llvm.getelementptr %1445[%1474] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1473, %1475 : i8, !llvm.ptr
%1476 = arith.constant 0 : i32
%1477 = arith.constant 0 : i32
%1478 = arith.trunci %1476 : i32 to i8
%1479 = arith.extsi %1477 : i32 to i64
%1480 = llvm.getelementptr %1454[%1479] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1478, %1480 : i8, !llvm.ptr
%1482 = arith.constant 4 : i32
%1483 = arith.extsi %1482 : i32 to i64
%1481 = func.call @calloc(%1444, %1483) : (i64, i64) -> !llvm.ptr
%1485 = arith.constant 4 : i32
%1486 = arith.extsi %1485 : i32 to i64
%1484 = func.call @calloc(%1444, %1486) : (i64, i64) -> !llvm.ptr
%1488 = arith.constant 1 : i32
%1489 = arith.extsi %1488 : i32 to i64
%1487 = func.call @calloc(%1444, %1489) : (i64, i64) -> !llvm.ptr
%1491 = arith.constant 1 : i32
%1492 = arith.extsi %1491 : i32 to i64
%1490 = func.call @calloc(%1444, %1492) : (i64, i64) -> !llvm.ptr
%1494 = arith.constant 1 : i32
%1495 = arith.extsi %1494 : i32 to i64
%1493 = func.call @calloc(%1444, %1495) : (i64, i64) -> !llvm.ptr
%1497 = arith.constant 1 : i32
%1498 = arith.extsi %1497 : i32 to i64
%1496 = func.call @calloc(%1444, %1498) : (i64, i64) -> !llvm.ptr
%1499 = arith.constant 0 : i32
%1500 = arith.extsi %1499 : i32 to i64
%1501 = llvm.mlir.constant(1 : i64) : i64
%1502 = llvm.alloca %1501 x i64 : (i64) -> !llvm.ptr
llvm.store %1500, %1502 : i64, !llvm.ptr
cf.br ^bb272
^bb272:
%1503 = llvm.load %1502 : !llvm.ptr -> i64
%1504 = arith.cmpi slt, %1503, %1444 : i64
cf.cond_br %1504, ^bb273, ^bb274
^bb273:
%1505 = arith.constant 1 : i32
%1507 = arith.constant 0 : i32
%1506 = arith.subi %1507, %1505 : i32
%1508 = llvm.load %1502 : !llvm.ptr -> i64
%1509 = llvm.getelementptr %1481[%1508] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1506, %1509 : i32, !llvm.ptr
%1510 = arith.constant 1 : i32
%1512 = arith.constant 0 : i32
%1511 = arith.subi %1512, %1510 : i32
%1513 = llvm.load %1502 : !llvm.ptr -> i64
%1514 = llvm.getelementptr %1484[%1513] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1511, %1514 : i32, !llvm.ptr
%1515 = llvm.load %1502 : !llvm.ptr -> i64
%1516 = arith.constant 1 : i32
%1518 = arith.extsi %1516 : i32 to i64
%1517 = arith.addi %1515, %1518 : i64
llvm.store %1517, %1502 : i64, !llvm.ptr
cf.br ^bb272
^bb274:
%1520 = arith.muli %1444, %1403 : i64
%1521 = arith.constant 4 : i32
%1522 = arith.extsi %1521 : i32 to i64
%1519 = func.call @calloc(%1520, %1522) : (i64, i64) -> !llvm.ptr
%1524 = arith.constant 1 : i32
%1525 = arith.extsi %1524 : i32 to i64
%1523 = func.call @calloc(%1444, %1525) : (i64, i64) -> !llvm.ptr
%1527 = arith.muli %1444, %1403 : i64
%1528 = arith.constant 4 : i32
%1529 = arith.extsi %1528 : i32 to i64
%1526 = func.call @calloc(%1527, %1529) : (i64, i64) -> !llvm.ptr
%1531 = arith.constant 1 : i32
%1532 = arith.extsi %1531 : i32 to i64
%1530 = func.call @calloc(%1444, %1532) : (i64, i64) -> !llvm.ptr
%1533 = arith.constant 1 : i32
%1534 = arith.constant 18 : i32
%1535 = arith.shli %1533, %1534 : i32
%1536 = arith.extsi %1535 : i32 to i64
%1538 = arith.constant 8 : i32
%1539 = arith.extsi %1538 : i32 to i64
%1537 = func.call @calloc(%1536, %1539) : (i64, i64) -> !llvm.ptr
%1541 = arith.constant 8 : i32
%1542 = arith.extsi %1541 : i32 to i64
%1540 = func.call @calloc(%1536, %1542) : (i64, i64) -> !llvm.ptr
%1544 = arith.constant 1 : i32
%1545 = arith.extsi %1544 : i32 to i64
%1543 = func.call @calloc(%1536, %1545) : (i64, i64) -> !llvm.ptr
%1547 = arith.constant 8 : i32
%1548 = arith.extsi %1547 : i32 to i64
%1546 = func.call @calloc(%1536, %1548) : (i64, i64) -> !llvm.ptr
%1550 = arith.constant 8 : i32
%1551 = arith.extsi %1550 : i32 to i64
%1549 = func.call @calloc(%1536, %1551) : (i64, i64) -> !llvm.ptr
%1553 = arith.constant 1 : i32
%1554 = arith.extsi %1553 : i32 to i64
%1552 = func.call @calloc(%1536, %1554) : (i64, i64) -> !llvm.ptr
%1555 = arith.constant 0 : i32
%1556 = arith.extsi %1555 : i32 to i64
%1557 = llvm.mlir.constant(1 : i64) : i64
%1558 = llvm.alloca %1557 x i64 : (i64) -> !llvm.ptr
llvm.store %1556, %1558 : i64, !llvm.ptr
%1559 = arith.constant 10 : i32
%1560 = arith.extsi %1559 : i32 to i64
llvm.store %1560, %1351 : i64, !llvm.ptr
%1561 = arith.constant 1 : i32
%1562 = arith.extsi %1561 : i32 to i64
llvm.store %1562, %1355 : i64, !llvm.ptr
cf.br ^bb275
^bb275:
%1563 = llvm.load %1355 : !llvm.ptr -> i64
%1564 = arith.constant 18 : i32
%1566 = arith.extsi %1564 : i32 to i64
%1565 = arith.cmpi sle, %1563, %1566 : i64
cf.cond_br %1565, ^bb276, ^bb277
^bb276:
%1567 = llvm.load %1351 : !llvm.ptr -> i64
%1568 = func.call @find_length(%1567, %1326, %1329, %1332, %1325, %1335, %1338, %1341, %1325) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1569 = arith.constant 1 : i32
%1571 = arith.extsi %1569 : i32 to i64
%1570 = arith.subi %1567, %1571 : i64
%1573 = arith.constant 1 : i32
%1575 = arith.extsi %1573 : i32 to i64
%1574 = arith.subi %1568, %1575 : i64
%1572 = func.call @count_prefix(%1574, %1326, %1329, %1332, %1325, %1335, %1338, %1341, %1325) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1576 = arith.subi %1570, %1572 : i64
%1578 = arith.constant 1 : i32
%1579 = arith.extsi %1578 : i32 to i64
%1577 = func.call @kth_word(%1568, %1576, %1579, %1326, %1329, %1332, %1325, %1445, %1448, %1451, %1454, %1457) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
func.call @evals_node(%1577, %1403, %1321, %1405, %1445, %1448, %1451, %1454, %1457, %1481, %1484, %1487, %1490, %1493, %1496, %1519, %1523, %1526, %1530, %1537, %1540, %1543, %1536, %1546, %1549, %1552, %1536) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%1582 = arith.muli %1577, %1403 : i64
%1583 = arith.constant 0 : i32
%1585 = arith.extsi %1583 : i32 to i64
%1584 = arith.addi %1582, %1585 : i64
%1586 = llvm.getelementptr %1519[%1584] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1581 = llvm.load %1586 : !llvm.ptr -> i32
%1587 = arith.extsi %1581 : i32 to i64
%1588 = llvm.load %1558 : !llvm.ptr -> i64
%1589 = arith.addi %1588, %1587 : i64
%1590 = arith.remsi %1589, %1321 : i64
llvm.store %1590, %1558 : i64, !llvm.ptr
%1591 = llvm.load %1355 : !llvm.ptr -> i64
%1592 = arith.constant 18 : i32
%1594 = arith.extsi %1592 : i32 to i64
%1593 = arith.cmpi slt, %1591, %1594 : i64
cf.cond_br %1593, ^bb278, ^bb279
^bb278:
%1595 = llvm.load %1351 : !llvm.ptr -> i64
%1596 = arith.constant 10 : i32
%1598 = arith.extsi %1596 : i32 to i64
%1597 = arith.muli %1595, %1598 : i64
llvm.store %1597, %1351 : i64, !llvm.ptr
cf.br ^bb280
^bb279:
cf.br ^bb280
^bb280:
%1599 = llvm.load %1355 : !llvm.ptr -> i64
%1600 = arith.constant 1 : i32
%1602 = arith.extsi %1600 : i32 to i64
%1601 = arith.addi %1599, %1602 : i64
llvm.store %1601, %1355 : i64, !llvm.ptr
cf.br ^bb275
^bb277:
%1603 = llvm.mlir.addressof @str_0 : !llvm.ptr
%1604 = llvm.load %1558 : !llvm.ptr -> i64
%1605 = llvm.call @printf(%1603, %1604) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%1606 = arith.constant 0 : i32
func.return %1606 : i32
}
}