Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Created April 1, 2013 10:19
Show Gist options
  • Save chrisdone/5284156 to your computer and use it in GitHub Desktop.
Save chrisdone/5284156 to your computer and use it in GitHub Desktop.
char jhc_c_compile[] = "gcc tmp_files/rts/profile.c tmp_files/rts/rts_support.c tmp_files/rts/gc_none.c tmp_files/rts/jhc_rts.c tmp_files/lib/lib_cbits.c tmp_files/rts/gc_jgc.c tmp_files/rts/stableptr.c -Itmp_files/cbits -Itmp_files tmp_files/main_code.c -o fib-ajhc '-std=gnu99' -D_GNU_SOURCE '-falign-functions=4' -ffast-math -Wextra -Wall -Wno-unused-parameter -fno-strict-aliasing -DNDEBUG -O3 '-D_JHC_GC=_JHC_GC_JGC'";
char jhc_command[] = "ajhc -o fib-ajhc fib.hs --tdir tmp_files";
char jhc_version[] = "ajhc 0.8.0.1 (46ba77fa0f2ed1fa16acdedae737deab365c9c25)";
#include "jhc_rts_header.h"
static struct s_cache *cCJhc_Prim_Prim_$x3a;
static struct s_cache *cFW$__fJhc_Inst_Show_showWord;
#include <stdio.h>
enum {
CJhc_Prim_Prim_$BE = 1,
CJhc_Prim_Prim_$LR = 0,
CJhc_Prim_Prim_$x3a = 0
};
struct sCJhc_Prim_Prim_$x3a A_ALIGNED;
struct sFW$__fJhc_Inst_Show_showWord A_ALIGNED;
struct sCJhc_Prim_Prim_$x3a {
sptr_t a1;
sptr_t a2;
};
struct sFW$__fJhc_Inst_Show_showWord {
fptr_t head;
wptr_t a2;
uint32_t a1;
};
void jhc_hs_init(void) ;
static wptr_t E__fW$__fJhc_Inst_Show_showWord(gc_t gc,struct sFW$__fJhc_Inst_Show_showWord* arg) A_STD A_FALIGNED;
void _amain(void) ;
static void b__main(gc_t gc) A_STD;
static wptr_t fW$__fJhc_Inst_Show_showWord(gc_t gc,uint32_t v1595416115,wptr_t v1598692909) A_STD A_MALLOC;
static uint32_t fW$__fMain_fib(gc_t gc,uint32_t v227981062) A_STD;
static void ftheMain(gc_t gc) A_STD;
/* CAFS */
const void * const nh_stuff[] = {
NULL
};
void
jhc_hs_init(void)
{
find_cache(&cCJhc_Prim_Prim_$x3a,arena,TO_BLOCKS(sizeof(struct sCJhc_Prim_Prim_$x3a)),2);
find_cache(&cFW$__fJhc_Inst_Show_showWord,arena,TO_BLOCKS(sizeof(struct sFW$__fJhc_Inst_Show_showWord)),2);
}
static wptr_t A_STD A_FALIGNED
E__fW$__fJhc_Inst_Show_showWord(gc_t gc,struct sFW$__fJhc_Inst_Show_showWord* arg)
{
{ wptr_t r;
gc_frame0(gc,1,MKLAZY(arg));
r = fW$__fJhc_Inst_Show_showWord(gc,arg->a1,arg->a2);
update(arg,r);
return r;
}
}
void
_amain(void)
{
return (void)b__main(saved_gc);
}
static void A_STD
b__main(gc_t gc)
{
return ftheMain(gc);
}
static wptr_t A_STD A_MALLOC
fW$__fJhc_Inst_Show_showWord(gc_t gc,uint32_t v1595416115,wptr_t v1598692909)
{
wptr_t v124940224;
uint32_t v115160438;
v115160438 = v1595416115;
v124940224 = v1598692909;
fW$__fR$__fJhc_Inst_Show_showWord__2:;
{ sptr_t v124940266 = demote(v124940224);
uint32_t v40405744 = (v115160438 / 10);
uint32_t v253468958 = (v115160438 % 10);
uintmax_t v110947986 = ((uintmax_t)v253468958);
uint32_t v132127022 = ((uint32_t)v110947986);
uint32_t v206747424 = (48 + v132127022);
uint32_t v186683834 = v206747424;
{ gc_frame0(gc,1,v124940266);
wptr_t v50 = RAW_SET_UF(v186683834);
sptr_t v130387134 = demote(v50);
if (0 == v40405744) {
{ gc_frame0(gc,1,v130387134);
wptr_t x3 = s_alloc(gc,cCJhc_Prim_Prim_$x3a);
((struct sCJhc_Prim_Prim_$x3a*)x3)->a1 = v130387134;
((struct sCJhc_Prim_Prim_$x3a*)x3)->a2 = v124940266;
return x3;
}
} else {
{ gc_frame0(gc,1,v130387134);
wptr_t x4 = s_alloc(gc,cCJhc_Prim_Prim_$x3a);
((struct sCJhc_Prim_Prim_$x3a*)x4)->a1 = v130387134;
((struct sCJhc_Prim_Prim_$x3a*)x4)->a2 = v124940266;
wptr_t v15 = x4;
v115160438 = v40405744;
v124940224 = v15;
goto fW$__fR$__fJhc_Inst_Show_showWord__2;
}
}
}
}
}
static uint32_t A_STD
fW$__fMain_fib(gc_t gc,uint32_t v227981062)
{
uint16_t v100014 = (((int32_t)2) > ((int32_t)v227981062));
if (0 == v100014) {
uint32_t v124940232;
uint32_t v29534750;
uint32_t v61835120 = (v227981062 - 1);
v124940232 = fW$__fMain_fib(gc,v61835120);
uint32_t v29534744 = (v227981062 - 2);
v29534750 = fW$__fMain_fib(gc,v29534744);
return v124940232 + v29534750;
} else {
/* 1 */
assert(1 == v100014);
return v227981062;
}
}
static void A_STD
ftheMain(gc_t gc)
{
sptr_t v10;
wptr_t v30;
uint32_t v209623814;
v209623814 = fW$__fMain_fib(gc,40);
uint16_t v100000 = (((int32_t)0) > ((int32_t)v209623814));
if (0 == v100000) {
uintmax_t v40405742 = ((intmax_t)((int32_t)v209623814));
uint32_t v110207578 = ((uint32_t)v40405742);
v30 = fW$__fJhc_Inst_Show_showWord(gc,v110207578,SET_RAW_TAG(CJhc_Prim_Prim_$BE));
} else {
/* 1 */
assert(1 == v100000);
uint32_t v179466816 = (-((int32_t)v209623814));
uintmax_t v29534746 = ((intmax_t)((int32_t)v179466816));
uint32_t v124235156 = ((uint32_t)v29534746);
sptr_t x5 = s_alloc(gc,cFW$__fJhc_Inst_Show_showWord);
((struct sFW$__fJhc_Inst_Show_showWord*)x5)->head = TO_FPTR(&E__fW$__fJhc_Inst_Show_showWord);
((struct sFW$__fJhc_Inst_Show_showWord*)x5)->a1 = v124235156;
((struct sFW$__fJhc_Inst_Show_showWord*)x5)->a2 = SET_RAW_TAG(CJhc_Prim_Prim_$BE);
sptr_t v123425722 = MKLAZY(x5);
{ gc_frame0(gc,1,v123425722);
wptr_t x6 = s_alloc(gc,cCJhc_Prim_Prim_$x3a);
((struct sCJhc_Prim_Prim_$x3a*)x6)->a1 = ((sptr_t)RAW_SET_UF('-'));
((struct sCJhc_Prim_Prim_$x3a*)x6)->a2 = v123425722;
v30 = x6;
}
}
sptr_t v32 = demote(v30);
v10 = v32;
fJhc_Monad_72__go__7:;
{ wptr_t v100010 = eval(gc,v10);
if (SET_RAW_TAG(CJhc_Prim_Prim_$BE) == v100010) {
SET_RAW_TAG(CJhc_Prim_Prim_$LR);
} else {
sptr_t v115160440;
sptr_t v12;
/* ("CJhc.Prim.Prim.:" ni12 ni115160440) */
v12 = ((struct sCJhc_Prim_Prim_$x3a*)v100010)->a1;
v115160440 = ((struct sCJhc_Prim_Prim_$x3a*)v100010)->a2;
{ uint32_t v253468956;
gc_frame0(gc,1,v115160440);
wptr_t v100012 = eval(gc,v12);
v253468956 = ((uint32_t)RAW_GET_UF(v100012));
uint32_t v163333524 = v253468956;
saved_gc = gc;
(void)jhc_utf8_putchar((int)v163333524);
v10 = v115160440;
goto fJhc_Monad_72__go__7;
}
}
}
saved_gc = gc;
return (void)jhc_utf8_putchar((int)10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment