Problem 054

How many hands does Player 1 win?

Answer376
Output376
StatusPASS
Native helperno
Runtime0 ms
Peak memory1136 KB
Time complexityO(n^2) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n)
Space complexityO(1)O(1)
ApproachFlow solutionDirect hand evaluation or enumeration
VerdictSuboptimal

Flow source

# Project Euler 054
# How many hands does Player 1 win?

extern {
    function fopen(path: string, mode: string) -> ptr<void>
    function fgetc(f: ptr<void>) -> i32
    function fclose(f: ptr<void>) -> i32
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
}

function rank_val(c: i32) -> i32 {
    if c == 84 { return 10 }
    if c == 74 { return 11 }
    if c == 81 { return 12 }
    if c == 75 { return 13 }
    if c == 65 { return 14 }
    return c - 48
}

function sort5(v: ptr<i32>) -> void {
    for i in 0..5 {
        for j in (i + 1)..5 {
            if v[j] < v[i] {
                let t: i32 = v[i]
                v[i] = v[j]
                v[j] = t
            }
        }
    }
}

enum HandCat {
    HighCard,
    Pair,
    TwoPair,
    ThreeOfAKind,
    Straight,
    Flush,
    FullHouse,
    FourOfAKind,
    StraightFlush
}

function max2i(a: i32, b: i32) -> i32 {
    if a > b { return a }
    return b
}

function min2i(a: i32, b: i32) -> i32 {
    if a < b { return a }
    return b
}

# Higher score wins. Category in high digits, then kickers.
function hand_score(ranks: ptr<i32>, suits: ptr<i32>) -> i64 {
    let r: ptr<i32> = calloc(5, 4)
    let cnt: ptr<i32> = calloc(15, 4)
    if r == null || cnt == null { return 0 }

    for i in 0..5 {
        r[i] = ranks[i]
    }
    sort5(r)

    let mut flush: bool = true
    for i in 1..5 {
        if suits[i] != suits[0] { flush = false }
    }

    let mut straight: bool = true
    let mut hi: i32 = r[4]
    for i in 0..4 {
        if r[i + 1] != r[i] + 1 { straight = false }
    }
    if r[0] == 2 && r[1] == 3 && r[2] == 4 && r[3] == 5 && r[4] == 14 {
        straight = true
        hi = 5
    }

    for i in 0..5 {
        cnt[r[i]] = cnt[r[i]] + 1
    }

    let mut four: i32 = 0
    let mut three: i32 = 0
    let mut p1: i32 = 0
    let mut p2: i32 = 0
    let mut pairs: i32 = 0
    let mut i: i32 = 14
    while i >= 2 {
        if cnt[i] == 4 { four = i }
        if cnt[i] == 3 { three = i }
        if cnt[i] == 2 {
            if p1 == 0 {
                p1 = i
            } else {
                p2 = i
            }
            pairs = pairs + 1
        }
        i = i - 1
    }

    let mut cat: HandCat = HandCat { tag: HandCat_HighCard }
    if straight && flush {
        cat = HandCat { tag: HandCat_StraightFlush }
    } elif four != 0 {
        cat = HandCat { tag: HandCat_FourOfAKind }
    } elif three != 0 && pairs >= 1 {
        cat = HandCat { tag: HandCat_FullHouse }
    } elif flush {
        cat = HandCat { tag: HandCat_Flush }
    } elif straight {
        cat = HandCat { tag: HandCat_Straight }
    } elif three != 0 {
        cat = HandCat { tag: HandCat_ThreeOfAKind }
    } elif pairs == 2 {
        cat = HandCat { tag: HandCat_TwoPair }
    } elif pairs == 1 {
        cat = HandCat { tag: HandCat_Pair }
    }

    let mut key: i64 = 0
    let mut cat_val: i64 = 0

    match cat.tag {
        HandCat_StraightFlush => {
            key = hi as i64
            cat_val = 8
        }
        HandCat_FourOfAKind => {
            key = four as i64
            i = 14
            while i >= 2 {
                if cnt[i] == 1 {
                    key = key * 100 + (i as i64)
                    break
                }
                i = i - 1
            }
            cat_val = 7
        }
        HandCat_FullHouse => {
            key = (three as i64) * 100 + (p1 as i64)
            cat_val = 6
        }
        HandCat_Flush => {
            key = (r[4] as i64) * 100000000 + (r[3] as i64) * 1000000 + (r[2] as i64) * 10000 + (r[1] as i64) * 100 + (r[0] as i64)
            cat_val = 5
        }
        HandCat_Straight => {
            key = hi as i64
            cat_val = 4
        }
        HandCat_ThreeOfAKind => {
            key = three as i64
            i = 14
            while i >= 2 {
                if cnt[i] == 1 {
                    key = key * 100 + (i as i64)
                }
                i = i - 1
            }
            cat_val = 3
        }
        HandCat_TwoPair => {
            let hi_p: i32 = max2i(p1, p2)
            let lo_p: i32 = min2i(p1, p2)
            key = (hi_p as i64) * 10000 + (lo_p as i64) * 100
            i = 14
            while i >= 2 {
                if cnt[i] == 1 {
                    key = key + (i as i64)
                    break
                }
                i = i - 1
            }
            cat_val = 2
        }
        HandCat_Pair => {
            key = p1 as i64
            i = 14
            while i >= 2 {
                if cnt[i] == 1 {
                    key = key * 100 + (i as i64)
                }
                i = i - 1
            }
            cat_val = 1
        }
        HandCat_HighCard => {
            key = (r[4] as i64) * 100000000 + (r[3] as i64) * 1000000 + (r[2] as i64) * 10000 + (r[1] as i64) * 100 + (r[0] as i64)
            cat_val = 0
        }
    }

    free(cnt)
    free(r)
    return cat_val * 10000000000 + key
}

function skip_ws(f: ptr<void>, c0: i32) -> i32 {
    let mut c: i32 = c0
    while c == 32 || c == 10 || c == 13 || c == 9 {
        c = fgetc(f)
    }
    return c
}

function main() -> i32 {
    let f: ptr<void> = fopen("data/p054.txt", "r")
    if f == null {
        printf("failed to read data/p054.txt\n")
        return 1
    }
    let r1: ptr<i32> = calloc(5, 4)
    let s1: ptr<i32> = calloc(5, 4)
    let r2: ptr<i32> = calloc(5, 4)
    let s2: ptr<i32> = calloc(5, 4)
    if r1 == null || s1 == null || r2 == null || s2 == null { return 1 }

    let mut wins: i64 = 0
    let mut c: i32 = fgetc(f)
    while c >= 0 {
        c = skip_ws(f, c)
        if c < 0 { break }

        for i in 0..5 {
            r1[i] = rank_val(c)
            s1[i] = fgetc(f)
            c = fgetc(f)
            c = skip_ws(f, c)
        }
        for i in 0..5 {
            r2[i] = rank_val(c)
            s2[i] = fgetc(f)
            c = fgetc(f)
            c = skip_ws(f, c)
        }

        if hand_score(r1, s1) > hand_score(r2, s2) {
            wins = wins + 1
        }
    }

    fclose(f)
    printf("%lld\n", wins)
    free(r1)
    free(s1)
    free(r2)
    free(s2)
    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; }

typedef enum {
    HandCat_HighCard,
    HandCat_Pair,
    HandCat_TwoPair,
    HandCat_ThreeOfAKind,
    HandCat_Straight,
    HandCat_Flush,
    HandCat_FullHouse,
    HandCat_FourOfAKind,
    HandCat_StraightFlush
} HandCat_Tag;

typedef struct {
    HandCat_Tag tag;
} HandCat;

int32_t rank_val_i32(int32_t c);
void sort5_ptr_i32(int32_t* v);
int32_t max2i_i32_i32(int32_t a, int32_t b);
int32_t min2i_i32_i32(int32_t a, int32_t b);
int64_t hand_score_ptr_i32_ptr_i32(int32_t* ranks, int32_t* suits);
int32_t skip_ws_ptr_void_i32(void* f, int32_t c0);
int32_t main(void);






int32_t rank_val_i32(int32_t c) {
    if (c == 84) {
        return 10;
    }
    if (c == 74) {
        return 11;
    }
    if (c == 81) {
        return 12;
    }
    if (c == 75) {
        return 13;
    }
    if (c == 65) {
        return 14;
    }
    return (c - 48);
}

void sort5_ptr_i32(int32_t* v) {
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= 5) ? i < 5 : i > 5; i += (0 <= 5) ? 1 : -1) {
        int32_t __flow_step_2 = 1;
        for (int32_t j = (i + 1); ((i + 1) <= 5) ? j < 5 : j > 5; j += ((i + 1) <= 5) ? 1 : -1) {
            if (v[j] < v[i]) {
                int32_t t = v[i];
                v[i] = v[j];
                v[j] = t;
            }
        }
    }
}

int32_t max2i_i32_i32(int32_t a, int32_t b) {
    if (a > b) {
        return a;
    }
    return b;
}

int32_t min2i_i32_i32(int32_t a, int32_t b) {
    if (a < b) {
        return a;
    }
    return b;
}

