package SPVM::Example {
  precompile sub sum : int ($nums : int[]) {
    my $total = 0;
    for (my $i = 0; $i < @$nums; $i++) {
      $total += $nums->[$i];
    }
    
    return $total;
  }
  
  native sub INFINITYF : float ();
  native sub NANF : float ();
  
  native sub isinff : int($x : float);
  native sub isfinitef : int($x : float);
  native sub isnanf : int ($x : float);
  
  native sub INFINITY : double ();
  native sub NAN : double ();
  
  native sub isinf : int ($x : double);
  native sub isfinite : int ($x : double);
  native sub isnan : int ($x : double);

  # Trigonometric functions
  native sub acos : double ($x : double);
  native sub asin : double($x : double);
  native sub atan : double ($x : double);
  native sub atan2 : double ($y : double, $x : double);
  native sub cos : double ($x : double);
  native sub sin : double ($x : double);
  native sub tan : double ($x : double);
  
  # Hyperbolic functions
  native sub acosh : double ($x : double);
  native sub asinh : double ($x : double);
  native sub atanh : double ($x : double);
  native sub cosh : double ($x : double);
  native sub sinh : double ($x : double);
  native sub tanh : double ($x : double);
  
  # Exponential functions and logarithmic functions
  native sub exp : double ($x : double);
  native sub exp2 : double ($x : double);
  native sub expm1 : double ($x : double);
  native sub log : double ($x : double);
  native sub log10 : double ($x : double);
  native sub log1p : double ($x : double);
  
  # Exponentiation functions and Absolute value functions
  native sub abs : int ($x : int);
  native sub labs : long ($x : long);
  native sub cbrt : double ($x : double);
  native sub fabs : double ($x : double);
  native sub hypot : double ($x : double, $y : double);
  native sub pow : double ($x : double, $y : double);
  native sub sqrt : double ($x : double);
  
  # Error function and Gamma function
  native sub erf : double ($x : double);
  native sub erfc : double ($x : double);
  native sub lgamma : double ($x : double);
  native sub tgamma : double ($x : double);

  # Nearest integer function
  native sub ceil : double ($x : double);
  native sub floor : double ($x : double);
  native sub nearbyint : double ($x : double);
  native sub round : double ($x : double);
  
  # Surplus functions
  native sub remainder : double ($x1 : double, $x2 : double);

  native sub PI : double ();
  native sub E : double ();
  
  native sub INT8_MIN : byte ();
  native sub INT8_MAX : byte ();

  native sub INT16_MIN : short ();
  native sub INT16_MAX : short ();

  native sub INT32_MIN : int ();
  native sub INT32_MAX : int ();

  native sub INT64_MIN : long ();
  native sub INT64_MAX : long ();

  native sub FLT_MAX : float ();
  native sub FLT_MIN : float();
  
  native sub DBL_MAX : double ();
  native sub DBL_MIN : double ();
}
