Problem 810

XOR-product primes — 5,000,000th xor-prime. Sieve using XOR-product: for each odd base found as prime, mark all base * cofactor (XOR multiplication) as composite.

Answer124136381
Output124136381
StatusPASS
Native helperno
Runtime1120 ms
Peak memory124000 KB
Time complexityO(n) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n)O(n * k)
Space complexityO(n)O(n)
ApproachFlow solutionKey search and XOR decryption
VerdictUnknown

Flow source

# Project Euler 810
# XOR-product primes — 5,000,000th xor-prime.
#
# Sieve using XOR-product: for each odd base found as prime,
# mark all base * cofactor (XOR multiplication) as composite.

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

function bit_length(x: i64) -> i32 {
    let mut c: i32 = 0
    let mut v: i64 = x
    while v != 0 {
        v = v >> 1
        c = c + 1
    }
    return c
}

function ctzll(x: i64) -> i32 {
    # count trailing zeros of a nonzero i64
    let mut count: i32 = 0
    let mut v: i64 = x
    while (v & 1) == 0 {
        v = v >> 1
        count = count + 1
    }
    return count
}

function main() -> i32 {
    let rank: i32 = 5000000
    if rank == 1 {
        printf("%lld\n", 2 as i64)
        return 0
    }

    let mut bit_limit: i32 = 24
    while bit_limit <= 34 {
        let limit: i64 = (1 as i64) << bit_limit
        let mark: ptr<i8> = calloc(limit >> 1, 1)
        if mark == null {
            bit_limit = bit_limit + 1
            continue
        }
        mark[0] = 1
        let mut found: i32 = 1
        let mut ans: i64 = -1

        let mut base: i64 = 3
        while base < limit {
            if mark[base >> 1] != 0 {
                base = base + 2
                continue
            }
            found = found + 1
            if found == rank {
                ans = base
                break
            }

            let degree: i32 = bit_length(base) - 1
            let max_cofactor_degree: i32 = bit_limit - degree - 1

            let mut cofactor_degree: i32 = degree
            while cofactor_degree <= max_cofactor_degree {
                let mut product: i64 = (base << cofactor_degree) ^ base
                if product < limit {
                    mark[product >> 1] = 1
                }
                let variants: i64 = (1 as i64) << (cofactor_degree - 1)
                let mut n: i64 = 1
                while n < variants {
                    let lsb: i64 = n & (0 - n)
                    let toggled_bit: i32 = ctzll(lsb) + 1
                    product = product ^ (base << toggled_bit)
                    if product >= 0 && product < limit {
                        mark[product >> 1] = 1
                    }
                    n = n + 1
                }
                cofactor_degree = cofactor_degree + 1
            }

            base = base + 2
        }

        free(mark)
        if ans >= 0 {
            printf("%lld\n", ans)
            return 0
        }
        bit_limit = bit_limit + 1
    }

    printf("%lld\n", (-1) as i64)
    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; }

int32_t bit_length_i64(int64_t x);
int32_t ctzll_i64(int64_t x);
int32_t main(void);



int32_t bit_length_i64(int64_t x) {
    int32_t c = 0;
    int64_t v = x;
    while (v != 0) {
        v = FLOW_CHECKED_SHR((v), (1));
        c = (c + 1);
    }
    return c;
}

int32_t ctzll_i64(int64_t x) {
    int32_t count = 0;
    int64_t v = x;
    while ((v & 1) == 0) {
        v = FLOW_CHECKED_SHR((v), (1));
        count = (count + 1);
    }
    return count;
}

