#include <perms.h>

                                                                //      1  %systemintegerfn stoi(%string(255) S)
#line 1 "regression-bugs-tmp/stoi.imp"
extern int stoi( _imp_string /*%string(255)*/ S )
#line 1 "regression-bugs-tmp/stoi.imp"
{
                                                                //      2  %integer i,k
#line 2 "regression-bugs-tmp/stoi.imp"
int I;
#line 2 "regression-bugs-tmp/stoi.imp"
int K;
                                                                //      3  %integer sign=0, val=0
#line 3 "regression-bugs-tmp/stoi.imp"
int SIGN;
#line 3 "regression-bugs-tmp/stoi.imp"
SIGN = 0;
#line 3 "regression-bugs-tmp/stoi.imp"
int VAL;
#line 3 "regression-bugs-tmp/stoi.imp"
VAL = 0;
                                                                //      4    i = 0
#line 4 "regression-bugs-tmp/stoi.imp"
I = 0;
                                                                //      5    %while i < length(s) %cycle
#line 5 "regression-bugs-tmp/stoi.imp"
L_0002:;
#line 5 "regression-bugs-tmp/stoi.imp"
if (((I) >= (*_imp_LENGTH(&S)))) goto L_0003;
                                                                //      6      i = i+1;  k = charno(s,i)
#line 6 "regression-bugs-tmp/stoi.imp"
I = (((int)(I)) + (1));
#line 6 "regression-bugs-tmp/stoi.imp"
K = *_imp_CHARNO(&S, I);
                                                                //      7      %continue %if k <= ' '
#line 7 "regression-bugs-tmp/stoi.imp"
if (((K) > (32))) goto L_0005;
#line 7 "regression-bugs-tmp/stoi.imp"
goto L_0004;
#line 7 "regression-bugs-tmp/stoi.imp"
L_0005:;
                                                                //      8      %if k = '-' %start
#line 8 "regression-bugs-tmp/stoi.imp"
if (((K) != (45))) goto L_0006;
                                                                //      9        sign = 1
#line 9 "regression-bugs-tmp/stoi.imp"
SIGN = 1;
                                                                //     10      %else %if '0' <= k <= '9'
#line 10 "regression-bugs-tmp/stoi.imp"
goto L_0007;
#line 10 "regression-bugs-tmp/stoi.imp"
L_0006:;
#line 10 "regression-bugs-tmp/stoi.imp"
if ((((48) > (K))) || (((K) > (57)))) goto L_0008;
                                                                //     11        val = val<<3+val+val+k-'0'
#line 11 "regression-bugs-tmp/stoi.imp"
VAL = (((int)((((int)((((int)((((int)(((VAL) << (3)))) + (VAL)))) + (VAL)))) + (K)))) - (48));
                                                                //     12      %else
#line 12 "regression-bugs-tmp/stoi.imp"
goto L_0007;
#line 12 "regression-bugs-tmp/stoi.imp"
L_0008:;
                                                                //     13        %signal 4, 1, k{, "Non-numeric character"
#line 13 "regression-bugs-tmp/stoi.imp"
_imp_signal(4, 1, K, "");
                                                                //     14      %finish
#line 14 "regression-bugs-tmp/stoi.imp"
L_0007:;
                                                                //     15    %repeat
#line 15 "regression-bugs-tmp/stoi.imp"
L_0004:;
#line 15 "regression-bugs-tmp/stoi.imp"
goto L_0002;
#line 15 "regression-bugs-tmp/stoi.imp"
L_0003:;
                                                                //     16    %result = val %if sign = 0
#line 16 "regression-bugs-tmp/stoi.imp"
if (((SIGN) != (0))) goto L_0009;
#line 16 "regression-bugs-tmp/stoi.imp"
/* Remove %on %event handler here if present for this block */
return VAL;
#line 16 "regression-bugs-tmp/stoi.imp"
L_0009:;
                                                                //     17    %result = -val
#line 17 "regression-bugs-tmp/stoi.imp"
/* Remove %on %event handler here if present for this block */
return (-(VAL));
                                                                //     18  %end
#line 18 "regression-bugs-tmp/stoi.imp"
} // End of block stoi at level 1
                                                                //     19  
                                                                //     20  %endoffile
#line 20 "regression-bugs-tmp/stoi.imp"
// End of file
