Problem 393

Migrating ants: f(10) ways without collisions/edge crossings.

Answer112398351350823112
Output112398351350823112
StatusPASS
Native helperno
Runtime3010 ms
Peak memory27616 KB
Time complexityO(n) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n)?
Space complexityO(n)?
ApproachFlow solutionNot curated
VerdictUnknown

Flow source

# Project Euler 393
# Migrating ants: f(10) ways without collisions/edge crossings.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
}

function cache_get(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 cache_put(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 get_move(bits: i64, pos: i64, size: i64) -> i64 {
    let mypos: i64 = size - (pos + 1)
    return (bits >> (2 * mypos)) & 3
}

function search(row: i64, down: i64, up: i64, size: i64,
                keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64) -> i64 {
    if row == size {
        if down == 0 && up == 0 { return 2 }
        return 0
    }

    let state_key: i64 = (row << 20) | (down << 10) | up
    let hit: i64 = cache_get(keys, vals, used, cap, state_key)
    if hit >= 0 { return hit }

    let mut movebuf: array<i32, 16> = [
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    ]
    let mut result: i64 = 0
    let combinations: i64 = 1 << (2 * size)
    let mut i: i64 = 0
    while i < combinations {
        let first_move: i64 = get_move(i, 0, size)
        if first_move == 3 {
            let skip_squares: i64 = size - 1
            let skip_ids: i64 = 1 << (2 * skip_squares)
            i = i + skip_ids
            continue
        }
        let last_move: i64 = get_move(i, size - 1, size)
        if last_move == 1 {
            i = i + 1
            continue
        }
        if row == 0 {
            if first_move != 1 {
                i = i + 1
                continue
            }
        }

        let mut previous: i64 = 1
        let mut invalid: i64 = 0
        let mut failed_at: i64 = 0
        let mut pos: i64 = 0
        while pos < size {
            let current: i64 = get_move(i, pos, size)
            let bit: i64 = 1 << pos
            if current == 0 {
                if (down & bit) != 0 { invalid = 1 }
                if (up & bit) == 0 { invalid = 1 }
            } else {
                if (up & bit) != 0 { invalid = 1 }
            }
            if current == 3 {
                if previous == 1 { invalid = 1 }
            }
            if current == 2 {
                if row + 1 == size { invalid = 1 }
            }
            if invalid == 1 {
                failed_at = pos
                break
            }
            previous = current
            pos = pos + 1
        }

        if invalid == 1 {
            if failed_at != size - 1 {
                let skip_squares: i64 = size - (failed_at + 1)
                let skip_ids: i64 = 1 << (2 * skip_squares)
                i = i + skip_ids
            } else {
                i = i + 1
            }
            continue
        }

        pos = 0
        while pos < size {
            movebuf[pos] = 0
            pos = pos + 1
        }
        pos = 0
        while pos < size {
            let bit: i64 = 1 << pos
            if (down & bit) != 0 {
                movebuf[pos] = movebuf[pos] + 1
            }
            movebuf[pos] = movebuf[pos] - 1
            let current: i64 = get_move(i, pos, size)
            if current == 3 {
                movebuf[pos - 1] = movebuf[pos - 1] + 1
            }
            if current == 1 {
                movebuf[pos + 1] = movebuf[pos + 1] + 1
            }
            pos = pos + 1
        }

        let mut next_down: i64 = 0
        let mut next_up: i64 = 0
        invalid = 0
        pos = 0
        while pos < size {
            if invalid == 1 { break }
            let bit: i64 = 1 << pos
            let current: i64 = get_move(i, pos, size)
            if current == 2 {
                next_down = next_down | bit
                if row + 1 == size { invalid = 1 }
            }
            let mv: i64 = movebuf[pos] as i64
            if mv > 0 { invalid = 1 }
            if mv < 0 - 1 { invalid = 1 }
            if mv == 0 - 1 {
                next_up = next_up | bit
                if current == 2 { invalid = 1 }
            }
            pos = pos + 1
        }

        if invalid == 0 {
            result = result + search(row + 1, next_down, next_up, size, keys, vals, used, cap)
        }
        i = i + 1
    }

    cache_put(keys, vals, used, cap, state_key, result)
    return result
}

function main() -> i32 {
    let size: i64 = 10
    let cap: i64 = 2097152
    let keys: ptr<i64> = calloc(cap, 8)
    let vals: ptr<i64> = calloc(cap, 8)
    let used: ptr<i8> = calloc(cap, 1)
    if keys == null || vals == null || used == null { return 1 }

    let ans: i64 = search(0, 0, 0, size, keys, vals, used, cap)
    printf("%lld\n", ans)

    free(used)
    free(vals)
    free(keys)
    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 cache_get_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key);
void cache_put_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 get_move_i64_i64_i64(int64_t bits, int64_t pos, int64_t size);
int64_t search_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t row, int64_t down, int64_t up, int64_t size, int64_t* keys, int64_t* vals, int8_t* used, int64_t cap);
int32_t main(void);



int64_t cache_get_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 cache_put_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 get_move_i64_i64_i64(int64_t bits, int64_t pos, int64_t size) {
    int64_t mypos = (size - (pos + 1));
    return (FLOW_CHECKED_SHR((bits), ((2 * mypos))) & 3);
}

int64_t search_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t row, int64_t down, int64_t up, int64_t size, int64_t* keys, int64_t* vals, int8_t* used, int64_t cap) {
    if (row == size) {
        if ((down == 0 && up == 0)) {
            return 2;
        }
        return 0;
    }
    int64_t state_key = ((FLOW_CHECKED_SHL((row), (20)) | FLOW_CHECKED_SHL((down), (10))) | up);
    int64_t hit = cache_get_ptr_i64_ptr_i64_ptr_i8_i64_i64(keys, vals, used, cap, state_key);
    if (hit >= 0) {
        return hit;
    }
    int32_t movebuf[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int64_t result = 0;
    int64_t combinations = FLOW_CHECKED_SHL((1), ((2 * size)));
    int64_t i = 0;
    while (i < combinations) {
        int64_t first_move = get_move_i64_i64_i64(i, 0, size);
        if (first_move == 3) {
            int64_t skip_squares = (size - 1);
            int64_t skip_ids = FLOW_CHECKED_SHL((1), ((2 * skip_squares)));
            i = (i + skip_ids);
            continue;
        }
        int64_t last_move = get_move_i64_i64_i64(i, (size - 1), size);
        if (last_move == 1) {
            i = (i + 1);
            continue;
        }
        if (row == 0) {
            if (first_move != 1) {
                i = (i + 1);
                continue;
            }
        }
        int64_t previous = 1;
        int64_t invalid = 0;
        int64_t failed_at = 0;
        int64_t pos = 0;
        while (pos < size) {
            int64_t current = get_move_i64_i64_i64(i, pos, size);
            int64_t bit = FLOW_CHECKED_SHL((1), (pos));
            if (current == 0) {
                if ((down & bit) != 0) {
                    invalid = 1;
                }
                if ((up & bit) == 0) {
                    invalid = 1;
                }
            } else {
                if ((up & bit) != 0) {
                    invalid = 1;
                }
            }
            if (current == 3) {
                if (previous == 1) {
                    invalid = 1;
                }
            }
            if (current == 2) {
                if ((row + 1) == size) {
                    invalid = 1;
                }
            }
            if (invalid == 1) {
                failed_at = pos;
                break;
            }
            previous = current;
            pos = (pos + 1);
        }
        if (invalid == 1) {
            if (failed_at != (size - 1)) {
                int64_t skip_squares = (size - (failed_at + 1));
                int64_t skip_ids = FLOW_CHECKED_SHL((1), ((2 * skip_squares)));
                i = (i + skip_ids);
            } else {
                i = (i + 1);
            }
            continue;
        }
        pos = 0;
        while (pos < size) {
            movebuf[pos] = 0;
            pos = (pos + 1);
        }
        pos = 0;
        while (pos < size) {
            int64_t bit = FLOW_CHECKED_SHL((1), (pos));
            if ((down & bit) != 0) {
                movebuf[pos] = ((((unsigned)(pos) < 16) ? movebuf[pos] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(pos), 16), flow_fault_handler("array index out of bounds"), movebuf[0])) + 1);
            }
            movebuf[pos] = ((((unsigned)(pos) < 16) ? movebuf[pos] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(pos), 16), flow_fault_handler("array index out of bounds"), movebuf[0])) - 1);
            int64_t current = get_move_i64_i64_i64(i, pos, size);
            if (current == 3) {
                movebuf[(pos - 1)] = ((((unsigned)((pos - 1)) < 16) ? movebuf[(pos - 1)] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)((pos - 1)), 16), flow_fault_handler("array index out of bounds"), movebuf[0])) + 1);
            }
            if (current == 1) {
                movebuf[(pos + 1)] = ((((unsigned)((pos + 1)) < 16) ? movebuf[(pos + 1)] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)((pos + 1)), 16), flow_fault_handler("array index out of bounds"), movebuf[0])) + 1);
            }
            pos = (pos + 1);
        }
        int64_t next_down = 0;
        int64_t next_up = 0;
        invalid = 0;
        pos = 0;
        while (pos < size) {
            if (invalid == 1) {
                break;
            }
            int64_t bit = FLOW_CHECKED_SHL((1), (pos));
            int64_t current = get_move_i64_i64_i64(i, pos, size);
            if (current == 2) {
                next_down = (next_down | bit);
                if ((row + 1) == size) {
                    invalid = 1;
                }
            }
            int64_t mv = ((int64_t)((((unsigned)(pos) < 16) ? movebuf[pos] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(pos), 16), flow_fault_handler("array index out of bounds"), movebuf[0]))));
            if (mv > 0) {
                invalid = 1;
            }
            if (mv < (0 - 1)) {
                invalid = 1;
            }
            if (mv == (0 - 1)) {
                next_up = (next_up | bit);
                if (current == 2) {
                    invalid = 1;
                }
            }
            pos = (pos + 1);
        }
        if (invalid == 0) {
            result = (result + search_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64((row + 1), next_down, next_up, size, keys, vals, used, cap));
        }
        i = (i + 1);
    }
    cache_put_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(keys, vals, used, cap, state_key, result);
    return result;
}