int32_t main(void) {
    int32_t rank = 5000000;
    if (rank == 1) {
        printf("%lld\n", ((int64_t)(2)));
        return 0;
    }
    int32_t bit_limit = 24;
    while (bit_limit <= 34) {
        int64_t limit = FLOW_CHECKED_SHL((((int64_t)(1))), (bit_limit));
        int8_t* mark = (int8_t*)(calloc(FLOW_CHECKED_SHR((limit), (1)), 1));
        if (mark == NULL) {
            bit_limit = (bit_limit + 1);
            continue;
        }
        mark[0] = 1;
        int32_t found = 1;
        int64_t ans = (-1);
        int64_t base = 3;
        while (base < limit) {
            if (mark[FLOW_CHECKED_SHR((base), (1))] != 0) {
                base = (base + 2);
                continue;
            }
            found = (found + 1);
            if (found == rank) {
                ans = base;
                break;
            }
            int32_t degree = (bit_length_i64(base) - 1);
            int32_t max_cofactor_degree = ((bit_limit - degree) - 1);
            int32_t cofactor_degree = degree;
            while (cofactor_degree <= max_cofactor_degree) {
                int64_t product = (FLOW_CHECKED_SHL((base), (cofactor_degree)) ^ base);
                if (product < limit) {
                    mark[FLOW_CHECKED_SHR((product), (1))] = 1;
                }
                int64_t variants = FLOW_CHECKED_SHL((((int64_t)(1))), ((cofactor_degree - 1)));
                int64_t n = 1;
                while (n < variants) {
                    int64_t lsb = (n & (0 - n));
                    int32_t toggled_bit = (ctzll_i64(lsb) + 1);
                    product = (product ^ FLOW_CHECKED_SHL((base), (toggled_bit)));
                    if ((product >= 0 && product < limit)) {
                        mark[FLOW_CHECKED_SHR((product), (1))] = 1;
                    }
                    n = (n + 1);
                }
                cofactor_degree = (cofactor_degree + 1);
            }
            base = (base + 2);
        }
        free(mark);
        if (ans >= 0) {
            printf("%lld\n", ans);
            return 0;
        }
        bit_limit = (bit_limit + 1);
    }
    printf("%lld\n", ((int64_t)((-1))));
    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 @bit_length(%arg0: i64) -> i32 {
    %0 = arith.constant 0 : i32
    %1 = llvm.mlir.constant(1 : i64) : i64
    %2 = llvm.alloca %1 x i32 : (i64) -> !llvm.ptr
    llvm.store %0, %2 : i32, !llvm.ptr
    %3 = llvm.mlir.constant(1 : i64) : i64
    %4 = llvm.alloca %3 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %4 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %5 = llvm.load %4 : !llvm.ptr -> i64
    %6 = arith.constant 0 : i32
    %8 = arith.extsi %6 : i32 to i64
    %7 = arith.cmpi ne, %5, %8 : i64
    cf.cond_br %7, ^bb1, ^bb2
    ^bb1:
      %9 = llvm.load %4 : !llvm.ptr -> i64
      %10 = arith.constant 1 : i32
      %12 = arith.extsi %10 : i32 to i64
      %11 = arith.shrsi %9, %12 : i64
      llvm.store %11, %4 : i64, !llvm.ptr
      %13 = llvm.load %2 : !llvm.ptr -> i32
      %14 = arith.constant 1 : i32
      %15 = arith.addi %13, %14 : i32
      llvm.store %15, %2 : i32, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %16 = llvm.load %2 : !llvm.ptr -> i32
    func.return %16 : i32
  }
  func.func @ctzll(%arg0: i64) -> i32 {
    %17 = arith.constant 0 : i32
    %18 = llvm.mlir.constant(1 : i64) : i64
    %19 = llvm.alloca %18 x i32 : (i64) -> !llvm.ptr
    llvm.store %17, %19 : i32, !llvm.ptr
    %20 = llvm.mlir.constant(1 : i64) : i64
    %21 = llvm.alloca %20 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %21 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %22 = llvm.load %21 : !llvm.ptr -> i64
    %23 = arith.constant 1 : i32
    %25 = arith.extsi %23 : i32 to i64
    %24 = arith.andi %22, %25 : i64
    %26 = arith.constant 0 : i32
    %28 = arith.extsi %26 : i32 to i64
    %27 = arith.cmpi eq, %24, %28 : i64
    cf.cond_br %27, ^bb4, ^bb5
    ^bb4:
      %29 = llvm.load %21 : !llvm.ptr -> i64
      %30 = arith.constant 1 : i32
      %32 = arith.extsi %30 : i32 to i64
      %31 = arith.shrsi %29, %32 : i64
      llvm.store %31, %21 : i64, !llvm.ptr
      %33 = llvm.load %19 : !llvm.ptr -> i32
      %34 = arith.constant 1 : i32
      %35 = arith.addi %33, %34 : i32
      llvm.store %35, %19 : i32, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %36 = llvm.load %19 : !llvm.ptr -> i32
    func.return %36 : i32
  }
  func.func @main() -> i32 {
    %37 = arith.constant 5000000 : i32
    %38 = arith.constant 1 : i32
    %39 = arith.cmpi eq, %37, %38 : i32
    cf.cond_br %39, ^bb6, ^bb7
    ^bb6:
      %40 = llvm.mlir.addressof @str_0 : !llvm.ptr
      %41 = arith.constant 2 : i32
      %42 = arith.extsi %41 : i32 to i64
      %43 = llvm.call @printf(%40, %42) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
      %44 = arith.constant 0 : i32
      func.return %44 : i32
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %45 = arith.constant 24 : i32
    %46 = llvm.mlir.constant(1 : i64) : i64
    %47 = llvm.alloca %46 x i32 : (i64) -> !llvm.ptr
    llvm.store %45, %47 : i32, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %48 = llvm.load %47 : !llvm.ptr -> i32
    %49 = arith.constant 34 : i32
    %50 = arith.cmpi sle, %48, %49 : i32
    cf.cond_br %50, ^bb10, ^bb11
    ^bb10:
      %51 = arith.constant 1 : i32
      %52 = arith.extsi %51 : i32 to i64
      %53 = llvm.load %47 : !llvm.ptr -> i32
      %55 = arith.extsi %53 : i32 to i64
      %54 = arith.shli %52, %55 : i64
      %57 = arith.constant 1 : i32
      %59 = arith.extsi %57 : i32 to i64
      %58 = arith.shrsi %54, %59 : i64
      %60 = arith.constant 1 : i32
      %61 = arith.extsi %60 : i32 to i64
      %56 = func.call @calloc(%58, %61) : (i64, i64) -> !llvm.ptr
      %62 = llvm.mlir.zero : !llvm.ptr
      %63 = llvm.icmp "eq" %56, %62 : !llvm.ptr
      cf.cond_br %63, ^bb12, ^bb13
      ^bb12:
        %64 = llvm.load %47 : !llvm.ptr -> i32
        %65 = arith.constant 1 : i32
        %66 = arith.addi %64, %65 : i32
        llvm.store %66, %47 : i32, !llvm.ptr
        cf.br ^bb9
      ^bb13:
        cf.br ^bb14
      ^bb14:
      %67 = arith.constant 1 : i32
      %68 = arith.constant 0 : i32
      %69 = arith.trunci %67 : i32 to i8
      %70 = arith.extsi %68 : i32 to i64
      %71 = llvm.getelementptr %56[%70] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %69, %71 : i8, !llvm.ptr
      %72 = arith.constant 1 : i32
      %73 = llvm.mlir.constant(1 : i64) : i64
      %74 = llvm.alloca %73 x i32 : (i64) -> !llvm.ptr
      llvm.store %72, %74 : i32, !llvm.ptr
      %75 = arith.constant 1 : i32
      %77 = arith.constant 0 : i32
      %76 = arith.subi %77, %75 : i32
      %78 = arith.extsi %76 : i32 to i64
      %79 = llvm.mlir.constant(1 : i64) : i64
      %80 = llvm.alloca %79 x i64 : (i64) -> !llvm.ptr
      llvm.store %78, %80 : i64, !llvm.ptr
      %81 = arith.constant 3 : i32
      %82 = arith.extsi %81 : i32 to i64
      %83 = llvm.mlir.constant(1 : i64) : i64
      %84 = llvm.alloca %83 x i64 : (i64) -> !llvm.ptr
      llvm.store %82, %84 : i64, !llvm.ptr
      cf.br ^bb15
      ^bb15:
      %85 = llvm.load %84 : !llvm.ptr -> i64
      %86 = arith.cmpi slt, %85, %54 : i64
      cf.cond_br %86, ^bb16, ^bb17
      ^bb16:
        %88 = llvm.load %84 : !llvm.ptr -> i64
        %89 = arith.constant 1 : i32
        %91 = arith.extsi %89 : i32 to i64
        %90 = arith.shrsi %88, %91 : i64
        %92 = llvm.getelementptr %56[%90] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        %87 = llvm.load %92 : !llvm.ptr -> i8
        %93 = arith.constant 0 : i32
        %95 = arith.extsi %87 : i8 to i32
        %94 = arith.cmpi ne, %95, %93 : i32
        cf.cond_br %94, ^bb18, ^bb19
        ^bb18:
          %96 = llvm.load %84 : !llvm.ptr -> i64
          %97 = arith.constant 2 : i32
          %99 = arith.extsi %97 : i32 to i64
          %98 = arith.addi %96, %99 : i64
          llvm.store %98, %84 : i64, !llvm.ptr
          cf.br ^bb15
        ^bb19:
          cf.br ^bb20
        ^bb20:
        %100 = llvm.load %74 : !llvm.ptr -> i32
        %101 = arith.constant 1 : i32
        %102 = arith.addi %100, %101 : i32
        llvm.store %102, %74 : i32, !llvm.ptr
        %103 = llvm.load %74 : !llvm.ptr -> i32
        %104 = arith.cmpi eq, %103, %37 : i32
        cf.cond_br %104, ^bb21, ^bb22
        ^bb21:
          %105 = llvm.load %84 : !llvm.ptr -> i64
          llvm.store %105, %80 : i64, !llvm.ptr
          cf.br ^bb17
        ^bb22:
          cf.br ^bb23
        ^bb23:
        %107 = llvm.load %84 : !llvm.ptr -> i64
        %106 = func.call @bit_length(%107) : (i64) -> i32
        %108 = arith.constant 1 : i32
        %109 = arith.subi %106, %108 : i32
        %110 = llvm.load %47 : !llvm.ptr -> i32
        %111 = arith.subi %110, %109 : i32
        %112 = arith.constant 1 : i32
        %113 = arith.subi %111, %112 : i32
        %114 = llvm.mlir.constant(1 : i64) : i64
        %115 = llvm.alloca %114 x i32 : (i64) -> !llvm.ptr
        llvm.store %109, %115 : i32, !llvm.ptr
        cf.br ^bb24
        ^bb24:
        %116 = llvm.load %115 : !llvm.ptr -> i32
        %117 = arith.cmpi sle, %116, %113 : i32
        cf.cond_br %117, ^bb25, ^bb26
        ^bb25:
          %118 = llvm.load %84 : !llvm.ptr -> i64
          %119 = llvm.load %115 : !llvm.ptr -> i32
          %121 = arith.extsi %119 : i32 to i64
          %120 = arith.shli %118, %121 : i64
          %122 = llvm.load %84 : !llvm.ptr -> i64
          %123 = arith.xori %120, %122 : i64
          %124 = llvm.mlir.constant(1 : i64) : i64
          %125 = llvm.alloca %124 x i64 : (i64) -> !llvm.ptr
          llvm.store %123, %125 : i64, !llvm.ptr
          %126 = llvm.load %125 : !llvm.ptr -> i64
          %127 = arith.cmpi slt, %126, %54 : i64
          cf.cond_br %127, ^bb27, ^bb28
          ^bb27:
            %128 = arith.constant 1 : i32
            %129 = llvm.load %125 : !llvm.ptr -> i64
            %130 = arith.constant 1 : i32
            %132 = arith.extsi %130 : i32 to i64
            %131 = arith.shrsi %129, %132 : i64
            %133 = arith.trunci %128 : i32 to i8
            %134 = llvm.getelementptr %56[%131] : (!llvm.ptr, i64) -> !llvm.ptr, i8
            llvm.store %133, %134 : i8, !llvm.ptr
            cf.br ^bb29
          ^bb28:
            cf.br ^bb29
          ^bb29:
          %135 = arith.constant 1 : i32
          %136 = arith.extsi %135 : i32 to i64
          %137 = llvm.load %115 : !llvm.ptr -> i32
          %138 = arith.constant 1 : i32
          %139 = arith.subi %137, %138 : i32
          %141 = arith.extsi %139 : i32 to i64
          %140 = arith.shli %136, %141 : i64
          %142 = arith.constant 1 : i32
          %143 = arith.extsi %142 : i32 to i64
          %144 = llvm.mlir.constant(1 : i64) : i64
          %145 = llvm.alloca %144 x i64 : (i64) -> !llvm.ptr
          llvm.store %143, %145 : i64, !llvm.ptr
          cf.br ^bb30
          ^bb30:
          %146 = llvm.load %145 : !llvm.ptr -> i64
          %147 = arith.cmpi slt, %146, %140 : i64
          cf.cond_br %147, ^bb31, ^bb32
          ^bb31:
            %148 = llvm.load %145 : !llvm.ptr -> i64
            %149 = arith.constant 0 : i32
            %150 = llvm.load %145 : !llvm.ptr -> i64
            %152 = arith.extsi %149 : i32 to i64
            %151 = arith.subi %152, %150 : i64
            %153 = arith.andi %148, %151 : i64
            %154 = func.call @ctzll(%153) : (i64) -> i32
            %155 = arith.constant 1 : i32
            %156 = arith.addi %154, %155 : i32
            %157 = llvm.load %125 : !llvm.ptr -> i64
            %158 = llvm.load %84 : !llvm.ptr -> i64
            %160 = arith.extsi %156 : i32 to i64
            %159 = arith.shli %158, %160 : i64
            %161 = arith.xori %157, %159 : i64
            llvm.store %161, %125 : i64, !llvm.ptr
            %162 = llvm.load %125 : !llvm.ptr -> i64
            %163 = arith.constant 0 : i32
            %165 = arith.extsi %163 : i32 to i64
            %164 = arith.cmpi sge, %162, %165 : i64
            %166 = scf.if %164 -> (i1) {
              %167 = llvm.load %125 : !llvm.ptr -> i64
              %168 = arith.cmpi slt, %167, %54 : i64
              scf.yield %168 : i1
            } else {
              %169 = arith.constant false
              scf.yield %169 : i1
            }
            cf.cond_br %166, ^bb33, ^bb34
            ^bb33:
              %170 = arith.constant 1 : i32
              %171 = llvm.load %125 : !llvm.ptr -> i64
              %172 = arith.constant 1 : i32
              %174 = arith.extsi %172 : i32 to i64
              %173 = arith.shrsi %171, %174 : i64
              %175 = arith.trunci %170 : i32 to i8
              %176 = llvm.getelementptr %56[%173] : (!llvm.ptr, i64) -> !llvm.ptr, i8
              llvm.store %175, %176 : i8, !llvm.ptr
              cf.br ^bb35
            ^bb34:
              cf.br ^bb35
            ^bb35:
            %177 = llvm.load %145 : !llvm.ptr -> i64
            %178 = arith.constant 1 : i32
            %180 = arith.extsi %178 : i32 to i64
            %179 = arith.addi %177, %180 : i64
            llvm.store %179, %145 : i64, !llvm.ptr
            cf.br ^bb30
          ^bb32:
          %181 = llvm.load %115 : !llvm.ptr -> i32
          %182 = arith.constant 1 : i32
          %183 = arith.addi %181, %182 : i32
          llvm.store %183, %115 : i32, !llvm.ptr
          cf.br ^bb24
        ^bb26:
        %184 = llvm.load %84 : !llvm.ptr -> i64
        %185 = arith.constant 2 : i32
        %187 = arith.extsi %185 : i32 to i64
        %186 = arith.addi %184, %187 : i64
        llvm.store %186, %84 : i64, !llvm.ptr
        cf.br ^bb15
      ^bb17:
      func.call @free(%56) : (!llvm.ptr) -> ()
      %189 = llvm.load %80 : !llvm.ptr -> i64
      %190 = arith.constant 0 : i32
      %192 = arith.extsi %190 : i32 to i64
      %191 = arith.cmpi sge, %189, %192 : i64
      cf.cond_br %191, ^bb36, ^bb37
      ^bb36:
        %193 = llvm.mlir.addressof @str_0 : !llvm.ptr
        %194 = llvm.load %80 : !llvm.ptr -> i64
        %195 = llvm.call @printf(%193, %194) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
        %196 = arith.constant 0 : i32
        func.return %196 : i32
      ^bb37:
        cf.br ^bb38
      ^bb38:
      %197 = llvm.load %47 : !llvm.ptr -> i32
      %198 = arith.constant 1 : i32
      %199 = arith.addi %197, %198 : i32
      llvm.store %199, %47 : i32, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %200 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %201 = arith.constant 1 : i32
    %203 = arith.constant 0 : i32
    %202 = arith.subi %203, %201 : i32
    %204 = arith.extsi %202 : i32 to i64
    %205 = llvm.call @printf(%200, %204) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %206 = arith.constant 0 : i32
    func.return %206 : i32
  }
}