Problem 974

Count numbers using digits {1,3,5,7,9}, divisible by 21, using all five digits, ending in 5. Find the 10^16-th such number (ordered by length then lexicographically). The answer is a 29-digit string that exceeds i64.

Answer13313751171933973557517973175
Output13313751171933973557517973175
StatusPASS
Native helperno
Runtime0 ms
Peak memory3248 KB
Time complexityO(n^4) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(n!)
Space complexityO(n)O(n)
ApproachFlow solutionPermutation enumeration or constraint search
VerdictOptimal

Flow source

# Project Euler 974
# Count numbers using digits {1,3,5,7,9}, divisible by 21, using all five
# digits, ending in 5. Find the 10^16-th such number (ordered by length then
# lexicographically). The answer is a 29-digit string that exceeds i64.

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

const MAXL: i64 = 201
const ALL: i64 = 31
const DP_SIZE: i64 = 135072

let mut g_dp: ptr<i128> = null

function dp_idx(pos: i64, m3: i64, m7: i64, mask: i64) -> i64 {
    return pos * 672 + m3 * 224 + m7 * 32 + mask
}

function bit_of(d: i64) -> i64 {
    if d == 1 { return 0 }
    if d == 3 { return 1 }
    if d == 5 { return 2 }
    if d == 7 { return 3 }
    return 4
}

function count_len(L: i64) -> i128 {
    let mut zi: i64 = 0
    while zi < DP_SIZE {
        g_dp[zi] = 0
        zi = zi + 1
    }
    g_dp[dp_idx(L, 0, 0, ALL)] = 1
    let DIGITS: array<i64, 5> = [1, 3, 5, 7, 9]
    let mut pos: i64 = L - 1
    while pos >= 0 {
        let mut nchoices: i64 = 5
        if pos == L - 1 { nchoices = 1 }
        let mut m3: i64 = 0
        while m3 < 3 {
            let mut m7: i64 = 0
            while m7 < 7 {
                let mut mask: i64 = 0
                while mask < 32 {
                    let mut total: i128 = 0
                    let mut ci: i64 = 0
                    while ci < nchoices {
                        let mut d: i64 = 5
                        if pos != L - 1 { d = DIGITS[ci] }
                        let nm3: i64 = (m3 * 10 + d) % 3
                        let nm7: i64 = (m7 * 10 + d) % 7
                        let nmask: i64 = mask ^ (1 << bit_of(d))
                        total = total + g_dp[dp_idx(pos + 1, nm3, nm7, nmask)]
                        ci = ci + 1
                    }
                    g_dp[dp_idx(pos, m3, m7, mask)] = total
                    mask = mask + 1
                }
                m7 = m7 + 1
            }
            m3 = m3 + 1
        }
        pos = pos - 1
    }
    return g_dp[dp_idx(0, 0, 0, 0)]
}

function unrank(L: i64, k0: i128, out: ptr<i8>) -> void {
    let DIGITS: array<i64, 5> = [1, 3, 5, 7, 9]
    let mut m3: i64 = 0
    let mut m7: i64 = 0
    let mut mask: i64 = 0
    let mut k: i128 = k0
    let mut pos: i64 = 0
    while pos < L {
        let mut nchoices: i64 = 5
        if pos == L - 1 { nchoices = 1 }
        let mut ci: i64 = 0
        let mut found: bool = false
        while ci < nchoices && !found {
            let mut d: i64 = 5
            if pos != L - 1 { d = DIGITS[ci] }
            let nm3: i64 = (m3 * 10 + d) % 3
            let nm7: i64 = (m7 * 10 + d) % 7
            let nmask: i64 = mask ^ (1 << bit_of(d))
            let cnt: i128 = g_dp[dp_idx(pos + 1, nm3, nm7, nmask)]
            if k > cnt {
                k = k - cnt
            } else {
                out[pos] = (48 + d) as i8
                m3 = nm3
                m7 = nm7
                mask = nmask
                found = true
            }
            ci = ci + 1
        }
        pos = pos + 1
    }
    out[L] = 0
}

