Mirror-machine

A Mirror-machine is an extremely simple program type invented by User:ReplayShells to check decision, addition, subtraction, loops, input and outputs. Process:

• Input vars a,b (b is unsigned.)
• Increment a
• Decrement b
• If a is not 0:
• Print a
• Set a to 0
• If b is not 1:
• Print b
• While b is not 0
• Print b
• Decrement b
• Input a,b
• Print a - b
• Print ABC
• Terminate program

The program, when expressed in pseudocode, adheres to the following principles:

```a ← input integer, where a ∈ ℤ
b ← input integer, where b ∈ ℤ ∧ b ≥ 0

a ← a + 1
b ← b - 1

if a ≠ 0 then
print a
a ← 0
end if

if b ≠ 1 then
print b
end if

while b ≠ 0 do
print b
b ← b - 1
end while

a ← input integer, where a ∈ ℤ
b ← input integer, where b ∈ ℤ ∧ b ≥ 0

print a - b

print "ABC"
terminate program
```

Implementations

C

```#include <stdio.h>
int main(void)
{
int a;
unsigned b;
scanf("%d %u", &a, &b);
++a;
--b;
if(a != 0)
{
printf("%d\n", a);
a = 0;
}
if(b != 1)
printf("%u\n", b);
while(b != 0)
{
printf("%u\n", b);
--b;
}
scanf("%d %u", &a, &b);
printf("%d\n", a - b);
printf("ABC\n");
return 0;
}
```

Phile

```OPEN "stdin.stream";
OPEN "stdout.stream";
OPEN "a";
OPEN "b";
/// Input variables a, b.
/// Increment a.
OVERWRITE "a" READ "a" + 1;
/// Decrement b.
OVERWRITE "b" READ "b" - 1;
/// Test of a.
OVERWRITE "stdout.stream" READ "a" + "\n";
OVERWRITE "a" 0;
/// Line 11:
/// Test of b.
OVERWRITE "stdout.stream" READ "b" + "\n";
/// Line 13:
/// While loop.
OVERWRITE "stdout.stream" READ "b" + "\n";
OVERWRITE "b" READ "b" - 1;
/// Line 17:
/// Input a, b.
/// Print a - b.
OVERWRITE "stdout.stream" "\n";
/// Print "ABC".
OVERWRITE "stdout.stream" "ABC" + "\n";
/// Terminate program.
CLOSE "stdin.stream";
CLOSE "stdout.stream";
CLOSE "a";
CLOSE "b";
```

Python

```a, b = int(input()), int(input())

a += 1
b -= 1

if a != 0:
print(a)
a = 0

if b != 1:
print(b)

while b != 0:
print(b)
b -= 1

a, b = int(input()), int(input())

print(a-b)

print("ABC")
```

```R/R\
[1:^1:P0 1;0^]
[0:\^0:P0^]
[0:^0:P\]
R1;R0;
[0:^\1:\1;]
[^]P
65p 66p 67p
```