#include <stdio.h>

#include "Rts.h"

FILE *hp_file;

/* From rts/ProfHeap.c */
static void
printSample(rtsBool beginSample, StgDouble sampleValue)
{
    StgDouble fractionalPart, integralPart;
    fractionalPart = modf(sampleValue, &integralPart);

    printf("%g %g\n", integralPart, fractionalPart);
    printf("%" FMT_Word64 " %02" FMT_Word64 "\n", (StgWord64)integralPart,(StgWord64)(fractionalPart * 100));
    printf("%" FMT_Word64, (StgWord64)integralPart);
    printf(" %02" FMT_Word64 "\n", (StgWord64)(fractionalPart * 100));

    fprintf(hp_file, "%s %" FMT_Word64 ".%02" FMT_Word64 "\n",
            (beginSample ? "BEGIN_SAMPLE" : "END_SAMPLE"),
            (StgWord64)integralPart, (StgWord64)(fractionalPart * 100));
}

main()
{
  hp_file = stdout;
  printSample(rtsTrue, 1.5);
}

/*
 * This prints
1 0.5
1 00
1 50
BEGIN_SAMPLE 1.00

 * but should print
1 0.5
1 50
1 50
BEGIN_SAMPLE 1.50
*/
