#include <math.h>
#include <stdlib.h>

int main(void) {
    double x; int r; char *end;

    /* sqrt */
    r = (int)(sqrt(4.0) + 0.5);
    if (r != 2) return 1;

    /* sin/cos — test single calls (known C frontend limitation with sequential calls) */
    x = sin(0.0);
    r = (int)(x * 100.0 + 0.5);
    if (r != 0) return 2;

    x = cos(0.0);
    r = (int)(x * 100.0 + 0.5);
    if (r != 100) return 3;

    /* tan */
    x = tan(0.0);
    r = (int)(x * 100.0 + 0.5);
    if (r != 0) return 4;

    /* exp/log */
    x = exp(1.0);
    if (x < 2.718 || x > 2.719) return 5;
    x = log(2.71828);
    r = (int)(x * 100.0 + 0.5);
    if (r != 100) return 6;

    /* pow */
    x = pow(2.0, 3.0);
    r = (int)(x + 0.5);
    if (r != 8) return 7;

    /* strtod / strtold */
    x = strtod("3.14159", &end);
    r = (int)(x * 100000.0 + 0.5);
    if (r != 314159) return 8;

    return 0;
}
