/*
!
! The hand-generated code below should be producable by PSR's compiler if it:
! A) delays stores as late as possible
!
! B) remembers registers over procedure calls
!
! C) has a general algorithm for drop-through conditionally executed
!    instructions, i.e. if there are no instructions between a conditional 
!    branch and its destination which set the condition codes, and the
!    sequence is less that a certain length, then all the instructions
!    within the sequence can be made conditional.
!
! D) does as above, but also allows instructions within the sequence
!    whose subsequent execution depends on the same condition, e.g.
!
!    %if a=b %and c=d %then a=b
!
!    CmpS   R0,R1            NAIVE STYLE
!    Bne    elsepart
!    Cmps   R2,R3
!    Bne    elsepart
!    Mov    R0,R2
!
!    CmpS   R0,R1            RULE (C) ABOVE
!    Bne    elsepart
!    CmpS   R2,R3
!    MovEQ  R0,R2
!
!    CmpS   R0,R1            RULE (D) SPECIAL CASE
!    CmpSEQ R2,R3
!    MovEQ  R0,R2
!
! E) alters conditions to generate similar condition codes on
!    condition AND condition AND condition to generate more cases
!    to which rule (D) can be applied.
!
! F) adjusts constants in < or <= cases to favour above, i.e. turning
!    CMP R,#const & BLE ... into CMP R,#const-1 & BLT ... etc.
!
! G) changes Newline back from the current implicit printsymbol(10) -
!    there is no run-time overhead in moving the MOV R0,#10 over to
!    the procedure body instead of having it in every call where it
!    takes up space - after all, Peter's code-moving stuff ought to
!    get %permroutine newline;printsymbol(10);%end correct - it will
!    place the Mov R0,#10 before the body of %permroutine printsymbol
!    and generate a suitable entry point for it...
!       Personally, I would recommend stacking/restoring R0 as well
!    as it might keep another variable in a register for a bit longer...
!
! I've only suggested optimisations which fit into the style of PSR's
! compilers...
!
*/
extern int readnum(void);
extern void write(int num, int pl);
extern void newline(void);

void main(void) {
int a,i,b;

  a = readnum();
  i = readnum();
  b = readnum();

  if ((a <= i) && (i <= b)) {
    i = 22;
  };

  if ((22 <= i) && (i <= b)) {
    i = 44;
  };

  if ((a <= i) && (i <= 77)) {
    i = 99;
  };

  if ((11 <= i) && (i <= 100)) {
    i = 1;
  };

  write(a,0);
  newline();
  write(i,0);
  newline();
  write(b,0);
  newline();

};