function main() -> i32 {
    g_dp = calloc(DP_SIZE, 16)
    let mut n: i128 = 1
    let mut i: i64 = 0
    while i < 16 {
        n = n * 10
        i = i + 1
    }
    let mut cum: i128 = 0
    let mut targetL: i64 = 0 - 1
    let mut L: i64 = 1
    while L <= 200 {
        let c: i128 = count_len(L)
        if cum + c >= n {
            targetL = L
            break
        }
        cum = cum + c
        L = L + 2
    }
    let out: ptr<i8> = calloc(256, 1)
    unrank(targetL, n - cum, out)
    printf("%s\n", out)
    free(out)
    free(g_dp)
    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 dp_idx_i64_i64_i64_i64(int64_t pos, int64_t m3, int64_t m7, int64_t mask);
int64_t bit_of_i64(int64_t d);
__int128 count_len_i64(int64_t L);
void unrank_i64_i128_ptr_i8(int64_t L, __int128 k0, int8_t* out);
int32_t main(void);

static const int64_t MAXL = 201;
static const int64_t ALL = 31;
static const int64_t DP_SIZE = 135072;

/* Module statics */
static __int128* g_dp = NULL;



int64_t dp_idx_i64_i64_i64_i64(int64_t pos, int64_t m3, int64_t m7, int64_t mask) {
    return ((((pos * 672) + (m3 * 224)) + (m7 * 32)) + mask);
}

int64_t bit_of_i64(int64_t d) {
    if (d == 1) {
        return 0;
    }
    if (d == 3) {
        return 1;
    }
    if (d == 5) {
        return 2;
    }
    if (d == 7) {
        return 3;
    }
    return 4;
}

__int128 count_len_i64(int64_t L) {
    int64_t zi = 0;
    while (zi < DP_SIZE) {
        g_dp[zi] = 0;
        zi = (zi + 1);
    }
    g_dp[dp_idx_i64_i64_i64_i64(L, 0, 0, ALL)] = 1;
    int64_t DIGITS[5] = { 1, 3, 5, 7, 9 };
    int64_t pos = (L - 1);
    while (pos >= 0) {
        int64_t nchoices = 5;
        if (pos == (L - 1)) {
            nchoices = 1;
        }
        int64_t m3 = 0;
        while (m3 < 3) {
            int64_t m7 = 0;
            while (m7 < 7) {
                int64_t mask = 0;
                while (mask < 32) {
                    __int128 total = 0;
                    int64_t ci = 0;
                    while (ci < nchoices) {
                        int64_t d = 5;
                        if (pos != (L - 1)) {
                            d = (((unsigned)(ci) < 5) ? DIGITS[ci] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(ci), 5), flow_fault_handler("array index out of bounds"), DIGITS[0]));
                        }
                        int64_t nm3 = FLOW_CHECKED_MOD((((m3 * 10) + d)), (3));
                        int64_t nm7 = FLOW_CHECKED_MOD((((m7 * 10) + d)), (7));
                        int64_t nmask = (mask ^ FLOW_CHECKED_SHL((1), (bit_of_i64(d))));
                        total = (total + g_dp[dp_idx_i64_i64_i64_i64((pos + 1), nm3, nm7, nmask)]);
                        ci = (ci + 1);
                    }
                    g_dp[dp_idx_i64_i64_i64_i64(pos, m3, m7, mask)] = total;
                    mask = (mask + 1);
                }
                m7 = (m7 + 1);
            }
            m3 = (m3 + 1);
        }
        pos = (pos - 1);
    }
    return g_dp[dp_idx_i64_i64_i64_i64(0, 0, 0, 0)];
}

void unrank_i64_i128_ptr_i8(int64_t L, __int128 k0, int8_t* out) {
    int64_t DIGITS[5] = { 1, 3, 5, 7, 9 };
    int64_t m3 = 0;
    int64_t m7 = 0;
    int64_t mask = 0;
    __int128 k = k0;
    int64_t pos = 0;
    while (pos < L) {
        int64_t nchoices = 5;
        if (pos == (L - 1)) {
            nchoices = 1;
        }
        int64_t ci = 0;
        bool found = 0;
        while ((ci < nchoices && (!(found)))) {
            int64_t d = 5;
            if (pos != (L - 1)) {
                d = (((unsigned)(ci) < 5) ? DIGITS[ci] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(ci), 5), flow_fault_handler("array index out of bounds"), DIGITS[0]));
            }
            int64_t nm3 = FLOW_CHECKED_MOD((((m3 * 10) + d)), (3));
            int64_t nm7 = FLOW_CHECKED_MOD((((m7 * 10) + d)), (7));
            int64_t nmask = (mask ^ FLOW_CHECKED_SHL((1), (bit_of_i64(d))));
            __int128 cnt = g_dp[dp_idx_i64_i64_i64_i64((pos + 1), nm3, nm7, nmask)];
            if (k > cnt) {
                k = (k - cnt);
            } else {
                out[pos] = ((int8_t)((48 + d)));
                m3 = nm3;
                m7 = nm7;
                mask = nmask;
                found = 1;
            }
            ci = (ci + 1);
        }
        pos = (pos + 1);
    }
    out[L] = 0;
}