int64_t hand_score_ptr_i32_ptr_i32(int32_t* ranks, int32_t* suits) {
    int32_t* r = (int32_t*)(calloc(5, 4));
    int32_t* cnt = (int32_t*)(calloc(15, 4));
    if ((r == NULL || cnt == NULL)) {
        return 0;
    }
    int32_t __flow_step_3 = 1;
    for (int32_t i = 0; (0 <= 5) ? i < 5 : i > 5; i += (0 <= 5) ? 1 : -1) {
        r[i] = ranks[i];
    }
    sort5_ptr_i32(r);
    bool flush = 1;
    int32_t __flow_step_4 = 1;
    for (int32_t i = 1; (1 <= 5) ? i < 5 : i > 5; i += (1 <= 5) ? 1 : -1) {
        if (suits[i] != suits[0]) {
            flush = 0;
        }
    }
    bool straight = 1;
    int32_t hi = r[4];
    int32_t __flow_step_5 = 1;
    for (int32_t i = 0; (0 <= 4) ? i < 4 : i > 4; i += (0 <= 4) ? 1 : -1) {
        if (r[(i + 1)] != (r[i] + 1)) {
            straight = 0;
        }
    }
    if (((((r[0] == 2 && r[1] == 3) && r[2] == 4) && r[3] == 5) && r[4] == 14)) {
        straight = 1;
        hi = 5;
    }
    int32_t __flow_step_6 = 1;
    for (int32_t i = 0; (0 <= 5) ? i < 5 : i > 5; i += (0 <= 5) ? 1 : -1) {
        cnt[r[i]] = (cnt[r[i]] + 1);
    }
    int32_t four = 0;
    int32_t three = 0;
    int32_t p1 = 0;
    int32_t p2 = 0;
    int32_t pairs = 0;
    int32_t i = 14;
    while (i >= 2) {
        if (cnt[i] == 4) {
            four = i;
        }
        if (cnt[i] == 3) {
            three = i;
        }
        if (cnt[i] == 2) {
            if (p1 == 0) {
                p1 = i;
            } else {
                p2 = i;
            }
            pairs = (pairs + 1);
        }
        i = (i - 1);
    }
    HandCat cat = (HandCat){ .tag = HandCat_HighCard };
    if ((straight && flush)) {
        cat = (HandCat){ .tag = HandCat_StraightFlush };
    } else if (four != 0) {
        cat = (HandCat){ .tag = HandCat_FourOfAKind };
    } else if ((three != 0 && pairs >= 1)) {
        cat = (HandCat){ .tag = HandCat_FullHouse };
    } else if (flush) {
        cat = (HandCat){ .tag = HandCat_Flush };
    } else if (straight) {
        cat = (HandCat){ .tag = HandCat_Straight };
    } else if (three != 0) {
        cat = (HandCat){ .tag = HandCat_ThreeOfAKind };
    } else if (pairs == 2) {
        cat = (HandCat){ .tag = HandCat_TwoPair };
    } else if (pairs == 1) {
        cat = (HandCat){ .tag = HandCat_Pair };
    }
    int64_t key = 0;
    int64_t cat_val = 0;
    { // match block
        if ((cat.tag) == HandCat_StraightFlush) {
            key = ((int64_t)(hi));
            cat_val = 8;
        } else if ((cat.tag) == HandCat_FourOfAKind) {
            key = ((int64_t)(four));
            i = 14;
            while (i >= 2) {
                if (cnt[i] == 1) {
                    key = ((key * 100) + ((int64_t)(i)));
                    break;
                }
                i = (i - 1);
            }
            cat_val = 7;
        } else if ((cat.tag) == HandCat_FullHouse) {
            key = ((((int64_t)(three)) * 100) + ((int64_t)(p1)));
            cat_val = 6;
        } else if ((cat.tag) == HandCat_Flush) {
            key = (((((((int64_t)(r[4])) * 100000000) + (((int64_t)(r[3])) * 1000000)) + (((int64_t)(r[2])) * 10000)) + (((int64_t)(r[1])) * 100)) + ((int64_t)(r[0])));
            cat_val = 5;
        } else if ((cat.tag) == HandCat_Straight) {
            key = ((int64_t)(hi));
            cat_val = 4;
        } else if ((cat.tag) == HandCat_ThreeOfAKind) {
            key = ((int64_t)(three));
            i = 14;
            while (i >= 2) {
                if (cnt[i] == 1) {
                    key = ((key * 100) + ((int64_t)(i)));
                }
                i = (i - 1);
            }
            cat_val = 3;
        } else if ((cat.tag) == HandCat_TwoPair) {
            int32_t hi_p = max2i_i32_i32(p1, p2);
            int32_t lo_p = min2i_i32_i32(p1, p2);
            key = ((((int64_t)(hi_p)) * 10000) + (((int64_t)(lo_p)) * 100));
            i = 14;
            while (i >= 2) {
                if (cnt[i] == 1) {
                    key = (key + ((int64_t)(i)));
                    break;
                }
                i = (i - 1);
            }
            cat_val = 2;
        } else if ((cat.tag) == HandCat_Pair) {
            key = ((int64_t)(p1));
            i = 14;
            while (i >= 2) {
                if (cnt[i] == 1) {
                    key = ((key * 100) + ((int64_t)(i)));
                }
                i = (i - 1);
            }
            cat_val = 1;
        } else { // exhaustive
            key = (((((((int64_t)(r[4])) * 100000000) + (((int64_t)(r[3])) * 1000000)) + (((int64_t)(r[2])) * 10000)) + (((int64_t)(r[1])) * 100)) + ((int64_t)(r[0])));
            cat_val = 0;
        }
    } // end match
    free(cnt);
    free(r);
    return ((cat_val * 10000000000) + key);
}

int32_t skip_ws_ptr_void_i32(void* f, int32_t c0) {
    int32_t c = c0;
    while ((((c == 32 || c == 10) || c == 13) || c == 9)) {
        c = fgetc(f);
    }
    return c;
}

