#include <stdint.h>
#include <windows.h>

#define UNDEFINED 0x7FFF800000000001ULL
#define NULL_VAL  0x7FFF800000000002ULL
#define TRUE_VAL  0x7FFF000000000001ULL
#define FALSE_VAL 0x7FFF000000000000ULL
#define STRING_TAG 0x7FFC000000000000ULL
#define ARRAY_TAG  0x7FFB000000000000ULL
#define OBJECT_TAG 0x7FFA000000000000ULL
#define TAG_MASK   0xFFFF000000000000ULL
#define PTR_MASK   0x0000FFFFFFFFFFFFULL

typedef struct { uint32_t len; uint32_t hash; uint8_t data[]; } JsString;
typedef struct { uint32_t len; uint32_t capacity; uint64_t data[]; } JsArray;
typedef struct { uint64_t key; uint64_t value; } ObjectEntry;
typedef struct { uint32_t size; uint32_t capacity; ObjectEntry entries[]; } JsObject;

static double bits_to_val(uint64_t bits) {
    double result;
    __asm__ volatile ("movq %1, %0" : "=x"(result) : "r"(bits));
    return result;
}

static uint64_t val_to_bits(double val) {
    uint64_t bits;
    __asm__ volatile ("movq %1, %0" : "=r"(bits) : "x"(val));
    return bits;
}

extern double main(void);

void _start() {
    double result = main();
    int exit_code = (int)result;
    ExitProcess(exit_code);
}
