#include <perms.h>

                                                                //      1  %begin
#line 1 "regression-bugs-tmp/leibnitz.imp"
int main(int argc, char **argv) {
  _imp_initialise(argc, argv);
                                                                //      2    %reals %long
                                                                //      3    
                                                                //      4    %integer rounds
#line 4 "regression-bugs-tmp/leibnitz.imp"
int ROUNDS;
                                                                //      5    %real pi = 1.0
#line 5 "regression-bugs-tmp/leibnitz.imp"
double PI;
#line 5 "regression-bugs-tmp/leibnitz.imp"
PI = 1.0;
                                                                //      6  
                                                                //      7    !%on %event 9 %start
                                                                //      8    !  print string("Cannot open file"); newline
                                                                //      9    !  %stop
                                                                //     10    !%finish
                                                                //     11  
                                                                //     12    %integer i
#line 12 "regression-bugs-tmp/leibnitz.imp"
int I;
                                                                //     13    
                                                                //     14    open input(1, "rounds.txt");   ! open file
#line 14 "regression-bugs-tmp/leibnitz.imp"
_imp_OPENINPUT(1, _imp_str_literal("rounds.txt"));
                                                                //     15    select input(1)
#line 15 "regression-bugs-tmp/leibnitz.imp"
_imp_SELECTINPUT(1);
                                                                //     16    
                                                                //     17    read(rounds);
#line 17 "regression-bugs-tmp/leibnitz.imp"
_imp_READ(&ROUNDS);
                                                                //     18    !print string("Rounds = "); write(rounds,0); newline
                                                                //     19  
                                                                //     20    close input;                   ! close file
#line 20 "regression-bugs-tmp/leibnitz.imp"
_imp_CLOSEINPUT();
                                                                //     21  
                                                                //     22    rounds = rounds + 2;           ! do this outside the loop
#line 22 "regression-bugs-tmp/leibnitz.imp"
ROUNDS = (((int)(ROUNDS)) + (2));
                                                                //     23  
                                                                //     24    %for i=2, 1, rounds %cycle
#line 24 "regression-bugs-tmp/leibnitz.imp"
{static int _initial, _increment, _final, _control;
_initial = 2; _increment = 1; _final = ROUNDS; I = _control = _initial;
if (((_final-_initial) % _increment) != 0) _imp_signal(5,1,0,"Illegal cycle I = 2, 1, ROUNDS");
I -= _increment; _control -= _increment;
L_0002:;
if (I == _final) goto L_0003;
I += _increment; _control += _increment;
if (I != _control) _imp_signal(4,2,0,"Corrupt control variable I"); /* FOR loop control variable corrupted */
}
/*promote*/                                                                //     25      %long %real x = -1.0 + 2.0 * (i & 1); ! allows vectorization
#line 25 "regression-bugs-tmp/leibnitz.imp"
double X;
#line 25 "regression-bugs-tmp/leibnitz.imp"
X = (((-1.0)) + ((double)(((2.0) * ((double)(((I) & (1))))))));
                                                                //     26      pi = pi + (x / (2 * i - 1)); ! double / unsigned = double
#line 26 "regression-bugs-tmp/leibnitz.imp"
PI = ((PI) + (((double)((double)((double)(X)) / (double)(((((int)((((int)(2)) * (I)))) - (1))))))));
                                                                //     27      !spaces(4); print fl(pi, 16); newline
                                                                //     28    %repeat
#line 28 "regression-bugs-tmp/leibnitz.imp"
goto L_0002;
#line 28 "regression-bugs-tmp/leibnitz.imp"
L_0003:;
/*promote*/                                                                //     29  
                                                                //     30    pi = pi * 4
#line 30 "regression-bugs-tmp/leibnitz.imp"
PI = ((PI) * ((double)(4)));
                                                                //     31    print fl(pi, 16);              ! print 16 decimal digits of pi
#line 31 "regression-bugs-tmp/leibnitz.imp"
_imp_PRINTFL(PI, 16);
                                                                //     32    newline
#line 32 "regression-bugs-tmp/leibnitz.imp"
_imp_NEWLINE();
                                                                //     33    
                                                                //     34  %endofprogram
#line 34 "regression-bugs-tmp/leibnitz.imp"
/* Remove %on %event handler here if present for this block */
return 0;
} // End of block _imp_main at level 1
#line 34 "regression-bugs-tmp/leibnitz.imp"
// End of file
