/* Auto generated GreenCard 2 code for FFI */
#include <stdlib.h>
#include "StdDIS_stub_ffi.h"
void prim_writeCharAddr(char* s,int i,char v)
{ do { s[i] = v; ;
      ;} while(0);
}
char prim_readCharAddr(char* s,int i)
{ char res1;
  do { res1 = s[i]; ;
      
      return((char)(res1));} while(0);
}
char* prim_allocCharStar(int arg1)
{ char* res1;
  do { res1 = (char *)malloc(sizeof(char) * arg1); ;
      
      return((char*)(res1));} while(0);
}
void* prim_malloc(unsigned int arg1)
{ static struct {HsPtr res1;HsInt gc_failed;HsPtr gc_failstring;} gc_result;
  void * res1;int gc_failed;
	      char* gc_failstring;
  do {res1 = malloc(arg1);
      if ((gc_failed = ( res1==0 ))) {gc_failstring =  "malloc failed"  ;}
      else {gc_failed = 0;}
      gc_result.res1 = (void *)(res1);
      gc_result.gc_failed = gc_failed;
      gc_result.gc_failstring = gc_failstring;
      
      return(&gc_result);} while(0);
}
void * access_prim_malloc_res1(void *ptr){ return(((struct {HsPtr res1;HsInt gc_failed;HsPtr gc_failstring;}*) ptr)->res1);}
int access_prim_malloc_gc_failed(void *ptr){ return(((struct {HsPtr res1;HsInt gc_failed;HsPtr gc_failstring;}*) ptr)->gc_failed);}
void* access_prim_malloc_gc_failstring(void *ptr){ return(((struct {HsPtr res1;HsInt gc_failed;HsPtr gc_failstring;}*) ptr)->gc_failstring);}
void prim_free(void * arg1)
{ do {free(arg1);
      ;} while(0);
}
