#include <ejit/ejit.h>
#include <assert.h>
#include "do_jit.h"

int main(int argc, char *argv[])
{
	(void)argv;
	bool do_jit = argc > 1;
	struct ejit_operand operands[1] = {
		EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
	};
	struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 1, operands);

	ejit_extr_d(f, EJIT_FPR(0), EJIT_GPR(0));
	ejit_retr_d(f, EJIT_FPR(0));

	ejit_select_compile_func(f, 1, 1, false, do_jit, true);

	assert(erfd1(f, EJIT_ARG(0, long)) == 0.0f);
	assert(erfd1(f, EJIT_ARG(1, long)) == 1.0f);
	assert(erfd1(f, EJIT_ARG(-100, long)) == -100.0f);

	ejit_destroy_func(f);
}