// Effectus auto-generated Mad Pascal source code listing
program sievePrg;

uses
  Crt, StringUtils, SySutils, CIO;

var
  strBuffer : string;
var
  eff_loop_var : byte;
  eff_cnt : byte;
  eff_string : string;
// Effectus example:
// SIEVE benchmark test
var
  RTCLOK : byte absolute 20;  // RTCLOK_byte_array
  SDMCTL : byte absolute 559;  // SDMCTL_byte_array
  FLAGS : array[0..8190] of byte;  // FLAGS_byte_array
  COUNT : word;  // COUNT_byte_array
  I : word;  // I_byte_array
  K : word;  // K_byte_array
  PRIME : word;  // PRIME_byte_array
  TIME : word;  // TIME_byte_array
  key : byte;  // key_byte_array

procedure SIEVEProc;
begin
  SDMCTL := 0;
  RTCLOK := 0;
  COUNT := 0;
 FOR I:=0 TO 8190 do begin
  FLAGS[I] := 84;
  end;
 FOR I:=0 TO 8190 do begin
  if  FLAGS[I]=84  then begin
  PRIME := I+I+3;
  K := I+PRIME;
 WHILE K<=8190 do begin
  FLAGS[K] := 70;
  Inc(K, PRIME);
  end;
  Inc(COUNT);
  end;  // if
  end;
  TIME := RTCLOK;
  SDMCTL := 34;
  Write('', eol, ' ', COUNT, ' PRIMES IN');
  Write('', eol, ' ', TIME, ' JIFFIES');
  key := Get(7);
  ReadKey;
end;

begin
  SIEVEProc;
end.
