// verified this matches hash.tal for tests

#include <stdint.h>
#include <stdio.h>

uint32_t hash(uint8_t *input) {
    uint16_t x = 0x1234;
    uint16_t y = 0xabcd;
    uint16_t a = 0x2443;
    uint16_t b = 0x118d;
    uint8_t c;
    uint16_t cc;

    while (c = *input) {
        cc = (c << 8) | c;
        x = (x * a) + cc;
        y = (y * b) + cc;
        input++;
    }

    return (x << 16) | y;
}

int main(int argc, char **argv) {
    printf("data1a %08x\n", hash("abc"));
    printf("data1b %08x\n", hash("ebc"));
    printf("\n");
    printf("data2a %08x\n", hash("wigjewigjewigjewigjewigjewigjcncmnbegejgiwejgieg"));
    printf("data2b %08x\n", hash("wigjewigjewigjewigjewigjewigjcmcmnbegejgiwejgieg"));
    printf("\n");
    printf("data3a %08x\n", hash("zzjiewgew"));
    printf("data3b %08x\n", hash("zzjiewge"));
    printf("\n");
    printf("data4a %08x\n", hash("this is a test"));
    printf("data4b %08x\n", hash("this is a test."));
    return 0;
}