JHC compiles to C and last time I tried this it looked very much like the original C version:
This is the same thing. Compile with --tdir=/tmp/ajhc and then cat /tmp/ajhc/main_code.c. Output should be like this:
static uint32_t A_STD
fW$__fMain_1__ack(gc_t gc,uint32_t v105553376,uint32_t v61835120)
{
if (0 == v105553376) {
return 1 + v61835120;
} else {
uint32_t v16;
uint32_t v22;
struct tup1 x2;
if (0 == v61835120) {
uint32_t v228308038 = (v105553376 - 1);
x2.t0 = v228308038;
x2.t1 = 1;
} else {
uint32_t v110947990;
uint32_t v215884490 = (v61835120 - 1);
uint32_t v62470112 = (v105553376 - 1);
v110947990 = fW$__fMain_1__ack(gc,v105553376,v215884490);
x2.t0 = v62470112;
x2.t1 = v110947990;
}
v22 = x2.t0;
v16 = x2.t1;
return fW$__fMain_1__ack(gc,v22,v16);
}
}
And it's as fast as C on my machine:
chris@midnight:~/Projects/me/ajhc$ time ./ack
65533
real 0m2.134s
user 0m2.124s
sys 0m0.000s
chris@midnight:~/Projects/me/ajhc$ gcc -O3 ack.c -o ack-c
ack.c: In function ‘main’:
ack.c:8:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
chris@midnight:~/Projects/me/ajhc$ time ./ack-c
65533
real 0m2.255s
user 0m2.248s
sys 0m0.000s
chris@midnight:~/Projects/me/ajhc$