int32_t main(void) {
    g_dp = calloc(DP_SIZE, 16);
    __int128 n = 1;
    int64_t i = 0;
    while (i < 16) {
        n = (n * 10);
        i = (i + 1);
    }
    __int128 cum = 0;
    int64_t targetL = (0 - 1);
    int64_t L = 1;
    while (L <= 200) {
        __int128 c = count_len_i64(L);
        if ((cum + c) >= n) {
            targetL = L;
            break;
        }
        cum = (cum + c);
        L = (L + 2);
    }
    int8_t* out = (int8_t*)(calloc(256, 1));
    unrank_i64_i128_ptr_i8(targetL, (n - cum), out);
    printf("%s\n", out);
    free(out);
    free(g_dp);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%s\n\00") {addr_space = 0 : i32} : !llvm.array<4 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  // Constant: MAXL
  llvm.mlir.global internal constant @MAXL(201 : i64) : i64
  // Constant: ALL
  llvm.mlir.global internal constant @ALL(31 : i64) : i64
  // Constant: DP_SIZE
  llvm.mlir.global internal constant @DP_SIZE(135072 : i64) : i64
  // Module static: g_dp
  llvm.mlir.global internal @g_dp() {addr_space = 0 : i32} : !llvm.ptr {
    %0 = llvm.mlir.zero : !llvm.ptr
    llvm.return %0 : !llvm.ptr
  }
  func.func @dp_idx(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i64 {
    %1 = arith.constant 672 : i32
    %3 = arith.extsi %1 : i32 to i64
    %2 = arith.muli %arg0, %3 : i64
    %4 = arith.constant 224 : i32
    %6 = arith.extsi %4 : i32 to i64
    %5 = arith.muli %arg1, %6 : i64
    %7 = arith.addi %2, %5 : i64
    %8 = arith.constant 32 : i32
    %10 = arith.extsi %8 : i32 to i64
    %9 = arith.muli %arg2, %10 : i64
    %11 = arith.addi %7, %9 : i64
    %12 = arith.addi %11, %arg3 : i64
    func.return %12 : i64
  }
  func.func @bit_of(%arg0: i64) -> i64 {
    %13 = arith.constant 1 : i32
    %15 = arith.extsi %13 : i32 to i64
    %14 = arith.cmpi eq, %arg0, %15 : i64
    cf.cond_br %14, ^bb0, ^bb1
    ^bb0:
      %16 = arith.constant 0 : i32
      %17 = arith.extsi %16 : i32 to i64
      func.return %17 : i64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %18 = arith.constant 3 : i32
    %20 = arith.extsi %18 : i32 to i64
    %19 = arith.cmpi eq, %arg0, %20 : i64
    cf.cond_br %19, ^bb3, ^bb4
    ^bb3:
      %21 = arith.constant 1 : i32
      %22 = arith.extsi %21 : i32 to i64
      func.return %22 : i64
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %23 = arith.constant 5 : i32
    %25 = arith.extsi %23 : i32 to i64
    %24 = arith.cmpi eq, %arg0, %25 : i64
    cf.cond_br %24, ^bb6, ^bb7
    ^bb6:
      %26 = arith.constant 2 : i32
      %27 = arith.extsi %26 : i32 to i64
      func.return %27 : i64
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %28 = arith.constant 7 : i32
    %30 = arith.extsi %28 : i32 to i64
    %29 = arith.cmpi eq, %arg0, %30 : i64
    cf.cond_br %29, ^bb9, ^bb10
    ^bb9:
      %31 = arith.constant 3 : i32
      %32 = arith.extsi %31 : i32 to i64
      func.return %32 : i64
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %33 = arith.constant 4 : i32
    %34 = arith.extsi %33 : i32 to i64
    func.return %34 : i64
  }
  func.func @count_len(%arg0: i64) -> i128 {
    %35 = arith.constant 0 : i32
    %36 = arith.extsi %35 : i32 to i64
    %37 = llvm.mlir.constant(1 : i64) : i64
    %38 = llvm.alloca %37 x i64 : (i64) -> !llvm.ptr
    llvm.store %36, %38 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %39 = llvm.load %38 : !llvm.ptr -> i64
    %40 = llvm.mlir.addressof @DP_SIZE : !llvm.ptr
    %41 = llvm.load %40 : !llvm.ptr -> i64
    %42 = arith.cmpi slt, %39, %41 : i64
    cf.cond_br %42, ^bb13, ^bb14
    ^bb13:
      %43 = arith.constant 0 : i32
      %44 = llvm.mlir.addressof @g_dp : !llvm.ptr
      %45 = llvm.load %44 : !llvm.ptr -> !llvm.ptr
      %46 = llvm.load %38 : !llvm.ptr -> i64
      %47 = arith.extsi %43 : i32 to i128
      %48 = llvm.getelementptr %45[%46] : (!llvm.ptr, i64) -> !llvm.ptr, i128
      llvm.store %47, %48 : i128, !llvm.ptr
      %49 = llvm.load %38 : !llvm.ptr -> i64
      %50 = arith.constant 1 : i32
      %52 = arith.extsi %50 : i32 to i64
      %51 = arith.addi %49, %52 : i64
      llvm.store %51, %38 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %53 = arith.constant 1 : i32
    %54 = llvm.mlir.addressof @g_dp : !llvm.ptr
    %55 = llvm.load %54 : !llvm.ptr -> !llvm.ptr
    %57 = arith.constant 0 : i32
    %58 = arith.constant 0 : i32
    %59 = llvm.mlir.addressof @ALL : !llvm.ptr
    %60 = llvm.load %59 : !llvm.ptr -> i64
    %61 = arith.extsi %57 : i32 to i64
    %62 = arith.extsi %58 : i32 to i64
    %56 = func.call @dp_idx(%arg0, %61, %62, %60) : (i64, i64, i64, i64) -> i64
    %63 = arith.extsi %53 : i32 to i128
    %64 = llvm.getelementptr %55[%56] : (!llvm.ptr, i64) -> !llvm.ptr, i128
    llvm.store %63, %64 : i128, !llvm.ptr
    %66 = arith.constant 1 : i32
    %67 = arith.constant 3 : i32
    %68 = arith.constant 5 : i32
    %69 = arith.constant 7 : i32
    %70 = arith.constant 9 : i32
    %71 = llvm.mlir.constant(1 : i64) : i64
    %72 = llvm.alloca %71 x !llvm.array<5 x i64> : (i64) -> !llvm.ptr
    %73 = llvm.mlir.zero : !llvm.array<5 x i64>
    llvm.store %73, %72 : !llvm.array<5 x i64>, !llvm.ptr
    %74 = arith.extsi %66 : i32 to i64
    %75 = arith.extsi %67 : i32 to i64
    %76 = arith.extsi %68 : i32 to i64
    %77 = arith.extsi %69 : i32 to i64
    %78 = arith.extsi %70 : i32 to i64
    %79 = llvm.mlir.constant(0 : i64) : i64
    %80 = llvm.getelementptr %72[0, %79] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %74, %80 : i64, !llvm.ptr
    %81 = llvm.mlir.constant(1 : i64) : i64
    %82 = llvm.getelementptr %72[0, %81] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %75, %82 : i64, !llvm.ptr
    %83 = llvm.mlir.constant(2 : i64) : i64
    %84 = llvm.getelementptr %72[0, %83] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %76, %84 : i64, !llvm.ptr
    %85 = llvm.mlir.constant(3 : i64) : i64
    %86 = llvm.getelementptr %72[0, %85] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %77, %86 : i64, !llvm.ptr
    %87 = llvm.mlir.constant(4 : i64) : i64
    %88 = llvm.getelementptr %72[0, %87] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %78, %88 : i64, !llvm.ptr
    %89 = arith.constant 1 : i32
    %91 = arith.extsi %89 : i32 to i64
    %90 = arith.subi %arg0, %91 : i64
    %92 = llvm.mlir.constant(1 : i64) : i64
    %93 = llvm.alloca %92 x i64 : (i64) -> !llvm.ptr
    llvm.store %90, %93 : i64, !llvm.ptr
    cf.br ^bb15
    ^bb15:
    %94 = llvm.load %93 : !llvm.ptr -> i64
    %95 = arith.constant 0 : i32
    %97 = arith.extsi %95 : i32 to i64
    %96 = arith.cmpi sge, %94, %97 : i64
    cf.cond_br %96, ^bb16, ^bb17
    ^bb16:
      %98 = arith.constant 5 : i32
      %99 = arith.extsi %98 : i32 to i64
      %100 = llvm.mlir.constant(1 : i64) : i64
      %101 = llvm.alloca %100 x i64 : (i64) -> !llvm.ptr
      llvm.store %99, %101 : i64, !llvm.ptr
      %102 = llvm.load %93 : !llvm.ptr -> i64
      %103 = arith.constant 1 : i32
      %105 = arith.extsi %103 : i32 to i64
      %104 = arith.subi %arg0, %105 : i64
      %106 = arith.cmpi eq, %102, %104 : i64
      cf.cond_br %106, ^bb18, ^bb19
      ^bb18:
        %107 = arith.constant 1 : i32
        %108 = arith.extsi %107 : i32 to i64
        llvm.store %108, %101 : i64, !llvm.ptr
        cf.br ^bb20
      ^bb19:
        cf.br ^bb20
      ^bb20:
      %109 = arith.constant 0 : i32
      %110 = arith.extsi %109 : i32 to i64
      %111 = llvm.mlir.constant(1 : i64) : i64
      %112 = llvm.alloca %111 x i64 : (i64) -> !llvm.ptr
      llvm.store %110, %112 : i64, !llvm.ptr
      cf.br ^bb21
      ^bb21:
      %113 = llvm.load %112 : !llvm.ptr -> i64
      %114 = arith.constant 3 : i32
      %116 = arith.extsi %114 : i32 to i64
      %115 = arith.cmpi slt, %113, %116 : i64
      cf.cond_br %115, ^bb22, ^bb23
      ^bb22:
        %117 = arith.constant 0 : i32
        %118 = arith.extsi %117 : i32 to i64
        %119 = llvm.mlir.constant(1 : i64) : i64
        %120 = llvm.alloca %119 x i64 : (i64) -> !llvm.ptr
        llvm.store %118, %120 : i64, !llvm.ptr
        cf.br ^bb24
        ^bb24:
        %121 = llvm.load %120 : !llvm.ptr -> i64
        %122 = arith.constant 7 : i32
        %124 = arith.extsi %122 : i32 to i64
        %123 = arith.cmpi slt, %121, %124 : i64
        cf.cond_br %123, ^bb25, ^bb26
        ^bb25:
          %125 = arith.constant 0 : i32
          %126 = arith.extsi %125 : i32 to i64
          %127 = llvm.mlir.constant(1 : i64) : i64
          %128 = llvm.alloca %127 x i64 : (i64) -> !llvm.ptr
          llvm.store %126, %128 : i64, !llvm.ptr
          cf.br ^bb27
          ^bb27:
          %129 = llvm.load %128 : !llvm.ptr -> i64
          %130 = arith.constant 32 : i32
          %132 = arith.extsi %130 : i32 to i64
          %131 = arith.cmpi slt, %129, %132 : i64
          cf.cond_br %131, ^bb28, ^bb29
          ^bb28:
            %133 = arith.constant 0 : i32
            %134 = arith.extsi %133 : i32 to i128
            %135 = llvm.mlir.constant(1 : i64) : i64
            %136 = llvm.alloca %135 x i128 : (i64) -> !llvm.ptr
            llvm.store %134, %136 : i128, !llvm.ptr
            %137 = arith.constant 0 : i32
            %138 = arith.extsi %137 : i32 to i64
            %139 = llvm.mlir.constant(1 : i64) : i64
            %140 = llvm.alloca %139 x i64 : (i64) -> !llvm.ptr
            llvm.store %138, %140 : i64, !llvm.ptr
            cf.br ^bb30
            ^bb30:
            %141 = llvm.load %140 : !llvm.ptr -> i64
            %142 = llvm.load %101 : !llvm.ptr -> i64
            %143 = arith.cmpi slt, %141, %142 : i64
            cf.cond_br %143, ^bb31, ^bb32
            ^bb31:
              %144 = arith.constant 5 : i32
              %145 = arith.extsi %144 : i32 to i64
              %146 = llvm.mlir.constant(1 : i64) : i64
              %147 = llvm.alloca %146 x i64 : (i64) -> !llvm.ptr
              llvm.store %145, %147 : i64, !llvm.ptr
              %148 = llvm.load %93 : !llvm.ptr -> i64
              %149 = arith.constant 1 : i32
              %151 = arith.extsi %149 : i32 to i64
              %150 = arith.subi %arg0, %151 : i64
              %152 = arith.cmpi ne, %148, %150 : i64
              cf.cond_br %152, ^bb33, ^bb34
              ^bb33:
                %154 = llvm.load %140 : !llvm.ptr -> i64
                %155 = llvm.getelementptr %72[0, %154] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
                %153 = llvm.load %155 : !llvm.ptr -> i64
                llvm.store %153, %147 : i64, !llvm.ptr
                cf.br ^bb35
              ^bb34:
                cf.br ^bb35
              ^bb35:
              %156 = llvm.load %112 : !llvm.ptr -> i64
              %157 = arith.constant 10 : i32
              %159 = arith.extsi %157 : i32 to i64
              %158 = arith.muli %156, %159 : i64
              %160 = llvm.load %147 : !llvm.ptr -> i64
              %161 = arith.addi %158, %160 : i64
              %162 = arith.constant 3 : i32
              %164 = arith.extsi %162 : i32 to i64
              %163 = arith.remsi %161, %164 : i64
              %165 = llvm.load %120 : !llvm.ptr -> i64
              %166 = arith.constant 10 : i32
              %168 = arith.extsi %166 : i32 to i64
              %167 = arith.muli %165, %168 : i64
              %169 = llvm.load %147 : !llvm.ptr -> i64
              %170 = arith.addi %167, %169 : i64
              %171 = arith.constant 7 : i32
              %173 = arith.extsi %171 : i32 to i64
              %172 = arith.remsi %170, %173 : i64
              %174 = llvm.load %128 : !llvm.ptr -> i64
              %175 = arith.constant 1 : i32
              %177 = llvm.load %147 : !llvm.ptr -> i64
              %176 = func.call @bit_of(%177) : (i64) -> i64
              %179 = arith.extsi %175 : i32 to i64
              %178 = arith.shli %179, %176 : i64
              %180 = arith.xori %174, %178 : i64
              %181 = llvm.load %136 : !llvm.ptr -> i128
              %183 = llvm.mlir.addressof @g_dp : !llvm.ptr
              %184 = llvm.load %183 : !llvm.ptr -> !llvm.ptr
              %186 = llvm.load %93 : !llvm.ptr -> i64
              %187 = arith.constant 1 : i32
              %189 = arith.extsi %187 : i32 to i64
              %188 = arith.addi %186, %189 : i64
              %185 = func.call @dp_idx(%188, %163, %172, %180) : (i64, i64, i64, i64) -> i64
              %190 = llvm.getelementptr %184[%185] : (!llvm.ptr, i64) -> !llvm.ptr, i128
              %182 = llvm.load %190 : !llvm.ptr -> i128
              %192 = arith.trunci %181 : i128 to i64
              %193 = arith.trunci %182 : i128 to i64
              %191 = arith.addi %192, %193 : i64
              %194 = arith.extsi %191 : i64 to i128
              llvm.store %194, %136 : i128, !llvm.ptr
              %195 = llvm.load %140 : !llvm.ptr -> i64
              %196 = arith.constant 1 : i32
              %198 = arith.extsi %196 : i32 to i64
              %197 = arith.addi %195, %198 : i64
              llvm.store %197, %140 : i64, !llvm.ptr
              cf.br ^bb30
            ^bb32:
            %199 = llvm.load %136 : !llvm.ptr -> i128
            %200 = llvm.mlir.addressof @g_dp : !llvm.ptr
            %201 = llvm.load %200 : !llvm.ptr -> !llvm.ptr
            %203 = llvm.load %93 : !llvm.ptr -> i64
            %204 = llvm.load %112 : !llvm.ptr -> i64
            %205 = llvm.load %120 : !llvm.ptr -> i64
            %206 = llvm.load %128 : !llvm.ptr -> i64
            %202 = func.call @dp_idx(%203, %204, %205, %206) : (i64, i64, i64, i64) -> i64
            %207 = llvm.getelementptr %201[%202] : (!llvm.ptr, i64) -> !llvm.ptr, i128
            llvm.store %199, %207 : i128, !llvm.ptr
            %208 = llvm.load %128 : !llvm.ptr -> i64
            %209 = arith.constant 1 : i32
            %211 = arith.extsi %209 : i32 to i64
            %210 = arith.addi %208, %211 : i64
            llvm.store %210, %128 : i64, !llvm.ptr
            cf.br ^bb27
          ^bb29:
          %212 = llvm.load %120 : !llvm.ptr -> i64
          %213 = arith.constant 1 : i32
          %215 = arith.extsi %213 : i32 to i64
          %214 = arith.addi %212, %215 : i64
          llvm.store %214, %120 : i64, !llvm.ptr
          cf.br ^bb24
        ^bb26:
        %216 = llvm.load %112 : !llvm.ptr -> i64
        %217 = arith.constant 1 : i32
        %219 = arith.extsi %217 : i32 to i64
        %218 = arith.addi %216, %219 : i64
        llvm.store %218, %112 : i64, !llvm.ptr
        cf.br ^bb21
      ^bb23:
      %220 = llvm.load %93 : !llvm.ptr -> i64
      %221 = arith.constant 1 : i32
      %223 = arith.extsi %221 : i32 to i64
      %222 = arith.subi %220, %223 : i64
      llvm.store %222, %93 : i64, !llvm.ptr
      cf.br ^bb15
    ^bb17:
    %225 = llvm.mlir.addressof @g_dp : !llvm.ptr
    %226 = llvm.load %225 : !llvm.ptr -> !llvm.ptr
    %228 = arith.constant 0 : i32
    %229 = arith.constant 0 : i32
    %230 = arith.constant 0 : i32
    %231 = arith.constant 0 : i32
    %232 = arith.extsi %228 : i32 to i64
    %233 = arith.extsi %229 : i32 to i64
    %234 = arith.extsi %230 : i32 to i64
    %235 = arith.extsi %231 : i32 to i64
    %227 = func.call @dp_idx(%232, %233, %234, %235) : (i64, i64, i64, i64) -> i64
    %236 = llvm.getelementptr %226[%227] : (!llvm.ptr, i64) -> !llvm.ptr, i128
    %224 = llvm.load %236 : !llvm.ptr -> i128
    func.return %224 : i128
  }
  func.func @unrank(%arg0: i64, %arg1: i128, %arg2: !llvm.ptr) -> () {
    %238 = arith.constant 1 : i32
    %239 = arith.constant 3 : i32
    %240 = arith.constant 5 : i32
    %241 = arith.constant 7 : i32
    %242 = arith.constant 9 : i32
    %243 = llvm.mlir.constant(1 : i64) : i64
    %244 = llvm.alloca %243 x !llvm.array<5 x i64> : (i64) -> !llvm.ptr
    %245 = llvm.mlir.zero : !llvm.array<5 x i64>
    llvm.store %245, %244 : !llvm.array<5 x i64>, !llvm.ptr
    %246 = arith.extsi %238 : i32 to i64
    %247 = arith.extsi %239 : i32 to i64
    %248 = arith.extsi %240 : i32 to i64
    %249 = arith.extsi %241 : i32 to i64
    %250 = arith.extsi %242 : i32 to i64
    %251 = llvm.mlir.constant(0 : i64) : i64
    %252 = llvm.getelementptr %244[0, %251] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %246, %252 : i64, !llvm.ptr
    %253 = llvm.mlir.constant(1 : i64) : i64
    %254 = llvm.getelementptr %244[0, %253] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %247, %254 : i64, !llvm.ptr
    %255 = llvm.mlir.constant(2 : i64) : i64
    %256 = llvm.getelementptr %244[0, %255] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %248, %256 : i64, !llvm.ptr
    %257 = llvm.mlir.constant(3 : i64) : i64
    %258 = llvm.getelementptr %244[0, %257] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %249, %258 : i64, !llvm.ptr
    %259 = llvm.mlir.constant(4 : i64) : i64
    %260 = llvm.getelementptr %244[0, %259] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
    llvm.store %250, %260 : i64, !llvm.ptr
    %261 = arith.constant 0 : i32
    %262 = arith.extsi %261 : i32 to i64
    %263 = llvm.mlir.constant(1 : i64) : i64
    %264 = llvm.alloca %263 x i64 : (i64) -> !llvm.ptr
    llvm.store %262, %264 : i64, !llvm.ptr
    %265 = arith.constant 0 : i32
    %266 = arith.extsi %265 : i32 to i64
    %267 = llvm.mlir.constant(1 : i64) : i64
    %268 = llvm.alloca %267 x i64 : (i64) -> !llvm.ptr
    llvm.store %266, %268 : i64, !llvm.ptr
    %269 = arith.constant 0 : i32
    %270 = arith.extsi %269 : i32 to i64
    %271 = llvm.mlir.constant(1 : i64) : i64
    %272 = llvm.alloca %271 x i64 : (i64) -> !llvm.ptr
    llvm.store %270, %272 : i64, !llvm.ptr
    %273 = llvm.mlir.constant(1 : i64) : i64
    %274 = llvm.alloca %273 x i128 : (i64) -> !llvm.ptr
    llvm.store %arg1, %274 : i128, !llvm.ptr
    %275 = arith.constant 0 : i32
    %276 = arith.extsi %275 : i32 to i64
    %277 = llvm.mlir.constant(1 : i64) : i64
    %278 = llvm.alloca %277 x i64 : (i64) -> !llvm.ptr
    llvm.store %276, %278 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %279 = llvm.load %278 : !llvm.ptr -> i64
    %280 = arith.cmpi slt, %279, %arg0 : i64
    cf.cond_br %280, ^bb37, ^bb38
    ^bb37:
      %281 = arith.constant 5 : i32
      %282 = arith.extsi %281 : i32 to i64
      %283 = llvm.mlir.constant(1 : i64) : i64
      %284 = llvm.alloca %283 x i64 : (i64) -> !llvm.ptr
      llvm.store %282, %284 : i64, !llvm.ptr
      %285 = llvm.load %278 : !llvm.ptr -> i64
      %286 = arith.constant 1 : i32
      %288 = arith.extsi %286 : i32 to i64
      %287 = arith.subi %arg0, %288 : i64
      %289 = arith.cmpi eq, %285, %287 : i64
      cf.cond_br %289, ^bb39, ^bb40
      ^bb39:
        %290 = arith.constant 1 : i32
        %291 = arith.extsi %290 : i32 to i64
        llvm.store %291, %284 : i64, !llvm.ptr
        cf.br ^bb41
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %292 = arith.constant 0 : i32
      %293 = arith.extsi %292 : i32 to i64
      %294 = llvm.mlir.constant(1 : i64) : i64
      %295 = llvm.alloca %294 x i64 : (i64) -> !llvm.ptr
      llvm.store %293, %295 : i64, !llvm.ptr
      %296 = arith.constant 0 : i1
      %297 = llvm.mlir.constant(1 : i64) : i64
      %298 = llvm.alloca %297 x i1 : (i64) -> !llvm.ptr
      llvm.store %296, %298 : i1, !llvm.ptr
      cf.br ^bb42
      ^bb42:
      %299 = llvm.load %295 : !llvm.ptr -> i64
      %300 = llvm.load %284 : !llvm.ptr -> i64
      %301 = arith.cmpi slt, %299, %300 : i64
      %302 = scf.if %301 -> (i1) {
        %303 = llvm.load %298 : !llvm.ptr -> i1
        %305 = arith.constant 1 : i1
        %304 = arith.xori %303, %305 : i1
        scf.yield %304 : i1
      } else {
        %307 = arith.constant false
        scf.yield %307 : i1
      }
      cf.cond_br %302, ^bb43, ^bb44
      ^bb43:
        %308 = arith.constant 5 : i32
        %309 = arith.extsi %308 : i32 to i64
        %310 = llvm.mlir.constant(1 : i64) : i64
        %311 = llvm.alloca %310 x i64 : (i64) -> !llvm.ptr
        llvm.store %309, %311 : i64, !llvm.ptr
        %312 = llvm.load %278 : !llvm.ptr -> i64
        %313 = arith.constant 1 : i32
        %315 = arith.extsi %313 : i32 to i64
        %314 = arith.subi %arg0, %315 : i64
        %316 = arith.cmpi ne, %312, %314 : i64
        cf.cond_br %316, ^bb45, ^bb46
        ^bb45:
          %318 = llvm.load %295 : !llvm.ptr -> i64
          %319 = llvm.getelementptr %244[0, %318] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<5 x i64>
          %317 = llvm.load %319 : !llvm.ptr -> i64
          llvm.store %317, %311 : i64, !llvm.ptr
          cf.br ^bb47
        ^bb46:
          cf.br ^bb47
        ^bb47:
        %320 = llvm.load %264 : !llvm.ptr -> i64
        %321 = arith.constant 10 : i32
        %323 = arith.extsi %321 : i32 to i64
        %322 = arith.muli %320, %323 : i64
        %324 = llvm.load %311 : !llvm.ptr -> i64
        %325 = arith.addi %322, %324 : i64
        %326 = arith.constant 3 : i32
        %328 = arith.extsi %326 : i32 to i64
        %327 = arith.remsi %325, %328 : i64
        %329 = llvm.load %268 : !llvm.ptr -> i64
        %330 = arith.constant 10 : i32
        %332 = arith.extsi %330 : i32 to i64
        %331 = arith.muli %329, %332 : i64
        %333 = llvm.load %311 : !llvm.ptr -> i64
        %334 = arith.addi %331, %333 : i64
        %335 = arith.constant 7 : i32
        %337 = arith.extsi %335 : i32 to i64
        %336 = arith.remsi %334, %337 : i64
        %338 = llvm.load %272 : !llvm.ptr -> i64
        %339 = arith.constant 1 : i32
        %341 = llvm.load %311 : !llvm.ptr -> i64
        %340 = func.call @bit_of(%341) : (i64) -> i64
        %343 = arith.extsi %339 : i32 to i64
        %342 = arith.shli %343, %340 : i64
        %344 = arith.xori %338, %342 : i64
        %346 = llvm.mlir.addressof @g_dp : !llvm.ptr
        %347 = llvm.load %346 : !llvm.ptr -> !llvm.ptr
        %349 = llvm.load %278 : !llvm.ptr -> i64
        %350 = arith.constant 1 : i32
        %352 = arith.extsi %350 : i32 to i64
        %351 = arith.addi %349, %352 : i64
        %348 = func.call @dp_idx(%351, %327, %336, %344) : (i64, i64, i64, i64) -> i64
        %353 = llvm.getelementptr %347[%348] : (!llvm.ptr, i64) -> !llvm.ptr, i128
        %345 = llvm.load %353 : !llvm.ptr -> i128
        %354 = llvm.load %274 : !llvm.ptr -> i128
        %356 = arith.trunci %354 : i128 to i64
        %357 = arith.trunci %345 : i128 to i64
        %355 = arith.cmpi sgt, %356, %357 : i64
        cf.cond_br %355, ^bb48, ^bb49
        ^bb48:
          %358 = llvm.load %274 : !llvm.ptr -> i128
          %360 = arith.trunci %358 : i128 to i64
          %361 = arith.trunci %345 : i128 to i64
          %359 = arith.subi %360, %361 : i64
          %362 = arith.extsi %359 : i64 to i128
          llvm.store %362, %274 : i128, !llvm.ptr
          cf.br ^bb50
        ^bb49:
          %363 = arith.constant 48 : i32
          %364 = llvm.load %311 : !llvm.ptr -> i64
          %366 = arith.extsi %363 : i32 to i64
          %365 = arith.addi %366, %364 : i64
          %367 = arith.trunci %365 : i64 to i8
          %368 = llvm.load %278 : !llvm.ptr -> i64
          %369 = llvm.getelementptr %arg2[%368] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %367, %369 : i8, !llvm.ptr
          llvm.store %327, %264 : i64, !llvm.ptr
          llvm.store %336, %268 : i64, !llvm.ptr
          llvm.store %344, %272 : i64, !llvm.ptr
          %370 = arith.constant 1 : i1
          llvm.store %370, %298 : i1, !llvm.ptr
          cf.br ^bb50
        ^bb50:
        %371 = llvm.load %295 : !llvm.ptr -> i64
        %372 = arith.constant 1 : i32
        %374 = arith.extsi %372 : i32 to i64
        %373 = arith.addi %371, %374 : i64
        llvm.store %373, %295 : i64, !llvm.ptr
        cf.br ^bb42
      ^bb44:
      %375 = llvm.load %278 : !llvm.ptr -> i64
      %376 = arith.constant 1 : i32
      %378 = arith.extsi %376 : i32 to i64
      %377 = arith.addi %375, %378 : i64
      llvm.store %377, %278 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %379 = arith.constant 0 : i32
    %380 = arith.trunci %379 : i32 to i8
    %381 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %380, %381 : i8, !llvm.ptr
    func.return
  }
  func.func @main() -> i32 {
    %383 = llvm.mlir.addressof @DP_SIZE : !llvm.ptr
    %384 = llvm.load %383 : !llvm.ptr -> i64
    %385 = arith.constant 16 : i32
    %386 = arith.extsi %385 : i32 to i64
    %382 = func.call @calloc(%384, %386) : (i64, i64) -> !llvm.ptr
    %387 = llvm.mlir.addressof @g_dp : !llvm.ptr
    llvm.store %382, %387 : !llvm.ptr, !llvm.ptr
    %388 = arith.constant 1 : i32
    %389 = arith.extsi %388 : i32 to i128
    %390 = llvm.mlir.constant(1 : i64) : i64
    %391 = llvm.alloca %390 x i128 : (i64) -> !llvm.ptr
    llvm.store %389, %391 : i128, !llvm.ptr
    %392 = arith.constant 0 : i32
    %393 = arith.extsi %392 : i32 to i64
    %394 = llvm.mlir.constant(1 : i64) : i64
    %395 = llvm.alloca %394 x i64 : (i64) -> !llvm.ptr
    llvm.store %393, %395 : i64, !llvm.ptr
    cf.br ^bb51
    ^bb51:
    %396 = llvm.load %395 : !llvm.ptr -> i64
    %397 = arith.constant 16 : i32
    %399 = arith.extsi %397 : i32 to i64
    %398 = arith.cmpi slt, %396, %399 : i64
    cf.cond_br %398, ^bb52, ^bb53
    ^bb52:
      %400 = llvm.load %391 : !llvm.ptr -> i128
      %401 = arith.constant 10 : i32
      %403 = arith.trunci %400 : i128 to i64
      %404 = arith.extsi %401 : i32 to i64
      %402 = arith.muli %403, %404 : i64
      %405 = arith.extsi %402 : i64 to i128
      llvm.store %405, %391 : i128, !llvm.ptr
      %406 = llvm.load %395 : !llvm.ptr -> i64
      %407 = arith.constant 1 : i32
      %409 = arith.extsi %407 : i32 to i64
      %408 = arith.addi %406, %409 : i64
      llvm.store %408, %395 : i64, !llvm.ptr
      cf.br ^bb51
    ^bb53:
    %410 = arith.constant 0 : i32
    %411 = arith.extsi %410 : i32 to i128
    %412 = llvm.mlir.constant(1 : i64) : i64
    %413 = llvm.alloca %412 x i128 : (i64) -> !llvm.ptr
    llvm.store %411, %413 : i128, !llvm.ptr
    %414 = arith.constant 0 : i32
    %415 = arith.constant 1 : i32
    %416 = arith.subi %414, %415 : i32
    %417 = arith.extsi %416 : i32 to i64
    %418 = llvm.mlir.constant(1 : i64) : i64
    %419 = llvm.alloca %418 x i64 : (i64) -> !llvm.ptr
    llvm.store %417, %419 : i64, !llvm.ptr
    %420 = arith.constant 1 : 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
    cf.br ^bb54
    ^bb54:
    %424 = llvm.load %423 : !llvm.ptr -> i64
    %425 = arith.constant 200 : i32
    %427 = arith.extsi %425 : i32 to i64
    %426 = arith.cmpi sle, %424, %427 : i64
    cf.cond_br %426, ^bb55, ^bb56
    ^bb55:
      %429 = llvm.load %423 : !llvm.ptr -> i64
      %428 = func.call @count_len(%429) : (i64) -> i128
      %430 = llvm.load %413 : !llvm.ptr -> i128
      %432 = arith.trunci %430 : i128 to i64
      %433 = arith.trunci %428 : i128 to i64
      %431 = arith.addi %432, %433 : i64
      %434 = llvm.load %391 : !llvm.ptr -> i128
      %436 = arith.trunci %434 : i128 to i64
      %435 = arith.cmpi sge, %431, %436 : i64
      cf.cond_br %435, ^bb57, ^bb58
      ^bb57:
        %437 = llvm.load %423 : !llvm.ptr -> i64
        llvm.store %437, %419 : i64, !llvm.ptr
        cf.br ^bb56
      ^bb58:
        cf.br ^bb59
      ^bb59:
      %438 = llvm.load %413 : !llvm.ptr -> i128
      %440 = arith.trunci %438 : i128 to i64
      %441 = arith.trunci %428 : i128 to i64
      %439 = arith.addi %440, %441 : i64
      %442 = arith.extsi %439 : i64 to i128
      llvm.store %442, %413 : i128, !llvm.ptr
      %443 = llvm.load %423 : !llvm.ptr -> i64
      %444 = arith.constant 2 : i32
      %446 = arith.extsi %444 : i32 to i64
      %445 = arith.addi %443, %446 : i64
      llvm.store %445, %423 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %448 = arith.constant 256 : i32
    %449 = arith.constant 1 : i32
    %450 = arith.extsi %448 : i32 to i64
    %451 = arith.extsi %449 : i32 to i64
    %447 = func.call @calloc(%450, %451) : (i64, i64) -> !llvm.ptr
    %453 = llvm.load %419 : !llvm.ptr -> i64
    %454 = llvm.load %391 : !llvm.ptr -> i128
    %455 = llvm.load %413 : !llvm.ptr -> i128
    %457 = arith.trunci %454 : i128 to i64
    %458 = arith.trunci %455 : i128 to i64
    %456 = arith.subi %457, %458 : i64
    %459 = arith.extsi %456 : i64 to i128
    func.call @unrank(%453, %459, %447) : (i64, i128, !llvm.ptr) -> ()
    %460 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %461 = llvm.call @printf(%460, %447) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, !llvm.ptr) -> i32
    func.call @free(%447) : (!llvm.ptr) -> ()
    %464 = llvm.mlir.addressof @g_dp : !llvm.ptr
    %465 = llvm.load %464 : !llvm.ptr -> !llvm.ptr
    func.call @free(%465) : (!llvm.ptr) -> ()
    %466 = arith.constant 0 : i32
    func.return %466 : i32
  }
}