int32_t main(void) {
    void* f = (void*)(fopen("data/p054.txt", "r"));
    if (f == NULL) {
        printf("failed to read data/p054.txt\n");
        return 1;
    }
    int32_t* r1 = (int32_t*)(calloc(5, 4));
    int32_t* s1 = (int32_t*)(calloc(5, 4));
    int32_t* r2 = (int32_t*)(calloc(5, 4));
    int32_t* s2 = (int32_t*)(calloc(5, 4));
    if ((((r1 == NULL || s1 == NULL) || r2 == NULL) || s2 == NULL)) {
        return 1;
    }
    int64_t wins = 0;
    int32_t c = fgetc(f);
    while (c >= 0) {
        c = skip_ws_ptr_void_i32(f, c);
        if (c < 0) {
            break;
        }
        int32_t __flow_step_7 = 1;
        for (int32_t i = 0; (0 <= 5) ? i < 5 : i > 5; i += (0 <= 5) ? 1 : -1) {
            r1[i] = rank_val_i32(c);
            s1[i] = fgetc(f);
            c = fgetc(f);
            c = skip_ws_ptr_void_i32(f, c);
        }
        int32_t __flow_step_8 = 1;
        for (int32_t i = 0; (0 <= 5) ? i < 5 : i > 5; i += (0 <= 5) ? 1 : -1) {
            r2[i] = rank_val_i32(c);
            s2[i] = fgetc(f);
            c = fgetc(f);
            c = skip_ws_ptr_void_i32(f, c);
        }
        if (hand_score_ptr_i32_ptr_i32(r1, s1) > hand_score_ptr_i32_ptr_i32(r2, s2)) {
            wins = (wins + 1);
        }
    }
    fclose(f);
    printf("%lld\n", wins);
    free(r1);
    free(s1);
    free(r2);
    free(s2);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("data/p054.txt\00") {addr_space = 0 : i32} : !llvm.array<14 x i8>
  llvm.mlir.global internal constant @str_1("r\00") {addr_space = 0 : i32} : !llvm.array<2 x i8>
  llvm.mlir.global internal constant @str_2("failed to read data/p054.txt\n\00") {addr_space = 0 : i32} : !llvm.array<30 x i8>
  llvm.mlir.global internal constant @str_3("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  llvm.mlir.global internal constant @HandCat_HighCard(0 : i32) : i32
  llvm.mlir.global internal constant @HandCat_Pair(1 : i32) : i32
  llvm.mlir.global internal constant @HandCat_TwoPair(2 : i32) : i32
  llvm.mlir.global internal constant @HandCat_ThreeOfAKind(3 : i32) : i32
  llvm.mlir.global internal constant @HandCat_Straight(4 : i32) : i32
  llvm.mlir.global internal constant @HandCat_Flush(5 : i32) : i32
  llvm.mlir.global internal constant @HandCat_FullHouse(6 : i32) : i32
  llvm.mlir.global internal constant @HandCat_FourOfAKind(7 : i32) : i32
  llvm.mlir.global internal constant @HandCat_StraightFlush(8 : i32) : i32
  func.func private @fopen(!llvm.ptr, !llvm.ptr) -> !llvm.ptr
  func.func private @fgetc(!llvm.ptr) -> i32
  func.func private @fclose(!llvm.ptr) -> i32
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func @rank_val(%arg0: i32) -> i32 {
    %0 = arith.constant 84 : i32
    %1 = arith.cmpi eq, %arg0, %0 : i32
    cf.cond_br %1, ^bb0, ^bb1
    ^bb0:
      %2 = arith.constant 10 : i32
      func.return %2 : i32
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %3 = arith.constant 74 : i32
    %4 = arith.cmpi eq, %arg0, %3 : i32
    cf.cond_br %4, ^bb3, ^bb4
    ^bb3:
      %5 = arith.constant 11 : i32
      func.return %5 : i32
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %6 = arith.constant 81 : i32
    %7 = arith.cmpi eq, %arg0, %6 : i32
    cf.cond_br %7, ^bb6, ^bb7
    ^bb6:
      %8 = arith.constant 12 : i32
      func.return %8 : i32
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %9 = arith.constant 75 : i32
    %10 = arith.cmpi eq, %arg0, %9 : i32
    cf.cond_br %10, ^bb9, ^bb10
    ^bb9:
      %11 = arith.constant 13 : i32
      func.return %11 : i32
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %12 = arith.constant 65 : i32
    %13 = arith.cmpi eq, %arg0, %12 : i32
    cf.cond_br %13, ^bb12, ^bb13
    ^bb12:
      %14 = arith.constant 14 : i32
      func.return %14 : i32
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %15 = arith.constant 48 : i32
    %16 = arith.subi %arg0, %15 : i32
    func.return %16 : i32
  }
  func.func @sort5(%arg0: !llvm.ptr) -> () {
    %17 = arith.constant 0 : i32
    %18 = arith.constant 5 : i32
    %19 = arith.index_cast %17 : i32 to index
    %20 = arith.index_cast %18 : i32 to index
    %22 = arith.constant 1 : index
    %23 = arith.constant -1 : index
    %24 = arith.cmpi sle, %19, %20 : index
    %21 = arith.select %24, %22, %23 : index
    cf.br ^bb15(%19 : index)
    ^bb15(%25: index):
    %26 = arith.cmpi slt, %25, %20 : index
    %27 = arith.cmpi sgt, %25, %20 : index
    %28 = arith.select %24, %26, %27 : i1
    cf.cond_br %28, ^bb16(%25 : index), ^bb17(%25 : index)
    ^bb16(%29: index):
      %30 = arith.constant 1 : i32
      %32 = arith.index_cast %29 : index to i32
      %31 = arith.addi %32, %30 : i32
      %33 = arith.constant 5 : i32
      %34 = arith.index_cast %31 : i32 to index
      %35 = arith.index_cast %33 : i32 to index
      %37 = arith.constant 1 : index
      %38 = arith.constant -1 : index
      %39 = arith.cmpi sle, %34, %35 : index
      %36 = arith.select %39, %37, %38 : index
      cf.br ^bb18(%34 : index)
      ^bb18(%40: index):
      %41 = arith.cmpi slt, %40, %35 : index
      %42 = arith.cmpi sgt, %40, %35 : index
      %43 = arith.select %39, %41, %42 : i1
      cf.cond_br %43, ^bb19(%40 : index), ^bb20(%40 : index)
      ^bb19(%44: index):
        %46 = arith.index_cast %44 : index to i64
        %47 = llvm.getelementptr %arg0[%46] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %45 = llvm.load %47 : !llvm.ptr -> i32
        %49 = arith.index_cast %29 : index to i64
        %50 = llvm.getelementptr %arg0[%49] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %48 = llvm.load %50 : !llvm.ptr -> i32
        %51 = arith.cmpi slt, %45, %48 : i32
        cf.cond_br %51, ^bb21, ^bb22
        ^bb21:
          %53 = arith.index_cast %29 : index to i64
          %54 = llvm.getelementptr %arg0[%53] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %52 = llvm.load %54 : !llvm.ptr -> i32
          %56 = arith.index_cast %44 : index to i64
          %57 = llvm.getelementptr %arg0[%56] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %55 = llvm.load %57 : !llvm.ptr -> i32
          %58 = arith.index_cast %29 : index to i64
          %59 = llvm.getelementptr %arg0[%58] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %55, %59 : i32, !llvm.ptr
          %60 = arith.index_cast %44 : index to i64
          %61 = llvm.getelementptr %arg0[%60] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %52, %61 : i32, !llvm.ptr
          cf.br ^bb23
        ^bb22:
          cf.br ^bb23
        ^bb23:
        %62 = arith.addi %44, %36 : index
        cf.br ^bb18(%62 : index)
      ^bb20(%63: index):
      %64 = arith.addi %29, %21 : index
      cf.br ^bb15(%64 : index)
    ^bb17(%65: index):
    func.return
  }
  // Enum: HandCat (lowered as tagged struct + variant constants)
  func.func @max2i(%arg0: i32, %arg1: i32) -> i32 {
    %66 = arith.cmpi sgt, %arg0, %arg1 : i32
    cf.cond_br %66, ^bb24, ^bb25
    ^bb24:
      func.return %arg0 : i32
    ^bb25:
      cf.br ^bb26
    ^bb26:
    func.return %arg1 : i32
  }
  func.func @min2i(%arg0: i32, %arg1: i32) -> i32 {
    %67 = arith.cmpi slt, %arg0, %arg1 : i32
    cf.cond_br %67, ^bb27, ^bb28
    ^bb27:
      func.return %arg0 : i32
    ^bb28:
      cf.br ^bb29
    ^bb29:
    func.return %arg1 : i32
  }
  func.func @hand_score(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i64 {
    %69 = arith.constant 5 : i32
    %70 = arith.constant 4 : i32
    %71 = arith.extsi %69 : i32 to i64
    %72 = arith.extsi %70 : i32 to i64
    %68 = func.call @calloc(%71, %72) : (i64, i64) -> !llvm.ptr
    %74 = arith.constant 15 : i32
    %75 = arith.constant 4 : i32
    %76 = arith.extsi %74 : i32 to i64
    %77 = arith.extsi %75 : i32 to i64
    %73 = func.call @calloc(%76, %77) : (i64, i64) -> !llvm.ptr
    %78 = llvm.mlir.zero : !llvm.ptr
    %79 = llvm.icmp "eq" %68, %78 : !llvm.ptr
    %80 = scf.if %79 -> (i1) {
      %81 = arith.constant true
      scf.yield %81 : i1
    } else {
      %82 = llvm.mlir.zero : !llvm.ptr
      %83 = llvm.icmp "eq" %73, %82 : !llvm.ptr
      scf.yield %83 : i1
    }
    cf.cond_br %80, ^bb30, ^bb31
    ^bb30:
      %84 = arith.constant 0 : i32
      %85 = arith.extsi %84 : i32 to i64
      func.return %85 : i64
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %86 = arith.constant 0 : i32
    %87 = arith.constant 5 : i32
    %88 = arith.index_cast %86 : i32 to index
    %89 = arith.index_cast %87 : i32 to index
    %91 = arith.constant 1 : index
    %92 = arith.constant -1 : index
    %93 = arith.cmpi sle, %88, %89 : index
    %90 = arith.select %93, %91, %92 : index
    cf.br ^bb33(%88 : index)
    ^bb33(%94: index):
    %95 = arith.cmpi slt, %94, %89 : index
    %96 = arith.cmpi sgt, %94, %89 : index
    %97 = arith.select %93, %95, %96 : i1
    cf.cond_br %97, ^bb34(%94 : index), ^bb35(%94 : index)
    ^bb34(%98: index):
      %100 = arith.index_cast %98 : index to i64
      %101 = llvm.getelementptr %arg0[%100] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %99 = llvm.load %101 : !llvm.ptr -> i32
      %102 = arith.index_cast %98 : index to i64
      %103 = llvm.getelementptr %68[%102] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %99, %103 : i32, !llvm.ptr
      %104 = arith.addi %98, %90 : index
      cf.br ^bb33(%104 : index)
    ^bb35(%105: index):
    func.call @sort5(%68) : (!llvm.ptr) -> ()
    %107 = arith.constant 1 : i1
    %108 = llvm.mlir.constant(1 : i64) : i64
    %109 = llvm.alloca %108 x i1 : (i64) -> !llvm.ptr
    llvm.store %107, %109 : i1, !llvm.ptr
    %110 = arith.constant 1 : i32
    %111 = arith.constant 5 : i32
    %112 = arith.index_cast %110 : i32 to index
    %113 = arith.index_cast %111 : i32 to index
    %115 = arith.constant 1 : index
    %116 = arith.constant -1 : index
    %117 = arith.cmpi sle, %112, %113 : index
    %114 = arith.select %117, %115, %116 : index
    cf.br ^bb36(%112 : index)
    ^bb36(%118: index):
    %119 = arith.cmpi slt, %118, %113 : index
    %120 = arith.cmpi sgt, %118, %113 : index
    %121 = arith.select %117, %119, %120 : i1
    cf.cond_br %121, ^bb37(%118 : index), ^bb38(%118 : index)
    ^bb37(%122: index):
      %124 = arith.index_cast %122 : index to i64
      %125 = llvm.getelementptr %arg1[%124] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %123 = llvm.load %125 : !llvm.ptr -> i32
      %127 = arith.constant 0 : i32
      %128 = arith.extsi %127 : i32 to i64
      %129 = llvm.getelementptr %arg1[%128] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %126 = llvm.load %129 : !llvm.ptr -> i32
      %130 = arith.cmpi ne, %123, %126 : i32
      cf.cond_br %130, ^bb39, ^bb40
      ^bb39:
        %131 = arith.constant 0 : i1
        llvm.store %131, %109 : i1, !llvm.ptr
        cf.br ^bb41
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %132 = arith.addi %122, %114 : index
      cf.br ^bb36(%132 : index)
    ^bb38(%133: index):
    %134 = arith.constant 1 : i1
    %135 = llvm.mlir.constant(1 : i64) : i64
    %136 = llvm.alloca %135 x i1 : (i64) -> !llvm.ptr
    llvm.store %134, %136 : i1, !llvm.ptr
    %138 = arith.constant 4 : i32
    %139 = arith.extsi %138 : i32 to i64
    %140 = llvm.getelementptr %68[%139] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %137 = llvm.load %140 : !llvm.ptr -> i32
    %141 = llvm.mlir.constant(1 : i64) : i64
    %142 = llvm.alloca %141 x i32 : (i64) -> !llvm.ptr
    llvm.store %137, %142 : i32, !llvm.ptr
    %143 = arith.constant 0 : i32
    %144 = arith.constant 4 : i32
    %145 = arith.index_cast %143 : i32 to index
    %146 = arith.index_cast %144 : i32 to index
    %148 = arith.constant 1 : index
    %149 = arith.constant -1 : index
    %150 = arith.cmpi sle, %145, %146 : index
    %147 = arith.select %150, %148, %149 : index
    cf.br ^bb42(%145 : index)
    ^bb42(%151: index):
    %152 = arith.cmpi slt, %151, %146 : index
    %153 = arith.cmpi sgt, %151, %146 : index
    %154 = arith.select %150, %152, %153 : i1
    cf.cond_br %154, ^bb43(%151 : index), ^bb44(%151 : index)
    ^bb43(%155: index):
      %157 = arith.constant 1 : i32
      %159 = arith.index_cast %155 : index to i32
      %158 = arith.addi %159, %157 : i32
      %160 = arith.extsi %158 : i32 to i64
      %161 = llvm.getelementptr %68[%160] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %156 = llvm.load %161 : !llvm.ptr -> i32
      %163 = arith.index_cast %155 : index to i64
      %164 = llvm.getelementptr %68[%163] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %162 = llvm.load %164 : !llvm.ptr -> i32
      %165 = arith.constant 1 : i32
      %166 = arith.addi %162, %165 : i32
      %167 = arith.cmpi ne, %156, %166 : i32
      cf.cond_br %167, ^bb45, ^bb46
      ^bb45:
        %168 = arith.constant 0 : i1
        llvm.store %168, %136 : i1, !llvm.ptr
        cf.br ^bb47
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %169 = arith.addi %155, %147 : index
      cf.br ^bb42(%169 : index)
    ^bb44(%170: index):
    %172 = arith.constant 0 : i32
    %173 = arith.extsi %172 : i32 to i64
    %174 = llvm.getelementptr %68[%173] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %171 = llvm.load %174 : !llvm.ptr -> i32
    %175 = arith.constant 2 : i32
    %176 = arith.cmpi eq, %171, %175 : i32
    %177 = scf.if %176 -> (i1) {
      %179 = arith.constant 1 : i32
      %180 = arith.extsi %179 : i32 to i64
      %181 = llvm.getelementptr %68[%180] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %178 = llvm.load %181 : !llvm.ptr -> i32
      %182 = arith.constant 3 : i32
      %183 = arith.cmpi eq, %178, %182 : i32
      scf.yield %183 : i1
    } else {
      %184 = arith.constant false
      scf.yield %184 : i1
    }
    %185 = scf.if %177 -> (i1) {
      %187 = arith.constant 2 : i32
      %188 = arith.extsi %187 : i32 to i64
      %189 = llvm.getelementptr %68[%188] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %186 = llvm.load %189 : !llvm.ptr -> i32
      %190 = arith.constant 4 : i32
      %191 = arith.cmpi eq, %186, %190 : i32
      scf.yield %191 : i1
    } else {
      %192 = arith.constant false
      scf.yield %192 : i1
    }
    %193 = scf.if %185 -> (i1) {
      %195 = arith.constant 3 : i32
      %196 = arith.extsi %195 : i32 to i64
      %197 = llvm.getelementptr %68[%196] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %194 = llvm.load %197 : !llvm.ptr -> i32
      %198 = arith.constant 5 : i32
      %199 = arith.cmpi eq, %194, %198 : i32
      scf.yield %199 : i1
    } else {
      %200 = arith.constant false
      scf.yield %200 : i1
    }
    %201 = scf.if %193 -> (i1) {
      %203 = arith.constant 4 : i32
      %204 = arith.extsi %203 : i32 to i64
      %205 = llvm.getelementptr %68[%204] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %202 = llvm.load %205 : !llvm.ptr -> i32
      %206 = arith.constant 14 : i32
      %207 = arith.cmpi eq, %202, %206 : i32
      scf.yield %207 : i1
    } else {
      %208 = arith.constant false
      scf.yield %208 : i1
    }
    cf.cond_br %201, ^bb48, ^bb49
    ^bb48:
      %209 = arith.constant 1 : i1
      llvm.store %209, %136 : i1, !llvm.ptr
      %210 = arith.constant 5 : i32
      llvm.store %210, %142 : i32, !llvm.ptr
      cf.br ^bb50
    ^bb49:
      cf.br ^bb50
    ^bb50:
    %211 = arith.constant 0 : i32
    %212 = arith.constant 5 : i32
    %213 = arith.index_cast %211 : i32 to index
    %214 = arith.index_cast %212 : i32 to index
    %216 = arith.constant 1 : index
    %217 = arith.constant -1 : index
    %218 = arith.cmpi sle, %213, %214 : index
    %215 = arith.select %218, %216, %217 : index
    cf.br ^bb51(%213 : index)
    ^bb51(%219: index):
    %220 = arith.cmpi slt, %219, %214 : index
    %221 = arith.cmpi sgt, %219, %214 : index
    %222 = arith.select %218, %220, %221 : i1
    cf.cond_br %222, ^bb52(%219 : index), ^bb53(%219 : index)
    ^bb52(%223: index):
      %226 = arith.index_cast %223 : index to i64
      %227 = llvm.getelementptr %68[%226] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %225 = llvm.load %227 : !llvm.ptr -> i32
      %228 = arith.extsi %225 : i32 to i64
      %229 = llvm.getelementptr %73[%228] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %224 = llvm.load %229 : !llvm.ptr -> i32
      %230 = arith.constant 1 : i32
      %231 = arith.addi %224, %230 : i32
      %233 = arith.index_cast %223 : index to i64
      %234 = llvm.getelementptr %68[%233] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %232 = llvm.load %234 : !llvm.ptr -> i32
      %235 = arith.extsi %232 : i32 to i64
      %236 = llvm.getelementptr %73[%235] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %231, %236 : i32, !llvm.ptr
      %237 = arith.addi %223, %215 : index
      cf.br ^bb51(%237 : index)
    ^bb53(%238: index):
    %239 = arith.constant 0 : i32
    %240 = llvm.mlir.constant(1 : i64) : i64
    %241 = llvm.alloca %240 x i32 : (i64) -> !llvm.ptr
    llvm.store %239, %241 : i32, !llvm.ptr
    %242 = arith.constant 0 : i32
    %243 = llvm.mlir.constant(1 : i64) : i64
    %244 = llvm.alloca %243 x i32 : (i64) -> !llvm.ptr
    llvm.store %242, %244 : i32, !llvm.ptr
    %245 = arith.constant 0 : i32
    %246 = llvm.mlir.constant(1 : i64) : i64
    %247 = llvm.alloca %246 x i32 : (i64) -> !llvm.ptr
    llvm.store %245, %247 : i32, !llvm.ptr
    %248 = arith.constant 0 : i32
    %249 = llvm.mlir.constant(1 : i64) : i64
    %250 = llvm.alloca %249 x i32 : (i64) -> !llvm.ptr
    llvm.store %248, %250 : i32, !llvm.ptr
    %251 = arith.constant 0 : i32
    %252 = llvm.mlir.constant(1 : i64) : i64
    %253 = llvm.alloca %252 x i32 : (i64) -> !llvm.ptr
    llvm.store %251, %253 : i32, !llvm.ptr
    %254 = arith.constant 14 : i32
    %255 = llvm.mlir.constant(1 : i64) : i64
    %256 = llvm.alloca %255 x i32 : (i64) -> !llvm.ptr
    llvm.store %254, %256 : i32, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %257 = llvm.load %256 : !llvm.ptr -> i32
    %258 = arith.constant 2 : i32
    %259 = arith.cmpi sge, %257, %258 : i32
    cf.cond_br %259, ^bb55, ^bb56
    ^bb55:
      %261 = llvm.load %256 : !llvm.ptr -> i32
      %262 = arith.extsi %261 : i32 to i64
      %263 = llvm.getelementptr %73[%262] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %260 = llvm.load %263 : !llvm.ptr -> i32
      %264 = arith.constant 4 : i32
      %265 = arith.cmpi eq, %260, %264 : i32
      cf.cond_br %265, ^bb57, ^bb58
      ^bb57:
        %266 = llvm.load %256 : !llvm.ptr -> i32
        llvm.store %266, %241 : i32, !llvm.ptr
        cf.br ^bb59
      ^bb58:
        cf.br ^bb59
      ^bb59:
      %268 = llvm.load %256 : !llvm.ptr -> i32
      %269 = arith.extsi %268 : i32 to i64
      %270 = llvm.getelementptr %73[%269] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %267 = llvm.load %270 : !llvm.ptr -> i32
      %271 = arith.constant 3 : i32
      %272 = arith.cmpi eq, %267, %271 : i32
      cf.cond_br %272, ^bb60, ^bb61
      ^bb60:
        %273 = llvm.load %256 : !llvm.ptr -> i32
        llvm.store %273, %244 : i32, !llvm.ptr
        cf.br ^bb62
      ^bb61:
        cf.br ^bb62
      ^bb62:
      %275 = llvm.load %256 : !llvm.ptr -> i32
      %276 = arith.extsi %275 : i32 to i64
      %277 = llvm.getelementptr %73[%276] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %274 = llvm.load %277 : !llvm.ptr -> i32
      %278 = arith.constant 2 : i32
      %279 = arith.cmpi eq, %274, %278 : i32
      cf.cond_br %279, ^bb63, ^bb64
      ^bb63:
        %280 = llvm.load %247 : !llvm.ptr -> i32
        %281 = arith.constant 0 : i32
        %282 = arith.cmpi eq, %280, %281 : i32
        cf.cond_br %282, ^bb66, ^bb67
        ^bb66:
          %283 = llvm.load %256 : !llvm.ptr -> i32
          llvm.store %283, %247 : i32, !llvm.ptr
          cf.br ^bb68
        ^bb67:
          %284 = llvm.load %256 : !llvm.ptr -> i32
          llvm.store %284, %250 : i32, !llvm.ptr
          cf.br ^bb68
        ^bb68:
        %285 = llvm.load %253 : !llvm.ptr -> i32
        %286 = arith.constant 1 : i32
        %287 = arith.addi %285, %286 : i32
        llvm.store %287, %253 : i32, !llvm.ptr
        cf.br ^bb65
      ^bb64:
        cf.br ^bb65
      ^bb65:
      %288 = llvm.load %256 : !llvm.ptr -> i32
      %289 = arith.constant 1 : i32
      %290 = arith.subi %288, %289 : i32
      llvm.store %290, %256 : i32, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %291 = llvm.mlir.undef : !llvm.struct<(i32)>
    %292 = arith.constant 0 : i32
    %293 = llvm.insertvalue %292, %291[0] : !llvm.struct<(i32)>
    %294 = llvm.mlir.constant(1 : i64) : i64
    %295 = llvm.alloca %294 x !llvm.struct<(i32)> : (i64) -> !llvm.ptr
    llvm.store %293, %295 : !llvm.struct<(i32)>, !llvm.ptr
    %296 = llvm.load %136 : !llvm.ptr -> i1
    %297 = scf.if %296 -> (i1) {
      %298 = llvm.load %109 : !llvm.ptr -> i1
      scf.yield %298 : i1
    } else {
      %299 = arith.constant false
      scf.yield %299 : i1
    }
    cf.cond_br %297, ^bb69, ^bb70
    ^bb69:
      %300 = llvm.mlir.undef : !llvm.struct<(i32)>
      %301 = arith.constant 8 : i32
      %302 = llvm.insertvalue %301, %300[0] : !llvm.struct<(i32)>
      llvm.store %302, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb70:
      %303 = llvm.load %241 : !llvm.ptr -> i32
      %304 = arith.constant 0 : i32
      %305 = arith.cmpi ne, %303, %304 : i32
      cf.cond_br %305, ^bb73, ^bb72
    ^bb73:
      %306 = llvm.mlir.undef : !llvm.struct<(i32)>
      %307 = arith.constant 7 : i32
      %308 = llvm.insertvalue %307, %306[0] : !llvm.struct<(i32)>
      llvm.store %308, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb72:
      %309 = llvm.load %244 : !llvm.ptr -> i32
      %310 = arith.constant 0 : i32
      %311 = arith.cmpi ne, %309, %310 : i32
      %312 = scf.if %311 -> (i1) {
        %313 = llvm.load %253 : !llvm.ptr -> i32
        %314 = arith.constant 1 : i32
        %315 = arith.cmpi sge, %313, %314 : i32
        scf.yield %315 : i1
      } else {
        %316 = arith.constant false
        scf.yield %316 : i1
      }
      cf.cond_br %312, ^bb75, ^bb74
    ^bb75:
      %317 = llvm.mlir.undef : !llvm.struct<(i32)>
      %318 = arith.constant 6 : i32
      %319 = llvm.insertvalue %318, %317[0] : !llvm.struct<(i32)>
      llvm.store %319, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb74:
      %320 = llvm.load %109 : !llvm.ptr -> i1
      cf.cond_br %320, ^bb77, ^bb76
    ^bb77:
      %321 = llvm.mlir.undef : !llvm.struct<(i32)>
      %322 = arith.constant 5 : i32
      %323 = llvm.insertvalue %322, %321[0] : !llvm.struct<(i32)>
      llvm.store %323, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb76:
      %324 = llvm.load %136 : !llvm.ptr -> i1
      cf.cond_br %324, ^bb79, ^bb78
    ^bb79:
      %325 = llvm.mlir.undef : !llvm.struct<(i32)>
      %326 = arith.constant 4 : i32
      %327 = llvm.insertvalue %326, %325[0] : !llvm.struct<(i32)>
      llvm.store %327, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb78:
      %328 = llvm.load %244 : !llvm.ptr -> i32
      %329 = arith.constant 0 : i32
      %330 = arith.cmpi ne, %328, %329 : i32
      cf.cond_br %330, ^bb81, ^bb80
    ^bb81:
      %331 = llvm.mlir.undef : !llvm.struct<(i32)>
      %332 = arith.constant 3 : i32
      %333 = llvm.insertvalue %332, %331[0] : !llvm.struct<(i32)>
      llvm.store %333, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb80:
      %334 = llvm.load %253 : !llvm.ptr -> i32
      %335 = arith.constant 2 : i32
      %336 = arith.cmpi eq, %334, %335 : i32
      cf.cond_br %336, ^bb83, ^bb82
    ^bb83:
      %337 = llvm.mlir.undef : !llvm.struct<(i32)>
      %338 = arith.constant 2 : i32
      %339 = llvm.insertvalue %338, %337[0] : !llvm.struct<(i32)>
      llvm.store %339, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb82:
      %340 = llvm.load %253 : !llvm.ptr -> i32
      %341 = arith.constant 1 : i32
      %342 = arith.cmpi eq, %340, %341 : i32
      cf.cond_br %342, ^bb84, ^bb71
    ^bb84:
      %343 = llvm.mlir.undef : !llvm.struct<(i32)>
      %344 = arith.constant 1 : i32
      %345 = llvm.insertvalue %344, %343[0] : !llvm.struct<(i32)>
      llvm.store %345, %295 : !llvm.struct<(i32)>, !llvm.ptr
      cf.br ^bb71
    ^bb71:
    %346 = arith.constant 0 : i32
    %347 = arith.extsi %346 : i32 to i64
    %348 = llvm.mlir.constant(1 : i64) : i64
    %349 = llvm.alloca %348 x i64 : (i64) -> !llvm.ptr
    llvm.store %347, %349 : i64, !llvm.ptr
    %350 = arith.constant 0 : i32
    %351 = arith.extsi %350 : i32 to i64
    %352 = llvm.mlir.constant(1 : i64) : i64
    %353 = llvm.alloca %352 x i64 : (i64) -> !llvm.ptr
    llvm.store %351, %353 : i64, !llvm.ptr
    %354 = llvm.load %295 : !llvm.ptr -> !llvm.struct<(i32)>
    %355 = llvm.getelementptr %295[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i32)>
    %356 = llvm.load %355 : !llvm.ptr -> i32
    %357 = arith.constant 8 : i32
    %358 = arith.cmpi eq, %356, %357 : i32
    cf.cond_br %358, ^bb85, ^bb86
^bb85:
      %359 = llvm.load %142 : !llvm.ptr -> i32
      %360 = arith.extsi %359 : i32 to i64
      llvm.store %360, %349 : i64, !llvm.ptr
      %361 = arith.constant 8 : i32
      %362 = arith.extsi %361 : i32 to i64
      llvm.store %362, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb86:
    %363 = arith.constant 7 : i32
    %364 = arith.cmpi eq, %356, %363 : i32
    cf.cond_br %364, ^bb87, ^bb88
^bb87:
      %365 = llvm.load %241 : !llvm.ptr -> i32
      %366 = arith.extsi %365 : i32 to i64
      llvm.store %366, %349 : i64, !llvm.ptr
      %367 = arith.constant 14 : i32
      llvm.store %367, %256 : i32, !llvm.ptr
      cf.br ^bb104
      ^bb104:
      %368 = llvm.load %256 : !llvm.ptr -> i32
      %369 = arith.constant 2 : i32
      %370 = arith.cmpi sge, %368, %369 : i32
      cf.cond_br %370, ^bb105, ^bb106
      ^bb105:
        %372 = llvm.load %256 : !llvm.ptr -> i32
        %373 = arith.extsi %372 : i32 to i64
        %374 = llvm.getelementptr %73[%373] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %371 = llvm.load %374 : !llvm.ptr -> i32
        %375 = arith.constant 1 : i32
        %376 = arith.cmpi eq, %371, %375 : i32
        cf.cond_br %376, ^bb107, ^bb108
        ^bb107:
          %377 = llvm.load %349 : !llvm.ptr -> i64
          %378 = arith.constant 100 : i32
          %380 = arith.extsi %378 : i32 to i64
          %379 = arith.muli %377, %380 : i64
          %381 = llvm.load %256 : !llvm.ptr -> i32
          %382 = arith.extsi %381 : i32 to i64
          %383 = arith.addi %379, %382 : i64
          llvm.store %383, %349 : i64, !llvm.ptr
          cf.br ^bb106
        ^bb108:
          cf.br ^bb109
        ^bb109:
        %384 = llvm.load %256 : !llvm.ptr -> i32
        %385 = arith.constant 1 : i32
        %386 = arith.subi %384, %385 : i32
        llvm.store %386, %256 : i32, !llvm.ptr
        cf.br ^bb104
      ^bb106:
      %387 = arith.constant 7 : i32
      %388 = arith.extsi %387 : i32 to i64
      llvm.store %388, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb88:
    %389 = arith.constant 6 : i32
    %390 = arith.cmpi eq, %356, %389 : i32
    cf.cond_br %390, ^bb89, ^bb90
^bb89:
      %391 = llvm.load %244 : !llvm.ptr -> i32
      %392 = arith.extsi %391 : i32 to i64
      %393 = arith.constant 100 : i32
      %395 = arith.extsi %393 : i32 to i64
      %394 = arith.muli %392, %395 : i64
      %396 = llvm.load %247 : !llvm.ptr -> i32
      %397 = arith.extsi %396 : i32 to i64
      %398 = arith.addi %394, %397 : i64
      llvm.store %398, %349 : i64, !llvm.ptr
      %399 = arith.constant 6 : i32
      %400 = arith.extsi %399 : i32 to i64
      llvm.store %400, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb90:
    %401 = arith.constant 5 : i32
    %402 = arith.cmpi eq, %356, %401 : i32
    cf.cond_br %402, ^bb91, ^bb92
^bb91:
      %404 = arith.constant 4 : i32
      %405 = arith.extsi %404 : i32 to i64
      %406 = llvm.getelementptr %68[%405] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %403 = llvm.load %406 : !llvm.ptr -> i32
      %407 = arith.extsi %403 : i32 to i64
      %408 = arith.constant 100000000 : i32
      %410 = arith.extsi %408 : i32 to i64
      %409 = arith.muli %407, %410 : i64
      %412 = arith.constant 3 : i32
      %413 = arith.extsi %412 : i32 to i64
      %414 = llvm.getelementptr %68[%413] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %411 = llvm.load %414 : !llvm.ptr -> i32
      %415 = arith.extsi %411 : i32 to i64
      %416 = arith.constant 1000000 : i32
      %418 = arith.extsi %416 : i32 to i64
      %417 = arith.muli %415, %418 : i64
      %419 = arith.addi %409, %417 : i64
      %421 = arith.constant 2 : i32
      %422 = arith.extsi %421 : i32 to i64
      %423 = llvm.getelementptr %68[%422] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %420 = llvm.load %423 : !llvm.ptr -> i32
      %424 = arith.extsi %420 : i32 to i64
      %425 = arith.constant 10000 : i32
      %427 = arith.extsi %425 : i32 to i64
      %426 = arith.muli %424, %427 : i64
      %428 = arith.addi %419, %426 : i64
      %430 = arith.constant 1 : i32
      %431 = arith.extsi %430 : i32 to i64
      %432 = llvm.getelementptr %68[%431] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %429 = llvm.load %432 : !llvm.ptr -> i32
      %433 = arith.extsi %429 : i32 to i64
      %434 = arith.constant 100 : i32
      %436 = arith.extsi %434 : i32 to i64
      %435 = arith.muli %433, %436 : i64
      %437 = arith.addi %428, %435 : i64
      %439 = arith.constant 0 : i32
      %440 = arith.extsi %439 : i32 to i64
      %441 = llvm.getelementptr %68[%440] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %438 = llvm.load %441 : !llvm.ptr -> i32
      %442 = arith.extsi %438 : i32 to i64
      %443 = arith.addi %437, %442 : i64
      llvm.store %443, %349 : i64, !llvm.ptr
      %444 = arith.constant 5 : i32
      %445 = arith.extsi %444 : i32 to i64
      llvm.store %445, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb92:
    %446 = arith.constant 4 : i32
    %447 = arith.cmpi eq, %356, %446 : i32
    cf.cond_br %447, ^bb93, ^bb94
^bb93:
      %448 = llvm.load %142 : !llvm.ptr -> i32
      %449 = arith.extsi %448 : i32 to i64
      llvm.store %449, %349 : i64, !llvm.ptr
      %450 = arith.constant 4 : i32
      %451 = arith.extsi %450 : i32 to i64
      llvm.store %451, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb94:
    %452 = arith.constant 3 : i32
    %453 = arith.cmpi eq, %356, %452 : i32
    cf.cond_br %453, ^bb95, ^bb96
^bb95:
      %454 = llvm.load %244 : !llvm.ptr -> i32
      %455 = arith.extsi %454 : i32 to i64
      llvm.store %455, %349 : i64, !llvm.ptr
      %456 = arith.constant 14 : i32
      llvm.store %456, %256 : i32, !llvm.ptr
      cf.br ^bb110
      ^bb110:
      %457 = llvm.load %256 : !llvm.ptr -> i32
      %458 = arith.constant 2 : i32
      %459 = arith.cmpi sge, %457, %458 : i32
      cf.cond_br %459, ^bb111, ^bb112
      ^bb111:
        %461 = llvm.load %256 : !llvm.ptr -> i32
        %462 = arith.extsi %461 : i32 to i64
        %463 = llvm.getelementptr %73[%462] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %460 = llvm.load %463 : !llvm.ptr -> i32
        %464 = arith.constant 1 : i32
        %465 = arith.cmpi eq, %460, %464 : i32
        cf.cond_br %465, ^bb113, ^bb114
        ^bb113:
          %466 = llvm.load %349 : !llvm.ptr -> i64
          %467 = arith.constant 100 : i32
          %469 = arith.extsi %467 : i32 to i64
          %468 = arith.muli %466, %469 : i64
          %470 = llvm.load %256 : !llvm.ptr -> i32
          %471 = arith.extsi %470 : i32 to i64
          %472 = arith.addi %468, %471 : i64
          llvm.store %472, %349 : i64, !llvm.ptr
          cf.br ^bb115
        ^bb114:
          cf.br ^bb115
        ^bb115:
        %473 = llvm.load %256 : !llvm.ptr -> i32
        %474 = arith.constant 1 : i32
        %475 = arith.subi %473, %474 : i32
        llvm.store %475, %256 : i32, !llvm.ptr
        cf.br ^bb110
      ^bb112:
      %476 = arith.constant 3 : i32
      %477 = arith.extsi %476 : i32 to i64
      llvm.store %477, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb96:
    %478 = arith.constant 2 : i32
    %479 = arith.cmpi eq, %356, %478 : i32
    cf.cond_br %479, ^bb97, ^bb98
^bb97:
      %481 = llvm.load %247 : !llvm.ptr -> i32
      %482 = llvm.load %250 : !llvm.ptr -> i32
      %480 = func.call @max2i(%481, %482) : (i32, i32) -> i32
      %484 = llvm.load %247 : !llvm.ptr -> i32
      %485 = llvm.load %250 : !llvm.ptr -> i32
      %483 = func.call @min2i(%484, %485) : (i32, i32) -> i32
      %486 = arith.extsi %480 : i32 to i64
      %487 = arith.constant 10000 : i32
      %489 = arith.extsi %487 : i32 to i64
      %488 = arith.muli %486, %489 : i64
      %490 = arith.extsi %483 : i32 to i64
      %491 = arith.constant 100 : i32
      %493 = arith.extsi %491 : i32 to i64
      %492 = arith.muli %490, %493 : i64
      %494 = arith.addi %488, %492 : i64
      llvm.store %494, %349 : i64, !llvm.ptr
      %495 = arith.constant 14 : i32
      llvm.store %495, %256 : i32, !llvm.ptr
      cf.br ^bb116
      ^bb116:
      %496 = llvm.load %256 : !llvm.ptr -> i32
      %497 = arith.constant 2 : i32
      %498 = arith.cmpi sge, %496, %497 : i32
      cf.cond_br %498, ^bb117, ^bb118
      ^bb117:
        %500 = llvm.load %256 : !llvm.ptr -> i32
        %501 = arith.extsi %500 : i32 to i64
        %502 = llvm.getelementptr %73[%501] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %499 = llvm.load %502 : !llvm.ptr -> i32
        %503 = arith.constant 1 : i32
        %504 = arith.cmpi eq, %499, %503 : i32
        cf.cond_br %504, ^bb119, ^bb120
        ^bb119:
          %505 = llvm.load %349 : !llvm.ptr -> i64
          %506 = llvm.load %256 : !llvm.ptr -> i32
          %507 = arith.extsi %506 : i32 to i64
          %508 = arith.addi %505, %507 : i64
          llvm.store %508, %349 : i64, !llvm.ptr
          cf.br ^bb118
        ^bb120:
          cf.br ^bb121
        ^bb121:
        %509 = llvm.load %256 : !llvm.ptr -> i32
        %510 = arith.constant 1 : i32
        %511 = arith.subi %509, %510 : i32
        llvm.store %511, %256 : i32, !llvm.ptr
        cf.br ^bb116
      ^bb118:
      %512 = arith.constant 2 : i32
      %513 = arith.extsi %512 : i32 to i64
      llvm.store %513, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb98:
    %514 = arith.constant 1 : i32
    %515 = arith.cmpi eq, %356, %514 : i32
    cf.cond_br %515, ^bb99, ^bb100
^bb99:
      %516 = llvm.load %247 : !llvm.ptr -> i32
      %517 = arith.extsi %516 : i32 to i64
      llvm.store %517, %349 : i64, !llvm.ptr
      %518 = arith.constant 14 : i32
      llvm.store %518, %256 : i32, !llvm.ptr
      cf.br ^bb122
      ^bb122:
      %519 = llvm.load %256 : !llvm.ptr -> i32
      %520 = arith.constant 2 : i32
      %521 = arith.cmpi sge, %519, %520 : i32
      cf.cond_br %521, ^bb123, ^bb124
      ^bb123:
        %523 = llvm.load %256 : !llvm.ptr -> i32
        %524 = arith.extsi %523 : i32 to i64
        %525 = llvm.getelementptr %73[%524] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %522 = llvm.load %525 : !llvm.ptr -> i32
        %526 = arith.constant 1 : i32
        %527 = arith.cmpi eq, %522, %526 : i32
        cf.cond_br %527, ^bb125, ^bb126
        ^bb125:
          %528 = llvm.load %349 : !llvm.ptr -> i64
          %529 = arith.constant 100 : i32
          %531 = arith.extsi %529 : i32 to i64
          %530 = arith.muli %528, %531 : i64
          %532 = llvm.load %256 : !llvm.ptr -> i32
          %533 = arith.extsi %532 : i32 to i64
          %534 = arith.addi %530, %533 : i64
          llvm.store %534, %349 : i64, !llvm.ptr
          cf.br ^bb127
        ^bb126:
          cf.br ^bb127
        ^bb127:
        %535 = llvm.load %256 : !llvm.ptr -> i32
        %536 = arith.constant 1 : i32
        %537 = arith.subi %535, %536 : i32
        llvm.store %537, %256 : i32, !llvm.ptr
        cf.br ^bb122
      ^bb124:
      %538 = arith.constant 1 : i32
      %539 = arith.extsi %538 : i32 to i64
      llvm.store %539, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb100:
    %540 = arith.constant 0 : i32
    %541 = arith.cmpi eq, %356, %540 : i32
    cf.cond_br %541, ^bb101, ^bb102
^bb101:
      %543 = arith.constant 4 : i32
      %544 = arith.extsi %543 : i32 to i64
      %545 = llvm.getelementptr %68[%544] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %542 = llvm.load %545 : !llvm.ptr -> i32
      %546 = arith.extsi %542 : i32 to i64
      %547 = arith.constant 100000000 : i32
      %549 = arith.extsi %547 : i32 to i64
      %548 = arith.muli %546, %549 : i64
      %551 = arith.constant 3 : i32
      %552 = arith.extsi %551 : i32 to i64
      %553 = llvm.getelementptr %68[%552] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %550 = llvm.load %553 : !llvm.ptr -> i32
      %554 = arith.extsi %550 : i32 to i64
      %555 = arith.constant 1000000 : i32
      %557 = arith.extsi %555 : i32 to i64
      %556 = arith.muli %554, %557 : i64
      %558 = arith.addi %548, %556 : i64
      %560 = arith.constant 2 : i32
      %561 = arith.extsi %560 : i32 to i64
      %562 = llvm.getelementptr %68[%561] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %559 = llvm.load %562 : !llvm.ptr -> i32
      %563 = arith.extsi %559 : i32 to i64
      %564 = arith.constant 10000 : i32
      %566 = arith.extsi %564 : i32 to i64
      %565 = arith.muli %563, %566 : i64
      %567 = arith.addi %558, %565 : i64
      %569 = arith.constant 1 : i32
      %570 = arith.extsi %569 : i32 to i64
      %571 = llvm.getelementptr %68[%570] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %568 = llvm.load %571 : !llvm.ptr -> i32
      %572 = arith.extsi %568 : i32 to i64
      %573 = arith.constant 100 : i32
      %575 = arith.extsi %573 : i32 to i64
      %574 = arith.muli %572, %575 : i64
      %576 = arith.addi %567, %574 : i64
      %578 = arith.constant 0 : i32
      %579 = arith.extsi %578 : i32 to i64
      %580 = llvm.getelementptr %68[%579] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %577 = llvm.load %580 : !llvm.ptr -> i32
      %581 = arith.extsi %577 : i32 to i64
      %582 = arith.addi %576, %581 : i64
      llvm.store %582, %349 : i64, !llvm.ptr
      %583 = arith.constant 0 : i32
      %584 = arith.extsi %583 : i32 to i64
      llvm.store %584, %353 : i64, !llvm.ptr
      cf.br ^bb103
^bb102:
    cf.br ^bb103
^bb103:
    func.call @free(%73) : (!llvm.ptr) -> ()
    func.call @free(%68) : (!llvm.ptr) -> ()
    %587 = llvm.load %353 : !llvm.ptr -> i64
    %588 = arith.constant 5705032704 : i32
    %590 = arith.extsi %588 : i32 to i64
    %589 = arith.muli %587, %590 : i64
    %591 = llvm.load %349 : !llvm.ptr -> i64
    %592 = arith.addi %589, %591 : i64
    func.return %592 : i64
  }
  func.func @skip_ws(%arg0: !llvm.ptr, %arg1: i32) -> i32 {
    %593 = llvm.mlir.constant(1 : i64) : i64
    %594 = llvm.alloca %593 x i32 : (i64) -> !llvm.ptr
    llvm.store %arg1, %594 : i32, !llvm.ptr
    cf.br ^bb128
    ^bb128:
    %595 = llvm.load %594 : !llvm.ptr -> i32
    %596 = arith.constant 32 : i32
    %597 = arith.cmpi eq, %595, %596 : i32
    %598 = scf.if %597 -> (i1) {
      %599 = arith.constant true
      scf.yield %599 : i1
    } else {
      %600 = llvm.load %594 : !llvm.ptr -> i32
      %601 = arith.constant 10 : i32
      %602 = arith.cmpi eq, %600, %601 : i32
      scf.yield %602 : i1
    }
    %603 = scf.if %598 -> (i1) {
      %604 = arith.constant true
      scf.yield %604 : i1
    } else {
      %605 = llvm.load %594 : !llvm.ptr -> i32
      %606 = arith.constant 13 : i32
      %607 = arith.cmpi eq, %605, %606 : i32
      scf.yield %607 : i1
    }
    %608 = scf.if %603 -> (i1) {
      %609 = arith.constant true
      scf.yield %609 : i1
    } else {
      %610 = llvm.load %594 : !llvm.ptr -> i32
      %611 = arith.constant 9 : i32
      %612 = arith.cmpi eq, %610, %611 : i32
      scf.yield %612 : i1
    }
    cf.cond_br %608, ^bb129, ^bb130
    ^bb129:
      %613 = func.call @fgetc(%arg0) : (!llvm.ptr) -> i32
      llvm.store %613, %594 : i32, !llvm.ptr
      cf.br ^bb128
    ^bb130:
    %614 = llvm.load %594 : !llvm.ptr -> i32
    func.return %614 : i32
  }
  func.func @main() -> i32 {
    %616 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %617 = llvm.mlir.addressof @str_1 : !llvm.ptr
    %615 = func.call @fopen(%616, %617) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr
    %618 = llvm.mlir.zero : !llvm.ptr
    %619 = llvm.icmp "eq" %615, %618 : !llvm.ptr
    cf.cond_br %619, ^bb131, ^bb132
    ^bb131:
      %620 = llvm.mlir.addressof @str_2 : !llvm.ptr
      %621 = llvm.call @printf(%620) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr) -> i32
      %622 = arith.constant 1 : i32
      func.return %622 : i32
    ^bb132:
      cf.br ^bb133
    ^bb133:
    %624 = arith.constant 5 : i32
    %625 = arith.constant 4 : i32
    %626 = arith.extsi %624 : i32 to i64
    %627 = arith.extsi %625 : i32 to i64
    %623 = func.call @calloc(%626, %627) : (i64, i64) -> !llvm.ptr
    %629 = arith.constant 5 : i32
    %630 = arith.constant 4 : i32
    %631 = arith.extsi %629 : i32 to i64
    %632 = arith.extsi %630 : i32 to i64
    %628 = func.call @calloc(%631, %632) : (i64, i64) -> !llvm.ptr
    %634 = arith.constant 5 : i32
    %635 = arith.constant 4 : i32
    %636 = arith.extsi %634 : i32 to i64
    %637 = arith.extsi %635 : i32 to i64
    %633 = func.call @calloc(%636, %637) : (i64, i64) -> !llvm.ptr
    %639 = arith.constant 5 : i32
    %640 = arith.constant 4 : i32
    %641 = arith.extsi %639 : i32 to i64
    %642 = arith.extsi %640 : i32 to i64
    %638 = func.call @calloc(%641, %642) : (i64, i64) -> !llvm.ptr
    %643 = llvm.mlir.zero : !llvm.ptr
    %644 = llvm.icmp "eq" %623, %643 : !llvm.ptr
    %645 = scf.if %644 -> (i1) {
      %646 = arith.constant true
      scf.yield %646 : i1
    } else {
      %647 = llvm.mlir.zero : !llvm.ptr
      %648 = llvm.icmp "eq" %628, %647 : !llvm.ptr
      scf.yield %648 : i1
    }
    %649 = scf.if %645 -> (i1) {
      %650 = arith.constant true
      scf.yield %650 : i1
    } else {
      %651 = llvm.mlir.zero : !llvm.ptr
      %652 = llvm.icmp "eq" %633, %651 : !llvm.ptr
      scf.yield %652 : i1
    }
    %653 = scf.if %649 -> (i1) {
      %654 = arith.constant true
      scf.yield %654 : i1
    } else {
      %655 = llvm.mlir.zero : !llvm.ptr
      %656 = llvm.icmp "eq" %638, %655 : !llvm.ptr
      scf.yield %656 : i1
    }
    cf.cond_br %653, ^bb134, ^bb135
    ^bb134:
      %657 = arith.constant 1 : i32
      func.return %657 : i32
    ^bb135:
      cf.br ^bb136
    ^bb136:
    %658 = arith.constant 0 : i32
    %659 = arith.extsi %658 : i32 to i64
    %660 = llvm.mlir.constant(1 : i64) : i64
    %661 = llvm.alloca %660 x i64 : (i64) -> !llvm.ptr
    llvm.store %659, %661 : i64, !llvm.ptr
    %662 = func.call @fgetc(%615) : (!llvm.ptr) -> i32
    %663 = llvm.mlir.constant(1 : i64) : i64
    %664 = llvm.alloca %663 x i32 : (i64) -> !llvm.ptr
    llvm.store %662, %664 : i32, !llvm.ptr
    cf.br ^bb137
    ^bb137:
    %665 = llvm.load %664 : !llvm.ptr -> i32
    %666 = arith.constant 0 : i32
    %667 = arith.cmpi sge, %665, %666 : i32
    cf.cond_br %667, ^bb138, ^bb139
    ^bb138:
      %669 = llvm.load %664 : !llvm.ptr -> i32
      %668 = func.call @skip_ws(%615, %669) : (!llvm.ptr, i32) -> i32
      llvm.store %668, %664 : i32, !llvm.ptr
      %670 = llvm.load %664 : !llvm.ptr -> i32
      %671 = arith.constant 0 : i32
      %672 = arith.cmpi slt, %670, %671 : i32
      cf.cond_br %672, ^bb140, ^bb141
      ^bb140:
        cf.br ^bb139
      ^bb141:
        cf.br ^bb142
      ^bb142:
      %673 = arith.constant 0 : i32
      %674 = arith.constant 5 : i32
      %675 = arith.index_cast %673 : i32 to index
      %676 = arith.index_cast %674 : i32 to index
      %678 = arith.constant 1 : index
      %679 = arith.constant -1 : index
      %680 = arith.cmpi sle, %675, %676 : index
      %677 = arith.select %680, %678, %679 : index
      cf.br ^bb143(%675 : index)
      ^bb143(%681: index):
      %682 = arith.cmpi slt, %681, %676 : index
      %683 = arith.cmpi sgt, %681, %676 : index
      %684 = arith.select %680, %682, %683 : i1
      cf.cond_br %684, ^bb144(%681 : index), ^bb145(%681 : index)
      ^bb144(%685: index):
        %687 = llvm.load %664 : !llvm.ptr -> i32
        %686 = func.call @rank_val(%687) : (i32) -> i32
        %688 = arith.index_cast %685 : index to i64
        %689 = llvm.getelementptr %623[%688] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %686, %689 : i32, !llvm.ptr
        %690 = func.call @fgetc(%615) : (!llvm.ptr) -> i32
        %691 = arith.index_cast %685 : index to i64
        %692 = llvm.getelementptr %628[%691] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %690, %692 : i32, !llvm.ptr
        %693 = func.call @fgetc(%615) : (!llvm.ptr) -> i32
        llvm.store %693, %664 : i32, !llvm.ptr
        %695 = llvm.load %664 : !llvm.ptr -> i32
        %694 = func.call @skip_ws(%615, %695) : (!llvm.ptr, i32) -> i32
        llvm.store %694, %664 : i32, !llvm.ptr
        %696 = arith.addi %685, %677 : index
        cf.br ^bb143(%696 : index)
      ^bb145(%697: index):
      %698 = arith.constant 0 : i32
      %699 = arith.constant 5 : i32
      %700 = arith.index_cast %698 : i32 to index
      %701 = arith.index_cast %699 : i32 to index
      %703 = arith.constant 1 : index
      %704 = arith.constant -1 : index
      %705 = arith.cmpi sle, %700, %701 : index
      %702 = arith.select %705, %703, %704 : index
      cf.br ^bb146(%700 : index)
      ^bb146(%706: index):
      %707 = arith.cmpi slt, %706, %701 : index
      %708 = arith.cmpi sgt, %706, %701 : index
      %709 = arith.select %705, %707, %708 : i1
      cf.cond_br %709, ^bb147(%706 : index), ^bb148(%706 : index)
      ^bb147(%710: index):
        %712 = llvm.load %664 : !llvm.ptr -> i32
        %711 = func.call @rank_val(%712) : (i32) -> i32
        %713 = arith.index_cast %710 : index to i64
        %714 = llvm.getelementptr %633[%713] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %711, %714 : i32, !llvm.ptr
        %715 = func.call @fgetc(%615) : (!llvm.ptr) -> i32
        %716 = arith.index_cast %710 : index to i64
        %717 = llvm.getelementptr %638[%716] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %715, %717 : i32, !llvm.ptr
        %718 = func.call @fgetc(%615) : (!llvm.ptr) -> i32
        llvm.store %718, %664 : i32, !llvm.ptr
        %720 = llvm.load %664 : !llvm.ptr -> i32
        %719 = func.call @skip_ws(%615, %720) : (!llvm.ptr, i32) -> i32
        llvm.store %719, %664 : i32, !llvm.ptr
        %721 = arith.addi %710, %702 : index
        cf.br ^bb146(%721 : index)
      ^bb148(%722: index):
      %723 = func.call @hand_score(%623, %628) : (!llvm.ptr, !llvm.ptr) -> i64
      %724 = func.call @hand_score(%633, %638) : (!llvm.ptr, !llvm.ptr) -> i64
      %725 = arith.cmpi sgt, %723, %724 : i64
      cf.cond_br %725, ^bb149, ^bb150
      ^bb149:
        %726 = llvm.load %661 : !llvm.ptr -> i64
        %727 = arith.constant 1 : i32
        %729 = arith.extsi %727 : i32 to i64
        %728 = arith.addi %726, %729 : i64
        llvm.store %728, %661 : i64, !llvm.ptr
        cf.br ^bb151
      ^bb150:
        cf.br ^bb151
      ^bb151:
      cf.br ^bb137
    ^bb139:
    %730 = func.call @fclose(%615) : (!llvm.ptr) -> i32
    %731 = llvm.mlir.addressof @str_3 : !llvm.ptr
    %732 = llvm.load %661 : !llvm.ptr -> i64
    %733 = llvm.call @printf(%731, %732) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%623) : (!llvm.ptr) -> ()
    func.call @free(%628) : (!llvm.ptr) -> ()
    func.call @free(%633) : (!llvm.ptr) -> ()
    func.call @free(%638) : (!llvm.ptr) -> ()
    %738 = arith.constant 0 : i32
    func.return %738 : i32
  }
}