Problem 049

Concatenate the three terms of the 4-digit prime permutation arithmetic sequence (excluding 1487/4817/8147).

Answer296962999629
Output296962999629
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(n^2) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log log n)
Space complexityO(n)O(n)
ApproachFlow solutionSieve + prime permutation search
VerdictSuboptimal

Flow source

# Project Euler 049
# Concatenate the three terms of the 4-digit prime permutation arithmetic
# sequence (excluding 1487/4817/8147).

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

function digit_sig(n0: i64) -> i64 {
    let mut counts: array<i32, 10> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    let mut n: i64 = n0
    while n > 0 {
        let d: i32 = (n % 10) as i32
        counts[d] = counts[d] + 1
        n = n / 10
    }
    let mut sig: i64 = 0
    let mut d: i32 = 0
    while d < 10 {
        sig = sig * 10 + (counts[d] as i64)
        d = d + 1
    }
    return sig
}

function main() -> i32 {
    let limit: i64 = 10000
    let sieve: ptr<i8> = calloc(limit, 1)
    if sieve == null { return 1 }
    sieve[0] = 1
    sieve[1] = 1
    let mut p: i64 = 2
    while p * p < limit {
        if sieve[p] == 0 {
            let mut m: i64 = p * p
            while m < limit {
                sieve[m] = 1
                m = m + p
            }
        }
        p = p + 1
    }

    let mut a: i64 = 1000
    while a < 10000 {
        if sieve[a] == 0 {
            let sig_a: i64 = digit_sig(a)
            let mut b: i64 = a + 1
            while b < 10000 {
                if sieve[b] == 0 && digit_sig(b) == sig_a {
                    let c: i64 = b + (b - a)
                    if c < 10000 && sieve[c] == 0 && digit_sig(c) == sig_a {
                        if a != 1487 {
                            let ans: i64 = a * 100000000 + b * 10000 + c
                            printf("%lld\n", ans)
                            free(sieve)
                            return 0
                        }
                    }
                }
                b = b + 1
            }
        }
        a = a + 1
    }
    free(sieve)
    return 1
}

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 digit_sig_i64(int64_t n0);
int32_t main(void);



int64_t digit_sig_i64(int64_t n0) {
    int32_t counts[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int64_t n = n0;
    while (n > 0) {
        int32_t d = ((int32_t)(FLOW_CHECKED_MOD((n), (10))));
        counts[d] = ((((unsigned)(d) < 10) ? counts[d] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(d), 10), flow_fault_handler("array index out of bounds"), counts[0])) + 1);
        n = FLOW_CHECKED_DIV((n), (10));
    }
    int64_t sig = 0;
    int32_t d = 0;
    while (d < 10) {
        sig = ((sig * 10) + ((int64_t)((((unsigned)(d) < 10) ? counts[d] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(d), 10), flow_fault_handler("array index out of bounds"), counts[0])))));
        d = (d + 1);
    }
    return sig;
}

int32_t main(void) {
    int64_t limit = 10000;
    int8_t* sieve = (int8_t*)(calloc(limit, 1));
    if (sieve == NULL) {
        return 1;
    }
    sieve[0] = 1;
    sieve[1] = 1;
    int64_t p = 2;
    while ((p * p) < limit) {
        if (sieve[p] == 0) {
            int64_t m = (p * p);
            while (m < limit) {
                sieve[m] = 1;
                m = (m + p);
            }
        }
        p = (p + 1);
    }
    int64_t a = 1000;
    while (a < 10000) {
        if (sieve[a] == 0) {
            int64_t sig_a = digit_sig_i64(a);
            int64_t b = (a + 1);
            while (b < 10000) {
                if ((sieve[b] == 0 && digit_sig_i64(b) == sig_a)) {
                    int64_t c = (b + (b - a));
                    if (((c < 10000 && sieve[c] == 0) && digit_sig_i64(c) == sig_a)) {
                        if (a != 1487) {
                            int64_t ans = (((a * 100000000) + (b * 10000)) + c);
                            printf("%lld\n", ans);
                            free(sieve);
                            return 0;
                        }
                    }
                }
                b = (b + 1);
            }
        }
        a = (a + 1);
    }
    free(sieve);
    return 1;
}

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