#include "common.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

static const size_t BUF_SIZE = 128;

static const uint8_t target[] = {
	0xd9, 0x32, 0xeb, 0xb1, 0x35, 0x22, 0xe6, 0x70, 0xbc, 0x8c, 0xcd, 0x65, 0x62, 0xad, 0x7d, 0xbe, 0xa5, 0xc6, 0x56, 0xdb, 0x36, 0x2c, 0xa6, 0x2f, 0x82, 0xd5, 0x87, 0x6d, 0xa8, 0x7a, 0x5b, 0xee, 0xb3, 0x6c, 0xab, 0x69, 0xc4, 0x8a, 0xb6, 0xdb, 0x20, 0xdd, 0x95, 0x9, 0x6e, 0xae, 0x90, 0xdd, 0xf3, 0x38, 0x43, 0x4b, 0x8c, 0x63, 0xfc, 0xc8, 0x1e, 0x20, 0x87, 0xc4, 0xd2, 0xe4, 0x40, 0x32, 0xf6, 0xc9, 0xd3, 0xd3, 0xab, 0xb7, 0x2b, 0xbb, 0x4b, 0x87, 0x7c, 0xb7, 0xa6, 0xcc, 0x39, 0xb5, 0x6e, 0x31, 0x56, 0x79, 0x49, 0xc5, 0x44, 0x66, 0x71, 0xb2, 0x9e, 0xee, 0x60, 0x2, 0xa, 0x54, 0x9d, 0x71, 0xf4, 0xc8, 0xbe, 0x3, 0x87, 0x93, 0x17, 0xdb, 0x6d, 0x6b, 0xe3, 0x7e, 0x16, 0x34, 0xab, 0x7d, 0x44, 0x4, 0xa2, 0xcc, 0x4e, 0x3c, 0x7e, 0xfd, 0xb1, 0x5d, 0x3, 0xd6, 0x32, 0xd4
};

int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
    if (size < BUF_SIZE)
        return TEPHRA_EXIT_FAILURE;

    if (memcmp(data, target, BUF_SIZE) == 0)
        BOOM();

    return TEPHRA_EXIT_SUCCESS;
}

#ifdef __cplusplus
}
#endif
