Problem 900

DistribuNim II — S(N) via order-5 linear recurrence mod 900497239.

Answer646900900
Output646900900
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(n) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n)O(log n)
Space complexityO(1)O(n^2)
ApproachFlow solutionMatrix exponentiation
VerdictSuboptimal

Flow source

# Project Euler 900
# DistribuNim II — S(N) via order-5 linear recurrence mod 900497239.

const MOD: i64 = 900497239

function next_pow2_gt(x: i64) -> i64 {
    let mut p: i64 = 1
    while p <= x {
        p = p << 1
    }
    return p
}

function t(n: i64) -> i64 {
    let p: i64 = next_pow2_gt(n)
    let mut v: i64 = (-(n * n) - (n & 1)) % p
    if v < 0 { v = v + p }
    return v
}

function S_mod(N: i64) -> i64 {
    # Seed with exact S(1)..S(5) from closed form (sum to 2^5=32).
    let mut S: [i64; 6]
    S[0] = 0
    let mut total: i64 = 0
    let mut n: i64 = 1
    while n <= 32 {
        total = total + t(n)
        if n == 2 { S[1] = total }
        if n == 4 { S[2] = total }
        if n == 8 { S[3] = total }
        if n == 16 { S[4] = total }
        if n == 32 { S[5] = total }
        n = n + 1
    }
    if N <= 5 {
        return S[N] % MOD
    }
    let mut p0: i64 = S[5] % MOD
    let mut p1: i64 = S[4] % MOD
    let mut p2: i64 = S[3] % MOD
    let mut p3: i64 = S[2] % MOD
    let mut p4: i64 = S[1] % MOD
    let mut k: i64 = 6
    while k <= N {
        let mut neu: i64 = (7 * p0 - 6 * p1 - 48 * p2 + 112 * p3 - 64 * p4) % MOD
        if neu < 0 { neu = neu + MOD }
        p4 = p3
        p3 = p2
        p2 = p1
        p1 = p0
        p0 = neu
        k = k + 1
    }
    return p0
}

function main() -> i32 {
    printf("%lld\n", S_mod(10000))
    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 next_pow2_gt_i64(int64_t x);
int64_t t_i64(int64_t n);
int64_t S_mod_i64(int64_t N);
int32_t main(void);

static const int64_t MOD = 900497239;

int64_t next_pow2_gt_i64(int64_t x) {
    int64_t p = 1;
    while (p <= x) {
        p = FLOW_CHECKED_SHL((p), (1));
    }
    return p;
}

int64_t t_i64(int64_t n) {
    int64_t p = next_pow2_gt_i64(n);
    int64_t v = FLOW_CHECKED_MOD((((-(n * n)) - (n & 1))), (p));
    if (v < 0) {
        v = (v + p);
    }
    return v;
}

int64_t S_mod_i64(int64_t N) {
    int64_t S[6];
    S[0] = 0;
    int64_t total = 0;
    int64_t n = 1;
    while (n <= 32) {
        total = (total + t_i64(n));
        if (n == 2) {
            S[1] = total;
        }
        if (n == 4) {
            S[2] = total;
        }
        if (n == 8) {
            S[3] = total;
        }
        if (n == 16) {
            S[4] = total;
        }
        if (n == 32) {
            S[5] = total;
        }
        n = (n + 1);
    }
    if (N <= 5) {
        return FLOW_CHECKED_MOD(((((unsigned)(N) < 6) ? S[N] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(N), 6), flow_fault_handler("array index out of bounds"), S[0]))), (MOD));
    }
    int64_t p0 = FLOW_CHECKED_MOD(((((unsigned)(5) < 6) ? S[5] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(5), 6), flow_fault_handler("array index out of bounds"), S[0]))), (MOD));
    int64_t p1 = FLOW_CHECKED_MOD(((((unsigned)(4) < 6) ? S[4] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(4), 6), flow_fault_handler("array index out of bounds"), S[0]))), (MOD));
    int64_t p2 = FLOW_CHECKED_MOD(((((unsigned)(3) < 6) ? S[3] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(3), 6), flow_fault_handler("array index out of bounds"), S[0]))), (MOD));
    int64_t p3 = FLOW_CHECKED_MOD(((((unsigned)(2) < 6) ? S[2] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(2), 6), flow_fault_handler("array index out of bounds"), S[0]))), (MOD));
    int64_t p4 = FLOW_CHECKED_MOD(((((unsigned)(1) < 6) ? S[1] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(1), 6), flow_fault_handler("array index out of bounds"), S[0]))), (MOD));
    int64_t k = 6;
    while (k <= N) {
        int64_t neu = FLOW_CHECKED_MOD(((((((7 * p0) - (6 * p1)) - (48 * p2)) + (112 * p3)) - (64 * p4))), (MOD));
        if (neu < 0) {
            neu = (neu + MOD);
        }
        p4 = p3;
        p3 = p2;
        p2 = p1;
        p1 = p0;
        p0 = neu;
        k = (k + 1);
    }
    return p0;
}

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