#include <perms.h>

                                                                //      1  ! for i2c: m-0mm(v/! i2c !/s/{ i2c }/, v/{imp77}/s/!imp77!/, r, m)0
                                                                //      2  ! for imp2026: m-0mm(v/{ i2c }/s/! i2c !/, v/!imp77!/s/{imp77}/, r, m)0
                                                                //      3  %begin
#line 3 "regression-run-tmp/dscond.imp"
int main(int argc, char **argv) {
  _imp_initialise(argc, argv);
                                                                //      4  
                                                                //      5    %routine unlink(%string(*)%name s)
#line 5 "regression-run-tmp/dscond.imp"
void UNLINK( _imp_string /*%string(255)*/ /*name*/*S )
#line 5 "regression-run-tmp/dscond.imp"
{
                                                                //      6      %begin
#line 6 "regression-run-tmp/dscond.imp"
void _BLOCK_1_LEVEL_2_(void) {
                                                                //      7        ! i2c uses %systemroutine to access linux externals with the normal name and parameter order.
                                                                //      8        ! imp2026 needs to use %alias to get the linux linkage name and reverses the order of all params.
                                                                //      9        
                                                                //     10        { i2c } %systemroutinespec unlink (%string(*)%name fname)
#line 10 "regression-run-tmp/dscond.imp"
extern void unlink( _imp_string /*%string(255)*/ /*name*/*FNAME );
                                                                //     11        !imp77! %externalroutinespec unlink %alias "unlink" (%string(*)%name fname)
                                                                //     12        %string(255) fname = s.TO STRING(0) { Add terminating \0 that C strings need. }
#line 12 "regression-run-tmp/dscond.imp"
_imp_string /*%string(255)*/ FNAME;
#line 12 "regression-run-tmp/dscond.imp"
FNAME = _imp_join((_imp_string)*S,(_imp_string)_imp_TOSTRING(0));
                                                                //     13        unlink(STRING(ADDR(fname)+1))
#line 13 "regression-run-tmp/dscond.imp"
unlink(_imp_STRING((((int)(_imp_ADDR(&FNAME))) + (1))));
                                                                //     14      %end
#line 14 "regression-run-tmp/dscond.imp"
return;
} // End of block _BLOCK_1_LEVEL_2_ at level 3
_BLOCK_1_LEVEL_2_();
                                                                //     15    %end
#line 15 "regression-run-tmp/dscond.imp"
/* Remove %on %event handler here if present for this block */
return;
} // End of block UNLINK at level 2
                                                                //     16  
                                                                //     17    %ownstring(255) fname = "/tmp/dscond-test.txt"
#line 17 "regression-run-tmp/dscond.imp"
static _imp_string /*%string(255)*/ FNAME = _imp_str_literal("/tmp/dscond-test.txt");
                                                                //     18    
                                                                //     19    ! A function with side-effects that can be used in the middle of a double-sided conditional test:
                                                                //     20    %integerfn getchar
#line 20 "regression-run-tmp/dscond.imp"
int GETCHAR( void )
#line 20 "regression-run-tmp/dscond.imp"
{
                                                                //     21      %integer sym
#line 21 "regression-run-tmp/dscond.imp"
int SYM;
                                                                //     22      readsymbol(sym)
#line 22 "regression-run-tmp/dscond.imp"
_imp_READSYMBOL(&SYM);
                                                                //     23      printstring("Call returned "); printsymbol(sym); newline
#line 23 "regression-run-tmp/dscond.imp"
_imp_PRINTSTRING(_imp_str_literal("Call returned "));
#line 23 "regression-run-tmp/dscond.imp"
_imp_PRINTSYMBOL(SYM);
#line 23 "regression-run-tmp/dscond.imp"
_imp_NEWLINE();
                                                                //     24      %result = sym
#line 24 "regression-run-tmp/dscond.imp"
/* Remove %on %event handler here if present for this block */
return SYM;
                                                                //     25    %end
#line 25 "regression-run-tmp/dscond.imp"
} // End of block GETCHAR at level 2
                                                                //     26  
                                                                //     27    ! using streams 2 and 3 in case imp2026 has opened stream 1 for default input/output.
                                                                //     28    ! (I'm not really very clear on what it is doing with the streams)
                                                                //     29    open output(2, fname)
#line 29 "regression-run-tmp/dscond.imp"
_imp_OPENOUTPUT(2, FNAME);
                                                                //     30    select output(2)
#line 30 "regression-run-tmp/dscond.imp"
_imp_SELECTOUTPUT(2);
                                                                //     31    printstring("BUG")
#line 31 "regression-run-tmp/dscond.imp"
_imp_PRINTSTRING(_imp_str_literal("BUG"));
                                                                //     32    newline
#line 32 "regression-run-tmp/dscond.imp"
_imp_NEWLINE();
                                                                //     33    close output
#line 33 "regression-run-tmp/dscond.imp"
_imp_CLOSEOUTPUT();
                                                                //     34  
                                                                //     35    ! restore stdout.
                                                                //     36  
                                                                //     37    ! under i2c, stream 0 is /dev/tty, stream 1 is /dev/stdout.  We want stdout so that
                                                                //     38    ! the result can be written to a file in order for the regression tests to check it.
                                                                //     39    ! under imp2026, selecting stream 1 causes a runtime failure but stream 0 is OK.
                                                                //     40    
                                                                //     41    { i2c } select output(1)
#line 41 "regression-run-tmp/dscond.imp"
_imp_SELECTOUTPUT(1);
                                                                //     42    !imp77! select output(0)
                                                                //     43  
                                                                //     44    open input(3, fname)
#line 44 "regression-run-tmp/dscond.imp"
_imp_OPENINPUT(3, FNAME);
                                                                //     45    select input(3)
#line 45 "regression-run-tmp/dscond.imp"
_imp_SELECTINPUT(3);
                                                                //     46  
                                                                //     47    %if 'A' <= getchar <= 'C' %start
#line 47 "regression-run-tmp/dscond.imp"
if (({int tmp1 = 65, tmp2 = GETCHAR(), tmp3 = 67; (tmp1 > tmp2) || (tmp2 > tmp3);})) goto L_0002;
                                                                //     48      printstring("Test successful."); newline
#line 48 "regression-run-tmp/dscond.imp"
_imp_PRINTSTRING(_imp_str_literal("Test successful."));
#line 48 "regression-run-tmp/dscond.imp"
_imp_NEWLINE();
                                                                //     49    %else
#line 49 "regression-run-tmp/dscond.imp"
goto L_0003;
#line 49 "regression-run-tmp/dscond.imp"
L_0002:;
                                                                //     50      printstring("Test failed - getchar was called twice."); newline
#line 50 "regression-run-tmp/dscond.imp"
_imp_PRINTSTRING(_imp_str_literal("Test failed - getchar was called twice."));
#line 50 "regression-run-tmp/dscond.imp"
_imp_NEWLINE();
                                                                //     51    %finish
#line 51 "regression-run-tmp/dscond.imp"
L_0003:;
                                                                //     52  
                                                                //     53    close input; select input(0)
#line 53 "regression-run-tmp/dscond.imp"
_imp_CLOSEINPUT();
#line 53 "regression-run-tmp/dscond.imp"
_imp_SELECTINPUT(0);
                                                                //     54    unlink(fname)
#line 54 "regression-run-tmp/dscond.imp"
UNLINK(&FNAME);
                                                                //     55  
                                                                //     56  %endofprogram
#line 56 "regression-run-tmp/dscond.imp"
/* Remove %on %event handler here if present for this block */
return 0;
} // End of block _imp_main at level 1
#line 56 "regression-run-tmp/dscond.imp"
// End of file