int32_t main(void) {
    int64_t size = 10;
    int64_t cap = 2097152;
    int64_t* keys = (int64_t*)(calloc(cap, 8));
    int64_t* vals = (int64_t*)(calloc(cap, 8));
    int8_t* used = (int8_t*)(calloc(cap, 1));
    if (((keys == NULL || vals == NULL) || used == NULL)) {
        return 1;
    }
    int64_t ans = search_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_i64(0, 0, 0, size, keys, vals, used, cap);
    printf("%lld\n", ans);
    free(used);
    free(vals);
    free(keys);
    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 @cache_get(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64) -> i64 {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg4, %1 : i64, !llvm.ptr
    %2 = llvm.load %1 : !llvm.ptr -> i64
    %3 = arith.constant 0 : i32
    %5 = arith.extsi %3 : i32 to i64
    %4 = arith.cmpi slt, %2, %5 : i64
    cf.cond_br %4, ^bb0, ^bb1
    ^bb0:
      %6 = arith.constant 0 : i32
      %7 = llvm.load %1 : !llvm.ptr -> i64
      %9 = arith.extsi %6 : i32 to i64
      %8 = arith.subi %9, %7 : i64
      llvm.store %8, %1 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %10 = llvm.load %1 : !llvm.ptr -> i64
    %11 = arith.constant 1 : i32
    %13 = arith.extsi %11 : i32 to i64
    %12 = arith.subi %arg3, %13 : i64
    %14 = arith.andi %10, %12 : i64
    llvm.store %14, %1 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %16 = llvm.load %1 : !llvm.ptr -> i64
    %17 = llvm.getelementptr %arg2[%16] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %15 = llvm.load %17 : !llvm.ptr -> i8
    %18 = arith.constant 0 : i32
    %20 = arith.extsi %15 : i8 to i32
    %19 = arith.cmpi ne, %20, %18 : i32
    cf.cond_br %19, ^bb4, ^bb5
    ^bb4:
      %22 = llvm.load %1 : !llvm.ptr -> i64
      %23 = llvm.getelementptr %arg0[%22] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %21 = llvm.load %23 : !llvm.ptr -> i64
      %24 = arith.cmpi eq, %21, %arg4 : i64
      cf.cond_br %24, ^bb6, ^bb7
      ^bb6:
        %26 = llvm.load %1 : !llvm.ptr -> i64
        %27 = llvm.getelementptr %arg1[%26] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %25 = llvm.load %27 : !llvm.ptr -> i64
        func.return %25 : i64
      ^bb7:
        cf.br ^bb8
      ^bb8:
      %28 = llvm.load %1 : !llvm.ptr -> i64
      %29 = arith.constant 1 : i32
      %31 = arith.extsi %29 : i32 to i64
      %30 = arith.addi %28, %31 : i64
      %32 = arith.constant 1 : i32
      %34 = arith.extsi %32 : i32 to i64
      %33 = arith.subi %arg3, %34 : i64
      %35 = arith.andi %30, %33 : i64
      llvm.store %35, %1 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %36 = arith.constant 0 : i32
    %37 = arith.constant 1 : i32
    %38 = arith.subi %36, %37 : i32
    %39 = arith.extsi %38 : i32 to i64
    func.return %39 : i64
  }
  func.func @cache_put(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64, %arg5: i64) -> () {
    %40 = llvm.mlir.constant(1 : i64) : i64
    %41 = llvm.alloca %40 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg4, %41 : i64, !llvm.ptr
    %42 = llvm.load %41 : !llvm.ptr -> i64
    %43 = arith.constant 0 : i32
    %45 = arith.extsi %43 : i32 to i64
    %44 = arith.cmpi slt, %42, %45 : i64
    cf.cond_br %44, ^bb9, ^bb10
    ^bb9:
      %46 = arith.constant 0 : i32
      %47 = llvm.load %41 : !llvm.ptr -> i64
      %49 = arith.extsi %46 : i32 to i64
      %48 = arith.subi %49, %47 : i64
      llvm.store %48, %41 : i64, !llvm.ptr
      cf.br ^bb11
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %50 = llvm.load %41 : !llvm.ptr -> i64
    %51 = arith.constant 1 : i32
    %53 = arith.extsi %51 : i32 to i64
    %52 = arith.subi %arg3, %53 : i64
    %54 = arith.andi %50, %52 : i64
    llvm.store %54, %41 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %56 = llvm.load %41 : !llvm.ptr -> i64
    %57 = llvm.getelementptr %arg2[%56] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %55 = llvm.load %57 : !llvm.ptr -> i8
    %58 = arith.constant 0 : i32
    %60 = arith.extsi %55 : i8 to i32
    %59 = arith.cmpi ne, %60, %58 : i32
    %61 = scf.if %59 -> (i1) {
      %63 = llvm.load %41 : !llvm.ptr -> i64
      %64 = llvm.getelementptr %arg0[%63] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %62 = llvm.load %64 : !llvm.ptr -> i64
      %65 = arith.cmpi ne, %62, %arg4 : i64
      scf.yield %65 : i1
    } else {
      %66 = arith.constant false
      scf.yield %66 : i1
    }
    cf.cond_br %61, ^bb13, ^bb14
    ^bb13:
      %67 = llvm.load %41 : !llvm.ptr -> i64
      %68 = arith.constant 1 : i32
      %70 = arith.extsi %68 : i32 to i64
      %69 = arith.addi %67, %70 : i64
      %71 = arith.constant 1 : i32
      %73 = arith.extsi %71 : i32 to i64
      %72 = arith.subi %arg3, %73 : i64
      %74 = arith.andi %69, %72 : i64
      llvm.store %74, %41 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %75 = arith.constant 1 : i32
    %76 = llvm.load %41 : !llvm.ptr -> i64
    %77 = arith.trunci %75 : i32 to i8
    %78 = llvm.getelementptr %arg2[%76] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %77, %78 : i8, !llvm.ptr
    %79 = llvm.load %41 : !llvm.ptr -> i64
    %80 = llvm.getelementptr %arg0[%79] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg4, %80 : i64, !llvm.ptr
    %81 = llvm.load %41 : !llvm.ptr -> i64
    %82 = llvm.getelementptr %arg1[%81] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg5, %82 : i64, !llvm.ptr
    func.return
  }
  func.func @get_move(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %83 = arith.constant 1 : i32
    %85 = arith.extsi %83 : i32 to i64
    %84 = arith.addi %arg1, %85 : i64
    %86 = arith.subi %arg2, %84 : i64
    %87 = arith.constant 2 : i32
    %89 = arith.extsi %87 : i32 to i64
    %88 = arith.muli %89, %86 : i64
    %90 = arith.shrsi %arg0, %88 : i64
    %91 = arith.constant 3 : i32
    %93 = arith.extsi %91 : i32 to i64
    %92 = arith.andi %90, %93 : i64
    func.return %92 : i64
  }
  func.func @search(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: i64) -> i64 {
    %94 = arith.cmpi eq, %arg0, %arg3 : i64
    cf.cond_br %94, ^bb15, ^bb16
    ^bb15:
      %95 = arith.constant 0 : i32
      %97 = arith.extsi %95 : i32 to i64
      %96 = arith.cmpi eq, %arg1, %97 : i64
      %98 = scf.if %96 -> (i1) {
        %99 = arith.constant 0 : i32
        %101 = arith.extsi %99 : i32 to i64
        %100 = arith.cmpi eq, %arg2, %101 : i64
        scf.yield %100 : i1
      } else {
        %102 = arith.constant false
        scf.yield %102 : i1
      }
      cf.cond_br %98, ^bb18, ^bb19
      ^bb18:
        %103 = arith.constant 2 : i32
        %104 = arith.extsi %103 : i32 to i64
        func.return %104 : i64
      ^bb19:
        cf.br ^bb20
      ^bb20:
      %105 = arith.constant 0 : i32
      %106 = arith.extsi %105 : i32 to i64
      func.return %106 : i64
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %107 = arith.constant 20 : i32
    %109 = arith.extsi %107 : i32 to i64
    %108 = arith.shli %arg0, %109 : i64
    %110 = arith.constant 10 : i32
    %112 = arith.extsi %110 : i32 to i64
    %111 = arith.shli %arg1, %112 : i64
    %113 = arith.ori %108, %111 : i64
    %114 = arith.ori %113, %arg2 : i64
    %115 = func.call @cache_get(%arg4, %arg5, %arg6, %arg7, %114) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
    %116 = arith.constant 0 : i32
    %118 = arith.extsi %116 : i32 to i64
    %117 = arith.cmpi sge, %115, %118 : i64
    cf.cond_br %117, ^bb21, ^bb22
    ^bb21:
      func.return %115 : i64
    ^bb22:
      cf.br ^bb23
    ^bb23:
    %120 = arith.constant 0 : i32
    %121 = arith.constant 0 : i32
    %122 = arith.constant 0 : i32
    %123 = arith.constant 0 : i32
    %124 = arith.constant 0 : i32
    %125 = arith.constant 0 : i32
    %126 = arith.constant 0 : i32
    %127 = arith.constant 0 : i32
    %128 = arith.constant 0 : i32
    %129 = arith.constant 0 : i32
    %130 = arith.constant 0 : i32
    %131 = arith.constant 0 : i32
    %132 = arith.constant 0 : i32
    %133 = arith.constant 0 : i32
    %134 = arith.constant 0 : i32
    %135 = arith.constant 0 : i32
    %136 = llvm.mlir.constant(1 : i64) : i64
    %137 = llvm.alloca %136 x !llvm.array<16 x i32> : (i64) -> !llvm.ptr
    %138 = llvm.mlir.zero : !llvm.array<16 x i32>
    llvm.store %138, %137 : !llvm.array<16 x i32>, !llvm.ptr
    %139 = llvm.mlir.constant(0 : i64) : i64
    %140 = llvm.getelementptr %137[0, %139] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %120, %140 : i32, !llvm.ptr
    %141 = llvm.mlir.constant(1 : i64) : i64
    %142 = llvm.getelementptr %137[0, %141] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %121, %142 : i32, !llvm.ptr
    %143 = llvm.mlir.constant(2 : i64) : i64
    %144 = llvm.getelementptr %137[0, %143] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %122, %144 : i32, !llvm.ptr
    %145 = llvm.mlir.constant(3 : i64) : i64
    %146 = llvm.getelementptr %137[0, %145] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %123, %146 : i32, !llvm.ptr
    %147 = llvm.mlir.constant(4 : i64) : i64
    %148 = llvm.getelementptr %137[0, %147] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %124, %148 : i32, !llvm.ptr
    %149 = llvm.mlir.constant(5 : i64) : i64
    %150 = llvm.getelementptr %137[0, %149] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %125, %150 : i32, !llvm.ptr
    %151 = llvm.mlir.constant(6 : i64) : i64
    %152 = llvm.getelementptr %137[0, %151] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %126, %152 : i32, !llvm.ptr
    %153 = llvm.mlir.constant(7 : i64) : i64
    %154 = llvm.getelementptr %137[0, %153] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %127, %154 : i32, !llvm.ptr
    %155 = llvm.mlir.constant(8 : i64) : i64
    %156 = llvm.getelementptr %137[0, %155] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %128, %156 : i32, !llvm.ptr
    %157 = llvm.mlir.constant(9 : i64) : i64
    %158 = llvm.getelementptr %137[0, %157] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %129, %158 : i32, !llvm.ptr
    %159 = llvm.mlir.constant(10 : i64) : i64
    %160 = llvm.getelementptr %137[0, %159] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %130, %160 : i32, !llvm.ptr
    %161 = llvm.mlir.constant(11 : i64) : i64
    %162 = llvm.getelementptr %137[0, %161] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %131, %162 : i32, !llvm.ptr
    %163 = llvm.mlir.constant(12 : i64) : i64
    %164 = llvm.getelementptr %137[0, %163] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %132, %164 : i32, !llvm.ptr
    %165 = llvm.mlir.constant(13 : i64) : i64
    %166 = llvm.getelementptr %137[0, %165] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %133, %166 : i32, !llvm.ptr
    %167 = llvm.mlir.constant(14 : i64) : i64
    %168 = llvm.getelementptr %137[0, %167] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %134, %168 : i32, !llvm.ptr
    %169 = llvm.mlir.constant(15 : i64) : i64
    %170 = llvm.getelementptr %137[0, %169] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
    llvm.store %135, %170 : i32, !llvm.ptr
    %171 = arith.constant 0 : i32
    %172 = arith.extsi %171 : i32 to i64
    %173 = llvm.mlir.constant(1 : i64) : i64
    %174 = llvm.alloca %173 x i64 : (i64) -> !llvm.ptr
    llvm.store %172, %174 : i64, !llvm.ptr
    %175 = arith.constant 1 : i32
    %176 = arith.constant 2 : i32
    %178 = arith.extsi %176 : i32 to i64
    %177 = arith.muli %178, %arg3 : i64
    %180 = arith.extsi %175 : i32 to i64
    %179 = arith.shli %180, %177 : i64
    %181 = arith.constant 0 : i32
    %182 = arith.extsi %181 : i32 to i64
    %183 = llvm.mlir.constant(1 : i64) : i64
    %184 = llvm.alloca %183 x i64 : (i64) -> !llvm.ptr
    llvm.store %182, %184 : i64, !llvm.ptr
    cf.br ^bb24
    ^bb24:
    %185 = llvm.load %184 : !llvm.ptr -> i64
    %186 = arith.cmpi slt, %185, %179 : i64
    cf.cond_br %186, ^bb25, ^bb26
    ^bb25:
      %188 = llvm.load %184 : !llvm.ptr -> i64
      %189 = arith.constant 0 : i32
      %190 = arith.extsi %189 : i32 to i64
      %187 = func.call @get_move(%188, %190, %arg3) : (i64, i64, i64) -> i64
      %191 = arith.constant 3 : i32
      %193 = arith.extsi %191 : i32 to i64
      %192 = arith.cmpi eq, %187, %193 : i64
      cf.cond_br %192, ^bb27, ^bb28
      ^bb27:
        %194 = arith.constant 1 : i32
        %196 = arith.extsi %194 : i32 to i64
        %195 = arith.subi %arg3, %196 : i64
        %197 = arith.constant 1 : i32
        %198 = arith.constant 2 : i32
        %200 = arith.extsi %198 : i32 to i64
        %199 = arith.muli %200, %195 : i64
        %202 = arith.extsi %197 : i32 to i64
        %201 = arith.shli %202, %199 : i64
        %203 = llvm.load %184 : !llvm.ptr -> i64
        %204 = arith.addi %203, %201 : i64
        llvm.store %204, %184 : i64, !llvm.ptr
        cf.br ^bb24
      ^bb28:
        cf.br ^bb29
      ^bb29:
      %206 = llvm.load %184 : !llvm.ptr -> i64
      %207 = arith.constant 1 : i32
      %209 = arith.extsi %207 : i32 to i64
      %208 = arith.subi %arg3, %209 : i64
      %205 = func.call @get_move(%206, %208, %arg3) : (i64, i64, i64) -> i64
      %210 = arith.constant 1 : i32
      %212 = arith.extsi %210 : i32 to i64
      %211 = arith.cmpi eq, %205, %212 : i64
      cf.cond_br %211, ^bb30, ^bb31
      ^bb30:
        %213 = llvm.load %184 : !llvm.ptr -> i64
        %214 = arith.constant 1 : i32
        %216 = arith.extsi %214 : i32 to i64
        %215 = arith.addi %213, %216 : i64
        llvm.store %215, %184 : i64, !llvm.ptr
        cf.br ^bb24
      ^bb31:
        cf.br ^bb32
      ^bb32:
      %217 = arith.constant 0 : i32
      %219 = arith.extsi %217 : i32 to i64
      %218 = arith.cmpi eq, %arg0, %219 : i64
      cf.cond_br %218, ^bb33, ^bb34
      ^bb33:
        %220 = arith.constant 1 : i32
        %222 = arith.extsi %220 : i32 to i64
        %221 = arith.cmpi ne, %187, %222 : i64
        cf.cond_br %221, ^bb36, ^bb37
        ^bb36:
          %223 = llvm.load %184 : !llvm.ptr -> i64
          %224 = arith.constant 1 : i32
          %226 = arith.extsi %224 : i32 to i64
          %225 = arith.addi %223, %226 : i64
          llvm.store %225, %184 : i64, !llvm.ptr
          cf.br ^bb24
        ^bb37:
          cf.br ^bb38
        ^bb38:
        cf.br ^bb35
      ^bb34:
        cf.br ^bb35
      ^bb35:
      %227 = arith.constant 1 : i32
      %228 = arith.extsi %227 : i32 to i64
      %229 = llvm.mlir.constant(1 : i64) : i64
      %230 = llvm.alloca %229 x i64 : (i64) -> !llvm.ptr
      llvm.store %228, %230 : i64, !llvm.ptr
      %231 = arith.constant 0 : i32
      %232 = arith.extsi %231 : i32 to i64
      %233 = llvm.mlir.constant(1 : i64) : i64
      %234 = llvm.alloca %233 x i64 : (i64) -> !llvm.ptr
      llvm.store %232, %234 : i64, !llvm.ptr
      %235 = arith.constant 0 : i32
      %236 = arith.extsi %235 : i32 to i64
      %237 = llvm.mlir.constant(1 : i64) : i64
      %238 = llvm.alloca %237 x i64 : (i64) -> !llvm.ptr
      llvm.store %236, %238 : i64, !llvm.ptr
      %239 = arith.constant 0 : i32
      %240 = arith.extsi %239 : i32 to i64
      %241 = llvm.mlir.constant(1 : i64) : i64
      %242 = llvm.alloca %241 x i64 : (i64) -> !llvm.ptr
      llvm.store %240, %242 : i64, !llvm.ptr
      cf.br ^bb39
      ^bb39:
      %243 = llvm.load %242 : !llvm.ptr -> i64
      %244 = arith.cmpi slt, %243, %arg3 : i64
      cf.cond_br %244, ^bb40, ^bb41
      ^bb40:
        %246 = llvm.load %184 : !llvm.ptr -> i64
        %247 = llvm.load %242 : !llvm.ptr -> i64
        %245 = func.call @get_move(%246, %247, %arg3) : (i64, i64, i64) -> i64
        %248 = arith.constant 1 : i32
        %249 = llvm.load %242 : !llvm.ptr -> i64
        %251 = arith.extsi %248 : i32 to i64
        %250 = arith.shli %251, %249 : i64
        %252 = arith.constant 0 : i32
        %254 = arith.extsi %252 : i32 to i64
        %253 = arith.cmpi eq, %245, %254 : i64
        cf.cond_br %253, ^bb42, ^bb43
        ^bb42:
          %255 = arith.andi %arg1, %250 : i64
          %256 = arith.constant 0 : i32
          %258 = arith.extsi %256 : i32 to i64
          %257 = arith.cmpi ne, %255, %258 : i64
          cf.cond_br %257, ^bb45, ^bb46
          ^bb45:
            %259 = arith.constant 1 : i32
            %260 = arith.extsi %259 : i32 to i64
            llvm.store %260, %234 : i64, !llvm.ptr
            cf.br ^bb47
          ^bb46:
            cf.br ^bb47
          ^bb47:
          %261 = arith.andi %arg2, %250 : i64
          %262 = arith.constant 0 : i32
          %264 = arith.extsi %262 : i32 to i64
          %263 = arith.cmpi eq, %261, %264 : i64
          cf.cond_br %263, ^bb48, ^bb49
          ^bb48:
            %265 = arith.constant 1 : i32
            %266 = arith.extsi %265 : i32 to i64
            llvm.store %266, %234 : i64, !llvm.ptr
            cf.br ^bb50
          ^bb49:
            cf.br ^bb50
          ^bb50:
          cf.br ^bb44
        ^bb43:
          %267 = arith.andi %arg2, %250 : i64
          %268 = arith.constant 0 : i32
          %270 = arith.extsi %268 : i32 to i64
          %269 = arith.cmpi ne, %267, %270 : i64
          cf.cond_br %269, ^bb51, ^bb52
          ^bb51:
            %271 = arith.constant 1 : i32
            %272 = arith.extsi %271 : i32 to i64
            llvm.store %272, %234 : i64, !llvm.ptr
            cf.br ^bb53
          ^bb52:
            cf.br ^bb53
          ^bb53:
          cf.br ^bb44
        ^bb44:
        %273 = arith.constant 3 : i32
        %275 = arith.extsi %273 : i32 to i64
        %274 = arith.cmpi eq, %245, %275 : i64
        cf.cond_br %274, ^bb54, ^bb55
        ^bb54:
          %276 = llvm.load %230 : !llvm.ptr -> i64
          %277 = arith.constant 1 : i32
          %279 = arith.extsi %277 : i32 to i64
          %278 = arith.cmpi eq, %276, %279 : i64
          cf.cond_br %278, ^bb57, ^bb58
          ^bb57:
            %280 = arith.constant 1 : i32
            %281 = arith.extsi %280 : i32 to i64
            llvm.store %281, %234 : i64, !llvm.ptr
            cf.br ^bb59
          ^bb58:
            cf.br ^bb59
          ^bb59:
          cf.br ^bb56
        ^bb55:
          cf.br ^bb56
        ^bb56:
        %282 = arith.constant 2 : i32
        %284 = arith.extsi %282 : i32 to i64
        %283 = arith.cmpi eq, %245, %284 : i64
        cf.cond_br %283, ^bb60, ^bb61
        ^bb60:
          %285 = arith.constant 1 : i32
          %287 = arith.extsi %285 : i32 to i64
          %286 = arith.addi %arg0, %287 : i64
          %288 = arith.cmpi eq, %286, %arg3 : i64
          cf.cond_br %288, ^bb63, ^bb64
          ^bb63:
            %289 = arith.constant 1 : i32
            %290 = arith.extsi %289 : i32 to i64
            llvm.store %290, %234 : i64, !llvm.ptr
            cf.br ^bb65
          ^bb64:
            cf.br ^bb65
          ^bb65:
          cf.br ^bb62
        ^bb61:
          cf.br ^bb62
        ^bb62:
        %291 = llvm.load %234 : !llvm.ptr -> i64
        %292 = arith.constant 1 : i32
        %294 = arith.extsi %292 : i32 to i64
        %293 = arith.cmpi eq, %291, %294 : i64
        cf.cond_br %293, ^bb66, ^bb67
        ^bb66:
          %295 = llvm.load %242 : !llvm.ptr -> i64
          llvm.store %295, %238 : i64, !llvm.ptr
          cf.br ^bb41
        ^bb67:
          cf.br ^bb68
        ^bb68:
        llvm.store %245, %230 : i64, !llvm.ptr
        %296 = llvm.load %242 : !llvm.ptr -> i64
        %297 = arith.constant 1 : i32
        %299 = arith.extsi %297 : i32 to i64
        %298 = arith.addi %296, %299 : i64
        llvm.store %298, %242 : i64, !llvm.ptr
        cf.br ^bb39
      ^bb41:
      %300 = llvm.load %234 : !llvm.ptr -> i64
      %301 = arith.constant 1 : i32
      %303 = arith.extsi %301 : i32 to i64
      %302 = arith.cmpi eq, %300, %303 : i64
      cf.cond_br %302, ^bb69, ^bb70
      ^bb69:
        %304 = llvm.load %238 : !llvm.ptr -> i64
        %305 = arith.constant 1 : i32
        %307 = arith.extsi %305 : i32 to i64
        %306 = arith.subi %arg3, %307 : i64
        %308 = arith.cmpi ne, %304, %306 : i64
        cf.cond_br %308, ^bb72, ^bb73
        ^bb72:
          %309 = llvm.load %238 : !llvm.ptr -> i64
          %310 = arith.constant 1 : i32
          %312 = arith.extsi %310 : i32 to i64
          %311 = arith.addi %309, %312 : i64
          %313 = arith.subi %arg3, %311 : i64
          %314 = arith.constant 1 : i32
          %315 = arith.constant 2 : i32
          %317 = arith.extsi %315 : i32 to i64
          %316 = arith.muli %317, %313 : i64
          %319 = arith.extsi %314 : i32 to i64
          %318 = arith.shli %319, %316 : i64
          %320 = llvm.load %184 : !llvm.ptr -> i64
          %321 = arith.addi %320, %318 : i64
          llvm.store %321, %184 : i64, !llvm.ptr
          cf.br ^bb74
        ^bb73:
          %322 = llvm.load %184 : !llvm.ptr -> i64
          %323 = arith.constant 1 : i32
          %325 = arith.extsi %323 : i32 to i64
          %324 = arith.addi %322, %325 : i64
          llvm.store %324, %184 : i64, !llvm.ptr
          cf.br ^bb74
        ^bb74:
        cf.br ^bb24
      ^bb70:
        cf.br ^bb71
      ^bb71:
      %326 = arith.constant 0 : i32
      %327 = arith.extsi %326 : i32 to i64
      llvm.store %327, %242 : i64, !llvm.ptr
      cf.br ^bb75
      ^bb75:
      %328 = llvm.load %242 : !llvm.ptr -> i64
      %329 = arith.cmpi slt, %328, %arg3 : i64
      cf.cond_br %329, ^bb76, ^bb77
      ^bb76:
        %330 = arith.constant 0 : i32
        %331 = llvm.load %242 : !llvm.ptr -> i64
        %332 = llvm.getelementptr %137[0, %331] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
        llvm.store %330, %332 : i32, !llvm.ptr
        %333 = llvm.load %242 : !llvm.ptr -> i64
        %334 = arith.constant 1 : i32
        %336 = arith.extsi %334 : i32 to i64
        %335 = arith.addi %333, %336 : i64
        llvm.store %335, %242 : i64, !llvm.ptr
        cf.br ^bb75
      ^bb77:
      %337 = arith.constant 0 : i32
      %338 = arith.extsi %337 : i32 to i64
      llvm.store %338, %242 : i64, !llvm.ptr
      cf.br ^bb78
      ^bb78:
      %339 = llvm.load %242 : !llvm.ptr -> i64
      %340 = arith.cmpi slt, %339, %arg3 : i64
      cf.cond_br %340, ^bb79, ^bb80
      ^bb79:
        %341 = arith.constant 1 : i32
        %342 = llvm.load %242 : !llvm.ptr -> i64
        %344 = arith.extsi %341 : i32 to i64
        %343 = arith.shli %344, %342 : i64
        %345 = arith.andi %arg1, %343 : i64
        %346 = arith.constant 0 : i32
        %348 = arith.extsi %346 : i32 to i64
        %347 = arith.cmpi ne, %345, %348 : i64
        cf.cond_br %347, ^bb81, ^bb82
        ^bb81:
          %350 = llvm.load %242 : !llvm.ptr -> i64
          %351 = llvm.getelementptr %137[0, %350] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
          %349 = llvm.load %351 : !llvm.ptr -> i32
          %352 = arith.constant 1 : i32
          %353 = arith.addi %349, %352 : i32
          %354 = llvm.load %242 : !llvm.ptr -> i64
          %355 = llvm.getelementptr %137[0, %354] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
          llvm.store %353, %355 : i32, !llvm.ptr
          cf.br ^bb83
        ^bb82:
          cf.br ^bb83
        ^bb83:
        %357 = llvm.load %242 : !llvm.ptr -> i64
        %358 = llvm.getelementptr %137[0, %357] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
        %356 = llvm.load %358 : !llvm.ptr -> i32
        %359 = arith.constant 1 : i32
        %360 = arith.subi %356, %359 : i32
        %361 = llvm.load %242 : !llvm.ptr -> i64
        %362 = llvm.getelementptr %137[0, %361] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
        llvm.store %360, %362 : i32, !llvm.ptr
        %364 = llvm.load %184 : !llvm.ptr -> i64
        %365 = llvm.load %242 : !llvm.ptr -> i64
        %363 = func.call @get_move(%364, %365, %arg3) : (i64, i64, i64) -> i64
        %366 = arith.constant 3 : i32
        %368 = arith.extsi %366 : i32 to i64
        %367 = arith.cmpi eq, %363, %368 : i64
        cf.cond_br %367, ^bb84, ^bb85
        ^bb84:
          %370 = llvm.load %242 : !llvm.ptr -> i64
          %371 = arith.constant 1 : i32
          %373 = arith.extsi %371 : i32 to i64
          %372 = arith.subi %370, %373 : i64
          %374 = llvm.getelementptr %137[0, %372] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
          %369 = llvm.load %374 : !llvm.ptr -> i32
          %375 = arith.constant 1 : i32
          %376 = arith.addi %369, %375 : i32
          %377 = llvm.load %242 : !llvm.ptr -> i64
          %378 = arith.constant 1 : i32
          %380 = arith.extsi %378 : i32 to i64
          %379 = arith.subi %377, %380 : i64
          %381 = llvm.getelementptr %137[0, %379] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
          llvm.store %376, %381 : i32, !llvm.ptr
          cf.br ^bb86
        ^bb85:
          cf.br ^bb86
        ^bb86:
        %382 = arith.constant 1 : i32
        %384 = arith.extsi %382 : i32 to i64
        %383 = arith.cmpi eq, %363, %384 : i64
        cf.cond_br %383, ^bb87, ^bb88
        ^bb87:
          %386 = llvm.load %242 : !llvm.ptr -> i64
          %387 = arith.constant 1 : i32
          %389 = arith.extsi %387 : i32 to i64
          %388 = arith.addi %386, %389 : i64
          %390 = llvm.getelementptr %137[0, %388] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
          %385 = llvm.load %390 : !llvm.ptr -> i32
          %391 = arith.constant 1 : i32
          %392 = arith.addi %385, %391 : i32
          %393 = llvm.load %242 : !llvm.ptr -> i64
          %394 = arith.constant 1 : i32
          %396 = arith.extsi %394 : i32 to i64
          %395 = arith.addi %393, %396 : i64
          %397 = llvm.getelementptr %137[0, %395] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
          llvm.store %392, %397 : i32, !llvm.ptr
          cf.br ^bb89
        ^bb88:
          cf.br ^bb89
        ^bb89:
        %398 = llvm.load %242 : !llvm.ptr -> i64
        %399 = arith.constant 1 : i32
        %401 = arith.extsi %399 : i32 to i64
        %400 = arith.addi %398, %401 : i64
        llvm.store %400, %242 : i64, !llvm.ptr
        cf.br ^bb78
      ^bb80:
      %402 = arith.constant 0 : i32
      %403 = arith.extsi %402 : i32 to i64
      %404 = llvm.mlir.constant(1 : i64) : i64
      %405 = llvm.alloca %404 x i64 : (i64) -> !llvm.ptr
      llvm.store %403, %405 : i64, !llvm.ptr
      %406 = arith.constant 0 : i32
      %407 = arith.extsi %406 : i32 to i64
      %408 = llvm.mlir.constant(1 : i64) : i64
      %409 = llvm.alloca %408 x i64 : (i64) -> !llvm.ptr
      llvm.store %407, %409 : i64, !llvm.ptr
      %410 = arith.constant 0 : i32
      %411 = arith.extsi %410 : i32 to i64
      llvm.store %411, %234 : i64, !llvm.ptr
      %412 = arith.constant 0 : i32
      %413 = arith.extsi %412 : i32 to i64
      llvm.store %413, %242 : i64, !llvm.ptr
      cf.br ^bb90
      ^bb90:
      %414 = llvm.load %242 : !llvm.ptr -> i64
      %415 = arith.cmpi slt, %414, %arg3 : i64
      cf.cond_br %415, ^bb91, ^bb92
      ^bb91:
        %416 = llvm.load %234 : !llvm.ptr -> i64
        %417 = arith.constant 1 : i32
        %419 = arith.extsi %417 : i32 to i64
        %418 = arith.cmpi eq, %416, %419 : i64
        cf.cond_br %418, ^bb93, ^bb94
        ^bb93:
          cf.br ^bb92
        ^bb94:
          cf.br ^bb95
        ^bb95:
        %420 = arith.constant 1 : i32
        %421 = llvm.load %242 : !llvm.ptr -> i64
        %423 = arith.extsi %420 : i32 to i64
        %422 = arith.shli %423, %421 : i64
        %425 = llvm.load %184 : !llvm.ptr -> i64
        %426 = llvm.load %242 : !llvm.ptr -> i64
        %424 = func.call @get_move(%425, %426, %arg3) : (i64, i64, i64) -> i64
        %427 = arith.constant 2 : i32
        %429 = arith.extsi %427 : i32 to i64
        %428 = arith.cmpi eq, %424, %429 : i64
        cf.cond_br %428, ^bb96, ^bb97
        ^bb96:
          %430 = llvm.load %405 : !llvm.ptr -> i64
          %431 = arith.ori %430, %422 : i64
          llvm.store %431, %405 : i64, !llvm.ptr
          %432 = arith.constant 1 : i32
          %434 = arith.extsi %432 : i32 to i64
          %433 = arith.addi %arg0, %434 : i64
          %435 = arith.cmpi eq, %433, %arg3 : i64
          cf.cond_br %435, ^bb99, ^bb100
          ^bb99:
            %436 = arith.constant 1 : i32
            %437 = arith.extsi %436 : i32 to i64
            llvm.store %437, %234 : i64, !llvm.ptr
            cf.br ^bb101
          ^bb100:
            cf.br ^bb101
          ^bb101:
          cf.br ^bb98
        ^bb97:
          cf.br ^bb98
        ^bb98:
        %439 = llvm.load %242 : !llvm.ptr -> i64
        %440 = llvm.getelementptr %137[0, %439] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<16 x i32>
        %438 = llvm.load %440 : !llvm.ptr -> i32
        %441 = arith.extsi %438 : i32 to i64
        %442 = arith.constant 0 : i32
        %444 = arith.extsi %442 : i32 to i64
        %443 = arith.cmpi sgt, %441, %444 : i64
        cf.cond_br %443, ^bb102, ^bb103
        ^bb102:
          %445 = arith.constant 1 : i32
          %446 = arith.extsi %445 : i32 to i64
          llvm.store %446, %234 : i64, !llvm.ptr
          cf.br ^bb104
        ^bb103:
          cf.br ^bb104
        ^bb104:
        %447 = arith.constant 0 : i32
        %448 = arith.constant 1 : i32
        %449 = arith.subi %447, %448 : i32
        %451 = arith.extsi %449 : i32 to i64
        %450 = arith.cmpi slt, %441, %451 : i64
        cf.cond_br %450, ^bb105, ^bb106
        ^bb105:
          %452 = arith.constant 1 : i32
          %453 = arith.extsi %452 : i32 to i64
          llvm.store %453, %234 : i64, !llvm.ptr
          cf.br ^bb107
        ^bb106:
          cf.br ^bb107
        ^bb107:
        %454 = arith.constant 0 : i32
        %455 = arith.constant 1 : i32
        %456 = arith.subi %454, %455 : i32
        %458 = arith.extsi %456 : i32 to i64
        %457 = arith.cmpi eq, %441, %458 : i64
        cf.cond_br %457, ^bb108, ^bb109
        ^bb108:
          %459 = llvm.load %409 : !llvm.ptr -> i64
          %460 = arith.ori %459, %422 : i64
          llvm.store %460, %409 : i64, !llvm.ptr
          %461 = arith.constant 2 : i32
          %463 = arith.extsi %461 : i32 to i64
          %462 = arith.cmpi eq, %424, %463 : i64
          cf.cond_br %462, ^bb111, ^bb112
          ^bb111:
            %464 = arith.constant 1 : i32
            %465 = arith.extsi %464 : i32 to i64
            llvm.store %465, %234 : i64, !llvm.ptr
            cf.br ^bb113
          ^bb112:
            cf.br ^bb113
          ^bb113:
          cf.br ^bb110
        ^bb109:
          cf.br ^bb110
        ^bb110:
        %466 = llvm.load %242 : !llvm.ptr -> i64
        %467 = arith.constant 1 : i32
        %469 = arith.extsi %467 : i32 to i64
        %468 = arith.addi %466, %469 : i64
        llvm.store %468, %242 : i64, !llvm.ptr
        cf.br ^bb90
      ^bb92:
      %470 = llvm.load %234 : !llvm.ptr -> i64
      %471 = arith.constant 0 : i32
      %473 = arith.extsi %471 : i32 to i64
      %472 = arith.cmpi eq, %470, %473 : i64
      cf.cond_br %472, ^bb114, ^bb115
      ^bb114:
        %474 = llvm.load %174 : !llvm.ptr -> i64
        %476 = arith.constant 1 : i32
        %478 = arith.extsi %476 : i32 to i64
        %477 = arith.addi %arg0, %478 : i64
        %479 = llvm.load %405 : !llvm.ptr -> i64
        %480 = llvm.load %409 : !llvm.ptr -> i64
        %475 = func.call @search(%477, %479, %480, %arg3, %arg4, %arg5, %arg6, %arg7) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
        %481 = arith.addi %474, %475 : i64
        llvm.store %481, %174 : i64, !llvm.ptr
        cf.br ^bb116
      ^bb115:
        cf.br ^bb116
      ^bb116:
      %482 = llvm.load %184 : !llvm.ptr -> i64
      %483 = arith.constant 1 : i32
      %485 = arith.extsi %483 : i32 to i64
      %484 = arith.addi %482, %485 : i64
      llvm.store %484, %184 : i64, !llvm.ptr
      cf.br ^bb24
    ^bb26:
    %487 = llvm.load %174 : !llvm.ptr -> i64
    func.call @cache_put(%arg4, %arg5, %arg6, %arg7, %114, %487) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
    %488 = llvm.load %174 : !llvm.ptr -> i64
    func.return %488 : i64
  }
  func.func @main() -> i32 {
    %489 = arith.constant 10 : i32
    %490 = arith.extsi %489 : i32 to i64
    %491 = arith.constant 2097152 : i32
    %492 = arith.extsi %491 : i32 to i64
    %494 = arith.constant 8 : i32
    %495 = arith.extsi %494 : i32 to i64
    %493 = func.call @calloc(%492, %495) : (i64, i64) -> !llvm.ptr
    %497 = arith.constant 8 : i32
    %498 = arith.extsi %497 : i32 to i64
    %496 = func.call @calloc(%492, %498) : (i64, i64) -> !llvm.ptr
    %500 = arith.constant 1 : i32
    %501 = arith.extsi %500 : i32 to i64
    %499 = func.call @calloc(%492, %501) : (i64, i64) -> !llvm.ptr
    %502 = llvm.mlir.zero : !llvm.ptr
    %503 = llvm.icmp "eq" %493, %502 : !llvm.ptr
    %504 = scf.if %503 -> (i1) {
      %505 = arith.constant true
      scf.yield %505 : i1
    } else {
      %506 = llvm.mlir.zero : !llvm.ptr
      %507 = llvm.icmp "eq" %496, %506 : !llvm.ptr
      scf.yield %507 : i1
    }
    %508 = scf.if %504 -> (i1) {
      %509 = arith.constant true
      scf.yield %509 : i1
    } else {
      %510 = llvm.mlir.zero : !llvm.ptr
      %511 = llvm.icmp "eq" %499, %510 : !llvm.ptr
      scf.yield %511 : i1
    }
    cf.cond_br %508, ^bb117, ^bb118
    ^bb117:
      %512 = arith.constant 1 : i32
      func.return %512 : i32
    ^bb118:
      cf.br ^bb119
    ^bb119:
    %514 = arith.constant 0 : i32
    %515 = arith.constant 0 : i32
    %516 = arith.constant 0 : i32
    %517 = arith.extsi %514 : i32 to i64
    %518 = arith.extsi %515 : i32 to i64
    %519 = arith.extsi %516 : i32 to i64
    %513 = func.call @search(%517, %518, %519, %490, %493, %496, %499, %492) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
    %520 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %521 = llvm.call @printf(%520, %513) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%499) : (!llvm.ptr) -> ()
    func.call @free(%496) : (!llvm.ptr) -> ()
    func.call @free(%493) : (!llvm.ptr) -> ()
    %525 = arith.constant 0 : i32
    func.return %525 : i32
  }
}