# A = 128
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A
CLEAR D
REPEAT A TIMES (
# I := 1 - D
CLEAR I
INCREASE I
REPEAT D TIMES ( CLEAR I )
# print X if not done
REPEAT I TIMES ( PRINT X )
# compute T, H, and O when not done
REPEAT I TIMES (
CLEAR T
CLEAR H
CLEAR O
# scan X times: toggle T; increment H when new T==0
REPEAT X TIMES (
# toggle T: T := 1 - T
CLEAR Z
INCREASE Z
REPEAT T TIMES ( CLEAR Z )
CLEAR T
REPEAT Z TIMES ( INCREASE T )
# Z := 1 - T (now Z==1 iff T==0)
CLEAR Z
INCREASE Z
REPEAT T TIMES ( CLEAR Z )
# if T==0 then H++
REPEAT Z TIMES ( INCREASE H )
)
# O := (X==1) = (H==0 and T==1)
# Z := 1 if H==0 else 0
CLEAR Z
INCREASE Z
REPEAT H TIMES ( CLEAR Z )
# O := Z AND T (start from Z, clear by (1-T))
CLEAR O
REPEAT Z TIMES ( INCREASE O )
# E := 1 - T
CLEAR Z
INCREASE Z
REPEAT T TIMES ( CLEAR Z )
REPEAT Z TIMES ( CLEAR O )
# D |= O
REPEAT O TIMES ( INCREASE D )
)
# I := 1 - D
CLEAR I
INCREASE I
REPEAT D TIMES ( CLEAR I )
# if not done, update X
REPEAT I TIMES (
# even/odd split using T
# even branch: X := H (when T==0 => Z=1 below)
CLEAR Z
INCREASE Z
REPEAT T TIMES ( CLEAR Z )
REPEAT Z TIMES (
CLEAR X
REPEAT H TIMES ( INCREASE X )
)
# odd branch: X := 3*X + 1 (when T==1)
REPEAT T TIMES (
CLEAR F
INCREASE F
# replace X by 3*X, clearing on first inner iteration
REPEAT X TIMES (
REPEAT F TIMES ( CLEAR X )
CLEAR F
INCREASE X
INCREASE X
INCREASE X
)
INCREASE X
)
)
)